From dab78c673f209281600118f44cb51626b9ef2bf9 Mon Sep 17 00:00:00 2001 From: Sijmen Date: Sun, 7 Aug 2022 22:44:58 +0200 Subject: [PATCH] nvim: lsp stuff --- common/nvim.lua | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/common/nvim.lua b/common/nvim.lua index 03a91a0..debccb7 100644 --- a/common/nvim.lua +++ b/common/nvim.lua @@ -14,6 +14,8 @@ vim.cmd [[ ]] g.mapleader = ' ' +g.indentLine_char = '⎸' +g.indentLine_color_gui = '#c7c7c7' opt.undofile = true opt.undodir = "/home/sijmen/.cache/nvim/undo" @@ -54,11 +56,39 @@ require("nvim-treesitter.configs").setup { }, } + +local opts = { noremap=true, silent=true } +vim.keymap.set('n', 'e', vim.diagnostic.open_float, 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', 'q', vim.diagnostic.setloclist, opts) + +local on_attach = function(client, bufnr) + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + + 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', 'K', vim.lsp.buf.hover, bufopts) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) + vim.keymap.set('n', '', vim.lsp.buf.signature_help, bufopts) + vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, bufopts) + vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, bufopts) + + vim.keymap.set('n', 'wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, bufopts) + + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, bufopts) + vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) + vim.keymap.set('n', 'f', vim.lsp.buf.formatting, bufopts) +end + local lspconfig = require("lspconfig") -lspconfig.rnix.setup {} -lspconfig.pyright.setup {} - -require("rust-tools").setup {} - +lspconfig.rnix.setup { on_attach = on_attach } +lspconfig.pyright.setup { on_attach = on_attach } +lspconfig.rust_analyzer.setup { on_attach = on_attach } vim.api.nvim_set_keymap("n", "", ":NvimTreeToggle", { noremap = true, silent = true })