66 lines
2.5 KiB
Lua
66 lines
2.5 KiB
Lua
local lspconfig = require('lspconfig')
|
|
|
|
lspconfig.lua_ls.setup {}
|
|
lspconfig.ts_ls.setup {}
|
|
lspconfig.eslint.setup {}
|
|
lspconfig.angularls.setup {}
|
|
lspconfig.ccls.setup {}
|
|
|
|
-- Global mappings.
|
|
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
|
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, {
|
|
desc = 'Open LSP diagnostics'
|
|
})
|
|
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, {
|
|
desc = 'Go to previous LSP diagnostic'
|
|
})
|
|
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, {
|
|
desc = 'Go to next LSP diagnostic'
|
|
})
|
|
|
|
-- Use LspAttach autocommand to only map the following keys
|
|
-- after the language server attaches to the current buffer
|
|
vim.api.nvim_create_autocmd('LspAttach', {
|
|
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
|
|
callback = function(ev)
|
|
-- Enable completion triggered by <c-x><c-o>
|
|
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
|
|
|
|
-- Buffer local mappings.
|
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
|
local opts = function (desc) return { buffer = ev.buf, desc = desc } end
|
|
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts('Go to declaration'))
|
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts('Go to definition'))
|
|
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts('Show LSP info'))
|
|
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts('Go to implementation'))
|
|
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts('Show function signature'))
|
|
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts('Add workspace folder'))
|
|
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts('Remove workspace folder'))
|
|
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts('Go to type definition'))
|
|
vim.keymap.set('n', '<space>r', vim.lsp.buf.rename, opts('Rename symbol'))
|
|
vim.keymap.set({ 'n', 'v' }, '<space>x', vim.lsp.buf.code_action, opts('Execute code action'))
|
|
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts('Go to references'))
|
|
vim.keymap.set('n', '<space>f', function()
|
|
vim.lsp.buf.format { async = true }
|
|
end, opts('Format buffer with LSP'))
|
|
end,
|
|
})
|
|
|
|
local rt = require("rust-tools")
|
|
|
|
rt.setup({
|
|
server = {
|
|
on_attach = function(_, bufnr)
|
|
-- Hover actions
|
|
vim.keymap.set("n", "<C-space>", rt.hover_actions.hover_actions, { buffer = bufnr })
|
|
-- Code action groups
|
|
vim.keymap.set("n", "<Leader>a", rt.code_action_group.code_action_group, { buffer = bufnr })
|
|
end,
|
|
},
|
|
})
|
|
|
|
local wk = require 'which-key'
|
|
wk.add({
|
|
{ '<space>w', group = 'LSP workspace' }
|
|
})
|