diff --git a/src/.config/nvim/init.vim b/src/.config/nvim/init.vim index c21097f..332ac29 100755 --- a/src/.config/nvim/init.vim +++ b/src/.config/nvim/init.vim @@ -162,6 +162,11 @@ Plug 'nvim-treesitter/nvim-treesitter' Plug 'axieax/urlview.nvim' +Plug 'neovim/nvim-lspconfig' +Plug 'nvim-lua/completion-nvim' +Plug 'nvim-lua/lsp-status.nvim' +Plug 'stevearc/dressing.nvim' + call plug#end() " copy URL under cursor to clipboard bind diff --git a/src/.config/nvim/lua/init.lua b/src/.config/nvim/lua/init.lua index 2a8b2e7..b3dd90d 100644 --- a/src/.config/nvim/lua/init.lua +++ b/src/.config/nvim/lua/init.lua @@ -23,3 +23,43 @@ require("urlview").setup({ next = "uh", }, }) + +local nvim_lsp = require('lspconfig') + +local on_attach = function(client, bufnr) + local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end + local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end + -- Enable completion triggered by + buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') + + local opts = { noremap=true, silent=true } + buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) + buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) + buf_set_keymap('n', 'gK', 'lua vim.lsp.buf.hover()', opts) + buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) + buf_set_keymap('n', 'gs', 'lua vim.lsp.buf.signature_help()', opts) + buf_set_keymap('n', 'gt', 'lua vim.lsp.buf.type_definition()', opts) + buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts) + buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) + buf_set_keymap('n', 'e', 'lua vim.lsp.diagnostic.show_line_diagnostics()', opts) + buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) + buf_set_keymap('n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) + buf_set_keymap('n', 'ca', 'lua vim.lsp.buf.code_action()', opts) +end + +local servers = { 'pylsp', 'clangd' } +for _, lsp in ipairs(servers) do +nvim_lsp[lsp].setup { + on_attach = on_attach, + flags = { + debounce_text_changes = 150, + } +} +end + +-- fancy prompts +require('dressing').setup({ + input = { + insert_only = false, + } +}) diff --git a/src/.config/nvim/makefile b/src/.config/nvim/makefile index 69d0a6d..930b895 100644 --- a/src/.config/nvim/makefile +++ b/src/.config/nvim/makefile @@ -3,3 +3,7 @@ ~/.cache/termdebug/%: %.cpp mkdir -p ~/.cache/termdebug/ $(LINK.cpp) -g -Wall -Wpedantic $^ $(LOADLIBES) $(LDLIBS) -o $@ + +~/.cache/termdebug/%: %.c + mkdir -p ~/.cache/termdebug/ + $(LINK.c) -g -Wall -Wpedantic $^ $(LOADLIBES) $(LDLIBS) -o $@