" " ███▄ █ ▓█████ ▒█████ ██▒ █▓ ██▓ ███▄ ▄███▓ " ██ ▀█ █ ▓█ ▀ ▒██▒ ██▒▓██░ █▒▓██▒▓██▒▀█▀ ██▒ " ▓██ ▀█ ██▒▒███ ▒██░ ██▒ ▓██ █▒░▒██▒▓██ ▓██░ " ▓██▒ ▐▌██▒▒▓█ ▄ ▒██ ██░ ▒██ █░░░██░▒██ ▒██ " ▒██░ ▓██░░▒████▒░ ████▓▒░ ▒▀█░ ░██░▒██▒ ░██▒ " ░ ▒░ ▒ ▒ ░░ ▒░ ░░ ▒░▒░▒░ ░ ▐░ ░▓ ░ ▒░ ░ ░ " ░ ░░ ░ ▒░ ░ ░ ░ ░ ▒ ▒░ ░ ░░ ▒ ░░ ░ ░ " ░ ░ ░ ░ ░ ░ ░ ▒ ░░ ▒ ░░ ░ " ░ ░ ░ ░ ░ ░ ░ ░ " ░ " " - Dorian's NeoVim Configuration - " General settings {{{ scriptencoding utf-16 " allow emojis in vimrc set nocompatible " vim, not vi syntax on " syntax highlighting filetype plugin indent on " try to recognize filetypes and load rel' plugins " }}} " Behavior Modification ---------------------- {{{ " set leader key let g:mapleader="\\" " alias for leader key nmap \ xmap \ set backspace=2 " Backspace deletes like most programs in insert mode set history=200 " how many : commands to save in history set ruler " show the cursor position all the time set showcmd " display incomplete commands set incsearch " do incremental searching set laststatus=2 " Always display the status line set autowrite " Automatically :write before running commands set ignorecase " ignore case in searches set smartcase " use case sensitive if capital letter present or \C set magic " Use 'magic' patterns (extended regular expressions). set guioptions= " remove scrollbars on macvim set noshowmode " don't show mode as airline already does set showcmd " show any commands set foldmethod=manual " set folds by syntax of current language set foldcolumn=2 " display gutter markings for folds set mouse=a " enable mouse (selection, resizing windows) set iskeyword+=- " treat dash separated words as a word text object set tabstop=2 " Softtabs or die! use 2 spaces for tabs. set shiftwidth=2 " Number of spaces to use for each step of (auto)indent. set expandtab " insert tab with right amount of spacing set shiftround " Round indent to multiple of 'shiftwidth' set termguicolors " enable true colors set hidden " enable hidden unsaved buffers if !has('nvim') " does not work on neovim set emoji " treat emojis 😄 as full width characters set cryptmethod=blowfish2 " set encryption to use blowfish2 (vim -x file.txt) end set ttyfast " should make scrolling faster set lazyredraw " should make scrolling faster " visual bell for errors set visualbell " text appearance set textwidth=80 set nowrap " nowrap by default set list " show invisible characters set listchars=tab:»·,trail:·,nbsp:· " Display extra whitespace " Numbers set number set numberwidth=1 " set where swap file and undo/backup files are saved set backupdir=~/.vim/tmp,. set directory=~/.vim/tmp,. " persistent undo between file reloads if has('persistent_undo') set undofile set undodir=~/.vim/tmp,. endif " Open new split panes to right and bottom, which feels more natural set splitbelow set splitright " Set spellfile to location that is guaranteed to exist, can be symlinked to " Dropbox or kept in Git set spellfile=$HOME/.vim-spell-en.utf-8.add " Autocomplete with dictionary words when spell check is on set complete+=kspell " Always use vertical diffs if has('nvim') set diffopt+=vertical endif " highlight fenced code blocks in markdown let g:markdown_fenced_languages = [ \ 'bash=sh', \ 'elixir', \ 'elm', \ 'graphql', \ 'html', \ 'js=javascript', \ 'json', \ 'python', \ 'ruby', \ 'sql', \ 'vim', \ ] " enable folding in bash files let g:sh_fold_enabled=1 " }}} " Plugin Modifications (BEFORE loading bundles) ----- {{{ " ==================================== " Floaterm " ==================================== let g:floaterm_position = 'center' let g:floaterm_background = '#272c35' let g:floaterm_winblend = 10 hi FloatermNF guibg=#272c35 hi FloatermBorderNF guibg=#272c35 guifg=white command! -nargs=0 FT FloatermToggle " Use 90% width for floaterm. If error occurs, update the plugin let g:floaterm_width = 0.9 let g:floaterm_height = 0.7 function s:floatermSettings() call SetColorColumn(0) endfunction augroup FloatermCustom autocmd! autocmd FileType floaterm call s:floatermSettings() " h : Hide the floating terminal window " q : Quit the floating terminal window autocmd FileType floaterm tmap q :call SetColorColumn(1):q autocmd FileType floaterm tmap h :call SetColorColumn(1):hide augroup END " function! floaterm#wrapper#lazygit() abort " let cmd = 'lazygit' " call SetColorColumn(0) " return [cmd, {'on_exit': funcref('s:lazygit_callback')}, v:false] " endfunction " function! s:ranger_callback(...) abort " call SetColorColumn(1) " endfunction nnoremap gg :FloatermNew lazygit " ==================================== " VimMatchUp: " ==================================== let g:matchup_matchparen_deferred = 1 " ==================================== " WinResizer: " ==================================== nnoremap r :WinResizerStartResize "" ==================================== " UndoTree: " ==================================== nnoremap ut :UndotreeToggle " ==================================== " COC " ==================================== " Tell CoC where node is if it doesn't know let current_node_path = trim(system('asdf where nodejs')) let g:coc_node_path = current_node_path . '/bin/node' inoremap pumvisible() ? "\" : "\" inoremap pumvisible() ? "\" : "\" " Use `[g` and `]g` to navigate diagnostics nmap [g (coc-diagnostic-prev) nmap ]g (coc-diagnostic-next) " Remap keys for gotos nmap gd (coc-definition) nmap gy (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) " Use K to show documentation in preview window. nnoremap K :call show_documentation() function! s:show_documentation() if (index(['vim','help'], &filetype) >= 0) execute 'h '.expand('') else call CocAction('doHover') endif endfunction augroup CocConfig autocmd! " coc-highlight: enable highlighting for symbol under cursor autocmd CursorHold * silent call CocActionAsync('highlight') " Update signature help on jump placeholder. autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') augroup END " Use `:Format` to format current buffer command! -nargs=0 Format :call CocAction('format') " set coc as nvim man page provider for functions " TODO: maybe need to check if coc is enabled for file and do setlocal? set keywordprg=:call\ CocAction('doHover') " ==================================== " Vista.vim " ==================================== " use coc as backend let g:vista_default_executive = 'coc' let g:vista_finder_alternative_executives = ['ctags'] " enable fzf preview let g:vista_fzf_preview = [] " enable icons (must have patched fonts) let g:vista#renderer#enable_icon = 1 " enable nicer indentation using patched fonts let g:vista_icon_indent = ["╰─▸ ", "├─▸ "] " how long before scrolling / floating the definition let g:vista_cursor_delay = 200 " how to show the definition let g:vista_echo_cursor_strategy = 'floating_win' " update symbol list when text changed (really it should be on file saved or " different file opened) let g:vista_update_on_text_changed = 1 " mappings nnoremap vv :Vista! nnoremap vf :Vista finder " ==================================== " Carbon Now Screenshots (vim-carbon-now-sh) " ==================================== vnoremap :CarbonNowSh " ==================================== " Neosnippet: " ==================================== let g:neosnippet#enable_completed_snippet = 1 " Plugin key-mappings. " Note: It must be "imap" and "smap". It uses mappings. imap (neosnippet_expand_or_jump) smap (neosnippet_expand_or_jump) xmap (neosnippet_expand_target) " SuperTab like snippets behavior. " Note: It must be "imap" and "smap". It uses mappings. imap \ pumvisible() ? "\" : \ neosnippet#expandable_or_jumpable() ? \ "\(neosnippet_expand_or_jump)" : "\" smap neosnippet#expandable_or_jumpable() ? \ "\(neosnippet_expand_or_jump)" : "\" let g:neosnippet#enable_snipmate_compatibility = 1 " ==================================== " PivotalTracker.vim: " ==================================== augroup PivotalTracker autocmd! autocmd FileType gitcommit setlocal completefunc=pivotaltracker#stories autocmd FileType gitcommit setlocal omnifunc=pivotaltracker#stories augroup END " ==================================== " NeoTerm: " ==================================== let g:neoterm_repl_ruby = 'pry' let g:neoterm_autoscroll = 1 " ==================================== " Gist: " ==================================== map gst :Gist " ==================================== " GitGutter: " ==================================== " nnoremap + :GitGutterNextHunk " nnoremap _ :GitGutterPrevHunk " ==================================== " Vim Scriptease: " ==================================== " Run commands that require an interactive shell nnoremap ri :RunInInteractiveShell " Reload current vim plugin nnoremap rr :Runtime " ==================================== " CopyRTF: Copy code as RTF " ==================================== nnoremap :set nonumber:CopyRTF:set number " ==================================== " SplitJoin: " ==================================== let g:splitjoin_align = 1 let g:splitjoin_trailing_comma = 1 let g:splitjoin_ruby_curly_braces = 0 let g:splitjoin_ruby_hanging_args = 0 " ==================================== " MatchTagAlways: " ==================================== let g:mta_filetypes = { \ 'jinja': 1, \ 'xhtml': 1, \ 'xml': 1, \ 'html': 1, \ 'django': 1, \ 'javascript.jsx': 1, \ 'eruby': 1, \ } " ==================================== " Snippets (UltiSnips): " ==================================== let g:UltiSnipsExpandTrigger="" let g:UltiSnipsListSnippets="" let g:UltiSnipsJumpForwardTrigger="" let g:UltiSnipsJumpBackwardTrigger="" " :UltiSnipsEdit opens in a vertical split let g:UltiSnipsEditSplit = 'vertical' let g:UltiSnipsSnippetsDir = $HOME . '/dotfiles/vim/UltiSnips' " ==================================== " indentLine " ==================================== let g:indentLine_fileType = [ \ 'java', \ 'ruby', \ 'elixir', \ 'javascript', \ 'javascript.jsx', \ 'html', \ 'eruby', \ 'vim' \ ] let g:indentLine_char = '│' let g:indentLine_color_term = 238 let g:indentLine_color_gui = '#454C5A' " ==================================== " setup airline " ==================================== let g:airline#extensions#branch#enabled = 0 let g:airline#extensions#tabline#enabled = 1 let g:airline#extensions#tabline#formatter = 'unique_tail' let g:airline_powerline_fonts = 1 let g:airline#extensions#tabline#show_buffers = 0 let g:airline_left_sep = '' let g:airline_right_sep = '' let g:airline_mode_map = { \ '__' : '-', \ 'n' : 'N', \ 'i' : 'I', \ 'R' : 'R', \ 'c' : 'C', \ 'v' : 'V', \ 'V' : 'V', \ '' : 'V', \ 's' : 'S', \ 'S' : 'S', \ '' : 'S', \ } " ==================================== " Bullets.vim: " ==================================== let g:bullets_enabled_file_types = [ \ 'markdown', \ 'text', \ 'gitcommit', \ 'scratch' \] " ===================================== " FZF " ===================================== let $FZF_DEFAULT_COMMAND = 'fd --type f --hidden --follow --color=always -E .git --ignore-file ~/.gitignore' let $FZF_DEFAULT_OPTS='--ansi --layout=reverse' let g:fzf_files_options = '--preview "(bat --color \"always\" --line-range 0:100 {} || head -'.&lines.' {})"' autocmd! FileType fzf autocmd FileType fzf set noshowmode noruler nonu let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } } function! FZFOpen(command_str) if (expand('%') =~# 'NERD_tree' && winnr('$') > 1) exe "normal! \\" endif exe 'normal! ' . a:command_str . "\" endfunction command! -bang -nargs=* FzfRg \ call fzf#vim#grep( \ 'rg --column --line-number --no-heading --color=always --smart-case '.shellescape(), 1, \ 0 ? fzf#vim#with_preview('up:60%') \ : fzf#vim#with_preview('right:50%:hidden', '?'), \ 0) nnoremap :call FZFOpen(':Buffers') nnoremap g :call FZFOpen(':FzfRg!') nnoremap c :call FZFOpen(':Commands') nnoremap l :call FZFOpen(':BLines') nnoremap :call FZFOpen(':Files') nnoremap :call FZFOpen(':History') nnoremap :call FZFOpen(':BTags') " nnoremap :call FZFOpen(':call Fzf_dev()') imap (fzf-complete-word) imap (fzf-complete-path) imap (fzf-complete-file-ag) imap (fzf-complete-line) " ====================================== " FZF + DevIcons " ====================================== function! FzfIcons() let l:fzf_files_options = '--preview "bat --color always --style numbers {2..} | head -'.&lines.'"' function! s:edit_devicon_prepended_file(item) let l:file_path = a:item[4:-1] execute 'silent e' l:file_path endfunction call fzf#run({ \ 'source': $FZF_DEFAULT_COMMAND . ' | devicon-lookup --color', \ 'sink': function('s:edit_devicon_prepended_file'), \ 'options': '-m ' . l:fzf_files_options, \ 'window': { 'width': 0.9, 'height': 0.6 } \ }) endfunction " Custom FZF commands ----------------------------- {{{ fun! s:parse_pivotal_story(entry) let l:stories = pivotaltracker#stories('', '') let l:filtered = filter(l:stories, {_idx, val -> val.menu == a:entry[0]}) return l:filtered[0].word endfun augroup PivotalTrackerCompletionMappings autocmd! autocmd FileType gitcommit inoremap # fzf#complete( \ { \ 'source': map(pivotaltracker#stories('', ''), {_key, val -> val.menu}), \ 'reducer': function('parse_pivotal_story'), \ 'options': '-m', \ 'down': '20%' \ }) autocmd FileType gitcommit inoremap t fzf#complete( \ { \ 'source': map(pivotaltracker#stories('', ''), {_key, val -> val.menu}), \ 'options': '-m', \ 'down': '20%' \ }) augroup END " ------ CHANGE BRANCH (Gbranch) ------- {{{ fun! s:change_branch(e) let l:_ = system('git checkout ' . a:e) :e! :AirlineRefresh echom 'Changed branch to' . a:e endfun command! Gbranch call fzf#run( \ { \ 'source': 'git branch', \ 'sink': function('change_branch'), \ 'options': '-m', \ 'window': { 'width': 0.9, 'height': 0.6 } \ }) " ------ /CHANGE BRANCH (Gbranch) ------- }}} " ------ CHANGE REMOTE BRANCH (Gbranch) ------- {{{ fun! s:change_remote_branch(e) let l:_ = system('git checkout --track ' . a:e) :e! :AirlineRefresh echom 'Changed to remote branch' . a:e endfun command! Grbranch call fzf#run( \ { \ 'source': 'git branch -r', \ 'sink': function('change_remote_branch'), \ 'options': '-m', \ 'window': { 'width': 0.9, 'height': 0.6 } \ }) " ------ /CHANGE REMOTE BRANCH (Gbranch) ------- }}} " ------ JUMP TO GIT CONFLICTS (Gconflict) ------- {{{ fun! s:jump_to_first_conflict(file_path) execute 'silent e ' . a:file_path :call search('^<<<') endfun fun! s:gconflict_preview_cmd() let l:first_conflict_line_num = "rg -I -n -m1 '^<<<<' {} | cut -f1 -d ':'" let l:line_range = '--line-range \"\$(' . l:first_conflict_line_num . '):\"' let l:bat_cmd = 'bat --color \"always\" ' . l:line_range . ' {}' return '--preview "' . l:bat_cmd . '"' endfun command! Gconflict call fzf#run( \ { \ 'source': "rg -l '^(<<<|===|>>>)'", \ 'sink': function('jump_to_first_conflict'), \ 'options': '-m '. s:gconflict_preview_cmd(), \ 'window': { 'width': 0.9, 'height': 0.6 } \ }) nmap gc :Gconflict " ------ /JUMP TO GIT CONFLICTS (Gconflict) ------- }}} " --------------------------------------------------}}} " ===================================== " JSX " ===================================== " Allow JSX in normal JS files let g:jsx_ext_required = 0 " ===================================== " Rg " ===================================== " Grep selection with Rg xnoremap gr y :Rg " nnoremap gr :Rg " Grep selection with Rg (excluding tests and migrations) xnoremap gt y :Rg " -g '!*/**/test/*' -g '!*/**/migrations/*' nnoremap gt :Rg -g '!*/**/test/*' -g '!*/**/migrations/*' " Put cursor after :Rg command (a little faster than typing :Rg) nnoremap rg ':Rg ' " Use RipGrep for grep https://www.wezm.net/technical/2016/09/ripgrep-with-vim/ if executable("rg") set grepprg=rg\ --vimgrep\ --no-heading set grepformat=%f:%l:%c:%m,%f:%l:%m endif " ---------------------------------------------------------------------------- " vim slime " ---------------------------------------------------------------------------- let g:slime_target='tmux' " ---------------------------------------------------------------------------- " Scratch.vim " ---------------------------------------------------------------------------- let g:scratch_no_mappings=1 nnoremap sc :Scratch augroup ScratchToggle autocmd! autocmd FileType scratch nnoremap sc :q augroup END " ---------------------------------------------------------------------------- " Emmet " ---------------------------------------------------------------------------- " better emmet leader key (must be followed with ,) let g:user_emmet_leader_key='' " ---------------------------------------------------------------------------- " Switch.vim " ---------------------------------------------------------------------------- let g:switch_custom_definitions = \ [ \ ['up', 'down', 'change'], \ ['add', 'drop', 'remove'], \ ['create', 'drop'], \ ['row', 'column'], \ ['first', 'second', 'third', 'fourth', 'fifth'], \ ] " ---------------------------------------------------------------------------- " Vim RSpec " ---------------------------------------------------------------------------- " Treat
  • and

    tags like the block tags they are let g:html_indent_tags = 'li\|p' nnoremap t :call RunCurrentSpecFile() nnoremap T :call RunNearestSpec() nnoremap l :call RunLastSpec() nnoremap sa :call RunAllSpecs() " ---------------------------------------------------------------------------- " Vim Flow JS " ---------------------------------------------------------------------------- let g:flow#autoclose = 1 " ---------------------------------------------------------------------------- " Vim Test " ---------------------------------------------------------------------------- if has('nvim') " run tests with neoterm in vim-test let g:test#strategy = 'neoterm' endif " Support Elixir Umbrella Apps (pre 1.9) {{{ " https://github.com/janko/vim-test/issues/136 function! ElixirUmbrellaTransform(cmd) abort if match(a:cmd, 'apps/') != -1 return substitute(a:cmd, 'mix test apps/\([^/]*\)/', 'mix cmd --app \1 mix test --color ', '') else return a:cmd end endfunction let g:test#custom_transformations = {'elixir_umbrella': function('ElixirUmbrellaTransform')} let g:test#transformation = 'elixir_umbrella' " }}} nmap T :TestNearest nmap t :TestFile nmap a :TestSuite nmap l :TestLast " ---------------------------------------------------------------------------- " ALE " ---------------------------------------------------------------------------- let g:airline#extensions#ale#enabled = 1 let g:ale_sign_error = '' let g:ale_sign_warning = '' " ALE automatically updates the loclist which makes it impossible to use some " other plugins such as GV let g:ale_set_loclist = 0 highlight link ALEWarningSign Directory highlight link ALEErrorSign WarningMsg nnoremap ne :ALENextWrap nnoremap pe :ALEPreviousWrap let g:ale_pattern_options = { \ '\.min\.js$': {'ale_linters': [], 'ale_fixers': []}, \ '\.min\.css$': {'ale_linters': [], 'ale_fixers': []}, \} let g:ale_fixers = { \ 'typescript': ['prettier'], \ 'typescript.tsx': ['prettier'], \ 'javascript': ['prettier'], \ 'javascript.jsx': ['prettier'], \ 'json': ['prettier'], \ 'scss': ['prettier'], \ 'bash': ['shfmt'], \ 'zsh': ['shfmt'], \ 'elixir': ['mix_format'], \ 'ruby': ['rubocop'], \ 'rust': ['rustfmt'], \ 'elm': ['elm-format'], \} let g:ale_sh_shfmt_options = '-i 2 -ci' let g:ale_fix_on_save = 1 " ---------------------------------------------------------------------------- " Investigate " ---------------------------------------------------------------------------- " Use Dash.app for documentation of word under cursor let g:investigate_use_dash=1 let g:investigate_syntax_for_rspec='ruby' " ---------------------------------------------------------------------------- " Startify " ---------------------------------------------------------------------------- let g:startify_files_number = 5 " ---------------------------------------------------------------------------- " Vim Hashrocket " ---------------------------------------------------------------------------- "Change cursor on insert mode (vim-hashrocket) if !has('nvim') let g:use_cursor_shapes = 1 end " ---------------------------------------------------------------------------- " Elm-vim " ---------------------------------------------------------------------------- " let g:elm_format_autosave=1 let g:elm_detailed_complete = 1 " ---------------------------------------------------------------------------- " NERDTree " ---------------------------------------------------------------------------- let g:NERDTreeIgnore = [ \ '\.vim$', \ '\~$', \ '\.beam', \ 'elm-stuff', \ 'deps', \ '_build', \ '.git', \ 'node_modules', \ 'tags', \ ] let g:NERDTreeShowHidden = 1 let g:NERDTreeAutoDeleteBuffer=1 " keep alternate files and jumps let g:NERDTreeCreatePrefix='silent keepalt keepjumps' nnoremap nt :NERDTreeToggle " not necessarily NTree related but uses NERDTree because I have it setup nnoremap d :e %:h augroup NERDTreeAuCmds autocmd! autocmd FileType nerdtree nmap - g:NERDTreeMapUpdir augroup END " move up a directory with "-" like using vim-vinegar (usually "u" does that) " ---------------------------------------------------------------------------- " WebDevIcons " ---------------------------------------------------------------------------- let g:WebDevIconsUnicodeDecorateFolderNodes = 1 let g:DevIconsEnableFoldersOpenClose = 1 let g:webdevicons_conceal_nerdtree_brackets = 1 let g:webdevicons_enable_airline_statusline = 1 let g:webdevicons_enable_airline_tabline = 1 let g:WebDevIconsOS = 'Darwin' let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols = {} let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['ex'] = '' let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['exs'] = '' let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['js'] = '' let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['jsx'] = '' let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['vim'] = '' let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['md'] = '' let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['rb'] = '' let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['rabl'] = '' let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['erb'] = '' let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['yaml'] = '' let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['yml'] = '' let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['svg'] = '' let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['json'] = '' let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['elm'] = '' let g:WebDevIconsUnicodeDecorateFileNodesPatternSymbols = {} " needed let g:WebDevIconsUnicodeDecorateFileNodesPatternSymbols['.*vimrc.*'] = '' let g:WebDevIconsUnicodeDecorateFileNodesPatternSymbols['.ruby-version'] = '' let g:WebDevIconsUnicodeDecorateFileNodesPatternSymbols['.ruby-gemset'] = '' let g:WebDevIconsUnicodeDecorateFileNodesPatternSymbols['.rspec'] = '' let g:WebDevIconsUnicodeDecorateFileNodesPatternSymbols['Rakefile'] = '' let g:WebDevIconsUnicodeDecorateFileNodesPatternSymbols['application.rb'] = '' let g:WebDevIconsUnicodeDecorateFileNodesPatternSymbols['environment.rb'] = '' let g:WebDevIconsUnicodeDecorateFileNodesPatternSymbols['routes.rb'] = '' let g:WebDevIconsUnicodeDecorateFileNodesPatternSymbols['spring.rb'] = '' let g:WebDevIconsUnicodeDecorateFileNodesPatternSymbols['.keep'] = '' let g:WebDevIconsUnicodeDecorateFileNodesPatternSymbols['package.json'] = '' " Useful alternatives:            " after a re-source, fix syntax matching issues (concealing brackets): if exists('g:loaded_webdevicons') call webdevicons#refresh() endif " ---------------------------------------------------------------------------- " vim-nerdtree-syntax-highlight: " ---------------------------------------------------------------------------- let g:NERDTreeFileExtensionHighlightFullName = 1 let g:NERDTreeExactMatchHighlightFullName = 1 let g:NERDTreePatternMatchHighlightFullName = 1 let g:NERDTreeExtensionHighlightColor = {} let g:NERDTreeExtensionHighlightColor['ex'] = '834F79' let g:NERDTreeExtensionHighlightColor['exs'] = 'c57bd8' let g:NERDTreeExtensionHighlightColor['rabl'] = 'ac4142' let g:NERDTreeExtensionHighlightColor['yml'] = 'f4bf70' let g:NERDTreeExtensionHighlightColor['yaml'] = 'f4bf70' let g:NERDTreeExtensionHighlightColor['elm'] = '39B7CF' " ---------------------------------------------------------------------------- " vim-go " ---------------------------------------------------------------------------- augroup CustomGoVimMappings autocmd! autocmd FileType go setlocal nolist listchars=tab:>-,trail:·,nbsp:· autocmd FileType go nmap r (go-run) autocmd FileType go nmap b (go-build) autocmd FileType go nmap t (go-test) autocmd FileType go nmap c (go-coverage) autocmd Filetype go \ command! -bang A call go#alternate#Switch(0, 'edit') \| command! -bang AV call go#alternate#Switch(0, 'vsplit') \| command! -bang AS call go#alternate#Switch(0, 'split') augroup END let g:go_fmt_autosave = 1 let g:go_term_mode = 'vsplit' let g:go_fmt_command='goimports' " ---------------------------------------------------------------------------- " goyo.vim + limelight.vim " ---------------------------------------------------------------------------- let g:limelight_paragraph_span = 1 let g:limelight_priority = -1 let g:background_before_goyo = &background function! s:goyo_enter() let g:background_before_goyo = &background if has('gui_running') set linespace=7 elseif exists('$TMUX') silent !tmux set status off endif Limelight endfunction function! s:goyo_leave() if has('gui_running') set linespace=0 elseif exists('$TMUX') silent !tmux set status on endif execute 'Limelight!' execute 'set background=' . g:background_before_goyo endfunction augroup GOYO autocmd! User GoyoEnter nested call goyo_enter() autocmd! User GoyoLeave nested call goyo_leave() augroup END " -------------------------------------------- " vim-legend " -------------------------------------------- let g:legend_active_auto = 0 let g:legend_hit_color = 'ctermfg=64 cterm=bold gui=bold guifg=Green' let g:legend_ignored_sign = '◌' let g:legend_ignored_color = 'ctermfg=234' let g:legend_mapping_toggle = 'cv' let g:legend_mapping_toggle_line = 'cv' " -------------------------------------------- " vim-ruby: " -------------------------------------------- " support ruby on rails omnicompletions let g:rubycomplete_rails = 1 " -------------------------------------------- " sideways.vim " -------------------------------------------- nnoremap :SidewaysLeft nnoremap :SidewaysRight " ----------------------------------------------------- }}} " Load all plugins ------------------------------- {{{ if filereadable(expand('~/.vimrc.bundles')) source ~/.vimrc.bundles endif " }}} " Plugin Modifications (AFTER loading bundles) ----- {{{ if has('nvim') && !exists('$TMUX') " ------------------------------------ " NVIMUX: " ------------------------------------ lua << EOF local nvimux = require('nvimux') -- Nvimux configuration nvimux.config.set_all{ prefix = '', open_term_by_default = true, new_window_buffer = 'single', quickterm_direction = 'botright', quickterm_orientation = 'vertical', -- Use 'g' for global quickterm quickterm_scope = 't', quickterm_size = '80', } -- Nvimux custom bindings nvimux.bindings.bind_all{ {'s', ':NvimuxHorizontalSplit', {'n', 'v', 'i', 't'}}, {'v', ':NvimuxVerticalSplit', {'n', 'v', 'i', 't'}}, } -- Required so nvimux sets the mappings correctly nvimux.bootstrap() EOF endif " }}} " UI Customizations --------------------------------{{{ if match($ITERM_PROFILE, 'light') >= 0 set background=light else set background=dark endif colorscheme one let g:one_allow_italics = 1 call one#highlight('elixirInclude', 'e06c75', '', 'none') call one#highlight('elixirOperator', 'd19a66', '', 'none') call one#highlight('vimTodo', '000000', 'ffec8b', 'none') let g:limelight_conceal_ctermfg = '#454d5a' let g:limelight_conceal_guifg = '#454d5a' " Make it obvious where 80 characters is " cheatsheet https://jonasjacek.github.io/colors/ fun! SetColorColumn(active) if a:active highlight ColorColumn ctermbg=236 guibg=#303030 let &colorcolumn=join(range(100,999),',') else highlight ColorColumn guibg=#272c35 endif endfun call SetColorColumn(1) " solid window border requires FuraCode Nerd Font set fillchars+=vert:│ " hide vertical split hi vertsplit guifg=fg guibg=bg " }}} " Text Objects {{{ augroup elixir_textobjs autocmd! autocmd FileType elixir call textobj#user#map('elixir', { \ 'map': { \ 'pattern': ['%{', '}'], \ 'select-a': ' aM', \ 'select-i': ' iM', \ }, \ }) augroup END " }}} " Own commands --------------------------------------------- {{{ command! PrettyPrintJSON %!python -m json.tool command! PrettyPrintHTML !tidy -mi -html -wrap 0 % command! PrettyPrintXML !tidy -mi -xml -wrap 0 % command! BreakLineAtComma :normal! f,. command! Retab :set ts=2 sw=2 et:retab " put result of fd command into quickfix list command! -bar -bang -complete=file -nargs=+ Cfd exe s:Grep(, , 'fd', '') function! s:Grep(bang, args, prg, type) abort let grepprg = &l:grepprg let grepformat = &l:grepformat let shellpipe = &shellpipe try let &l:grepprg = a:prg setlocal grepformat=%f if &shellpipe ==# '2>&1| tee' || &shellpipe ==# '|& tee' let &shellpipe = "| tee" endif execute 'silent '.a:type.'grep! '.a:args if empty(a:bang) && !empty(getqflist()) return 'cfirst' else return '' endif finally let &l:grepprg = grepprg let &l:grepformat = grepformat let &shellpipe = shellpipe endtry endfunction nnoremap fd ':Cfd ' " }}} " Auto commands ------------------------------------------------- {{{ augroup vimrcEx autocmd! " Remove trailing whitespace on save for ruby files. autocmd BufWritePre *.rb,*.ex,*.exs :%s/\s\+$//e if exists('$ITERM_PROFILE') " Preview images in vim (while in iterm) autocmd BufEnter *.png,*.jpg,*gif exec "! ~/.iterm2/imgcat ".expand("%") | :bw endif " When editing a file, always jump to the last known cursor position. " Don't do it for commit messages, when the position is invalid, or when " inside an event handler (happens when dropping a file on gvim). autocmd BufReadPost * \ if &ft != 'gitcommit' && line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal g`\"" | \ endif " Set syntax highlighting for specific file types autocmd BufRead,BufNewFile Appraisals,*.rabl set filetype=ruby autocmd BufRead,BufNewFile .babelrc set filetype=json autocmd BufRead,BufNewFile *.yrl set filetype=erlang autocmd BufRead,BufNewFile *.md set filetype=markdown autocmd BufRead,BufNewFile .eslintrc,.prettierrc set filetype=json " Enable spellchecking for Markdown autocmd FileType markdown setlocal spell " Automatically wrap at 80 characters for Markdown autocmd BufRead,BufNewFile *.md setlocal textwidth=80 " Automatically wrap at 72 characters and spell check git commit messages autocmd FileType gitcommit setlocal textwidth=72 autocmd FileType gitcommit setlocal spell " Allow stylesheets to autocomplete hyphenated words autocmd FileType css,scss,sass setlocal iskeyword+=- " Vim/tmux layout rebalancing " automatically rebalance windows on vim resize autocmd VimResized * :wincmd = " add support for comments in json (jsonc format used as configuration for " many utilities) autocmd FileType json syntax match Comment +\/\/.\+$+ " notify if file changed outside of vim to avoid multiple versions autocmd FocusGained * checktime augroup END " add operator pending mode for elixir maps - needs to support multiline map augroup ElixirAutoCommands autocmd! autocmd FileType elixir,eelixir let b:surround_{char2nr("m")} = '%{ \r }' augroup END " }}} " Vim Script file settings ------------------------ {{{ augroup filetype_vim autocmd! autocmd FileType vim setlocal foldmethod=marker augroup END " }}} " Key Mappings -------------------------------------------------- {{{ " Delete current buffer without losing the split nnoremap :bp\|bd # " open FZF in current file's directory nnoremap _ :Files =expand('%:h') " fold file based on syntax nnoremap zs :setlocal foldmethod=syntax " rename current file nnoremap rn :Move =expand("%") " replace word under cursor, globally, with confirmation nnoremap k :%s/\<\>//gc vnoremap k y :%s/"//gc " insert frozen string literal comment at the top of the file (ruby) map fsl ggO# frozen_string_literal: truejO " remove highlighting on escape nnoremap :nohlsearch " sort selected lines vmap gs :sort " Pasting support set pastetoggle= " Press F2 in insert mode to preserve tabs when " pasting from clipboard into terminal " re-indent file and jump back to where the cursor was map mzgg=G`z " Allow j and k to work on visual lines (when wrapping) noremap w :call ToggleWrap() function! ToggleWrap() if &wrap echo 'Wrap OFF' setlocal nowrap set virtualedit=all silent! nunmap j silent! nunmap k else echo 'Wrap ON' setlocal wrap linebreak nolist set virtualedit= setlocal display+=lastline noremap k gk noremap j gj inoremap gk inoremap gj endif endfunction " qq to record, Q to replay nnoremap Q @q " Zoom function! s:zoom() if winnr('$') > 1 tab split elseif len(filter(map(range(tabpagenr('$')), 'tabpagebuflist(v:val + 1)'), \ 'index(v:val, '.bufnr('').') >= 0')) > 1 tabclose endif endfunction nnoremap z :call zoom() " Tab/shift-tab to indent/outdent in visual mode. vnoremap >gv vnoremap >gv vnoremap < x " Split edit your vimrc. Type space, v, r in sequence to trigger fun! OpenConfigFile(file) if (&filetype ==? 'startify') execute 'e ' . a:file else execute 'tabe ' . a:file endif endfun nnoremap vr :call OpenConfigFile('~/.vimrc') nnoremap vb :call OpenConfigFile('~/.vimrc.bundles') " " Source (reload) your vimrc. Type space, s, o in sequence to trigger nnoremap so :source $MYVIMRC " toggle background light / dark fun! ToggleBackground() if (&background ==? 'dark') set background=light else set background=dark endif endfun nnoremap :call ToggleBackground() "split edit your tmux conf nnoremap mux :vsp ~/.tmux.conf " VimPlug: nnoremap pi :PlugInstall nnoremap pu :PlugUpdate nnoremap pc :PlugClean " change dir to current file's dir nnoremap cd :cd %:p:h:pwd " zoom a vim pane, = to re-balance nnoremap - :wincmd _:wincmd \| nnoremap = :wincmd = " close all other windows with o nnoremap wo o " Index ctags from any project, including those outside Rails map ct :!ctags -R . " Switch between the last two files nnoremap " command typo mapping cnoremap WQ wq cnoremap Wq wq cnoremap QA qa cnoremap qA qa cnoremap Q! q! " copy to end of line nnoremap Y y$ " copy to system clipboard noremap gy "+y " copy whole file to system clipboard nnoremap gY gg"+yG " Prettier: " shows the output from prettier - useful for syntax errors nnoremap pt :!prettier % " CtrlSF: nnoremap f :CtrlSF nnoremap g :CtrlSF " disable arrow keys in normal mode nnoremap :call animate#window_delta_height(10) nnoremap :call animate#window_delta_height(-10) nnoremap :call animate#window_delta_width(10) nnoremap :call animate#window_delta_width(-10) " last typed word to lower case inoremap u guawA " last typed word to UPPER CASE inoremap U gUawA " entire line to lower case inoremap u guuA " entire line to UPPER CASE inoremap U gUUA " last word to title case inoremap t bvgUA " current line to title case inoremap t :s/\v<(.)(\w*)/\u\1\L\2/gA " Quicker window movement nnoremap j nnoremap k nnoremap h nnoremap l " Incsearch: map / (incsearch-forward) map ? (incsearch-backward) map g/ (incsearch-stay) " Open files relative to current path: nnoremap ed :edit =expand("%:p:h") . "/" nnoremap sp :split =expand("%:p:h") . "/" nnoremap vs :vsplit =expand("%:p:h") . "/" " move lines up and down in visual mode xnoremap :move '<-2gv=gv xnoremap :move '>+1gv=gv " --------------------- Key Mappings ---------------------------- }}} " Higher Order Immutable Funcs {{{ fun! Map(list, fn) let new_list = deepcopy(a:list) call map(new_list, a:fn) return new_list endfun fun! Filter(list, fn) let new_list = deepcopy(a:list) call filter(new_list, a:fn) return new_list endfun fun! Find(list, fn) let l:fn = substitute(a:fn, 'v:val', 'l:item', 'g') for l:item in a:list let l:new_item = deepcopy(l:item) if execute('echon (' . l:fn . ')') ==# '1' return l:new_item endif endfor return 0 endfun fun! HasItem(list, fn) return !empty(Find(a:list, a:fn)) endfun " }}} " Abbreviations --------------------------------------- {{{ iabbrev @@ dkarter@gmail.com iabbrev ccopy Copyleft 2016 Dorian Karter. augroup DebuggerBrevs autocmd! autocmd FileType ruby,eruby iabbrev bpry require 'pry'; binding.pry; autocmd FileType javascript iabbrev bpry debugger; autocmd FileType elixir iabbrev bpry require IEx; IEx.pry; autocmd FileType elixir iabbrev ipry require IEx; IEx.pry; augroup END " Local config if filereadable($HOME . '/.vimrc.local') source ~/.vimrc.local endif " -------- Abbreviations ---------------------------------- }}} " For NeoVim ----------------------------------------------------- {{{ if has('nvim') " use neovim-remote (pip3 install neovim-remote) allows " opening a new split inside neovim instead of nesting " neovim processes for git commit let $VISUAL = 'nvr -cc split --remote-wait +"setlocal bufhidden=delete"' let $GIT_EDITOR = 'nvr -cc split --remote-wait +"setlocal bufhidden=delete"' let $EDITOR = 'nvr -l' let $ECTO_EDITOR = 'nvr -l' " interactive find replace preview set inccommand=nosplit augroup TerminalMod autocmd! autocmd BufEnter * \ if &buftype == 'terminal' | \ setlocal foldcolumn=0 | \ endif autocmd TermEnter * setlocal foldcolumn=0 augroup END " share data between nvim instances (registers etc) augroup SHADA autocmd! autocmd CursorHold,TextYankPost,FocusGained,FocusLost * \ if exists(':rshada') | rshada | wshada | endif augroup END " set pum background visibility to 20 percent set pumblend=20 " set file completion in command to use pum set wildoptions=pum " Navigate neovim + neovim terminal emulator with alt+direction tnoremap h tnoremap j tnoremap k tnoremap l " easily escape terminal tnoremap tnoremap " quickly toggle term nnoremap o :vertical botright Ttogglel nnoremap O :botright Ttogglej nnoremap :vertical botright Ttogglel " close terminal tnoremap o :Ttoggle tnoremap :Ttoggle " send stuff to REPL using NeoTerm nnoremap l :TREPLSendLine vnoremap s :TREPLSendSelection " pasting works quite well in neovim as is so disabling yo nnoremap yo o nnoremap yO O endif " }}} " For TMux {{{ function! Mux() echom 'Loaded TMux plugins' endfunction command! Mux :call Mux() if exists('$TMUX') :Mux endif " }}} " For VimPlug {{{ function! PlugGx() let l:line = getline('.') let l:sha = matchstr(l:line, '^ \X*\zs\x\{7,9}\ze ') if (&filetype ==# 'vim-plug') " inside vim plug splits such as :PlugStatus let l:name = empty(l:sha) \ ? matchstr(l:line, '^[-x+] \zs[^:]\+\ze:') \ : getline(search('^- .*:$', 'bn'))[2:-2] else " in .vimrc.bundles let l:name = matchlist(l:line, '\v/([A-Za-z0-9\-_\.]+)')[1] endif let l:uri = get(get(g:plugs, l:name, {}), 'uri', '') if l:uri !~? 'github.com' return endif let l:repo = matchstr(l:uri, '[^:/]*/'.l:name) let l:url = empty(l:sha) \ ? 'https://github.com/'.l:repo \ : printf('https://github.com/%s/commit/%s', l:repo, l:sha) call netrw#BrowseX(l:url, 0) endfunction augroup PlugGxGroup autocmd! autocmd BufRead,BufNewFile .vimrc.bundles nnoremap gx :call PlugGx() autocmd FileType vim-plug nnoremap gx :call PlugGx() augroup END " }}} " Load project specific vimrc {{{ if (getcwd() != expand('~')) && filereadable(getcwd() . '/.vimrc') echom '-------------> loading project specific local vimrc' set exrc execute 'source ' . getcwd() . '/.vimrc' endif " }}} " Temporary {{{ " testing for bullets.vim nnoremap m :vs test.md nnoremap q :q! "}}}