10 votes
Accepted

User borders around LSP floating windows

Since version 5.0, neovim supports adding borders to floating windows. :h lsp integrates it, too. But not by default; we have to enable it. The following configuration would do so. local _border = &...
3N4N's user avatar
  • 5,684
7 votes
Accepted

Is there a way to write a file and skip the autocmd on write?

Generally speaking, that's exactly what the :noautocmd command modifier is for. Just prefix your command with that and all autocommands should be disabled for just the run of that command. :noautocmd ...
B Layer's user avatar
  • 19.8k
6 votes

How to add keymapping for LSP code formatting in visual mode?

I found this question while solving the same problem, but now the function range_formatting() is deprecated. Now should use vim.lsp.formatexpr() or vim.lsp.buf.format() instead. You can define a ...
Fanteria's user avatar
6 votes
Accepted

How do I close a hover'ed window with LSP information, Escape does not work?

If you do NOT focus (click inside) of the hover, closing it is as simple as using any navigation key (h, j, k, l). However, if you do click inside, you'll either have to focus outside again or use :q....
Evan Carroll's user avatar
  • 1,304
6 votes
Accepted

Autocommand to run :Prettier on :w

We can use :h BufWritePre autocmd event. augroup Prettier au! au BufWritePre *.tsx,*.ts,*.js,*.html,*.css Prettier augroup END For explanation, see :h autocmd.
3N4N's user avatar
  • 5,684
5 votes

How to configure neovim to properly format python code?

Here is an example of how to make this work with lspconfig ~/.config/nvim/init.lua require("_plugins") ~/.config/nvim/lua/_plugins.lua local fn = vim.fn local install_path = fn.stdpath(&...
casonadams's user avatar
4 votes
Accepted

Where to find debug logs for an LSP started with vim.lsp.start()?

It seems like the vim.lsp.log module has to be required. :lua =require('vim.lsp.log').get_filename() works for me and gives me the correct location.
J_Tarasovic's user avatar
3 votes

How to add keymapping for LSP code formatting in visual mode?

It's sufficient just to do vim.keymap.set("v", "<leader>qf", vim.lsp.buf.format, { remap = false }) From :h vim.lsp.buf.format(), range (table|nil) Range to format. Table ...
wardw's user avatar
  • 230
3 votes
Accepted

Neovim LSP with Go

It turns out, the buffer doesn't get attached unless I have a .git folder in the project root directory, or a go.mod file. I didn't have those, I just had a main.go.
J86's user avatar
  • 225
2 votes
Accepted

Completion sources not recognized by nvim-cmp

This turned out to be an issue with the way that the completion sources are structured. Pathogen is not able to load them. I resolved the issue by switching to packer.
Floegipoky's user avatar
2 votes
Accepted

rust-analyzer not working in NeoVim on Windows 10

I had missed the section of the documentation that says: Other editors generally require the rust-analyzer binary to be in $PATH. You can download pre-built binaries from the releases page. You will ...
Matt Hogan-Jones's user avatar
2 votes

Make LanguageServer aware of requirements without activating virtual environment (Python)

As statox pointed out in a comment, there is probably no way around having the dependencies installed somewhere on the machine: Your LSP server needs to have the declarations stored somewhere, if you ...
Jonathan Scholbach's user avatar
2 votes

Error while configuring nvim cmp

My mistake at line # 148 -- Setup lspconfig. 148 require('lspconfig')[tsserver].setup { 149 capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol....
Mopparthy Ravindranath's user avatar
2 votes
Accepted

Typescript add missing import on cursor?

Ok, I assume the following according to your post + image: You're using neovim >= 0.5.0 You've already set up the server with (assuming that the following code is in a lua file like ~/.config/nvim/...
TornaxO7's user avatar
  • 561
2 votes
Accepted

What is the term of feature used by on-the-fly checkers?

As far as I can tell the term for that feature is inline diagnostics. I don't see any obvious source (like neovim help) for an answer to how to disable it but I found these two possible solutions: vim....
B Layer's user avatar
  • 19.8k
2 votes

Vim LSP: change keybindings only if there is a LS attached to buffer

I would suggest to refactor it, introducing a dedicated function that does all the mappings: func! s:lsp_mappings() nnoremap <silent> <buffer> <c-]> <cmd>lua vim.lsp.buf....
Maxim Kim's user avatar
  • 13.4k
2 votes

How to set the diagnostic level for neovim lsp

Not sure if LunarVim has a layer on top, but the minimal setup in Lua would be: vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( vim.lsp.diagnostic....
Tae's user avatar
  • 2,125
2 votes

Is there a way to write a file and skip the autocmd on write?

Just ignore all errors from LanguageClient silent! call LanguageClient#textDocument_formatting_sync() Note: the last error message is still available as echo v:errmsg.
Matt's user avatar
  • 20.7k
2 votes

Can I go to the implementation in the c project with lsp?

As far as I know, clangd is not able to jump to func1() via "Go To Definition" or "Find References" capabilities because there is not a direct link to func1.c. As an alternative, ...
r_31415's user avatar
  • 576
2 votes

How do I close a hover'ed window with LSP information, Escape does not work?

Improving Telemachus' answer further, if you want to toggle the hover with K, you can do the following: vim.api.nvim_create_autocmd("LspAttach", { callback = function(ev) vim....
Daniel's user avatar
  • 121
2 votes
Accepted

How can i use Enter to select item from popup menu?

See :help popup-menu-keys assuming these plugins are using :help ins-completion-menu. You could probably setup a conditional mapping like :inoremap <expr> <cr> pumvisible() ? '<c-y>' ...
D. Ben Knoble's user avatar
  • 26.1k
2 votes

How to configure neovim to properly format python code?

It took some time to figure out what is happening. Short answer: looks like LSP servers do not affect nvim's indentation when you press "Enter" button while editing text. I had to install ...
lesnik's user avatar
  • 471
2 votes

nvim-lspconfig omnifunc opens preview window

This happens when completeopt has the preview option in it. You probably added this to your config at one point. Check verbose set completeopt? to see its contents and where it was last set from, so ...
shadowtalker's user avatar
2 votes
Accepted

Prevent Neovim LSP from opening a scratch preview buffer

You should be able to use :set completeopt-=preview to remove this behavior.
D. Ben Knoble's user avatar
  • 26.1k
2 votes
Accepted

Neovim - LSP attached to client but not working

So I found out why the code completion isn't working!! After tracing the processes spawned by vscode when opening an angular project. I found out that vscode spawned both ngserver (Angular) and ...
anonymous-1234's user avatar
2 votes

How to use ALE with clangd and C++20

I am also using Vim 9.0 with ALE plugin I am also configuring ALE for different programming languages. I saw your post and decided to try C++ first. Thank you for posting this query. I tried your code,...
Khushal's user avatar
  • 21
2 votes

ALE Code Action for python

I'm not aware of a Vim plugin that provide fix for warning detected by the linter. But for automatic correction of missing Python import you could be interested by autoimport You can fix the import ...
Vivian De Smedt's user avatar
2 votes

How to search workspace symbols across multiple languages by using LSP in Neovim?

:Telescope lsp_workspace_symbols query=searchTerm There is a bug related to this, you need the query=searchTerm.
Channing Walton's user avatar
2 votes

How do I add a custom LSP to `nvim-lspconfig`?

You must do something like this (this example is for a different LSP, please adapt accordingly): require('lspconfig.configs').templ = { default_config = { cmd = {"templ", "lsp&...
fiatjaf's user avatar
  • 123
2 votes
Accepted

How can I go to the definition (gD) in a new tab?

I believe you don't have the distinction declaration and definition in typescript like you have it in C or C++. myfile.h // declaration int myfunction(int a, char *name); myfile.c // definition int ...
Vivian De Smedt's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible