-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: snippet completions for functions #116
Conversation
a5b3bbe
to
7cae371
Compare
4220706
to
37a5e99
Compare
`tsserver` does not create snippets for functions in the completions list; only upon completion resolve (presumably this is for performance reasons). `typescript-language-server` deals with this by manually constructing the snippet and tweaking the `inputTextFormat`. We copy that here - as long as `includeCompletionsWithSnippetText = true`. INFO: refactor/fix: move default configs to `config.lua` so they can be referenced outside of just `text_document/did_open`
37a5e99
to
1de9bd5
Compare
Very nice! Thank you for contribution! I looked into code and it looks fine, but can you add type annotations for new functions and ad least one test which contain new snippet response for regression purposes? |
Also adds type annotations to function snippet feature.
be16443
to
c3046cc
Compare
@pmizio Sure, no problem, just added. For the tests, this feature actually turned the existing test cases into snippets, so I instead added back test cases for non-snippets. |
The value is the same as Which is tested here: I'm actually not sure how to trigger the |
Oh, I'm blind sorry :D ok I will work with this for one or two days and merge it if everything will be ok. Once again thanks for contrib! |
@llllvvuu Just noticed one thing - Nagranie.z.ekranu.2023-07-24.o.15.04.03.movEdit: I checked it and it look like cmp add |
typescript.suggest.completeFunctionCalls
(off by default)
8c6457c
to
d3bfb7d
Compare
@pmizio good catch, I didn't realize it was I changed one more thing, which is to turn off the feature by default, similar to VSCode. I updated the README.md to show how to turn it on. |
d3bfb7d
to
bce78e7
Compare
feat: copy the VSCode config option `typescript.suggest.completeFunctionCalls` and have it off by default
2e94ec4
to
f21fb2f
Compare
Ok, so I tested this and it looks fine for me to merge, @llllvvuu do you want to change something before merge or I can do that? |
@pmizio All good on my end 👍 |
typescript.suggest.completeFunctionCalls
(off by default)
Once again thanks for contrib @llllvvuu! |
resolves #56
demo.mp4
tsserver
does not create snippets for functions in the completions list; only upon completion resolve (presumably this is for performance reasons).typescript-language-server
deals with this by manually constructing the snippet and tweaking theinputTextFormat
. We copy that here - as long asincludeCompletionsWithSnippetText = true
.I chose to do one thing different from
typescript-language-server
: even though we can't put preview all the snippet params in the cmp menu, I still at least add "(...)" so that it visually distinguishes them as snippets. This is especially sincenvim_cmp
is unable to detect them as snippets.Note that VSCode's own
completeFunctionCalls
feature is very rough around the edges. For example, it doesn't work on arrow functions, which is fundamentally becausetsserver
labels then as variables and so it doesn't make sense for them to beinputTextFormat = Snippet
.INFO:
refactor/fix: move default configs to
config.lua
so they can be referenced outside of justtext_document/did_open
test: test both the
completeFunctionCalls = true
case andcompleteFunctionCalls = false
case.