Support snippets
Thanks for the extension! I would like to make a request.
Please support snippets for common language constructs
ex:
snippet: if
expansion:
if [ $expression ] then
$statement
fi
This is a great idea. :)
Contributions are more than welcome.
@kaushalyap @polyzen @bbb651 please review https://github.com/bash-lsp/bash-language-server/pull/664 if you have time. Thanks!
I use bashls under Neovim, it would be appreciated if they were part of the language server in general.
@skovhus Seems good to me, we can change things as we go forward.
~~supposed #664 is only for vscode, and/or something like put some bash snips in vscode local snip folder (~/.config/.../snip) but to vim (official vim at least) i think there had common snip plugins or integrated with lsp client can do snip such already, and seems more common, to me, i do not like or wish it is only for vscode only (if it wish to go). // sorry for jumping in, haha... since you did not ask me to review..~~ :smile:
We now have 30 snippets, contributions are more than welcome. :)
~~@skovhus not sure if you got my point, i meant if there was snip from this lsp server perhaps better be just for vscode only, i saw you moved that snip feature to server side which for all kinds clients, so far looks no direct way (e.g in official vim lsp client) to make it work,~~ e.g when i typed 'if-el' perhaps it would prompt 'if-else', but when i confirmed that item that actually it would NOT be able to do snip complete at all, then seems such compl item ('if-else') is useless or a bit strange. opposite to that there are some snip plugins for vim already which can do snip completion for many languages already, which looks more common and useful.
~~// something like codeaction feature, that quickfix kind codeaction looks fitting for vscode, vs it looks did not work for e.g vim lsp client, or did not really reply codeaction result to others lsp client but vscode only, looks so.~~
~~// compare to codeaction feature, probably wish codeaction worked for all clients, vs snip feature perhaps should just for vscode.~~
Works with https://github.com/hrsh7th/cmp-nvim-lsp
Works with https://github.com/hrsh7th/cmp-nvim-lsp
thx, yea, should be able to integrated with it (something like that).
but perhaps i think should respect CompletionClientCapabilities.snipSupport option, if it is false perhaps there should be no snip items.
another hand, if-else generally - is not one of keyword char, how about _ or just ifelse or ifel ?
~~and the compl.item.kind should be set to 'snip' as well. // now, seems it is empty.~~ @skovhus
The completion item type is correctly set. That is aæsp why it works in most clients.
About naming then we seem to follow common snippet naming. And we have strived for making them explicit and without too much magic. So rather if-else compared to ifel.
It should respect the client compatibility though. That is a good catch.
~~what is aæsp? compl item kind seems was a number which less than 25 (0~25) if I recall correctly, what did you set for snip compl item?~~
~~I do not know how others work, but generally lsp client judge the compl was based on the previous typed chars, and that better be keyword chars which generally not included -, which that would make base recognize incorrectly, if you preferred~~ I suggested use _ instead, but most snips for many Languages I saw it is ifel or ifelse.
-- shane.xb.qian