From a26e27c52e4669684d21f18134cb0141c590580e Mon Sep 17 00:00:00 2001 From: lelgenio Date: Fri, 26 Jun 2020 19:36:36 -0300 Subject: [PATCH] make choosing language server easier --- config.yaml | 1 - dotfiles/nvim/init.vim | 174 +++++++++++++++++++---------------------- 2 files changed, 81 insertions(+), 94 deletions(-) diff --git a/config.yaml b/config.yaml index 9cee5b2..551700d 100644 --- a/config.yaml +++ b/config.yaml @@ -130,7 +130,6 @@ actions: vimplug: > nvim +PlugUpgrade - +PlugClean! +PlugInstall +PlugUpdate +qall diff --git a/dotfiles/nvim/init.vim b/dotfiles/nvim/init.vim index b1eba12..2337938 100644 --- a/dotfiles/nvim/init.vim +++ b/dotfiles/nvim/init.vim @@ -24,21 +24,23 @@ Plug 'airblade/vim-gitgutter' Plug 'chrisbra/Colorizer' - Plug 'junegunn/vim-easy-align' " Language server support " - " Plug 'sheerun/vim-polyglot' - " Plug 'dense-analysis/ale' - - " Plug 'neoclide/coc.nvim', {'branch': 'release'} +{%@@ set lsp = "vim-lsp" @@%} +{%@@ if lsp == "vim-lsp" @@%} Plug 'prabirshrestha/vim-lsp' Plug 'mattn/vim-lsp-settings' Plug 'prabirshrestha/asyncomplete.vim' Plug 'prabirshrestha/asyncomplete-lsp.vim' Plug 'prabirshrestha/asyncomplete-file.vim' +{%@@ elif lsp == "coc" @@%} + Plug 'neoclide/coc.nvim', {'branch': 'release'} +{%@@ endif @@%} + + Plug 'sheerun/vim-polyglot' " Plug 'autozimu/LanguageClient-neovim', { " \ 'branch': 'next', @@ -55,41 +57,27 @@ " Completions " Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } - " Pais + " HTML shortcuts + Plug 'mattn/emmet-vim' + Plug 'jiangmiao/auto-pairs' Plug 'tpope/vim-surround' - - " Comments + Plug 'junegunn/vim-easy-align' Plug 'tpope/vim-commentary' " Status bar Plug 'vim-airline/vim-airline' " Plug 'vim-airline/vim-airline-themes' - " let g:airline#extensions#ale#enabled = 1 +{%@@ if lsp == "ale" @@%} + let g:airline#extensions#ale#enabled = 1 +{%@@ endif @@%} " Bufferlist (integrates with airline) " Plug 'bling/vim-bufferline' " Color scheme Plug 'dikiaap/minimalist' - " Plug 'morhetz/gruvbox' - - " Simplify movement - " Plug 'easymotion/vim-easymotion' - - " Simplify file management - " Plug 'scrooloose/nerdtree' - " Plug 'ryanoasis/vim-devicons' - " Plug 'Xuyuanp/nerdtree-git-plugin' - - " Format using prettier - " Plug 'prettier/vim-prettier', { 'do': 'yarn install' } - - " Make markdown fun again - "Plug 'junegunn/limelight.vim' - - " Better buffer management - "Plug 'qpkorr/vim-bufkill' + " Plug 'morhetz/gruvbox' " Not that good " Utilities "Plug 'xolox/vim-misc' @@ -104,12 +92,12 @@ " Plug 'powerman/vim-plugin-AnsiEsc' " Language sytax highlight improvements - Plug 'mboughaba/i3config.vim' - Plug 'dag/vim-fish' - Plug 'arrufat/vala.vim' - Plug 'NLKNguyen/c-syntax.vim' - Plug 'vim-python/python-syntax' - Plug 'stephpy/vim-yaml' + " Plug 'mboughaba/i3config.vim' + " Plug 'dag/vim-fish' + " Plug 'arrufat/vala.vim' + " Plug 'NLKNguyen/c-syntax.vim' + " Plug 'vim-python/python-syntax' + " Plug 'stephpy/vim-yaml' call plug#end() @@ -244,10 +232,66 @@ call plug#end() " map e (easymotion-prefix) set ignorecase - map :GFiles + map :GFiles + map :Files +"}}} +" Lanugage Server{{{ +" + set foldmethod=marker + set hidden + set autoread + + autocmd BufWritePre * :call StripTrailingWhitespaces() + function! StripTrailingWhitespaces() + let l = line(".") + let c = col(".") + %s/\s\+$//e + call cursor(l, c) + endfun + + " Allow saving of files as sudo when I forgot to start vim using sudo. + cmap w!! w !sudo tee % >/dev/null + + " Auto deploy dotfiles + autocmd BufWritePost /**/dotdrop/{config.yaml,dotfiles/**} silent !dotdrop install -f + + {%@@ if lsp == "vim-lsp" @@%} +" vim-lsp{{{ + + "allow json comments + autocmd FileType json syntax match Comment +\/\/.\+$+ + + " Complete + inoremap pumvisible() ? "\" : "\" + inoremap pumvisible() ? "\" : "\" + inoremap pumvisible() ? "\" : "\" + imap (asyncomplete_force_refresh) + + " Fix + nmap gf (lsp-document-format) + vmap gf (lsp-document-range-format) + nmap gr :LspRename + + " Move around + nmap [g (lsp-previous-diagnostic) + nmap ]g (lsp-next-diagnostic) + + nmap gd :LspDefinition + nmap K :LspHover + + + " Colors + highlight LspErrorHighlight gui=undercurl guisp=red + highlight LspErrorText guibg=none guifg=red gui=underline + + highlight LspWarningHighlight gui=undercurl guisp={{@@ color.normal.yellow @@}} + highlight LspWarningText gui=underline guifg={{@@ color.normal.yellow @@}} guibg=none + +"}}} + {%@@ elif lsp == "coc" @@%} "" coc {{{ - {#@@ + "allow json comments autocmd FileType json syntax match Comment +\/\/.\+$+ @@ -319,13 +363,11 @@ call plug#end() omap ic (coc-classobj-i) xmap ac (coc-classobj-a) omap ac (coc-classobj-a) - @@#} "}}} + {%@@ elif lsp == "ale" @@%} " ale{{{ - -{#@@ " Lint let g:ale_echo_msg_error_str = 'E' let g:ale_echo_msg_warning_str = 'W' @@ -397,62 +439,8 @@ call plug#end() highlight ALEWarning gui=undercurl guisp=yellow highlight ALEWarningSign guifg=yellow -@@#} - "}}} -" vim-lsp - - "allow json comments - autocmd FileType json syntax match Comment +\/\/.\+$+ - - " Complete - inoremap pumvisible() ? "\" : "\" - inoremap pumvisible() ? "\" : "\" - inoremap pumvisible() ? "\" : "\" - imap (asyncomplete_force_refresh) - - " Fix - nmap gf (lsp-document-format) - vmap gf (lsp-document-range-format) - nmap gr :LspRename - - " Move around - nmap [g (lsp-previous-diagnostic) - nmap ]g (lsp-next-diagnostic) - - nmap gd :LspDefinition - nmap K :LspHover - - - " Colors - highlight LspErrorHighlight gui=undercurl guisp=red - highlight LspErrorText guibg=none guifg=red gui=underline - - highlight LspWarningHighlight gui=undercurl guisp={{@@ color.normal.yellow @@}} - highlight LspWarningText gui=underline guifg={{@@ color.normal.yellow @@}} guibg=none - - -"}}} -" Lanugage Server{{{ -" - set foldmethod=marker - set hidden - set autoread - - function! StripTrailingWhitespaces() - let l = line(".") - let c = col(".") - %s/\s\+$//e - call cursor(l, c) - endfun - - " Allow saving of files as sudo when I forgot to start vim using sudo. - cmap w!! w !sudo tee % >/dev/null - - autocmd BufWritePre * :call StripTrailingWhitespaces() - - " Auto deploy dotfiles - autocmd BufWritePost /**/dotdrop/{config.yaml,dotfiles/**} silent !dotdrop install -f + {%@@ endif @@%} "python env{{{ let g:python_host_prog = '/usr/bin/python2'