From ecaa74de185201c39dc7d3bb1c779ed289bc92fc Mon Sep 17 00:00:00 2001 From: Daniel Lundin Date: Thu, 1 Apr 2021 19:33:21 +0200 Subject: [PATCH] nvim: completion settings --- .config/nvim/init.vim | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index d6a1fb6..ffa4588 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -317,10 +317,14 @@ nnoremap gd lua vim.lsp.buf.declaration() :lua << EOF local nvim_lsp = require('lspconfig') +local completion = require('completion') + 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 + completion.on_attach(); + buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') -- Mappings. @@ -330,23 +334,23 @@ local on_attach = function(client, bufnr) buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) - buf_set_keymap('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) - buf_set_keymap('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) - buf_set_keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) - buf_set_keymap('n', 'D', 'lua vim.lsp.buf.type_definition()', opts) - buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts) + -- buf_set_keymap('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) + -- buf_set_keymap('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) + -- buf_set_keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) + -- buf_set_keymap('n', 'D', 'lua vim.lsp.buf.type_definition()', opts) + -- buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts) + -- buf_set_keymap('n', 'e', 'lua vim.lsp.diagnostic.show_line_diagnostics()', 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', 'q', 'lua vim.lsp.diagnostic.set_loclist()', opts) - - -- Set some keybinds conditional on server capabilities - if client.resolved_capabilities.document_formatting then - buf_set_keymap("n", "f", "lua vim.lsp.buf.formatting()", opts) - elseif client.resolved_capabilities.document_range_formatting then - buf_set_keymap("n", "f", "lua vim.lsp.buf.range_formatting()", opts) - end + -- buf_set_keymap('n', 'q', 'lua vim.lsp.diagnostic.set_loclist()', opts) + -- + -- -- Set some keybinds conditional on server capabilities + -- if client.resolved_capabilities.document_formatting then + -- buf_set_keymap("n", "f", "lua vim.lsp.buf.formatting()", opts) + -- elseif client.resolved_capabilities.document_range_formatting then + -- buf_set_keymap("n", "f", "lua vim.lsp.buf.range_formatting()", opts) + -- end -- Set autocommands conditional on server_capabilities if client.resolved_capabilities.document_highlight then @@ -389,7 +393,6 @@ EOF " \{'mode': ''} " \] -let g:completion_matching_strategy_list = ['exact', 'substring', 'fuzzy'] inoremap pumvisible() ? "\" : "\" inoremap pumvisible() ? "\" : "\" @@ -397,6 +400,9 @@ inoremap pumvisible() ? "\" : "\" " Use and to navigate through popup menu inoremap pumvisible() ? "\" : "\" inoremap pumvisible() ? "\" : "\" +imap (completion_smart_tab) +imap (completion_smart_s_tab) +imap (completion_trigger) "" Diagnostics