vscode-intelephense
vscode-intelephense copied to clipboard
Code actions and renaming not working in Neovim
Describe the bug Code actions ("textDocument/codeAction") and renaming ("textDocument/rename") seems not to be working with neovim builtin lsp.
To Reproduce Install neovim 0.5.0, configure with intelephense and try to trigger a code action like implementing methods or try to trigger a rename action. I've tried triggering code actions with plugins like Telescope or lsp saga, also tried to manually triggering a buf_request "textDocument/codeAction" request directly from lua, none of these seems to work.
lsp configuration:
require'lspconfig'.intelephense.setup{
init_options = {
licenceKey = "LICENSE_KEY"
}
}
Expected behavior Code actions and renaming should be available in neovim.
Screenshots
Platform and version OS: macOs Catalina Intelephense version: 1.7.1.
I can confirm the same behaviour in emacs, are you able to do anything else premium or just code actions?
@bmewburn is this logic not part of the core intelephense? And is it needed? I don't think the emacs-lsp package calls it, some way to verify premium status would be useful.
https://github.com/bmewburn/vscode-intelephense/blob/master/src/extension.ts#L274
The activation routine is also in the server. I'll look into this.
I have refactoring working in emacs, just lacking code actions oddly.
Weirdly, this morning I have code actions now.
Premium features still not working in neovim
I'll try and setup nvim for intelephense and see if there's something missing later
I have this working for a long time (see screenshot):
Might be a setting or config. I use native lsp + some additional extensions, config is here: https://github.com/haringsrob/neovim-config
Aye I can verify the same behaviour in emacs (phpdoc shows up in the actions list)
I think this is indeed a local setup issue and should probably be closed, thanks anyway :)
Thanks @haringsrob . @maxime-aknin are you still having trouble with this?
@bmewburn I've been facing this issue for a while and can't figure out what's happening.
I've tried using both LunarVim
and NvChad
neovim configs/framework and they don't work in either. They both use Lspinstall
to set up the server, but, that only changes the cmd
path in the config - the rest stay as is. I have activated my license using vscode to make sure, and it's okay there.
EDIT: I can confirm that LspInstall
is not the issue.
EDIT2: tried clearing out the intelephense cache in tmp, tried to downgrade to 1.6.1
.. still no go. The errors I get in neovim are:
When renaming:
Error executing lua /usr/share/nvim/runtime/lua/vim/lsp/handlers.lau:461: bad argument #2 to 'format' (number expected, got nil).
When executing code_action:
Error executing lua /usr/share/nvim/runtime/lua/vim/lsp.lua:1320: table index is nil.
I did run LSP in debug mode and I log says that textDocument/codeAction
is not supported by the attathed server (being intelephense). I have my license in ~/intelephense/license.txt
. I tried pasting in the license directly within init_options
as well, and using it as an env.
Code actions and rename work for me just fine with the other LSPs that i'm running.
EDIT:
I got the fix:
Emailed Ben. License vs Licence.. US vs UK spelling.....
Same thing than @marwan38
@syrm Check out the edit at the bottom of that comment. It was a sillllly mistake that cost me many hours.
Oh yeah good spot, @maxime-aknin licenceKey = "LICENSE_KEY"
should be licenseKey = "LICENSE_KEY"
. Seems like user error rather than a genuine issue.
fixed for me too thank you
Hi there! Happy to open a new issue if you'd rather close this one out (just let me know), but I'm bumping into the same issue here where things like codeAction
and rename
aren't being supported by the Intelephense server. I read through the comments so far and double-checked that I wasn't falling victim to any of the things that have been discussed so far, but even after changing my spelling of licenseKey
, I'm still not able to run code actions or rename classes, variables, etc.
I've tried using both Telescope and LspSaga to run these commands, and they fail using both methods. My premium license key is definitely making into my configuration (which I've pasted down below), because I can do things like "Go To Declaration".
Here's the information that I have:
Neovim Editor LSP Errors (Telescope):
LSP: server does not support code_action
Neovim LSP Log Errors (LspSaga):
[WARN][2021-10-14 20:15:24] .../lua/vim/lsp.lua:87 "method textDocument/codeAction is not supported by any of the servers registered for the current buffer"
[WARN][2021-10-14 20:15:46] .../lua/vim/lsp.lua:87 "method textDocument/rename is not supported by any of the servers registered for the current buffer"
Intelephense Version: 1.7.1
Neovim Version: v0.5.1
Configuration – LSP Capabilities
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
capabilities.textDocument.completion.completionItem.snippetSupport = true
capabilities.textDocument.completion.completionItem.resolveSupport = {
properties = {
'documentation',
'detail',
'additionalTextEdits',
}
}
Configuration – Intelephense Config
lspconfig.intelephense.setup{
capabilities = capabilities, -- from the local capabilities variable in the above snippet
init_options = {
licenseKey = os.getenv('INTELEPHENSE_LICENSE_KEY'), -- this is tested and working as intended
},
settings = {
intelephense = {
telemetry = {
enabled = false,
},
completion = {
fullyQualifyGlobalConstantsAndFunctions = false
},
phpdoc = {
returnVoid = false,
}
},
}
}
Admittedly, I only have a passing knowledge of Lua (most of this configuration came from more knowledgable Lua folks in this Issue) and even less knowledge of writing language parsers, but I'm happy to help where I can–Intelephense has been indispensable for me when I use VSCode.
Let me know if you need any more information from me–if you can point out what you want, I can definitely get it for you.
Same issue. I've spent hours debugging. No luck!
Ok, found my issue. I'm using https://github.com/ray-x/navigator.lua and I use it to disable formatting for the intelephense language server. Later in the file, I try to setup the language server again with the init options.
So, basically, I was unknowingly calling setup
twice.
:heart:
@alexandersix
Hi. I solved this issue for myself by updating the config key as follows:
init_options = { licenceKey = "my key" }
notice the spelling of the word licence
it is very confusing, cause from reading this thread I see that for other people it was the other way around, as in updating from licence to license fixed their issue. I have no idea why.
Hi, check this. https://intelephense.com/faq.html
Currently, setting the license key in initializationOptions is deprecated. https://github.com/bmewburn/vscode-intelephense/blob/master/package.json#L626
It is better to place licence.txt files.
@haringsrob could you please share your config again? Your mentioned link does not work any more...
And does anybody know how you can rename a function name workspace (project) wide? :lua vim.lsp.buf.rename()
does not do that.
And does anybody know how you can rename a function name workspace (project) wide?
:lua vim.lsp.buf.rename()
does not do that.
It actually does, but all buffers need to be written (:wa
).
Thnx @Fadarrizz for sharing!
I did not realise that all the files containing the renamed functions are placed in a new buffer. I was supposing that the renaming was done directly in the files (outside Vim).
:wa
indeed does the trick!
Hi, @elken.
How was you able to make it work in Emacs?
I've a license key at ~/intelephense/licence.txt
already.
I'm also trying (setq lsp-intelephense-licence-key "LICENSE-KEY")
, but no lucky.
Ps.: the same key works in VSCode.
EDIT (w/ solution) It was my Netskope client blocking the intelephense.com/activate url, after disabling it, the Intelphense premium features could be enabled.
just in case... Make sure you check the spelling on your licence key file!
It MUST be licence.txt
Mine was named license.txt with a freaking S! 🤦
Any news on code actions not working? I can get PHPActor code actions to work, but don't want to run both Intelephense and PHPActor. Then I get duplicate linting messages (PHPStan) and completions. Would rather have code actions from Intelephense only.
When I run vim.lsp.buf.code_action()
without PHPActor enabled I get message:
No code actions available
With PHPActor enabled I get actual code actions.
I can provide my lspconfig if needed, but it's pretty basic.