diff options
author | Thomas Voss <mail@thomasvoss.com> | 2023-11-07 13:39:23 +0100 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2023-11-07 13:42:36 +0100 |
commit | 9bbe0077104e5e0dab8b1a8f197f7ce9bb240be4 (patch) | |
tree | d481d1ad6a50d7dc17f0f0f4a023806514295db9 /.config/nvim/after/plugin/lsp.lua | |
parent | 26e9302a62b7461ebffda8ae9a56025a90658194 (diff) |
nvim: Make LSP config more minimal
Diffstat (limited to '.config/nvim/after/plugin/lsp.lua')
-rw-r--r-- | .config/nvim/after/plugin/lsp.lua | 84 |
1 files changed, 45 insertions, 39 deletions
diff --git a/.config/nvim/after/plugin/lsp.lua b/.config/nvim/after/plugin/lsp.lua index dcf98f1..12e1025 100644 --- a/.config/nvim/after/plugin/lsp.lua +++ b/.config/nvim/after/plugin/lsp.lua @@ -1,40 +1,46 @@ -local lsp = require('lsp-zero') -local lib = require('mango.lib') - -lsp.preset('recommended') -lsp.ensure_installed({ - 'clangd', - 'gopls', - 'rust_analyzer', -}) - -lsp.nvim_workspace() - -local cmp = require('cmp') -local cmp_select = { behavior = cmp.SelectBehavior.Select } -local cmp_mappings = lsp.defaults.cmp_mappings({ - ['<C-k>'] = cmp.mapping.select_prev_item(cmp_select), - ['<C-j>'] = cmp.mapping.select_next_item(cmp_select), - ['<CR>'] = cmp.mapping.confirm({ select = true }), - ['<C-Space>'] = cmp.mapping.complete(), -}) - -lsp.set_preferences({ - suggest_lsp_servers = false, - sign_icons = {} +local conf = require('lspconfig') + +conf.clangd.setup {} +conf.gopls.setup {} +conf.rust_analyzer.setup {} +conf.lua_ls.setup { + settings = { + Lua = { + runtime = { + version = 'LuaJIT', + }, + diagnostics = { + globals = { + 'vim', + 'require', + }, + }, + workspace = { + library = vim.api.nvim_get_runtime_file('', true), + }, + telemetry = { + enable = false, + }, + }, + }, +} + +vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('MangoLspConfig', {}), + callback = function(ev) + local function remap(mode, map, fn) + vim.keymap.set(mode, map, fn, { buffer = ev.buf }) + end + + vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' + remap('n', 'K', vim.lsp.buf.hover) + remap('n', 'gd', vim.lsp.buf.definition) + remap('n', 'gi', vim.lsp.buf.implementation) + remap('n', 'gr', vim.lsp.buf.rename) + remap('n', 'gt', vim.lsp.buf.type_definition) + remap('n', 'g=', function() vim.lsp.buf.format { async = true } end) + remap('n', ']d', vim.diagnostic.goto_prev) + remap('n', '[d', vim.diagnostic.goto_next) + remap('n', '<leader>la', vim.lsp.buf.code_action) + end, }) - -lsp.setup_nvim_cmp({ - mapping = cmp_mappings -}) - -lsp.on_attach(function(_, bufnr) - local opts = { buffer = bufnr, remap = false } - - lib.remap('n', 'gd', vim.lsp.buf.definition, opts) - lib.remap('n', '<leader>la', vim.lsp.buf.code_action, opts) - lib.remap('n', '<leader>lr', vim.lsp.buf.rename, opts) - lib.remap('n', '<leader>l=', vim.lsp.buf.format, opts) -end) - -lsp.setup() |