L3MON4D3 / LuaSnip

Snippet Engine for Neovim written in Lua.
Apache License 2.0
3.37k stars 241 forks source link

[feature request] parse simple condition flags in snipmate #1183

Open yao-weijie opened 4 months ago

yao-weijie commented 4 months ago

I use luasnip as my snip egine and vim-snippets as main snippet source.

I notice that some of the snippets in vim-snippets has a suffix flag such as:

snippet sk "skip unittests" b
    @unittest.skip(${1:skip_reason})
snippet allow "allow lint attribute" b
    #[allow(${1:unused_variables})]

and similar ultisnips samples:

snippet prop "Proposition" bi
\begin{prop}[$1]
    ${0:${VISUAL}}
\end{prop}
endsnippet

snippet xx "cross" Aw
\times 
endsnippet

current version of luasnip doesn't process the flags b, w, A, i etc, which means some basic conditions, if it is possible to parse such flags in snipmate loader?

L3MON4D3 commented 4 months ago

Hi :)

This seems very reasonable, I'll look into adding those we support. Thanks for mentioning that vim-snippets contains these, I was not aware :)

I took a quick look at vim-snippets, it seems like snippets with these suffixes always have the description in quotes, is that consistent? (otherwise, we may mistake some last word of the description for the suffix-string, for example Ai (there are not many words that can be made from these flag-chars, but still :D ))