From 2660d9e7c4c8cd5a6fd5430809a80d17c460945a Mon Sep 17 00:00:00 2001 From: Daniel Lynn Date: Wed, 13 Oct 2021 11:32:56 -0500 Subject: [PATCH] Add autocomplete support --- nvim/nvim-cmp.vimrc | 42 ++++++++++++++++++++++++++++++++++++++++++ nvim/plugins.vimrc | 9 ++++++++- vimrc | 6 ++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 nvim/nvim-cmp.vimrc diff --git a/nvim/nvim-cmp.vimrc b/nvim/nvim-cmp.vimrc new file mode 100644 index 0000000..210a9da --- /dev/null +++ b/nvim/nvim-cmp.vimrc @@ -0,0 +1,42 @@ +set completeopt=menu,menuone,noselect + +lua <'] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.close(), + [''] = 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 diff --git a/nvim/plugins.vimrc b/nvim/plugins.vimrc index e08550e..36d3979 100644 --- a/nvim/plugins.vimrc +++ b/nvim/plugins.vimrc @@ -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' | diff --git a/vimrc b/vimrc index 22ba83f..eedf8d2 100644 --- a/vimrc +++ b/vimrc @@ -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