Add autocomplete support

This commit is contained in:
Daniel Lynn 2021-10-13 11:32:56 -05:00
parent 467933a14e
commit 2660d9e7c4
Signed by: daniel
GPG Key ID: 655C07B9B3DDC88B
3 changed files with 56 additions and 1 deletions

42
nvim/nvim-cmp.vimrc Normal file
View File

@ -0,0 +1,42 @@
set completeopt=menu,menuone,noselect
lua <<EOF
-- Setup nvim-cmp.
local cmp = require'cmp'
cmp.setup({
snippet = {
expand = function(args)
-- For `vsnip` user.
vim.fn["vsnip#anonymous"](args.body)
-- For `luasnip` user.
-- require('luasnip').lsp_expand(args.body)
-- For `ultisnips` user.
-- vim.fn["UltiSnips#Anon"](args.body)
end,
},
mapping = {
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
},
sources = {
{ name = 'nvim_lsp' },
-- For vsnip user.
{ name = 'vsnip' },
-- For luasnip user.
-- { name = 'luasnip' },
-- For ultisnips user.
-- { name = 'ultisnips' },
{ name = 'buffer' },
}
})
EOF

View File

@ -5,7 +5,6 @@ Plug 'jiangmiao/auto-pairs'
Plug 'leafgarland/typescript-vim', { 'for': 'typescript' }
Plug 'leafoftree/vim-svelte-plugin', { 'for': 'svelte' }
Plug 'lukas-reineke/indent-blankline.nvim'
Plug 'neovim/nvim-lspconfig'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'posva/vim-vue', { 'for': 'vue' }
Plug 'ron-rs/ron.vim', { 'for': 'ron' }
@ -18,6 +17,14 @@ Plug 'tpope/vim-surround'
Plug 'vim-test/vim-test'
Plug 'wakatime/vim-wakatime'
" LSP and autocomplete
Plug 'neovim/nvim-lspconfig' |
\ Plug 'hrsh7th/cmp-nvim-lsp' |
\ Plug 'hrsh7th/cmp-buffer' |
\ Plug 'hrsh7th/nvim-cmp' |
\ Plug 'hrsh7th/cmp-vsnip' |
\ Plug 'hrsh7th/vim-vsnip'
" Lightline
Plug 'itchyny/lightline.vim' |
\ Plug 'albertomontesg/lightline-asyncrun' |

6
vimrc
View File

@ -68,6 +68,12 @@ if filereadable(expand("~/.config/nvim/plugins.vimrc"))
endif
call plug#end()
" Autocomplete
if filereadable(expand("~/.config/nvim/nvim-cmp.vimrc"))
source ~/.config/nvim/nvim-cmp.vimrc
endif
" LSP
if filereadable(expand("~/.config/nvim/lspconfig.vimrc"))
source ~/.config/nvim/lspconfig.vimrc
endif