Migrate to vim.lsp
This commit is contained in:
@@ -1,140 +0,0 @@
|
||||
return {
|
||||
-- LSP Configuration & Plugins
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
"williamboman/mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
||||
|
||||
-- Some of the lsp keybindings rely on telescope
|
||||
"nvim-telescope/telescope.nvim",
|
||||
-- Set capabilities from cmp
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
|
||||
-- Add document color
|
||||
"mrshmllow/document-color.nvim",
|
||||
|
||||
"b0o/schemastore.nvim",
|
||||
|
||||
-- Rename with immediate visual feedback
|
||||
},
|
||||
config = function()
|
||||
local border = require("symbols.window").border
|
||||
|
||||
-- Set borders
|
||||
local handlers = {
|
||||
["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border }),
|
||||
["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = border }),
|
||||
}
|
||||
|
||||
require("lspconfig.ui.windows").default_options = {
|
||||
border = border,
|
||||
}
|
||||
|
||||
vim.diagnostic.config({
|
||||
severity_sort = true,
|
||||
})
|
||||
|
||||
-- Create the signs for diagnostic symbols
|
||||
local diagnostic = require("symbols.diagnostic")
|
||||
local signs = {
|
||||
Error = diagnostic.error,
|
||||
Warn = diagnostic.warn,
|
||||
Hint = diagnostic.hint,
|
||||
Info = diagnostic.info,
|
||||
}
|
||||
for type, icon in pairs(signs) do
|
||||
local hl_sign = "DiagnosticSign" .. type
|
||||
local hl_text = "Diagnostic" .. type
|
||||
vim.fn.sign_define(hl_sign, { text = icon, texthl = hl_sign })
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = vim.api.nvim_create_augroup("lsp-attach", { clear = true }),
|
||||
callback = function(event)
|
||||
local map = function(keys, func, desc)
|
||||
vim.keymap.set("n", keys, func, { buffer = event.buf, desc = "LSP:" .. desc })
|
||||
end
|
||||
|
||||
map("gd", vim.lsp.buf.definition, "Goto definition")
|
||||
map("gr", require("telescope.builtin").lsp_references, "Goto references")
|
||||
map("gI", require("telescope.builtin").lsp_implementations, "Goto implementation")
|
||||
map("<leader>D", vim.lsp.buf.type_definition, "Type definition")
|
||||
map("<leader>ds", require("telescope.builtin").lsp_document_symbols, "Document symbols")
|
||||
map("<leader>ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "Workspace symbols")
|
||||
|
||||
vim.keymap.set("n", "<leader>rn", function()
|
||||
return ":IncRename " .. vim.fn.expand("<cword>")
|
||||
end, { buffer = event.buf, expr = true, desc = "Rename" })
|
||||
|
||||
-- TODO: Do we need this to work in visal mode?
|
||||
vim.keymap.set(
|
||||
{ "v", "n" },
|
||||
"<leader>ca",
|
||||
vim.lsp.buf.code_action,
|
||||
{ buffer = event.buf, desc = "Code actions", remap = true }
|
||||
)
|
||||
|
||||
-- Signature help
|
||||
map("K", vim.lsp.buf.hover, "Hover Documentation")
|
||||
map("<C-k>", vim.lsp.buf.signature_help, "Signature Documentation")
|
||||
|
||||
-- Lesser used LSP functionality
|
||||
map("gD", vim.lsp.buf.declaration, "Goto declaration")
|
||||
|
||||
local client = vim.lsp.get_client_by_id(event.data.client_id)
|
||||
-- Turn of lsp based syntax highlighting
|
||||
if client then
|
||||
client.server_capabilities.semanticTokensProvider = nil
|
||||
if client.server_capabilities.documentHighlightProvider then
|
||||
local highlight_augrup = vim.api.nvim_create_augroup("lsp-highlight", { clear = false })
|
||||
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
|
||||
buffer = event.buf,
|
||||
group = highlight_augrup,
|
||||
callback = vim.lsp.buf.document_highlight,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
|
||||
buffer = event.buf,
|
||||
group = highlight_augrup,
|
||||
callback = vim.lsp.buf.clear_references,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("LspDetach", {
|
||||
group = vim.api.nvim_create_augroup("lsp-detach", { clear = true }),
|
||||
callback = function(event2)
|
||||
vim.lsp.buf.clear_references()
|
||||
vim.api.nvim_clear_autocmds({ group = highlight_augrup, buffer = event2.buf })
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
-- TODO: Only do this is cmp_nvim_lsp is enabled
|
||||
capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_capabilities())
|
||||
capabilities.textDocument.colorProvider = {
|
||||
dynamicRegistration = true,
|
||||
}
|
||||
|
||||
local handler = function(server_name)
|
||||
local server = require("tools").servers()[server_name] or {}
|
||||
server.capabilities = vim.tbl_deep_extend("force", capabilities, server.capabilities or {})
|
||||
server.handlers = handlers
|
||||
|
||||
require("lspconfig")[server_name].setup(server)
|
||||
end
|
||||
|
||||
for server, config in pairs(require("tools").servers()) do
|
||||
if config.system then
|
||||
handler(server)
|
||||
end
|
||||
end
|
||||
|
||||
require("mason-lspconfig").setup({
|
||||
handlers = { handler },
|
||||
})
|
||||
end,
|
||||
}
|
||||
@@ -1,28 +1,26 @@
|
||||
return {
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
opts = {
|
||||
ui = {
|
||||
border = require("symbols.window").border,
|
||||
height = 0.8,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
||||
dependencies = {
|
||||
"williamboman/mason.nvim",
|
||||
{ "mason-org/mason.nvim", opts = {} },
|
||||
"mason-org/mason-lspconfig.nvim",
|
||||
},
|
||||
config = function()
|
||||
local tools = require("tools")
|
||||
local ensure_installed = vim.tbl_keys(vim.tbl_map(function(tool)
|
||||
if tool.system then
|
||||
return nil
|
||||
local lsp = require("tools.lsp")
|
||||
|
||||
local ensure_installed = vim.tbl_values(vim.tbl_map(function(tool)
|
||||
if type(tool) == "table" then
|
||||
if not tool.system then
|
||||
return {
|
||||
tool[1],
|
||||
condition = tool.condition,
|
||||
}
|
||||
end
|
||||
else
|
||||
return tool
|
||||
end
|
||||
end, tools.servers()))
|
||||
ensure_installed = vim.list_extend(ensure_installed, tools.extra)
|
||||
return nil
|
||||
end, lsp))
|
||||
|
||||
require("mason-tool-installer").setup({
|
||||
ensure_installed = ensure_installed,
|
||||
@@ -30,6 +28,14 @@ return {
|
||||
})
|
||||
end,
|
||||
},
|
||||
{
|
||||
"mason-org/mason-lspconfig.nvim",
|
||||
opts = {},
|
||||
dependencies = {
|
||||
{ "mason-org/mason.nvim", opts = {} },
|
||||
"neovim/nvim-lspconfig",
|
||||
},
|
||||
},
|
||||
{
|
||||
"zapling/mason-conform.nvim",
|
||||
opts = {},
|
||||
|
||||
13
nvim/dot-config/nvim/lua/plugins/schemastore.lua
Normal file
13
nvim/dot-config/nvim/lua/plugins/schemastore.lua
Normal file
@@ -0,0 +1,13 @@
|
||||
return {
|
||||
"b0o/schemastore.nvim",
|
||||
config = function()
|
||||
vim.lsp.config("jsonls", {
|
||||
settings = {
|
||||
json = {
|
||||
validate = { enable = true },
|
||||
schemas = require("schemastore").json.schemas(),
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
}
|
||||
@@ -1,11 +1,19 @@
|
||||
return {
|
||||
"someone-stole-my-name/yaml-companion.nvim",
|
||||
dependencies = {
|
||||
"neovim/nvim-lspconfig",
|
||||
"nvim-lua/plenary.nvim",
|
||||
"nvim-telescope/telescope.nvim",
|
||||
"nvim-telescope/telescope.nvim",
|
||||
"diogo464/kubernetes.nvim",
|
||||
},
|
||||
config = function()
|
||||
require("telescope").load_extension("yaml_schema")
|
||||
|
||||
vim.lsp.config("yamlls", require("yaml-companion").setup({
|
||||
builtin_matchers = {
|
||||
kubernetes = { enabled = false },
|
||||
kubernetes_custom = { enabled = true },
|
||||
},
|
||||
}))
|
||||
end,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user