bash-language-server icon indicating copy to clipboard operation
bash-language-server copied to clipboard

Support snippets

Open kawpiya opened this issue 6 years ago • 1 comments

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


kawpiya avatar Jan 22 '20 12:01 kawpiya

This is a great idea. :)

Contributions are more than welcome.

skovhus avatar Jan 22 '20 12:01 skovhus

@kaushalyap @polyzen @bbb651 please review https://github.com/bash-lsp/bash-language-server/pull/664 if you have time. Thanks!

skovhus avatar Jan 09 '23 13:01 skovhus

I use bashls under Neovim, it would be appreciated if they were part of the language server in general.

polyzen avatar Jan 09 '23 21:01 polyzen

@skovhus Seems good to me, we can change things as we go forward.

kawpiya avatar Jan 10 '23 01:01 kawpiya

~~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:

Shane-XB-Qian avatar Jan 10 '23 12:01 Shane-XB-Qian

We now have 30 snippets, contributions are more than welcome. :)

skovhus avatar Jan 17 '23 12:01 skovhus

~~@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.~~

Shane-XB-Qian avatar Jan 19 '23 13:01 Shane-XB-Qian

Works with https://github.com/hrsh7th/cmp-nvim-lsp

polyzen avatar Jan 19 '23 20:01 polyzen

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 ?

Shane-XB-Qian avatar Jan 20 '23 01:01 Shane-XB-Qian

~~and the compl.item.kind should be set to 'snip' as well. // now, seems it is empty.~~ @skovhus

Shane-XB-Qian avatar Jan 20 '23 01:01 Shane-XB-Qian

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.

skovhus avatar Jan 20 '23 06:01 skovhus

~~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

Shane-XB-Qian avatar Jan 20 '23 06:01 Shane-XB-Qian