+ nvim-cmp looks pretty cool
This commit is contained in:
parent
e97a43814e
commit
9cb2e7af38
1 changed files with 150 additions and 69 deletions
|
@ -41,26 +41,6 @@ Plug 'ryanoasis/vim-devicons'
|
||||||
" -- Markdown preview, not really useful since it's only support github's md format.
|
" -- Markdown preview, not really useful since it's only support github's md format.
|
||||||
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' }
|
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' }
|
||||||
|
|
||||||
" --- Auto complete with deoplete
|
|
||||||
" if has('nvim')
|
|
||||||
" Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
|
|
||||||
" else
|
|
||||||
" Plug 'Shougo/deoplete.nvim'
|
|
||||||
" Plug 'roxma/nvim-yarp'
|
|
||||||
" Plug 'roxma/vim-hug-neovim-rpc'
|
|
||||||
" endif
|
|
||||||
" deoplete source
|
|
||||||
" if has('win32') || has('win64')
|
|
||||||
" Plug 'tbodt/deoplete-tabnine', { 'do': 'powershell.exe .\install.ps1' }
|
|
||||||
" else
|
|
||||||
" Plug 'tbodt/deoplete-tabnine', { 'do': './install.sh' }
|
|
||||||
" endif
|
|
||||||
" Plug 'MarcWeber/vim-addon-mw-utils'
|
|
||||||
" Plug 'tomtom/tlib_vim'
|
|
||||||
" Plug 'garbas/vim-snipmate'
|
|
||||||
" Plug 'honza/vim-snippets'
|
|
||||||
" Plug 'deoplete-plugins/deoplete-jedi'
|
|
||||||
|
|
||||||
" --- Auto complete with NCM2 (nvim-completion-manager)
|
" --- Auto complete with NCM2 (nvim-completion-manager)
|
||||||
" Plug 'ncm2/ncm2'
|
" Plug 'ncm2/ncm2'
|
||||||
" Plug 'roxma/nvim-yarp'
|
" Plug 'roxma/nvim-yarp'
|
||||||
|
@ -68,16 +48,25 @@ Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' }
|
||||||
" Plug 'ncm2/ncm2-jedi' " python
|
" Plug 'ncm2/ncm2-jedi' " python
|
||||||
" Plug 'ncm2/ncm2-racer' " rust
|
" Plug 'ncm2/ncm2-racer' " rust
|
||||||
|
|
||||||
" --- Auto complete with DDC
|
" --- nvm built-in lsp
|
||||||
Plug 'Shougo/ddc.vim', { 'branch': 'main' }
|
|
||||||
Plug 'vim-denops/denops.vim', { 'branch': 'main' }
|
|
||||||
Plug 'neovim/nvim-lspconfig'
|
Plug 'neovim/nvim-lspconfig'
|
||||||
" - DDC sources
|
|
||||||
Plug 'Shougo/ddc-around', { 'branch': 'main' }
|
" --- Auto complete with DDC
|
||||||
Plug 'Shougo/ddc-nvim-lsp', { 'branch': 'main' }
|
" Plug 'Shougo/ddc.vim', { 'branch': 'main' }
|
||||||
" - DDC filters
|
" Plug 'vim-denops/denops.vim', { 'branch': 'main' }
|
||||||
Plug 'Shougo/ddc-matcher_head', { 'branch': 'main' }
|
" " - DDC sources
|
||||||
Plug 'Shougo/ddc-sorter_rank', { 'branch': 'main' }
|
" Plug 'Shougo/ddc-around', { 'branch': 'main' }
|
||||||
|
" Plug 'Shougo/ddc-nvim-lsp', { 'branch': 'main' }
|
||||||
|
" " - DDC filters
|
||||||
|
" Plug 'Shougo/ddc-matcher_head', { 'branch': 'main' }
|
||||||
|
" Plug 'Shougo/ddc-sorter_rank', { 'branch': 'main' }
|
||||||
|
|
||||||
|
" --- Auto complete with CMP
|
||||||
|
Plug 'hrsh7th/cmp-nvim-lsp'
|
||||||
|
Plug 'hrsh7th/cmp-buffer'
|
||||||
|
Plug 'hrsh7th/cmp-path'
|
||||||
|
Plug 'hrsh7th/cmp-cmdline'
|
||||||
|
Plug 'hrsh7th/nvim-cmp'
|
||||||
|
|
||||||
" --- Indent visualization
|
" --- Indent visualization
|
||||||
" Plug 'Yggdroot/indentLine'
|
" Plug 'Yggdroot/indentLine'
|
||||||
|
@ -238,59 +227,60 @@ hi Conceal ctermfg=0 ctermbg=NONE
|
||||||
let g:python_highlight_all = 1
|
let g:python_highlight_all = 1
|
||||||
|
|
||||||
" --- DDC
|
" --- DDC
|
||||||
" Customize global settings
|
" " Customize global settings
|
||||||
" Use around source.
|
" " Use around source.
|
||||||
" https://github.com/Shougo/ddc-around
|
" " https://github.com/Shougo/ddc-around
|
||||||
call ddc#custom#patch_global('sources', ['around', 'nvim-lsp'])
|
" call ddc#custom#patch_global('sources', ['around', 'nvim-lsp'])
|
||||||
|
|
||||||
" Use matcher_head and sorter_rank.
|
" " Use matcher_head and sorter_rank.
|
||||||
" https://github.com/Shougo/ddc-matcher_head
|
" " https://github.com/Shougo/ddc-matcher_head
|
||||||
" https://github.com/Shougo/ddc-sorter_rank
|
" " https://github.com/Shougo/ddc-sorter_rank
|
||||||
call ddc#custom#patch_global('sourceOptions', {
|
" call ddc#custom#patch_global('sourceOptions', {
|
||||||
\ '_': {
|
" \ '_': {
|
||||||
\ 'matchers': ['matcher_head'],
|
" \ 'matchers': ['matcher_head'],
|
||||||
\ 'sorters': ['sorter_rank']},
|
" \ 'sorters': ['sorter_rank']},
|
||||||
\ })
|
" \ })
|
||||||
|
|
||||||
" Change source options
|
" " Change source options
|
||||||
call ddc#custom#patch_global('sourceOptions', {
|
" call ddc#custom#patch_global('sourceOptions', {
|
||||||
\ 'around': {'mark': 'A'},
|
" \ 'around': {'mark': 'A'},
|
||||||
\ 'nvim-lsp': { 'mark': 'lsp', 'forceCompletionPattern': '\.|:|->' },
|
" \ 'nvim-lsp': { 'mark': 'lsp', 'forceCompletionPattern': '\.|:|->' },
|
||||||
\ })
|
" \ })
|
||||||
call ddc#custom#patch_global('sourceParams', {
|
" call ddc#custom#patch_global('sourceParams', {
|
||||||
\ 'around': {'maxSize': 500},
|
" \ 'around': {'maxSize': 500},
|
||||||
\ 'nvim-lsp': { 'kindLabels': { 'Class': 'c' } },
|
" \ 'nvim-lsp': { 'kindLabels': { 'Class': 'c' } },
|
||||||
\ })
|
" \ })
|
||||||
|
|
||||||
" Customize settings on a filetype
|
" " Customize settings on a filetype
|
||||||
call ddc#custom#patch_filetype(['rust'], 'sources', ['around', 'nvim-lsp'])
|
" call ddc#custom#patch_filetype(['rust'], 'sources', ['around', 'nvim-lsp'])
|
||||||
call ddc#custom#patch_filetype(['c', 'cpp'], 'sources', ['around', 'clangd'])
|
" call ddc#custom#patch_filetype(['c', 'cpp'], 'sources', ['around', 'clangd'])
|
||||||
call ddc#custom#patch_filetype(['c', 'cpp'], 'sourceOptions', {
|
" call ddc#custom#patch_filetype(['c', 'cpp'], 'sourceOptions', {
|
||||||
\ 'clangd': {'mark': 'C'},
|
" \ 'clangd': {'mark': 'C'},
|
||||||
\ })
|
" \ })
|
||||||
call ddc#custom#patch_filetype('markdown', 'sourceParams', {
|
" call ddc#custom#patch_filetype('markdown', 'sourceParams', {
|
||||||
\ 'around': {'maxSize': 100},
|
" \ 'around': {'maxSize': 100},
|
||||||
\ })
|
" \ })
|
||||||
|
|
||||||
" Mappings
|
" " Mappings
|
||||||
|
|
||||||
" <TAB>: completion.
|
" " <TAB>: completion.
|
||||||
inoremap <silent><expr> <TAB>
|
" inoremap <silent><expr> <TAB>
|
||||||
\ pumvisible() ? '<C-n>' :
|
" \ pumvisible() ? '<C-n>' :
|
||||||
\ (col('.') <= 1 <Bar><Bar> getline('.')[col('.') - 2] =~# '\s') ?
|
" \ (col('.') <= 1 <Bar><Bar> getline('.')[col('.') - 2] =~# '\s') ?
|
||||||
\ '<TAB>' : ddc#manual_complete()
|
" \ '<TAB>' : ddc#manual_complete()
|
||||||
|
|
||||||
" <S-TAB>: completion back.
|
" " <S-TAB>: completion back.
|
||||||
inoremap <expr><S-TAB> pumvisible() ? '<C-p>' : '<C-h>'
|
" inoremap <expr><S-TAB> pumvisible() ? '<C-p>' : '<C-h>'
|
||||||
|
|
||||||
" Use ddc.
|
" " Use ddc.
|
||||||
call ddc#enable()
|
" call ddc#enable()
|
||||||
|
|
||||||
" --- nvim-lsp
|
" --- nvim-lsp
|
||||||
lua << EOF
|
lua << EOF
|
||||||
local nvim_lsp = require'lspconfig'
|
local nvim_lsp = require'lspconfig'
|
||||||
|
|
||||||
nvim_lsp.pyright.setup{}
|
nvim_lsp.pyright.setup{}
|
||||||
|
-- nvim_lsp.jedi_language_server.setup{}
|
||||||
nvim_lsp.rust_analyzer.setup({
|
nvim_lsp.rust_analyzer.setup({
|
||||||
settings = {
|
settings = {
|
||||||
["rust-analyzer"] = {
|
["rust-analyzer"] = {
|
||||||
|
@ -317,3 +307,94 @@ let g:ale_fixers = {
|
||||||
let g:ale_linters = {
|
let g:ale_linters = {
|
||||||
\ "python": ["pflake8", "black"],
|
\ "python": ["pflake8", "black"],
|
||||||
\}
|
\}
|
||||||
|
|
||||||
|
" --- CMP
|
||||||
|
lua <<EOF
|
||||||
|
-- Setup nvim-cmp.
|
||||||
|
local cmp = require'cmp'
|
||||||
|
|
||||||
|
cmp.setup({
|
||||||
|
snippet = {
|
||||||
|
-- REQUIRED - you must specify a snippet engine
|
||||||
|
expand = function(args)
|
||||||
|
-- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
||||||
|
-- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
|
||||||
|
-- require('snippy').expand_snippet(args.body) -- For `snippy` users.
|
||||||
|
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
window = {
|
||||||
|
-- completion = cmp.config.window.bordered(),
|
||||||
|
-- documentation = cmp.config.window.bordered(),
|
||||||
|
},
|
||||||
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||||
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||||
|
['<C-Space>'] = cmp.mapping.complete(),
|
||||||
|
['<C-e>'] = cmp.mapping.abort(),
|
||||||
|
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||||
|
["<Tab>"] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
|
elseif vim.fn["vsnip#available"](1) == 1 then
|
||||||
|
feedkey("<Plug>(vsnip-expand-or-jump)", "")
|
||||||
|
elseif has_words_before() then
|
||||||
|
cmp.complete()
|
||||||
|
else
|
||||||
|
fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
|
||||||
|
end
|
||||||
|
end, { "i", "s" }),
|
||||||
|
|
||||||
|
["<S-Tab>"] = cmp.mapping(function()
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_prev_item()
|
||||||
|
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
|
||||||
|
feedkey("<Plug>(vsnip-jump-prev)", "")
|
||||||
|
end
|
||||||
|
end, { "i", "s" }),
|
||||||
|
}),
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = 'nvim_lsp' },
|
||||||
|
-- { name = 'vsnip' }, -- For vsnip users.
|
||||||
|
-- { name = 'luasnip' }, -- For luasnip users.
|
||||||
|
-- { name = 'ultisnips' }, -- For ultisnips users.
|
||||||
|
-- { name = 'snippy' }, -- For snippy users.
|
||||||
|
}, {
|
||||||
|
{ name = 'buffer' },
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Set configuration for specific filetype.
|
||||||
|
cmp.setup.filetype('gitcommit', {
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
|
||||||
|
}, {
|
||||||
|
{ name = 'buffer' },
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
|
||||||
|
cmp.setup.cmdline('/', {
|
||||||
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
|
sources = {
|
||||||
|
{ name = 'buffer' }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||||
|
cmp.setup.cmdline(':', {
|
||||||
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = 'path' }
|
||||||
|
}, {
|
||||||
|
{ name = 'cmdline' }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Setup lspconfig.
|
||||||
|
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||||
|
-- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
|
||||||
|
require('lspconfig')['pyright'].setup {
|
||||||
|
capabilities = capabilities
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue