From d0af27648a9a11f11f2a31ce035678cac33cba9f Mon Sep 17 00:00:00 2001 From: siduck Date: Tue, 5 Mar 2024 08:01:37 +0530 Subject: [PATCH] disable semantic tokens in on_init, in lspconfig.lua --- lua/core/mappings.lua | 4 ++-- lua/plugins/configs/lspconfig.lua | 25 ++++++++++++++----------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index ba80b4f..2c06e88 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -54,7 +54,7 @@ end, { desc = "Comment Toggle" }) map( "v", "/", - ":lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", + "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", { desc = "Comment Toggle" } ) @@ -132,4 +132,4 @@ map("n", "cc", function() end end, { desc = "Blankline Jump to current context" }) -pcall(require, "custom.mappings") +require "custom.mappings" diff --git a/lua/plugins/configs/lspconfig.lua b/lua/plugins/configs/lspconfig.lua index 1b5adc9..ca2bb87 100644 --- a/lua/plugins/configs/lspconfig.lua +++ b/lua/plugins/configs/lspconfig.lua @@ -1,19 +1,9 @@ local M = {} local map = vim.keymap.set +local conf = require("nvconfig").ui.lsp -- export on_attach & capabilities for custom lspconfigs M.on_attach = function(client, bufnr) - local conf = require("nvconfig").ui.lsp - - -- semanticTokens - if not conf.semantic_tokens and client.supports_method "textDocument/semanticTokens" then - client.server_capabilities.semanticTokensProvider = nil - end - - if conf.signature and client.server_capabilities.signatureHelpProvider then - require("nvchad.signature").setup(client, bufnr) - end - local function opts(desc) return { buffer = bufnr, desc = desc } end @@ -38,6 +28,18 @@ M.on_attach = function(client, bufnr) map({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts "Lsp Code action") map("n", "gr", vim.lsp.buf.references, opts "Lsp Show references") + + -- setup signature popup + if conf.signature and client.server_capabilities.signatureHelpProvider then + require("nvchad.signature").setup(client, bufnr) + end +end + +-- disable semanticTokens +M.on_init = function(client, _) + if not conf.semantic_tokens and client.supports_method "textDocument/semanticTokens" then + client.server_capabilities.semanticTokensProvider = nil + end end M.capabilities = vim.lsp.protocol.make_client_capabilities() @@ -67,6 +69,7 @@ M.defaults = function() require("lspconfig").lua_ls.setup { on_attach = M.on_attach, capabilities = M.capabilities, + on_init = M.on_init, settings = { Lua = {