Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- " 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="\<Esc>[38;2;%lu;%lu;%lum"
- let &t_8b="\<Esc>[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 <EOL>, 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 <C-h>, <C-j> <C-k> and <C-l> mappings are already mapped
- " by the vim-tmux-navigator plugin as shown below:
- " nnoremap <silent> <C-h> :TmuxNavigateLeft<CR>
- " nnoremap <silent> <C-j> :TmuxNavigateDown<CR>
- " nnoremap <silent> <C-k> :TmuxNavigateUp<CR>
- " nnoremap <silent> <C-l> :TmuxNavigateRight<CR>
- " nnoremap <silent> <C-h> :TmuxNavigatePrevious<CR>
- " Edit/source .vimrc|init.vim
- nnoremap <silent> <leader>ev :tabe $MYVIMRC<CR>
- nnoremap <silent> <leader>sv :so $MYVIMRC<CR>
- " Automatically set search patterns in 'very magic' mode.
- " nnoremap / /\v
- " Call custom diffmode function (see Diff Mode section).
- nnoremap <F7> :call DiffWithFileFromDisk()<CR>
- "_____ 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")<CR>
- " Change entire line.
- nnoremap cc 0C
- " Enter inserts a newline.
- nnoremap <CR> i<CR><ESC>k$
- " 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 <space> za
- "_____ Window/Buffer Navigation _____
- " Move between buffers (Use Prefix +h/j/k/l key in tmux).
- nnoremap gh <C-w>h
- nnoremap gj <C-w>j
- nnoremap gk <C-w>k
- nnoremap gl <C-w>l
- " Close window
- nnoremap gc <C-w>c
- " Reposition buffers.
- nnoremap gH <C-w>H
- nnoremap gJ <C-w>J
- nnoremap gK <C-w>K
- nnoremap gL <C-w>L
- " Buffer next/previous.
- nnoremap gn :bn<CR>
- nnoremap gp :bp<CR>
- " nnoremap gq :q<CR>
- " Create a new vertical split.
- nnoremap gs <C-W>v
- " Allow movements over wrapped lines.
- nnoremap j gj
- nnoremap k gk
- nnoremap $ g$
- nnoremap 0 g0
- nnoremap p gp
- "_____ Help File Navigation _____
- nnoremap <silent> <RIGHT> :cnext<CR>
- nnoremap <silent> <RIGHT><RIGHT> :cnfile<CR><C-G>
- nnoremap <silent> <LEFT> :cprev<CR>
- nnoremap <silent> <LEFT><LEFT> :cpfile<CR><C-G>
- "_____ Not In Use _____
- " nnoremap <BS> :noh<CR>
- " Open current file in google chrome
- " nnoremap <F5> :exe ':silent !chrome %'<CR>
- "}}}
- " Insert Mode -----------------------------------------------------{{{
- " Exit insert mode (must have classic).
- inoremap jj <ESC>
- " Insert a newline above/below current line & preserve indentation.
- inoremap JJ <ESC>o
- inoremap KK <ESC>O
- " Move up/down a line in insert mode.
- inoremap GJ <DOWN>
- inoremap GK <UP>
- "Insert a semi-colon at the end of the line.
- inoremap ;; <ESC>A;<ESC>
- "_____ Omni-Complete _____
- "inoremap ,o <C-x><C-o>
- " Remap onmi menu up/down navigation.
- " inoremap <C-j> <C-n>
- " inoremap <C-k> <C-p>
- "_____ Not In Use _____
- "inoremap == <C-r>=
- "}}}
- " Command Mode ----------------------------------------------------{{{
- " Write all buffers active/hidden buffers.
- cnoremap W<CR> wa<CR>
- "}}}
- "}}}
- " 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\+\%#\@<!$/
- " autocmd InsertLeave * match ExtraWhitespace /\s\+$/
- " autocmd BufWinLeave * call clearmatches()
- augroup SetFoldmethodAndFoldLevel
- autocmd!
- autocmd FileType javascript,typescript,json setlocal foldmethod=syntax
- autocmd FileType javascript,html,css,scss,typescript setlocal foldlevel=99
- augroup END
- "TODO: Autocommand to load sessions. Look further into this. Change the
- "session.vim name**
- " autocmd VimEnter * call LoadSession()
- " autocmd VimLeave * call SaveSession()
- " function! SaveSession()
- " execute 'mksession! $VIMRC_CONFIG/.vim/sessions/session.vim'
- " endfunction
- " function! LoadSession()
- " if argc() == 0
- " execute 'source $VIMRC_CONFIG/.vim/sessions/session.vim'
- " endif
- " endfunction
- "}}}
- " Functions -------------------------------------------------------{{{
- " Source function definitions.
- source $NVIM_VIMRC/functions.vim
- nnoremap <Leader>q :call DeleteCurBufferNotCloseWindow()<CR>
- "}}}
- " 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 <leader>n :NERDTreeToggle<CR>
- " Open the current file in NERDTree.
- nnoremap <silent> <leader>v :NERDTreeFind<CR>
- "_____ 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 <buffer> <space> 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 <expr> <CR> (pumvisible() ? "\<c-y>\<CR>" : "\<CR>")
- "}}}
- " EASY MOTION -----------------------------------------------------{{{
- "_____ Mappings _____
- nmap <Leader>f <Plug>(easymotion-bd-w)
- nmap <Leader>w <Plug>(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 = "<tab>"
- let g:UltiSnipsJumpForwardTrigger = "<tab>"
- let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
- " let g:UltiSnipsJumpForwardTrigger = "<C-j>"
- " let g:UltiSnipsJumpBackwardTrigger = "<C-k>"
- " Global Snippets Config
- let g:ultisnips_javascript = {
- \ 'semi': 'never',
- \ }
- "_____ Abbreviations _____
- cnoreabbrev editsnips :UltiSnipsEdit<CR>
- "_____ 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 <C-t> :GFiles<CR>
- "}}}
- " 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<CR> Gstatus<CR>
- "}}}
- " 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 <buffer> <leader>h :JSContextColorToggle<CR>
- "}}}
- " 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 <leader>an :ALENextWrap<CR>
- nnoremap <leader>ap :ALEPreviousWrap<CR>
- "}}}
- " 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 <expr> <CR> delimitMate#WithinEmptyPair() ?
- \ "<Plug>delimitMateCR" :
- \ "<CR>"
- "}}}
- " 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
- " }}}
Advertisement