From 92d2d3dd53fcac4c189aac04cccd01004d22017a Mon Sep 17 00:00:00 2001 From: serxoz Date: Sat, 27 Nov 2021 23:39:38 +0100 Subject: [PATCH] completion pluggin change and retab --- nvim/.config/nvim/init.vim | 193 ++++++++++++++++++++++++++----------- 1 file changed, 135 insertions(+), 58 deletions(-) diff --git a/nvim/.config/nvim/init.vim b/nvim/.config/nvim/init.vim index 3f35aa1..bc028e3 100644 --- a/nvim/.config/nvim/init.vim +++ b/nvim/.config/nvim/init.vim @@ -77,16 +77,16 @@ let vimplug_exists=expand('~/.config/nvim/autoload/plug.vim') " let g:vim_bootstrap_editor = "nvim" " nvim or vim if !filereadable(vimplug_exists) - if !executable("curl") - echoerr "You have to install curl or first install vim-plug yourself!" - execute "q!" - endif - echo "Installing Vim-Plug..." - echo "" - silent exec "!\curl -fLo " . vimplug_exists . " --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" - let g:not_finish_vimplug = "yes" + if !executable("curl") + echoerr "You have to install curl or first install vim-plug yourself!" + execute "q!" + endif + echo "Installing Vim-Plug..." + echo "" + silent exec "!\curl -fLo " . vimplug_exists . " --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" + let g:not_finish_vimplug = "yes" - autocmd VimEnter * PlugInstall + autocmd VimEnter * PlugInstall endif " Required: @@ -112,10 +112,19 @@ Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} " LSP (Language Server Protocol) - para autocompletar, vamos... Plug 'neovim/nvim-lspconfig' -Plug 'kabouzeid/nvim-lspinstall' +Plug 'williamboman/nvim-lsp-installer' +" Plug 'kabouzeid/nvim-lspinstall' " Plug 'hrsh7th/nvim-compe' -Plug 'nvim-lua/completion-nvim' -Plug 'glepnir/lspsaga.nvim' +"Plug 'nvim-lua/completion-nvim' +"Plug 'glepnir/lspsaga.nvim' +Plug 'hrsh7th/cmp-nvim-lsp' +Plug 'hrsh7th/cmp-buffer' +Plug 'hrsh7th/cmp-path' +Plug 'hrsh7th/cmp-cmdline' +Plug 'hrsh7th/nvim-cmp' +" For vsnip users. +Plug 'hrsh7th/cmp-vsnip' +Plug 'hrsh7th/vim-vsnip' Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } Plug 'junegunn/fzf.vim' @@ -150,34 +159,102 @@ nnoremap :NERDTreeToggle lua <'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), + [''] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `` mapping. + [''] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + [''] = cmp.mapping.confirm({ select = true }), + }, + 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' }, + }) + }) + + -- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline('/', { + sources = { + { name = 'buffer' } + } + }) + + -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline(':', { + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }) + }) + +-- setup lsp installer +local lsp_installer = require("nvim-lsp-installer") + +-- Register a handler that will be called for all installed servers. +-- Alternatively, you may also register handlers on specific server instances instead (see example below). +lsp_installer.on_server_ready(function(server) + local opts = {} + + -- (optional) Customize the options passed to the server + -- if server.name == "tsserver" then + -- opts.root_dir = function() ... end + -- end + + -- setup lspconfig + local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) + opts.capabilities = capabilities + + -- This setup() function is exactly the same as lspconfig's setup function. + -- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md + server:setup(opts) +end) EOF + + """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Mapeos """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -217,9 +294,9 @@ vnoremap K :m '<-2gv=gv """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " This is the default extra key bindings let g:fzf_action = { - \ 'ctrl-t': 'tab split', - \ 'ctrl-x': 'split', - \ 'ctrl-v': 'vsplit' } + \ 'ctrl-t': 'tab split', + \ 'ctrl-x': 'split', + \ 'ctrl-v': 'vsplit' } " Enable per-command history. " CTRL-N and CTRL-P will be automatically bound to next-history and @@ -243,45 +320,45 @@ let $FZF_DEFAULT_COMMAND="rg --files --hidden" " Customize fzf colors to match your color scheme let g:fzf_colors = -\ { 'fg': ['fg', 'Normal'], - \ 'bg': ['bg', 'Normal'], - \ 'hl': ['fg', 'Comment'], - \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], - \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], - \ 'hl+': ['fg', 'Statement'], - \ 'info': ['fg', 'PreProc'], - \ 'border': ['fg', 'Ignore'], - \ 'prompt': ['fg', 'Conditional'], - \ 'pointer': ['fg', 'Exception'], - \ 'marker': ['fg', 'Keyword'], - \ 'spinner': ['fg', 'Label'], - \ 'header': ['fg', 'Comment'] } + \ { 'fg': ['fg', 'Normal'], + \ 'bg': ['bg', 'Normal'], + \ 'hl': ['fg', 'Comment'], + \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], + \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], + \ 'hl+': ['fg', 'Statement'], + \ 'info': ['fg', 'PreProc'], + \ 'border': ['fg', 'Ignore'], + \ 'prompt': ['fg', 'Conditional'], + \ 'pointer': ['fg', 'Exception'], + \ 'marker': ['fg', 'Keyword'], + \ 'spinner': ['fg', 'Label'], + \ 'header': ['fg', 'Comment'] } "Get Files command! -bang -nargs=? -complete=dir Files - \ call fzf#vim#files(, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline']}), 0) + \ call fzf#vim#files(, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline']}), 0) " Get text in files with Rg command! -bang -nargs=* Rg - \ call fzf#vim#grep( - \ 'rg --column --line-number --no-heading --color=always --smart-case '.shellescape(), 1, - \ fzf#vim#with_preview(), 0) + \ call fzf#vim#grep( + \ 'rg --column --line-number --no-heading --color=always --smart-case '.shellescape(), 1, + \ fzf#vim#with_preview(), 0) " Ripgrep advanced function! RipgrepFzf(query, fullscreen) - let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case %s || true' - let initial_command = printf(command_fmt, shellescape(a:query)) - let reload_command = printf(command_fmt, '{q}') - let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]} - call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen) + let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case %s || true' + let initial_command = printf(command_fmt, shellescape(a:query)) + let reload_command = printf(command_fmt, '{q}') + let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]} + call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen) endfunction command! -nargs=* -bang RG call RipgrepFzf(, 0) " Git grep command! -bang -nargs=* GGrep - \ call fzf#vim#grep( - \ 'git grep --line-number '.shellescape(), 0, - \ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), 0) + \ call fzf#vim#grep( + \ 'git grep --line-number '.shellescape(), 0, + \ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), 0)