Skip to content
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

Send the correct insertTextFormat #3005

Merged
merged 1 commit into from
Dec 26, 2024

Conversation

andrewbraxton
Copy link
Contributor

Per LSP specification, insertTextFormat should be 2 for snippets and 1 for plain text. Using 2 unconditionally can make clients behave in unexpected ways. For example, the nvim-cmp plugin for Neovim doesn't properly handle the case of completion inside of a snippet when insertTextFormat is incorrect.

The code calling into provider.lua sets insertTextFormat to 2 for all snippets and leaves it nil for other types, so we can reuse that information in provider.lua to make sure we send the correct value.

This was previously brought up in #992, but the closing PR didn't resolve the issue directly.

Per LSP specification, `insertTextFormat` should be `2` for snippets and
`1` for plain text. Using `2` unconditionally can make clients behave in
unexpected ways.

The code calling into `provider.lua` sets `insertTextFormat` to 2 for
all snippets and leaves it nil for other types, so we can reuse that
information in `provider.lua` to make sure we send the correct value.
@sumneko sumneko merged commit 3a39d06 into LuaLS:master Dec 26, 2024
10 of 11 checks passed
@sumneko
Copy link
Collaborator

sumneko commented Dec 26, 2024

Thank you!

andrewbraxton added a commit to andrewbraxton/lua-language-server that referenced this pull request Jan 3, 2025
The PR LuaLS#3005 assumed that all snippets were setting `insertTextFormat`
to 2 and leaving plaintext completions nil, but that was not the case.
Function completions need to be marked as snippets too.

fixes LuaLS#3021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants