Disable diagnostics by default

The LSP makes me feel extremely under siege, especially since seemingly every LSP server insists on throwing hundreds of totally useless style warnings.

I would really like the diagnostics to be toggle-able, defaulting to OFF, but for the LSP server to start running in the background when I start neovim whether I use the diagnostics or not.

The current API doesn’t seem to provide particularly great ways of doing this… I can probably hobble something together with the documented functions, but it won’t be pretty… and in my early experiments with this I have utterly failed to get neovim to start with diagnostics off.

Any suggestions?


autocmd BufEnter * lua vim.lsp.diagnostic.disable() will probably do what you want. You can map a key to lua vim.lsp.diagnostic.enable()

Note, there is no turning diagnostics on or off, only turning the display of diagnostics on/off. Most servers send diagnostics regardless of if we report the diagnostic capability. You should also look into configuring your language server to remove style warnings you do not want.

1 Like

Thanks for your response, that’s really helpful.

For others reading along wondering why vim.lsp.diagnostic.disable() doesn’t work in NVIM 0.5.0, it’s because it was only added 12 days ago:

In case of noisy lsp diagnostics in your vim config you might want to create some ignore patterns.

For instance:

local luadev =
    lspconfig = {
      on_attach = on_attach,
      cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"}
    settings = {
      Lua = {
        diagnostics = {
          globals = {"vim", "use"}

or even better, make the lsp aware of stuff like “use” as been described here: https://www.reddit.com/r/neovim/comments/kv0tce/sumneko_lua_lsp_says_packers_use_is_an_undefined/

Alternatively, is there a way to change the color of the inline diagnostics? Right now they use the same color as un-highlighted code.

Yep, see the lspconfig wiki under ui customization