disable semantic tokens in on_init, in lspconfig.lua

This commit is contained in:
siduck 2024-03-05 08:01:37 +05:30
parent 2eac8906fc
commit d0af27648a
2 changed files with 16 additions and 13 deletions

View File

@ -54,7 +54,7 @@ end, { desc = "Comment Toggle" })
map( map(
"v", "v",
"<leader>/", "<leader>/",
"<ESC>:lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<CR>", "<ESC><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<CR>",
{ desc = "Comment Toggle" } { desc = "Comment Toggle" }
) )
@ -132,4 +132,4 @@ map("n", "<leader>cc", function()
end end
end, { desc = "Blankline Jump to current context" }) end, { desc = "Blankline Jump to current context" })
pcall(require, "custom.mappings") require "custom.mappings"

View File

@ -1,19 +1,9 @@
local M = {} local M = {}
local map = vim.keymap.set local map = vim.keymap.set
local conf = require("nvconfig").ui.lsp
-- export on_attach & capabilities for custom lspconfigs -- export on_attach & capabilities for custom lspconfigs
M.on_attach = function(client, bufnr) 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) local function opts(desc)
return { buffer = bufnr, desc = desc } return { buffer = bufnr, desc = desc }
end end
@ -38,6 +28,18 @@ M.on_attach = function(client, bufnr)
map({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts "Lsp Code action") map({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts "Lsp Code action")
map("n", "gr", vim.lsp.buf.references, opts "Lsp Show references") 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 end
M.capabilities = vim.lsp.protocol.make_client_capabilities() M.capabilities = vim.lsp.protocol.make_client_capabilities()
@ -67,6 +69,7 @@ M.defaults = function()
require("lspconfig").lua_ls.setup { require("lspconfig").lua_ls.setup {
on_attach = M.on_attach, on_attach = M.on_attach,
capabilities = M.capabilities, capabilities = M.capabilities,
on_init = M.on_init,
settings = { settings = {
Lua = { Lua = {