all repos — dotfiles @ 83ae2901b2ff61a0cd4fac05f93b69b9ccaddbfa

my *nix dotfiles

nvim: Setup completion-nvim
Anirudh Oppiliappan x@icyphox.sh
Thu, 11 Feb 2021 10:13:12 +0530
commit

83ae2901b2ff61a0cd4fac05f93b69b9ccaddbfa

parent

689d7c59fe5957e0ac6efe7d3f79a7c2e51499a6

M config/nvim/init.luaconfig/nvim/init.lua

@@ -14,6 +14,9 @@ paq 'tpope/vim-rsi'

paq 'editorconfig/editorconfig-vim' paq 'zah/nim.vim' paq 'neovim/nvim-lspconfig' +paq 'nvim-lua/completion-nvim' +paq 'steelsojka/completion-buffers' + require('settings') require('maps')
M config/nvim/lua/lsp/lua.luaconfig/nvim/lua/lsp/lua.lua

@@ -7,10 +7,6 @@ local bin_path = root_path .. '/bin/macOS/lua-language-server'

require'lspconfig'.sumneko_lua.setup { cmd = { bin_path, "-E", root_path .. '/main.lua' }, - root_dir = function(fname) - return util.find_git_ancestor(fname) or - util.path.dirname(fname) - end, settings = { Lua = { runtime = {
M config/nvim/lua/maps.luaconfig/nvim/lua/maps.lua

@@ -64,11 +64,22 @@ function M.on_attach(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 - buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') + buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', options) + buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', options) +end + +-- completion-nvim +-- FIXME: rewrite this in Lua +vim.api.nvim_exec([[ +" Use <Tab> and <S-Tab> to navigate through popup menu +inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>" +inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>" + +" Set completeopt to have a better completion experience +set completeopt=menuone,noinsert,noselect - local opts = { noremap=true, silent=true } - buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts) - buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts) -end +" Avoid showing message extra message when using completion +set shortmess+=c +]], false) return M
M config/nvim/lua/settings.luaconfig/nvim/lua/settings.lua

@@ -81,3 +81,14 @@ ]] }

}, 'restorecursor') cmd('au BufNewFile,BufRead * if &ft == "" | set ft=text | endif') + +-- completion-nvim +cmd('au BufEnter * lua require"completion".on_attach()') +g.completion_chain_complete_list = { + default = { + { complete_items = { 'lsp' } }, + { complete_items = { 'buffers' } }, + { mode = { '<c-p>' } }, + { mode = { '<c-n>' } } + }, +}