This repository has been archived on 2024-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
neovim/plugins/lsp/lspconfig.lua

82 lines
3 KiB
Lua
Raw Permalink Normal View History

2022-09-16 23:42:53 +03:00
local lsp_config = require("lspconfig")
2022-09-19 20:43:20 +03:00
local saga = require("lspsaga")
2022-11-10 00:01:34 +03:00
local nlsp_settings = require("nlspsettings")
2022-09-19 20:43:20 +03:00
-- See: https://github.com/glepnir/lspsaga.nvim#configuration
2022-11-19 00:56:53 +03:00
saga.init_lsp_saga(@lspSagaSettings@)
2022-09-16 23:42:53 +03:00
-- always show signcolumns
vim.opt.signcolumn = "yes"
-- Mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
local opts = { noremap = true, silent = true }
vim.keymap.set("n", "<space>e", vim.diagnostic.open_float, opts)
2022-10-02 22:19:10 +03:00
vim.keymap.set("n", "[d", "<Cmd>Lspsaga diagnostic_jump_prev<CR>", opts)
vim.keymap.set("n", "]d", "<Cmd>Lspsaga diagnostic_jump_next<CR>", opts)
2022-09-16 23:42:53 +03:00
vim.keymap.set("n", "<space>q", vim.diagnostic.setloclist, opts)
2022-09-19 20:43:20 +03:00
-- Only jump to error
vim.keymap.set("n", "[e", function()
require("lspsaga.diagnostic").goto_prev({ severity = vim.diagnostic.severity.ERROR })
end, opts)
vim.keymap.set("n", "]e", function()
require("lspsaga.diagnostic").goto_next({ severity = vim.diagnostic.severity.ERROR })
end, opts)
2022-09-16 23:42:53 +03:00
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
2022-09-17 17:29:42 +03:00
-- vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
2022-09-16 23:42:53 +03:00
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local bufopts = { noremap = true, silent = true, buffer = bufnr }
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, bufopts)
vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts)
vim.keymap.set("n", "gy", vim.lsp.buf.type_definition, bufopts)
vim.keymap.set("n", "gr", vim.lsp.buf.references, bufopts)
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, bufopts)
-- vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, bufopts)
-- vim.keymap.set("n", "<localleader>f", vim.lsp.buf.formatting, bufopts)
2022-09-19 20:43:20 +03:00
vim.keymap.set("n", "<localleader>n", "<Cmd>Lspsaga rename<CR>", bufopts)
vim.keymap.set({ "n", "v" }, "<localleader>a", "<Cmd>Lspsaga code_action<CR>", bufopts)
vim.keymap.set("n", "K", "<Cmd>Lspsaga hover_doc<CR>", bufopts)
vim.keymap.set("n", "co", "<Cmd>LSoutlineToggle<CR>", bufopts)
2022-09-16 23:42:53 +03:00
end
-- nvim-cmp
2023-02-03 02:22:57 +03:00
local capabilities = require("cmp_nvim_lsp").default_capabilities()
2022-09-16 23:42:53 +03:00
2022-11-10 00:01:34 +03:00
-- for local configurations
nlsp_settings.setup({})
2022-09-16 23:42:53 +03:00
-------------------------------------------------------------------------------
-- See: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
--
vim.g.markdown_fenced_languages = { "ts=typescript" }
2022-11-19 00:56:53 +03:00
-- Override the default configuration to be applied to all servers
lsp_config.util.default_config = vim.tbl_extend("force", lsp_config.util.default_config, {
on_attach = on_attach,
capabilities = capabilities,
})
2022-11-19 00:56:53 +03:00
local root_pattern = lsp_config.util.root_pattern
for name, settings in pairs(@lspConfigServers@) do
lsp_config[name].setup(settings)
2022-09-16 23:42:53 +03:00
if name == "eslint" then
vim.cmd([[
aug eslint_fix
au!
2023-06-21 12:39:58 +03:00
au BufWritePre *.tsx,*.ts,*.jsx,*.js silent! EslintFixAll
aug END
]])
end
end
2022-11-18 00:03:36 +03:00