Code actions not working in neovim
See original GitHub issueDescribe the bug In neovim, code actions work when choosing one of the “correction” option, but not when choosing one of the following:
Add <word> to dictionary
Hide false positives
Disable rule
Steps to reproduce Steps to reproduce the behavior:
- Create a markdown file with the following line
CustomWord is not a word
CustomWord
is rightly marked as not a correct word- Move the cursor on it
- Type:
:lua vim.lsp.buf.code_action()
- Choose
5: Add 'CustomWord' to dictionary
- Nothing happens, the error is still here. And there is no error message either.
Expected behavior
I expect it to add the CustomWord
to dictionary and remove errors linked to it in the rest of the document, without having to manually add the word in the configuration.
Sample document
CustomWord is not a word
LTeX configuration
I’m using it in neovim with lspconfig
and nvim-lsp-installer
with the default config, just calling it:
nvim_lsp.ltex.setup {
on_attach = on_attach
}
LTeX LS log No error log unfortunately.
Version information
- OS:
Linux <hostname> 5.18.3-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 09 Jun 2022 16:14:10 +0000 x86_64 GNU/Linux
- ltex-ls: 15.2.0
- Java: 11.0.12
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:7
Top Results From Across the Web
Code actions and renaming not working in Neovim #1888
Code actions ("textDocument/codeAction") and renaming ("textDocument/rename") seems not to be working with neovim builtin lsp. To Reproduce
Read more >LspConfig code action does not work : r/neovim - Reddit
LspConfig code action does not work. I have problems with LspConfig when extracting a method to a new file. When executing the following...
Read more >neovim - LspConfig code action does not work
I have problems with LspConfig when extracting a method to a new file. When executing the following command buf_set_keymap("n","<space>ca" ...
Read more >Neovim built-in LSP shows No code actions available for ...
When I open a python file, diagnostics seem to be working fine. Then I navigate to a line with a ...
Read more >User Manual - rust-analyzer
Toolchain; VS Code; rust-analyzer Language Server Binary; Emacs; Vim/NeoVim ... Note that installing via xtask install does not work for VS Code Remote, ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Based on the work-around @David-Else provided in the comment above, I added a local dictionary capability. The VS Code extension version creates
ltex.dictionary.en-US.txt
file under.vscode/
directory and adds the word to this text file, by default, when add-to-dictionary option is selected in VS Code. Based on this behavior, I come up with the following solution. The code snippetvim.fn.expand("%:p:h")
gets the absolute path of the Neovim buffer, so the provided solution looks for a.vscode/ltex.dictionary.en-US.txt
hierarchy in the same directory. Then, the lines in both global user dictionary and local dictionary are utilized if these paths are valid. You can change/add different paths as well. One of the caveats is that the provided solution is not dynamic as in the VS Code extension, i.e., if you update the dictionary.txt
file, you need to restart Neovim. This problem can be prevented by defining anautocmd
to revaluate the table of words.I use this workaround, you can add words to your normal Neovim spelling directory and ltex-ls will use them. Not perfect, but works!