From fe54bfdc5f6c65e62065b478fc7b2ddbe2f2a012 Mon Sep 17 00:00:00 2001 From: Ahmad Ansori Palembani Date: Sun, 15 Jun 2025 12:07:18 +0700 Subject: [PATCH] fix(nvim/lsp): Diagnostic not working properly I don't even know why setting capabilities.textDocument.diagnostic to vim.NIL fix the issue... --- .config/nvim/lazy-lock.json | 2 +- .config/nvim/lua/null/plugins/lsp.lua | 55 ++++++++++++++------------- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index ce61ee0..45b5e72 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -15,7 +15,7 @@ "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, "nvim-lint": { "branch": "master", "commit": "2b0039b8be9583704591a13129c600891ac2c596" }, - "nvim-lspconfig": { "branch": "master", "commit": "f6d31b1c17f1a338ddcf56aaa930a8c88e904662" }, + "nvim-lspconfig": { "branch": "master", "commit": "7ad4a11cc5742774877c529fcfb2702f7caf75e4" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, "nvim-web-devicons": { "branch": "master", "commit": "1fb58cca9aebbc4fd32b086cb413548ce132c127" }, "oil.nvim": { "branch": "master", "commit": "08c2bce8b00fd780fb7999dbffdf7cd174e896fb" }, diff --git a/.config/nvim/lua/null/plugins/lsp.lua b/.config/nvim/lua/null/plugins/lsp.lua index f3cc10a..ef59a8b 100644 --- a/.config/nvim/lua/null/plugins/lsp.lua +++ b/.config/nvim/lua/null/plugins/lsp.lua @@ -76,23 +76,6 @@ return { "nvim-lua/plenary.nvim", "mason-org/mason.nvim", }, - opts = { - platform = { - type = "roblox", - }, - types = { - roblox_security_level = "PluginSecurity", - }, - sourcemap = { - enabled = true, - autogenerate = true, -- automatic generation when the server is attached - rojo_project_file = "default.project.json", - sourcemap_file = "sourcemap.json", - }, - }, - config = function(_, opts) - require("luau-lsp").setup(opts) - end, }, { "neovim/nvim-lspconfig", @@ -105,11 +88,12 @@ return { diagnostics = { underline = true, update_in_insert = false, - virtual_text = { - spacing = 4, - source = "if_many", - prefix = "•", - }, + virtual_lines = true, + -- virtual_text = { + -- spacing = 4, + -- source = "if_many", + -- prefix = "•", + -- }, severity_sort = true, signs = { text = { @@ -126,6 +110,9 @@ return { dynamicRegistration = true, }, }, + textDocument = { + diagnostic = vim.NIL, -- I don't know why, but I need to set this to vim.NIL otherwise diagnostic would show up + }, }, } end, @@ -137,10 +124,10 @@ return { -- Setup lspconfig local has_cmp, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") - local capabilities = vim.tbl_deep_extend( + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities = vim.tbl_deep_extend( "force", - {}, - vim.lsp.protocol.make_client_capabilities(), + capabilities, has_cmp and cmp_nvim_lsp.default_capabilities() or {}, opts.capabilities or {} ) @@ -176,8 +163,8 @@ return { }, }, } - -- "luau_lsp" already handle vim.lsp.enable(...), so it's no longer needed - vim.lsp.config["luau_lsp"] = { + -- "require("luau-lsp").setup(...)" already handle vim.lsp.enable(...), so it's no longer needed + vim.lsp.config("luau-lsp", { capabilities = capabilities, on_attach = on_attach, settings = { @@ -190,6 +177,20 @@ return { }, }, }, + }) + require("luau-lsp").setup { + platform = { + type = "roblox", + }, + types = { + roblox_security_level = "PluginSecurity", + }, + sourcemap = { + enabled = true, + autogenerate = true, -- automatic generation when the server is attached + rojo_project_file = "default.project.json", + sourcemap_file = "sourcemap.json", + }, } --#endregion --#region Rust