@ -0,0 +1,52 @@ | |||||
local M = {} | |||||
local servers = { | |||||
gopls = {}, | |||||
html = {}, | |||||
jsonls = {}, | |||||
pyright = {}, | |||||
tsserver = {}, | |||||
vimls = {}, | |||||
dartls = {}, | |||||
dockerls = {}, | |||||
intelephense = {}, | |||||
sqlls = {}, | |||||
volar = {}, | |||||
} | |||||
local function on_attach(client, bufnr) | |||||
-- Enable completion triggered by <C-X><C-O> | |||||
-- See `:help omnifunc` and `:help ins-completion` for more information. | |||||
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") | |||||
-- Use LSP as the handler for formatexpr. | |||||
-- See `:help formatexpr` for more information. | |||||
vim.api.nvim_buf_set_option(0, "formatexpr", "v:lua.vim.lsp.formatexpr()") | |||||
-- Configure key mappings | |||||
require("config.lsp.keymaps").setup(client, bufnr) | |||||
end | |||||
local lsp_signature = require "lsp_signature" | |||||
lsp_signature.setup { | |||||
bind = true, | |||||
handler_opts = { | |||||
border = "rounded", | |||||
}, | |||||
} | |||||
local capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities()) | |||||
local opts = { | |||||
on_attach = on_attach, | |||||
capabilities = cababilities, | |||||
flags = { | |||||
debounce_text_changes = 150, | |||||
}, | |||||
} | |||||
function M.setup() | |||||
require("config.lsp.installer").setup(servers, opts) | |||||
end | |||||
return M |
@ -0,0 +1,26 @@ | |||||
local lsp_installer_servers = require "nvim-lsp-installer.servers" | |||||
local utils = require "utils" | |||||
local M = {} | |||||
function M.setup(servers, options) | |||||
for server_name, _ in pairs(servers) do | |||||
local server_available, server = lsp_installer_servers.get_server(server_name) | |||||
if server_available then | |||||
server:on_ready(function() | |||||
local opts = vim.tbl_deep_extend("force", options, servers[server.name] or {}) | |||||
server:setup(opts) | |||||
end) | |||||
if not server:is_installed() then | |||||
utils.info("Installing " .. server.name) | |||||
server:install() | |||||
end | |||||
else | |||||
utils.error(server) | |||||
end | |||||
end | |||||
end | |||||
return M |
@ -0,0 +1,36 @@ | |||||
local M = {} | |||||
local keymap = vim.api.nvim_set_keymap | |||||
local buf_keymap = vim.api.nvim_buf_set_keymap | |||||
local function keymappings(client, bufnr) | |||||
local opts = { noremap = true, silent = true } | |||||
-- Key mappings | |||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) | |||||
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) | |||||
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts) | |||||
vim.keymap.set("n", "[e", function () vim.diagnostic.goto_prev({severity = vim.diagnostic.severity.ERROR}) end, opts) | |||||
vim.keymap.set("n", "]e", function () vim.diagnostic.goto_next({severity = vim.diagnostic.severity.ERROR}) end, opts) | |||||
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts) | |||||
vim.keymap.set("n", "K", vim.lsp.buf.code_action, opts) | |||||
vim.keymap.set("n", "<leader>of", vim.diagnostic.open_float, opts) | |||||
-- if client.resolved_capabilities.document_formatting then | |||||
-- vim.keymap.set("n", "<leader>ff", vim.lsp.buf.formatting, opts) | |||||
-- end | |||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) | |||||
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) | |||||
vim.keymap.set("n", "gh", vim.lsp.buf.signature_help, opts) | |||||
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts) | |||||
vim.keymap.set("n", "gT", vim.lsp.buf.type_definition, opts) | |||||
end | |||||
function M.setup(client, bufnr) | |||||
keymappings(client, bufnr) | |||||
end | |||||
return M |