diff options
author | davidpkj <davidpenkow1@gmail.com> | 2022-12-03 22:26:26 +0100 |
---|---|---|
committer | davidpkj <davidpenkow1@gmail.com> | 2022-12-03 22:26:26 +0100 |
commit | 5d4a749b7c51649bcd3953cd1686856408d08121 (patch) | |
tree | d0ddab7d5ee206e9b4403d4f177d942ec1608aa0 /neovim/.config/nvim/lua/plugins/lsp.lua | |
parent | 4f7ccffecdfa36c5e531654b8eec44199935d497 (diff) |
Merge in dotfiles
Diffstat (limited to 'neovim/.config/nvim/lua/plugins/lsp.lua')
-rw-r--r-- | neovim/.config/nvim/lua/plugins/lsp.lua | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/neovim/.config/nvim/lua/plugins/lsp.lua b/neovim/.config/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..db73c10 --- /dev/null +++ b/neovim/.config/nvim/lua/plugins/lsp.lua @@ -0,0 +1,79 @@ +require("lspconfig") + +local sign = function(opts) + vim.fn.sign_define(opts.name, { + texthl = opts.name, + text = opts.text, + numhl = '' + }) +end + +sign({name = 'DiagnosticSignError', text = ''}) +sign({name = 'DiagnosticSignWarn', text = ''}) +sign({name = 'DiagnosticSignHint', text = ''}) +sign({name = 'DiagnosticSignInfo', text = ''}) + +vim.diagnostic.config({ + signs = true, + virtual_text = false, + update_in_insert = true, + underline = false, + severity_sort = true, + float = { + source = 'always', + header = '', + prefix = '', + }, +}) + +require("keybinds") + +map("n", "<F2>", "<cmd>lua vim.lsp.buf.rename()<cr>") +map("n", "<C-h>", "<cmd>lua vim.diagnostic.open_float()<cr>") + +--[[ +nnoremap <silent> <c-]> <cmd>lua vim.lsp.buf.definition()<CR> +nnoremap <silent> K <cmd>lua vim.lsp.buf.hover()<CR> +nnoremap <silent> gD <cmd>lua vim.lsp.buf.implementation()<CR> +nnoremap <silent> <c-k> <cmd>lua vim.lsp.buf.signature_help()<CR> +nnoremap <silent> 1gD <cmd>lua vim.lsp.buf.type_definition()<CR> +nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR> +nnoremap <silent> g0 <cmd>lua vim.lsp.buf.document_symbol()<CR> +nnoremap <silent> gW <cmd>lua vim.lsp.buf.workspace_symbol()<CR> +nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR> + +-- Jump to the definition +bufmap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>') + +-- Jump to declaration +bufmap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>') + +-- Lists all the implementations for the symbol under the cursor +bufmap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>') + +-- Jumps to the definition of the type symbol +bufmap('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>') + +-- Lists all the references +bufmap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>') + +-- Displays a function's signature information +bufmap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<cr>') + +-- Renames all references to the symbol under the cursor +bufmap('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>') + +-- Selects a code action available at the current cursor position +bufmap('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>') +bufmap('x', '<F4>', '<cmd>lua vim.lsp.buf.range_code_action()<cr>') + +-- Show diagnostics in a floating window +bufmap('n', 'gl', '<cmd>lua vim.diagnostic.open_float()<cr>') + +-- Move to the previous diagnostic +bufmap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<cr>') + +-- Move to the next diagnostic +bufmap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<cr>') +]] + |