Mopparthy Ravindranath
Mopparthy Ravindranath

Reputation: 3308

How to disable LSP virtual text

My neovim details:

NVIM v0.10.1
Build type: Release
LuaJIT 2.1.1713484068

OS details (if useful)

WSL2
Distributor ID: Ubuntu
Description:    Ubuntu 24.04 LTS
Release:        24.04
Codename:       noble

Also, I am using nvchad with lazyvim

What I want to do:

What I did to achieve this but not working..

vim.diagnostic.config({
  signs = true,
  underline = true,
  update_in_insert = false,
  virtual_text = false,
  severity_sort = true,
})
-- load defaults i.e lua_lsp
require("nvchad.configs.lspconfig").defaults()

local lspconfig = require "lspconfig"

-- EXAMPLE
local servers = { "html", "cssls", "rust_analyzer" }
local nvlsp = require "nvchad.configs.lspconfig"

-- Define custom LSP options
local custom_opts = {
  diagnostics = {
    underline = true,
    update_in_insert = false,
    virtual_text = false,
    severity_sort = true,
    signs = {
      text = {
        [vim.diagnostic.severity.ERROR] = "",
        [vim.diagnostic.severity.WARN] = "",
        [vim.diagnostic.severity.HINT] = "",
        [vim.diagnostic.severity.INFO] = "",
      },
    },
  },
  inlay_hints = {
    enabled = true,
    exclude = { "vue" },
  },
  document_highlight = {
    enabled = true,
  },
  capabilities = nvlsp.capabilities,
}

-- lsps with default config
for _, lsp in ipairs(servers) do
  lspconfig[lsp].setup {
    on_attach = nvlsp.on_attach,
    on_init = nvlsp.on_init,
    -- capabilities = nvlsp.capabilities,
    capabilities = custom_opts.capabilities,
    settings = custom_opts,
  }
end

But with no luck. The errors are shown inline. Any help is highly appreciated.

Upvotes: 1

Views: 596

Answers (1)

DipS
DipS

Reputation: 1

The closest I could get was to use - vim.diagnostic.enable(false);
which works, but disables linters as well.

Upvotes: 0

Related Questions