From c74ea2f46a75da06b082cbf3321b4c7638eb1c46 Mon Sep 17 00:00:00 2001 From: James Dixon Date: Mon, 26 Oct 2020 15:55:47 -0400 Subject: [PATCH] add vim-lsp and replace sytanx plugins with vim-polyglot --- stow/vim/.vim/vimrc | 104 ++++++++++++++++++++++++++++---------------- 1 file changed, 67 insertions(+), 37 deletions(-) diff --git a/stow/vim/.vim/vimrc b/stow/vim/.vim/vimrc index cfaa44a..970b759 100644 --- a/stow/vim/.vim/vimrc +++ b/stow/vim/.vim/vimrc @@ -15,7 +15,6 @@ endif "{{{ if has('win32') let &runtimepath.=",$HOME/.vim" - set shell=pwsh endif if has("gui_running") @@ -142,38 +141,40 @@ endif call plug#begin(pluginDir) Plug 'junegunn/vim-plug' - - "quality of life - Plug 'tpope/vim-surround' + " quality of life + "normal mode keybinds Plug 'tpope/vim-commentary' + Plug 'tpope/vim-surround' Plug 'tpope/vim-unimpaired' + "command mode keybinds Plug 'tpope/vim-rsi' Plug 'tpope/vim-eunuch' Plug 'tpope/vim-repeat' + "git + Plug 'tpope/vim-fugitive' + + " syntax and colorscheme packs + Plug 'flazz/vim-colorschemes' + Plug 'sheerun/vim-polyglot' + + " linting and lsp + Plug 'w0rp/ale' + Plug 'prabirshrestha/vim-lsp' + Plug 'mattn/vim-lsp-settings' + + " extra language plugins + "go + Plug 'fatih/vim-go' + "html + Plug 'mattn/emmet-vim' + + " other useful things + "editorconfig Plug 'editorconfig/editorconfig-vim' "browser/url opener Plug 'tyru/open-browser.vim' - "git - Plug 'tpope/vim-fugitive' - "visual - "Plug 'flazz/vim-colorschemes' - "linting - Plug 'w0rp/ale' - - "javascript/css/html - Plug 'pangloss/vim-javascript' - Plug 'mattn/emmet-vim' - "gdscript - Plug 'calviken/vim-gdscript3' - "powershell - Plug 'PProvost/vim-ps1' - "go - Plug 'fatih/vim-go' - "md + "tables Plug 'godlygeek/tabular' - Plug 'plasticboy/vim-markdown' - "toml - Plug 'cespare/vim-toml' call plug#end() "}}} @@ -232,7 +233,7 @@ runtime macros/matchit.vim " {{{ " colorscheme 1989 " colorscheme PaperColor -" colorscheme gruvbox +colorscheme gruvbox " colorscheme jellybeans " colorscheme molokai " colorscheme Benokai @@ -245,6 +246,17 @@ runtime macros/matchit.vim " colorscheme monokai-phoenix " }}} +"custom commands +"{{{ +"common typos and abbreviations +cnoremap w!! w !sudo tee % > /dev/null +command! W w !sudo tee % > /dev/null +command! Trim %s/\s\+$// +command! Q q +command! WQ wq +command! Q1 q! +"}}} + "keybinds "{{{ "leader key @@ -267,29 +279,42 @@ nnoremap dt :r !date nnoremap rc :vsplit $MYVIMRC nnoremap so :source $MYVIMRC +"insert mode +inoreabbrev #!! "#!/usr/bin/env" + "formatting tools nnoremap =j :%!python -m json.tool +"}}} "plugin keybinds +"{{{ +"netrw nnoremap e :call ToggleNetrw() + +"openbrowser nmap gx (openbrowser-smart-search) vmap gx (openbrowser-smart-search) + +"ale nnoremap at :ALEToggle nmap af (ale_fix) -"insert mode -inoreabbrev #!! "#!/usr/bin/env" -"}}} +"lsp +function! s:on_lsp_buffer_enabled() abort + setlocal omnifunc=lsp#complete + setlocal signcolumn=yes + if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif + nmap gd (lsp-definition) + nmap gr (lsp-references) + nmap gi (lsp-implementation) + nmap gt (lsp-type-definition) + nmap rn (lsp-rename) + nmap [g (lsp-previous-diagnostic) + nmap ]g (lsp-next-diagnostic) + nmap K (lsp-hover) + nmap lf (lsp-document-format) +endfunction -"custom commands -"{{{ -"common typos and abbreviations -cnoremap w!! w !sudo tee % > /dev/null -command! W w !sudo tee % > /dev/null -command! Trim %s/\s\+$// -command! Q q -command! WQ wq -command! Q1 q! "}}} "toggle functions @@ -404,5 +429,10 @@ if has("autocmd") augroup filetype_halftab autocmd! FileType html,javascript,css,json,yaml,sh call HalftabSettings() augroup END + + augroup lsp_install + autocmd! + autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled() + augroup END endif "}}}