Created
February 20, 2021 01:06
-
-
Save woahdae/5dcfc957fd334bc3dedc506eff47944d to your computer and use it in GitHub Desktop.
Current vim config (via neovim & vim-plug)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Specify a directory for plugins | |
call plug#begin('~/.config/nvim/plugged') | |
" What I consider essential essentials - these make vim vim-ier (IMHO) | |
Plug 'mhinz/vim-grepper' " Makes grepping feel like other editors | |
Plug 'svermeulen/vim-yoink' " Adds a 'kill ring' to vim, i.e. yank history | |
Plug 'mbbill/undotree' " visualize Vim's built-in undo branches | |
Plug 'PeterRincker/vim-searchlight' " highlights the current search result | |
Plug 'tpope/vim-repeat' " makes repeating (.) work in more cases | |
Plug 'ludovicchabant/vim-gutentags' " Auto ctag managemnet that 'just works' | |
Plug 'tpope/vim-surround' " Adds a 'surrounding' text object (ex. ds' = del surrounding apostrophe) | |
Plug 'michaeljsmith/vim-indent-object' " Adds an 'inside' text object (ex. dii = del in indent) | |
" Language support | |
Plug 'slim-template/vim-slim' " slim template highlighting | |
Plug 'aklt/plantuml-syntax' " PlantUML syntax highlighting | |
Plug 'evanleck/vim-svelte' " svelte file support | |
Plug 'pangloss/vim-javascript' " Vastly improved Javascript support | |
Plug 'kana/vim-textobj-user' " vim-textobj-rubyblock depends on this | |
Plug 'tpope/vim-endwise' " Intelligently adds 'end' etc to relevant languages | |
Plug 'nelstrom/vim-textobj-rubyblock' " Adds a Ruby textobject (ex. dir = delete in ruby block) | |
" Essential to my workflow, but not necessarily vim-y. Ordered by excitement. | |
Plug 'junegunn/fzf.vim' " AWESOME fuzzy finder. | |
Plug 'junegunn/fzf', | |
\{ 'do': { -> fzf#install() } } | |
Plug 'scrooloose/nerdtree', " on-demand file tree | |
\{ 'on': 'NerdTreeToggle' } | |
Plug 'cohama/lexima.vim' " Automatically closes blocks, functions, etc | |
Plug 'AndrewRadev/splitjoin.vim' " expand one-liners to multi-line & vice versa | |
Plug 'dense-analysis/ale' " A good async linter | |
Plug 'vim-test/vim-test' " quickly run tests inside vim | |
Plug 'tpope/vim-fugitive' " Git stuff (blame, diff, etc) | |
Plug 'airblade/vim-gitgutter' " marks changed lines in the gutter | |
Plug 'tpope/vim-rhubarb' " GitHub stuff (ie Gbrowse) | |
Plug 'bronson/vim-trailing-whitespace' " Highlights trailing whitespace | |
Plug 'junegunn/vim-easy-align' " align blocks of text in misc ways | |
Plug 'vimwiki/vimwiki' " Personal wiki for notes via vim | |
Plug 'troydm/zoomwintab.vim' " When using split windows, use 'c-w o' to toggle split/unsplit | |
" Things I'm trying out | |
Plug 'unblevable/quick-scope' " testing - Highlights characters to help with `f` | |
Plug 'easymotion/vim-easymotion' " testing - extra motion abilities | |
Plug 'kshenoy/vim-signature' " testing - extra marks functionality | |
Plug 'rhysd/clever-f.vim' " testing - changes how f,t,F,T work for repeats | |
Plug 'floobits/floobits-neovim' " testing - remote pairing service | |
Plug 'tyru/open-browser.vim' " testing - plantuml-previewer depends on this | |
Plug 'tbodt/deoplete-tabnine', " testing - AI completion | |
\{ 'do': './install.sh' } | |
Plug 'weirongxu/plantuml-previewer.vim' " testing - preview PlantUML as you edit | |
" Snippets | |
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } | |
Plug 'honza/vim-snippets' | |
Plug 'SirVer/ultisnips' | |
Plug 'tpope/vim-rails' | |
" Theme | |
Plug 'lifepillar/vim-solarized8' | |
" Initialize plugin system | |
call plug#end() | |
""" | |
" Settings | |
" | |
let mapleader="\<SPACE>" " change leader key from default '\' to the space bar | |
set showcmd " Show (partial) command in status line. | |
set showmatch " Show matching brackets. | |
set showmode " Show current mode. | |
set ruler " Show the line and column numbers of the cursor. | |
set number " Show the line numbers on the left side. | |
set formatoptions+=o " Continue comment marker in new lines. | |
set textwidth=0 " Hard-wrap long lines as you type them. | |
set softtabstop=2 " A tab equals 2 spaces | |
set tabstop=2 " Render TABs using this many spaces. | |
set shiftwidth=2 " Indentation amount for < and > commands. | |
set expandtab " Insert spaces when TAB is pressed. | |
set breakindent " Soft-wraps things at the same level of indentation | |
set showbreak=› " " Make soft wrap a little more obvious | |
set hidden " Allows any buffer to be 'hidden' without saving | |
set confirm " Only prompt to save buffers when quitting vim | |
set noerrorbells " No beeps. | |
set modeline " Enable modeline. | |
set linespace=0 " Set line-spacing to minimum. | |
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J) | |
set copyindent " copy the previous indentation on autoindenting | |
" More natural splits | |
set splitbelow " Horizontal split below current. | |
set splitright " Vertical split to right of current. | |
" More natural scrolling | |
set scrolloff=3 " Show next 3 lines while scrolling. | |
set sidescrolloff=5 " Show next 5 columns while side-scrolling. | |
set nostartofline " Do not jump to first character with page commands. | |
set ignorecase " Make searching case insensitive | |
set smartcase " ... unless the query has capital letters. | |
" make hidden characters visible | |
set list " show hidden characters | |
set listchars=tab:▸\ ,eol:¬,extends:›,precedes:‹ " specify hidden characters | |
set gdefault " Use 'g' flag by default with :s/foo/bar/. | |
set magic " Use 'magic' patterns (extended regular expressions). | |
set grepprg=rg\ --vimgrep " Use rg (ripgrep) instead of grep | |
set colorcolumn=81 " puts a bar after 80 characters to encourage 80 char width | |
" Linters use the 'signcolumn' feature, but by default the signcolumn is | |
" hidden until the linter finds an error. With async linting, this means | |
" your display is shifting left and right as you type and the linter is | |
" complaining about your unfisished code. This makes the signcolumn always be | |
" present so even if the linter is complaining, it's not nearly as jarring. | |
" https://superuser.com/questions/558876/how-can-i-make-the-sign-column-show-up-all-the-time-even-if-no-signs-have-been-a | |
autocmd BufRead,BufNewFile * setlocal signcolumn=yes | |
autocmd FileType nerdtree setlocal signcolumn=no | |
" enable built-in code block jump improvements for ruby, python (see :help %) | |
runtime macros/matchit.vim | |
" Return to last position when re-opening a file | |
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | |
\| exe "normal! g`\"" | endif | |
" Theme | |
set termguicolors | |
set background=light | |
colorscheme solarized8 | |
highlight NonText ctermfg=7 guifg=lightgrey | |
set guifont=Inconsolata:h14 | |
" Only applies to the neovide GUI (this speeds up) | |
let g:neovide_cursor_animation_length=0.05 | |
" Use better (IMO) block-style indentation for ruby | |
" https://github.com/vim-ruby/vim-ruby/issues/314 | |
let g:ruby_indent_block_style = 'do' | |
""" | |
" Misc leader, movement, etc mappings | |
" | |
" move by screen line instead of file line | |
nnoremap j gj | |
nnoremap k gk | |
" enter insert mode with padding above and below | |
nmap <Leader>i o<Esc>O | |
" go back to last buffer [dvorak] | |
nmap <Leader>- :e#<CR> | |
" close current buffer, but keep the split/window | |
nmap <Leader>x :bp\|bd #<CR> | |
" close current split/window | |
nmap <Leader>q :q<CR> | |
" save current window | |
" (can't decide between s and w, trying both) | |
nmap <Leader>w :w<CR> | |
nmap <leader>s :w<CR> | |
" Turn off highlighting | |
nnoremap <Leader>th :noh<CR> | |
" Vim has a built-in undo branches - let's make 'em more accessible | |
nnoremap <Leader>z :UndotreeToggle<cr> | |
""" project/file/buffer/tag navigation [dvorak] | |
" Project-wide regex search | |
nmap <Leader>a :GrepperRg<space> | |
" FZF project-wide file finder | |
nmap <leader>o :<C-u>Files<cr> | |
" FZF open buffers file finder | |
nmap <leader>e :<C-u>Buffers<cr> | |
" FZF go-to-line for method and class definitions | |
nmap <leader>u :<C-u>BTags<cr> | |
" File browser | |
nmap <leader>n :NERDTreeToggle<CR> | |
nmap <Leader>cn :cnext<CR> | |
nmap <Leader>cp :cprevious<CR> | |
" Use * in visual select to search for highlighted word | |
" (vim already supports * to search for word under cursor in normal mode) | |
vnoremap <silent> * :<C-U> | |
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR> | |
\gvy/<C-R>=&ic?'\c':'\C'<CR><C-R><C-R>=substitute( | |
\escape(@", '/\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR> | |
\gVzv:call setreg('"', old_reg, old_regtype)<CR> | |
" Copy the visual selection into the system clipboard | |
" (i'd like to figure out how to get <M-c> to work...) | |
vmap <C-c> "*y | |
" select last pasted text | |
nnoremap <expr> gp '`[' . getregtype()[0] . '`]' | |
" Use Q to execute a default register for quicker macros | |
" (use `qq` to record your macro, then `Q` to repeat it) | |
nnoremap Q @q | |
" testing - [dvorak] make jumping to marks match QUERTY ' location | |
" (also I prefer to jump to the line *and* column, hence `) | |
noremap - ` | |
" Shortcut to access the default register with 'r' instead of " | |
inoremap <C-r>r <C-r>" | |
" testing - automatically set marks to help typical fullstack workflows. | |
" Tailored esp. for Rails dev. | |
autocmd BufLeave *.css,*.less,*scss normal! mS | |
autocmd BufLeave *.js,*.coffee,*.jsx normal! mJ | |
autocmd BufLeave *app/models/* normal! mM | |
autocmd BufLeave *.erb,*.haml normal! mV | |
autocmd BufLeave *app/controllers/* normal! mC | |
autocmd BufLeave */test_,*_spec\.* normal! mT | |
autocmd BufLeave routes.rb normal! mR | |
""" | |
" Sets up persistent, global undos | |
" | |
" set undo to global dir | |
if isdirectory($HOME . '/.vim/_undo') == 0 | |
:silent !mkdir -p ~/.vim/_undo > /dev/null 2>&1 | |
endif | |
set undodir=~/.vim/_undo// | |
" make one undo file per project file, | |
" vs one big undo file for everything | |
set undofile | |
" centralize backup and temp files (alongside undofiles, too) | |
set backupdir=~/.vim/_backup// | |
set directory=~/.vim/_temp// | |
""" | |
" Plugin configuration | |
" | |
" https://www.reddit.com/r/vim/comments/d77t6j/guide_how_to_setup_ctags_with_gutentags_properly | |
let g:gutentags_add_default_project_roots = 0 | |
let g:gutentags_project_root = ['package.json', '.git'] | |
let g:gutentags_cache_dir = expand('~/.vim/_ctags') | |
" https://github.com/ludovicchabant/vim-gutentags/issues/178 | |
let g:gutentags_exclude_filetypes = ['gitcommit', 'gitconfig', 'gitrebase', 'gitsendemail', 'git'] | |
" I've found that the most interesting results are in the top 3, | |
" and after that it's significantly worse than other heuristics, which | |
" then get pushed out of the autocomplete menu by odd tabnine results. | |
call deoplete#custom#var('tabnine', { 'max_num_results': 3 }) | |
" make vimwiki use markdown syntax | |
let g:vimwiki_list = [{'path': '~/vimwiki/', | |
\ 'syntax': 'markdown', 'ext': '.md'}] | |
augroup filetypedetect | |
au! BufRead,BufNewFile */vimwiki/* set filetype=vimwiki | |
augroup END | |
" Configuring yoink | |
nmap p <plug>(YoinkPaste_p) | |
nmap P <plug>(YoinkPaste_P) | |
" After paste, use this to cycle back through the yank/delete history | |
nmap <C-p> <plug>(YoinkPostPasteSwapBack) | |
nmap <C-n> <plug>(YoinkPostPasteSwapForward) | |
" Yoink conflicts with some other plugin, but this makes it work | |
" https://github.com/svermeulen/vim-yoink/issues/12 | |
let g:yoinkChangeTickThreshold = 1 | |
let g:UltiSnipsSnippetsDir='/Users/woody/.config/nvim/plugged/vim-snippets' | |
let g:UltiSnipsSnippetDirectories=["vim-snippets"] | |
let g:UltiSnipsExpandTrigger="<Tab>" | |
let g:UltiSnipsJumpForwardTrigger="<Tab>" | |
let g:UltiSnipsJumpBackwardTrigger="<S-Tab>" | |
let g:deoplete#enable_at_startup = 1 | |
" Have FZF use ripgrep, which ignores dotfiles and anything in .gitignore | |
let $FZF_DEFAULT_COMMAND='rg --files --hidden' | |
" Tell fzf to put the preview window on the bottom - works better w/ splits | |
let g:fzf_layout = { 'window': 'enew' } | |
let g:fzf_preview_window = 'down:60%' | |
" Start interactive EasyAlign in visual mode (e.g. vipga) | |
xmap ga <Plug>(EasyAlign) | |
" Start interactive EasyAlign for a motion/text object (e.g. gaip) | |
nmap ga <Plug>(EasyAlign) | |
" Some ale configs | |
let g:ale_fixers = { | |
\ 'ruby': ['prettier'] | |
\} | |
" More ale configs | |
augroup ale_ruby | |
au! | |
au FileType ruby let b:ale_javascript_prettier_executable = 'rbprettier' | |
augroup END | |
" these two turn off ale/linting while changing a line in insert mode | |
let g:ale_lint_on_text_changed = 'normal' | |
let g:ale_lint_on_insert_leave = 1 | |
" mappings for vim-test | |
let test#strategy = 'kitty' | |
nmap <silent> <leader>tn :w<CR>:TestNearest<CR> | |
nmap <silent> <leader>tf :w<CR>:TestFile<CR> | |
nmap <silent> <leader>ts :w<CR>:TestSuite<CR> | |
nmap <silent> <leader>tg :w<CR>:TestVisit<CR> | |
nmap <silent> <leader>tl :w<CR>:TestLast<CR> | |
" not semantic, but handy | |
nmap <silent> <leader>tt :w<CR>:TestLast<CR> | |
let g:splitjoin_split_mapping = 'gj' " I like this better, can't say why | |
let g:splitjoin_ruby_hanging_args = 0 " make argument splits start w/ newline | |
let g:splitjoin_ruby_curly_braces = 0 " don't insert curly braces for hash arguments | |
" By default, lexima breaks <CR> while autocompleting | |
let g:lexima_nvim_accept_pum_with_enter = 0 | |
let g:clever_f_chars_match_any_signs = ';' " match any symbol with ex. f; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment