|
1 | | --- src: https://github.com/neovim/nvim-lspconfig |
2 | | -local function setup_keybinding_diagnostic() |
3 | | - -- Global mappings. |
4 | | - -- See `:help vim.diagnostic.*` for documentation on any of the below functions |
5 | | - -- Show diagnostics in a floating window |
6 | | - --vim.keymap.set('n', '<space>e', vim.diagnostic.open_float) |
7 | | - -- Show diagnostics in a bottom window |
8 | | - vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist) |
9 | | - -- Move to the previous diagnostic |
10 | | - vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) |
11 | | - -- Move to the next diagnostic |
12 | | - vim.keymap.set('n', ']d', vim.diagnostic.goto_next) |
13 | | -end |
14 | | - |
15 | | --- src: https://github.com/neovim/nvim-lspconfig |
16 | | -local function setup_keybinding_when_lspserver_attach_to_buffer() |
17 | | - -- Use LspAttach autocommand to only map the following keys |
18 | | - -- after the language server attaches to the current buffer |
19 | | - vim.api.nvim_create_autocmd('LspAttach', { |
20 | | - group = vim.api.nvim_create_augroup('UserLspConfig', {}), |
21 | | - callback = function(ev) |
22 | | - -- Enable completion triggered by <c-x><c-o> |
23 | | - -- -- ommi-func: manual completion |
24 | | - -- -- nvim-cmp : auto completion |
25 | | - -- - Disable ommi-func for nvim-cmp: https://github.com/neovim/nvim-lspconfig/wiki/Autocompletion |
26 | | - -- vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' |
27 | | - |
28 | | - -- Buffer local mappings. |
29 | | - -- See `:help vim.lsp.*` for documentation on any of the below functions |
30 | | - local opts = { buffer = ev.buf } |
31 | | - vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) |
32 | | - -- Jump to the definition |
33 | | - vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) |
34 | | - -- Displays hover information about the symbol under the cursor |
35 | | - vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) |
36 | | - -- Lists all the implementations for the symbol under the cursor |
37 | | - vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts) |
38 | | - -- Displays a function's signature information |
39 | | - vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts) |
40 | | - vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts) |
41 | | - vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts) |
42 | | - vim.keymap.set('n', '<space>wl', function() |
43 | | - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) |
44 | | - end, opts) |
45 | | - -- Jumps to the definition of the type symbol |
46 | | - vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts) |
47 | | - -- Renames all references to the symbol under the cursor |
48 | | - vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts) |
49 | | - -- Selects a code action available at the current cursor position |
50 | | - vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts) |
51 | | - -- Lists all the references |
52 | | - vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) |
53 | | - -- Set some key bindings conditional on server capabilities |
54 | | - vim.keymap.set('n', '<space>f', function() |
55 | | - vim.lsp.buf.format { async = true } |
56 | | - end, opts) |
57 | | - |
58 | | - -- FIXME: Continue with https://github.com/jdhao/nvim-config/blob/4d8ef868ad0ef7f6433d91332aa6649186d9a2fb/lua/config/lsp.lua |
59 | | - end, |
60 | | - }) |
61 | | -end |
62 | | - |
63 | 1 | local function setup_lsp(vim_lsp, lsp_name, client_lsp_capabilities, settings, flags) |
64 | 2 | -- Extend config for a language |
65 | 3 | vim_lsp.config(lsp_name,{ |
@@ -244,9 +182,6 @@ local function config() |
244 | 182 | {}, |
245 | 183 | {} |
246 | 184 | ) |
247 | | - |
248 | | - setup_keybinding_diagnostic() |
249 | | - setup_keybinding_when_lspserver_attach_to_buffer() |
250 | 185 | end |
251 | 186 |
|
252 | 187 | return {config = config} |
0 commit comments