eslintneovimlinternvim-lspconfig

How to silence linter for eslint


This is the setting I have in my nvim config file

  local servers = { 'tsserver', 'eslint', 'bashls' }

  for _, lsp in ipairs(servers) do
      lspconfig[lsp].setup {
          capabilities = capabilities,
          on_attach = on_attach,
          flags = lsp_flags,
          on_attach = function(client, bufnr)
            navbuddy.attach(client, bufnr)
            vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
            vim.keymap.set('n', 'gl', vim.diagnostic.open_float, opts)
          end
      }
  end

I love the go to definition etc capabilities offered, but the linter can be distracting:

enter image description here

(note: the code isn’t my own so don’t judge)

How can I silence the linter (ideally i would be able to turn it on/off from vim itself, but lacking that I’m ok enabling/disabling it from the nvim config file iteself)


Solution

  • You can disable virtual text for LSP diagnostics in your configuration, see :help vim.diagnostic.config :

    vim.diagnostic.config({ virtual_text = false })