|
|
|
@ -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" }, "<leader>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 = {
|
|
|
|
|