-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
LSP: filetype sent as language id breaks sourcekit-lsp #3264
Comments
Filetypes are purely a Neovim thing; the server cares not. The issue is usually with project detection; sourcekit is finicky in this regard (read the documentation). In any case, this issue belongs at nvim-lspconfig (on mobile so can't transfer it now). |
Thanks. I was going to post the issue there but the warning in the README made me consider this might be an LSP client issue. |
The reason I suspected it might be a language ID issue is that the sourcekit-lsp can handle multiple types.
I have to assume that the language ID that neovim sends through to the lsp must play a role here (and there's no language matching |
It does not send any language ID at all; that is simply not part of the protocol. |
Right. Thanks for clarifying. |
Sorry, I don't know much about the protocol but based on all the references I saw when researching this issue, I wanted to figure out why I thought what I did. So I went looking and found the spec for the
Then based on the fact that the lsp client in neovim just uses the filetype as the language ID, I added the following to my config: lspconfig.sourcekit.setup {
filetypes = { 'swift', 'c', 'cpp', 'objective-c', 'objc', 'objective-cpp' },
get_language_id = function(_, ftype)
if ftype == "objc" then
return "objective-c"
end
return ftype
end,
...
} and now the lsp works. Now I'm happy that my issue was solved, but this tells me that, based on the spec, the lsp client in neovim should be replacing Assuming it does send a language id and I'm not misinterpreting everything above. |
You learn something new every day. Sorry for giving you the runaround! |
No worries. It was equally educational for me too :) |
Moved it again to lspconfig because the mapping needs to be added there.
|
Need to work around a bug in nvim-lspconfig: neovim/nvim-lspconfig#3264
Problem
I'm having trouble getting the lsp to work with objective c files and sourcekit-lsp. The filetype is detected as
objc
, but it seems sourcekit-lsp calls itobjective-c
. Addingobjc
to the filetypes in the config enables the connection with the lsp, but no lsp-based features actually work (completion, inline warnings, etc).I suspect the issue might be that sourcekit-lsp expects the filetype to be
objective-c
and neovim is passingobjc
.Steps to reproduce using "nvim -u minimal_init.lua"
Here's a minimal config:
and launching nvim with that config on a
.m
objc file shows the following:LspInfo
Forcing the filetype detection by adding
makes it appear like it's working:
but none of the lsp functionality actually works.
The included log file is from after the
filetypes
line was added.Expected behavior
Completion and checks from sourcekit-lsp to work with objective c files.
Neovim version (nvim -v)
NVIM v0.10.1
Language server name/version
sourcekit-lsp (part of Xcode 15.4)
Operating system/version
macOS Sonoma 14.5
Log file
https://gist.github.com/achilleas-k/fe2409175dc0be879b729ccf7e7ebdeb
The text was updated successfully, but these errors were encountered: