diff --git a/.config/vim/vim_plug b/.config/vim/vim_plug index 59f2e3f..4f3a138 100644 --- a/.config/vim/vim_plug +++ b/.config/vim/vim_plug @@ -41,26 +41,6 @@ Plug 'ryanoasis/vim-devicons' " -- Markdown preview, not really useful since it's only support github's md format. 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) " Plug 'ncm2/ncm2' " 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-racer' " rust -" --- Auto complete with DDC -Plug 'Shougo/ddc.vim', { 'branch': 'main' } -Plug 'vim-denops/denops.vim', { 'branch': 'main' } +" --- nvm built-in lsp Plug 'neovim/nvim-lspconfig' -" - DDC sources -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 DDC +" Plug 'Shougo/ddc.vim', { 'branch': 'main' } +" Plug 'vim-denops/denops.vim', { 'branch': 'main' } +" " - DDC sources +" 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 " Plug 'Yggdroot/indentLine' @@ -238,59 +227,60 @@ hi Conceal ctermfg=0 ctermbg=NONE let g:python_highlight_all = 1 " --- DDC -" Customize global settings -" Use around source. -" https://github.com/Shougo/ddc-around -call ddc#custom#patch_global('sources', ['around', 'nvim-lsp']) +" " Customize global settings +" " Use around source. +" " https://github.com/Shougo/ddc-around +" call ddc#custom#patch_global('sources', ['around', 'nvim-lsp']) -" Use matcher_head and sorter_rank. -" https://github.com/Shougo/ddc-matcher_head -" https://github.com/Shougo/ddc-sorter_rank -call ddc#custom#patch_global('sourceOptions', { - \ '_': { - \ 'matchers': ['matcher_head'], - \ 'sorters': ['sorter_rank']}, - \ }) +" " Use matcher_head and sorter_rank. +" " https://github.com/Shougo/ddc-matcher_head +" " https://github.com/Shougo/ddc-sorter_rank +" call ddc#custom#patch_global('sourceOptions', { +" \ '_': { +" \ 'matchers': ['matcher_head'], +" \ 'sorters': ['sorter_rank']}, +" \ }) -" Change source options -call ddc#custom#patch_global('sourceOptions', { - \ 'around': {'mark': 'A'}, - \ 'nvim-lsp': { 'mark': 'lsp', 'forceCompletionPattern': '\.|:|->' }, - \ }) -call ddc#custom#patch_global('sourceParams', { - \ 'around': {'maxSize': 500}, - \ 'nvim-lsp': { 'kindLabels': { 'Class': 'c' } }, - \ }) +" " Change source options +" call ddc#custom#patch_global('sourceOptions', { +" \ 'around': {'mark': 'A'}, +" \ 'nvim-lsp': { 'mark': 'lsp', 'forceCompletionPattern': '\.|:|->' }, +" \ }) +" call ddc#custom#patch_global('sourceParams', { +" \ 'around': {'maxSize': 500}, +" \ 'nvim-lsp': { 'kindLabels': { 'Class': 'c' } }, +" \ }) -" Customize settings on a filetype -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'], 'sourceOptions', { - \ 'clangd': {'mark': 'C'}, - \ }) -call ddc#custom#patch_filetype('markdown', 'sourceParams', { - \ 'around': {'maxSize': 100}, - \ }) +" " Customize settings on a filetype +" 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'], 'sourceOptions', { +" \ 'clangd': {'mark': 'C'}, +" \ }) +" call ddc#custom#patch_filetype('markdown', 'sourceParams', { +" \ 'around': {'maxSize': 100}, +" \ }) -" Mappings +" " Mappings -" : completion. -inoremap -\ pumvisible() ? '' : -\ (col('.') <= 1 getline('.')[col('.') - 2] =~# '\s') ? -\ '' : ddc#manual_complete() +" " : completion. +" inoremap +" \ pumvisible() ? '' : +" \ (col('.') <= 1 getline('.')[col('.') - 2] =~# '\s') ? +" \ '' : ddc#manual_complete() -" : completion back. -inoremap pumvisible() ? '' : '' +" " : completion back. +" inoremap pumvisible() ? '' : '' -" Use ddc. -call ddc#enable() +" " Use ddc. +" call ddc#enable() " --- nvim-lsp lua << EOF local nvim_lsp = require'lspconfig' nvim_lsp.pyright.setup{} +-- nvim_lsp.jedi_language_server.setup{} nvim_lsp.rust_analyzer.setup({ settings = { ["rust-analyzer"] = { @@ -317,3 +307,94 @@ let g:ale_fixers = { let g:ale_linters = { \ "python": ["pflake8", "black"], \} + +" --- CMP +lua <'] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif vim.fn["vsnip#available"](1) == 1 then + feedkey("(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 ``. + end + end, { "i", "s" }), + + [""] = cmp.mapping(function() + if cmp.visible() then + cmp.select_prev_item() + elseif vim.fn["vsnip#jumpable"](-1) == 1 then + feedkey("(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 with each lsp server you've enabled. + require('lspconfig')['pyright'].setup { + capabilities = capabilities + } +EOF