" Source external config files. source $NVIM_VIMRC/plugins.vim source $NVIM_VIMRC/backups.vim source $NVIM_VIMRC/abbreviations.vim " Searching & Patterns --------------------------------------------{{{ set incsearch nohlsearch set ignorecase smartcase " searches are only case-sensitive when an uppercase letter is used. set showmatch " Briefly jump to matching brackets when new bracket is inserted. set gdefault " Default g flag on searches. set startofline " Seaches start at the first non-blank character or a line instead of the current cursor position. "Set command and modifyer timeouts set timeout set timeoutlen=800 set ttimeoutlen=100 "}}} " Text Display & Colorscheme --------------------------------------{{{ " Solarized, dark, with true color support and patched nerd font. colorscheme solarized set background=dark set guifont=Meslo_LG_S_DZ_Regular_for_Powerline_Nerd_Font_Complete:h12 " Force true colour on, since vim can’t detect it within tmux. let &t_8f="\[38;2;%lu;%lu;%lum" let &t_8b="\[48;2;%lu;%lu;%lum" " Line/relative numbers and number gutter col width. set number relativenumber numberwidth=4 set cursorline " Cursor highlighting. set wrap linebreak " Wrap words and word break at end of lines. set nolist " Disable list when using wrap + linebreak. set textwidth=0 " No window width limit. set fileformat=unix " Set , prevent conversion errors in Git. set encoding=utf8 fileencoding=utf8 " Set UTF-8 encoding. set conceallevel=1 " Allow syntax concealing with symbols. "set scrolloff=1 " Number of context lines above and below cursor" " set list " Cannot have listchars with linebreak. " set listchars=tab:▸\ ,eol:¬,trail:␠,nbsp:⎵,precedes:←,extends:→ "}}} " Hightlighting ---------------------------------------------------{{{ " Enable italicized comments (requires xterm-256color-italic). highlight Comment cterm=italic "}}} " Windows & Buffers -----------------------------------------------{{{ " Change the current working directory whenever you open a file, " switch buffers, delete a buffer or open/close a window. set autochdir " Open new files even if current buffer has unsaved changes. set hidden "set noequalalways " Do not automatically resize windows "}}} " Messages & Info -------------------------------------------------{{{ set showcmd " Shows typed commands in the botton right. set laststatus=2 " Set the status bar such that it always displays. "set noshowmode " Hide the mode title bar. "}}} " Tabs & Indenting ------------------------------------------------{{{ " set autoindent " Next line indent defaults to the same space. set tabstop=4 shiftwidth=4 softtabstop=4 " Set tab spacing. set shiftround " Round non mutiples of tabs to the shiftwidth multiple. "set smartindent "set expandtab "}}} " Text Editing ----------------------------------------------------{{{ " Make all yanking/deleting operations automatically copy to the system " clipboard (works with tmux). set clipboard=unnamedplus " Normal backspace behaviour. set backspace=indent,eol,start set history=1000 undolevels=5000 set noerrorbells visualbell t_vb= " Allow copy and pasting to Vim since Sierra upgrade. "highlight ColorColumn ctermbg=magenta "set colorcolumn=81 "Dividing column to limit code length "call matchadd('ColorColumn', '\%81v', 100) "Column highlights when text reaches. "call matchadd('ColorColumn', '\%>80v', 100) "Highlight everything past the 80th column "}}} " Folding ---------------------------------------------------------{{{ " Enable folds with a fold column of 3. set foldenable foldcolumn=3 "}}} "Diff Mode --------------------------------------------------------{{{ "Stores a temporary copy of the file in the current buffer (including latest changes) and diffs it against the "version of the file on your hard drive. function! DiffWithFileFromDisk() let filename=expand('%') let diffname = filename.'.fileFromBuffer' exec 'saveas! '.diffname diffthis vsplit exec 'edit '.filename diffthis endfunction "}}} " Mappings --------------------------------------------------------{{{ let mapleader = "," " Normal Mode -----------------------------------------------------{{{ " ** Note: the , and mappings are already mapped " by the vim-tmux-navigator plugin as shown below: " nnoremap :TmuxNavigateLeft " nnoremap :TmuxNavigateDown " nnoremap :TmuxNavigateUp " nnoremap :TmuxNavigateRight " nnoremap :TmuxNavigatePrevious " Edit/source .vimrc|init.vim nnoremap ev :tabe $MYVIMRC nnoremap sv :so $MYVIMRC " Automatically set search patterns in 'very magic' mode. " nnoremap / /\v " Call custom diffmode function (see Diff Mode section). nnoremap :call DiffWithFileFromDisk() "_____ File Manipulation _____ " Yank from the cursor to the end of the line. nnoremap Y y$ " Yank the current line and paste it below/above. nnoremap yj yyp nnoremap yk yyP " Copy the current buffer path to the clipboard nnoremap cp :let @+ = expand("%:p") " Change entire line. nnoremap cc 0C " Enter inserts a newline. nnoremap ik$ " Add a marker in register a when moving to the bottom of the page. nnoremap G mhG nnoremap gg mggg " Toggle folds open and close. nnoremap za "_____ Window/Buffer Navigation _____ " Move between buffers (Use Prefix +h/j/k/l key in tmux). nnoremap gh h nnoremap gj j nnoremap gk k nnoremap gl l " Close window nnoremap gc c " Reposition buffers. nnoremap gH H nnoremap gJ J nnoremap gK K nnoremap gL L " Buffer next/previous. nnoremap gn :bn nnoremap gp :bp " nnoremap gq :q " Create a new vertical split. nnoremap gs v " Allow movements over wrapped lines. nnoremap j gj nnoremap k gk nnoremap $ g$ nnoremap 0 g0 nnoremap p gp "_____ Help File Navigation _____ nnoremap :cnext nnoremap :cnfile nnoremap :cprev nnoremap :cpfile "_____ Not In Use _____ " nnoremap :noh " Open current file in google chrome " nnoremap :exe ':silent !chrome %' "}}} " Insert Mode -----------------------------------------------------{{{ " Exit insert mode (must have classic). inoremap jj " Insert a newline above/below current line & preserve indentation. inoremap JJ o inoremap KK O " Move up/down a line in insert mode. inoremap GJ inoremap GK "Insert a semi-colon at the end of the line. inoremap ;; A; "_____ Omni-Complete _____ "inoremap ,o " Remap onmi menu up/down navigation. " inoremap " inoremap "_____ Not In Use _____ "inoremap == = "}}} " Command Mode ----------------------------------------------------{{{ " Write all buffers active/hidden buffers. cnoremap W wa "}}} "}}} " Command Line Editing --------------------------------------------{{{ set wildmenu set wildmode=full:longest,full "}}} "Autocommands -----------------------------------------------------{{{ augroup vimrc autocmd! autocmd BufWritePost,BufWinLeave *.* \ if expand('%') != '' && &buftype !~ 'nofile' \| mkview \| endif autocmd BufRead,BufWinEnter *.* \ if expand('%') != '' && &buftype !~ 'nofile' \| silent! loadview \| endif augroup END " Remembers the cursor position upon re-entering a buffer. " autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal g'\"" | endif " autocmd GUIEnter * set visualbell t_vb= "_____ Automatically Equalize Splits _____ augroup AutomaticallyResizeWindows autocmd! autocmd VimResized * wincmd = augroup END "_____ Highlights Extra Whitespace _____ " highlight ExtraWhitespace ctermbg=red guibg=red " match ExtraWhitespace /\s\+$/ " autocmd BufWinEnter * match ExtraWhitespace /\s\+$/ " autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@q :call DeleteCurBufferNotCloseWindow() "}}} " Plugins ---------------------------------------------------------{{{ "NERD TREE --------------------------------------------------------{{{ "_____ Globals _____ let NERDTreeMinimalUI=1 " Simply the UI. let g:NERDTreeQuitOnOpen=1 " Close NERD Tree when opening file. let NERDTreeAutoDeleteBuffer=1 " Automatically delete buffers of files deleted with NerdTree. let NERDTreeCascadeSingleChildDir=0 " Do not collapse dirs with one child. "let NERDTreeChDirMode=2 " let NERDTreeShowBookmarks=1 " let NERDTreeIgnore=['\~$','\.pyc$', '\.swp$'] " let NERDTreeSortOrder=['^__\.py$','\/$','*','\.swp$','\~$'] "_____ Mappings _____ " Toogle NERTree open/close. nnoremap n :NERDTreeToggle " Open the current file in NERDTree. nnoremap v :NERDTreeFind "_____ Autocommands _____ augroup CustomNERDTreeMappings autocmd! " Open NERDTree when no arguments are supplied. autocmd StdinReadPre * let s:std_in=1 autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif " Space opens/closes files/directories. autocmd FileType nerdtree nmap o augroup END "}}} "NERD TREE COMMENTER ----------------------------------------------{{{ "_____ Globals _____ let NERDSpaceDelims=1 let NERDCompactSexyComs=1 let NERDDefaultAlign='start' let NERDTrimTrailingWhitespace=1 "}}} "NERDTREE GIT PLUGIN ----------------------------------------------{{{ let g:NERDTreeIndicatorMapCustom = { \ "Modified" : "", \ "Staged" : "✚", \ "Untracked" : "✭", \ "Renamed" : "➜", \ "Unmerged" : "═", \ "Deleted" : "✖", \ "Dirty" : "✗", \ "Clean" : "✔︎", \ 'Ignored' : '', \ "Unknown" : "?" \ } let g:WebDevIconsOS = 'Darwin' " Set MacOS specific glyps (avoid system() call). let g:NERDTreeShowIgnoredStatus = 1 " Show ignored git files (might affect performance). " let g:WebDevIconsUnicodeDecorateFolderNodes = 1 " Enable folder glyphs. "}}} " COMPLETION MANAGER ----------------------------------------------{{{ "_____ Globals _____ set shortmess+=c "_____ Mappings _____ inoremap (pumvisible() ? "\\" : "\") "}}} " EASY MOTION -----------------------------------------------------{{{ "_____ Mappings _____ nmap f (easymotion-bd-w) nmap w (easymotion-overwin-w) "}}} " AIRLINE TAB -----------------------------------------------------{{{ "_____ Globals _____ let g:airline_solarized_bg='dark' let g:airline#extensions#tabline#enabled = 1 "let g:airline#extensions#bufferline#enabled = 1 let g:airline#extensions#tabline#formatter = 'jsformatter' let g:airline_powerline_fonts = 1 "Allow Powerline Fonts "Define straight tab seperators "let g:airline#extensions#tabline#left_sep = ' ' "let g:airline#extensions#tabline#left_alt_sep = '|' "}}} " ULTISNIPS -------------------------------------------------------{{{ "_____ Globals _____ let g:UltiSnipsSnippetsDir ="~/.config/nvim/UltiSnips/" " Default snippets :UltiSipsEdits directory let g:UltiSnipsEnableSnipMate = 0 " Disable search for Snipmate snippets let g:UltiSnipsEditSplit="vertical" " :UltiSipsEdits splits vertically " Key Bindings. let g:UltiSnipsExpandTrigger = "" let g:UltiSnipsJumpForwardTrigger = "" let g:UltiSnipsJumpBackwardTrigger = "" " let g:UltiSnipsJumpForwardTrigger = "" " let g:UltiSnipsJumpBackwardTrigger = "" " Global Snippets Config let g:ultisnips_javascript = { \ 'semi': 'never', \ } "_____ Abbreviations _____ cnoreabbrev editsnips :UltiSnipsEdit "_____ Autocommands _____ autocmd FileType html UltiSnipsAddFiletypes javascript "}}} " CTRLP -----------------------------------------------------------{{{ "_____ Globals _____ " let g:ctrlp_working_path_mode = 'ra' " Search within these nearest ancestors: .git .hg .svn .bzr _darcs " let g:ctrlp_extensions = ['dir'] " Default dir name search " let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard'] " Ignore files in .gitignore " let g:ctrlp_cmd = 'CtrlP' "}}} " FZF -----------------------------------------------------------{{{ "_____ Globals _____ " Customize fzf colors to match the 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'] } let g:fzf_history_dir = '~/.config/.fzf/fzf-history' "_____ Globals _____ nnoremap :GFiles "}}} " VIM FUGITIVE ----------------------------------------------------{{{ "_____ Globals _____ " Make EditorConfig comptible with Fugitive plugin/avoid loading remote files over ssh. let g:EditorConfig_exclude_patterns = ['fugitive://.*', 'scp://.*'] "_____ Abbreviations _____ " cnoremap gs Gstatus "}}} " JAVASCRIPT LIBRARIES SYNTAX ------------------------------------{{{ "_____ Globals _____ let g:used_javascript_libs = 'underscore,react,flux,ramda,requirejs,jquery' " Set libraries used "}}} " VIM JAVASCRIPT --------------------------------------------------{{{ "_____ Globals _____ let g:javascript_plugin_flow = 1 let g:javascript_plugin_jsdoc = 1 let g:javascript_plugin_ngdoc = 1 let g:javascript_conceal_NaN = "ℕ" let g:javascript_conceal_null = "ø" let g:javascript_conceal_this = "@" let g:javascript_conceal_super = "Ω" let g:javascript_conceal_static = "•" let g:javascript_conceal_return = "⇚" let g:javascript_conceal_function = "ƒ" let g:javascript_conceal_undefined = "¿" let g:javascript_conceal_prototype = "¶" let g:javascript_conceal_arrow_function = "⇒" let g:javascript_conceal_noarg_arrow_function = "λ" "let g:javascript_conceal_underscore_arrow_function = "λ" "}}} " VIM JS CONTEXT COLORING -----------------------------------------{{{ "_____ Globals _____ let g:js_context_colors_enabled = 0 let g:js_context_colors_highlight_function_names = 1 let g:js_context_colors_jsx = 1 "_____ Mappings _____ autocmd FileType javascript,typescript nnoremap h :JSContextColorToggle "}}} " ALE -------------------------------------------------------------{{{ "_____ Globals _____ let g:ale_sign_error = '✘' let g:ale_statusline_format = ['X %d', '? %d', ''] " %linter% is the name of the linter that provided the message " %s is the error or warning message let g:ale_echo_msg_format = '%linter% says %s' " Limit linters used for JavaScript. "let g:ale_linters = { "\ 'javascript': ['flow', 'eslint'] "\} "_____ Mappings _____ " Next and previous error msg nnoremap an :ALENextWrap nnoremap ap :ALEPreviousWrap "}}} " EMMET -----------------------------------------------------------{{{ "_____ Globals _____ " Replace class with className. let g:user_emmet_settings = { \ 'javascript.jsx' : { \ 'extends' : 'jsx', \ }, \} "}}} " DELIMITMATE -----------------------------------------------------{{{ "_____ Globals _____ let delimitMate_expand_cr = 1 " Expand pairs into block. let delimitMate_expand_space = 1 " Space pairs evenly. "_____ Mappings _____ " Fix delimitMate_expand_cr functionality imap delimitMate#WithinEmptyPair() ? \ "delimitMateCR" : \ "" "}}} " VIM NOTES -------------------------------------------------------{{{ "_____ Globals _____ let g:notes_suffix = '.notes' let g:notes_directories = ['~/Documents/Notes'] "}}} "}}} " TODOS -----------------------------------------------------------{{{ " Opens a files using gf (does not curently work) "set path+=**/src/main/**,** "set suffixesadd+=.js "turn off line wrapping when working on html files. "autocmd BufNewFile,BufRead *.html setlocal nowrap " }}}