Tue, 14 Feb 2023 02:39:04 -0600
Add more plain vim plugins
1016 | 1 | vim.diagnostic.config({ |
2 | virtual_text = { true, severity = "WARN", }, | |
3 | }) | |
4 | ||
5 | vim.api.nvim_create_autocmd("LspAttach", { | |
6 | once = true, | |
7 | callback = function(args) | |
8 | vim.opt.number = true | |
9 | end, | |
10 | }) | |
11 | ||
12 | local opts = { noremap=true, silent=true } | |
13 | vim.keymap.set('n', '<leader>d', vim.diagnostic.open_float, opts) | |
14 | vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) | |
15 | vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts) | |
16 | vim.keymap.set('n', '<leader>ld', vim.diagnostic.setloclist, opts) | |
17 | ||
18 | vim.api.nvim_create_autocmd("LspAttach", { | |
19 | callback = function(args) | |
20 | local bufnr = args.buf | |
21 | local bufopts = { noremap=true, silent=true, buffer=bufnr } | |
22 | ||
23 | vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) | |
24 | vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) | |
25 | vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) | |
26 | vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) | |
27 | vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts) | |
28 | vim.keymap.set('n', '<leader>wa', vim.lsp.buf.add_workspace_folder, bufopts) | |
29 | vim.keymap.set('n', '<leader>wr', vim.lsp.buf.remove_workspace_folder, bufopts) | |
30 | vim.keymap.set('n', '<leader>wl', function() | |
31 | print(vim.inspect(vim.lsp.buf.list_workspace_folders())) | |
32 | end, bufopts) | |
33 | vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, bufopts) | |
34 | vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, bufopts) | |
35 | vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, bufopts) | |
36 | vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) | |
37 | vim.keymap.set('n', '<leader>f', function() vim.lsp.buf.format { async = true } end, bufopts) | |
38 | end, | |
39 | }) | |
40 | ||
41 |