Created
December 13, 2018 17:38
-
-
Save GarySmith/5935f247da6c34fb7eca00f9ede5ca7f to your computer and use it in GitHub Desktop.
This file contains 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
" Load plugins via Vundle | |
filetype off | |
" Use the simple plugin manager vim-plug. | |
" (https://github.com/junegunn/vim-plug) to manage plugins. This avoids the | |
" pain and confusion that vundle may cause. Its setup in this file is | |
" simpler, plus it uses shallow git glones (for less space), and is very | |
" fast and simple to update. | |
" | |
" PlugStatus - check status of installed plugins | |
" PlugClean - remove unused plugins | |
" PlugUpdate - update plugins | |
" | |
" Set the plugin dir according to whether vim or neovim is being used | |
if has('nvim') | |
let plugindir = "~/.local/share/nvim/plugged" | |
else | |
let plugindir = "~/.vim/bundle" | |
endif | |
" Specify a directory for plugins to get installed into | |
call plug#begin(plugindir) | |
" Plug 'burnettk/vim-angular' " Re-enable if working with angular | |
Plug 'scrooloose/nerdcommenter' " \cc (line comment) | |
" \cm (block comment) | |
" \cu (uncomment) | |
Plug 'tpope/vim-fugitive' " git commands :help fugitive | |
Plug 'tpope/vim-surround' " Use cs<old><new> to change surrounding quotes | |
Plug 'airblade/vim-gitgutter' " Show lines added/changed/removed in gutter | |
Plug 'scrooloose/nerdtree' " File finder | |
Plug 'Xuyuanp/nerdtree-git-plugin' " Annotate git status in nerdtree | |
Plug 'vim-syntastic/syntastic' | |
Plug 'alx741/vinfo' " Use vi to read info files: :Vinfo doc | |
Plug 'mattn/webapi-vim' " Needed for gist-vim | |
Plug 'jremmen/vim-ripgrep' " :Rg to search for word under cursor <Alt>-j/k to go next/prev | |
Plug 'mattn/gist-vim' " :Gist for creating and downloading gists | |
Plug 'ctrlpvim/ctrlp.vim' " ^P to find files/buffers | |
Plug 'ervandew/supertab' " <TAB> in insert mode matches lots of thing | |
Plug 'jeetsukumaran/vim-buffergator' " \b to list, go to buffers | |
Plug 'jreybert/vimagit' " git integration ala magit | |
Plug 'davidhalter/jedi-vim' | |
" python functions: (https://github.com/davidhalter/jedi-vim) | |
" C-space - auto completion | |
" \g - go to function | |
" \d - go to definition | |
" \n - show usages | |
" K - show docs | |
" c-space to complete, \g to do func, K | |
Plug 'tpope/vim-unimpaired' " See all mappings with :help unimpaired | |
" Lots of keymappings: | |
" [l, ]l, [L, ]L :lprevious/next/first/last | |
" [c, ]c, [C, ]C :previous/next/first/last | |
" Same convention (upper/lower ][) for | |
" t (tabs) b (buffers) a (args) | |
" yop " insert in paste, then exit after | |
" yol " :set list! | |
" yoh " :set hls! | |
" yos " :set spell! | |
Plug 'christoomey/vim-tmux-navigator' " Use same set of commands to navigate across vim windows and tmux panes. Amazingly useful! | |
Plug 'ap/vim-buftabline' " Put buffers on tag line | |
" Plug 'craigemery/vim-autotag' " Update tags file automatically | |
" Conditionally start plugins | |
if has('nvim') | |
Plug 'codeindulgence/vim-tig' " Invoke tig with :Tig | |
endif | |
Plug 'python-mode/python-mode' | |
" Initialize plugin system | |
call plug#end() | |
" Global options settings | |
" | |
" set verbose=2 " usefor for debugging vim options | |
set autochdir " automatically cd to the dir containing the file being edited | |
set autoindent " automatically indent each new line same as previous one | |
set autoread " automatically re-read file if changed externally but not internally | |
set backupdir=/tmp,~/tmp,~ " Dirs where backup files will be written | |
set backupcopy=yes " overwrite the file rather than renaming and re-creating | |
set undodir=/tmp,~/tmp,~ " Dirs where backup files will be written | |
set clipboard+=unnamedplus " Use system clipboard for unnamed buffer (all copy/paste operations) | |
set colorcolumn=+0 " Color the column when textwidth is set to some specific number | |
set complete=.,i " scan include files for keyword completion | |
set confirm " prompt for save, instead of fail, when :q with unwritten changes | |
set cursorline " highlight the line that has the cursor on it | |
set diffopt=iwhite,context:10000 " ignore whitespace in diffs, turn off folding | |
set directory^=/tmp/swap | |
set directory-=. | |
set display=lastline,uhex " Better handling of long lines at the end of a screen | |
set equalalways " Resize all screens | |
set formatoptions+=roln " Add comment-formatting options. NEVER include 'a' | |
set hidden " allow hiding buffers with unsaved changes | |
set history=1000 " command history | |
set hlsearch " highlight searched pattern | |
set ignorecase " perform case-insensitive searches | |
set incsearch " do incremental searches (like emacs) | |
if has('nvim') | |
set inccommand=split " show result of :s command incrementally as you type | |
endif | |
set infercase " adjust capitalization when doing keyword completion | |
set nojoinspaces " avoid adding two spaces after . when joining lines | |
set laststatus=2 " always put status bar at bottom of screen | |
set matchpairs+=<:> " Add <> to matching done by % command | |
set modeline " Interpret vim commands in the file | |
set nrformats+=alpha " Permit incrementing single alpha characters | |
set path+=** " Search recursively down for files when using the :find command | |
set ruler " display ruler (bold line containing filename, position) | |
set scrollopt=hor " When scrolling windows together, scroll horizontally together | |
set shellslash " use forward slashes, even in Windows | |
set shortmess=atToI " avoid Hit return messages by shortening output | |
set showcmd " show command being executed | |
set showmode " show whether in INSERT or REPLACE mode | |
set showmatch " briefly jump to matching bracket when inserting a new one | |
set sidescroll=5 " scroll horizontally by one char at a time | |
set smartcase " case sensitive when search string in CAPS | |
set smartindent " Smarter than c-indent | |
set splitbelow " new split screens appear below current one | |
set spellcapcheck= " disable checking for missing capitalization during spell checks | |
set spellsuggest=best,10 " Show just 10 possible matches instead of lots of garbage | |
set spelllang=en_us | |
set spellfile=~/.vim/spell/en.utf-8.add | |
set nostartofline " don't go back to line start w/^F, ^B, H, M, L, G, etc. | |
set statusline=%<%f\ %h%m%r%y%=%l/%L,%c%V\ %P | |
set tags+=./tags; " add ; to search upward for tagfiles | |
set nowrap " don't wrap long lines on the screen | |
set nowrapscan " don't wrap around to top of file when searching | |
set wrapmargin=1 " wrap at RHS of screen | |
" Tab settings | |
set expandtab " behavior when typing <Tab> | |
set shiftwidth=0 " >> indents to the same as tabstop | |
set tabstop=4 " set tabstops | |
set shiftround " shift in muliples of tabstop | |
set smarttab " Use sw for indenting, unindenting | |
set listchars=tab:»-,trail:·,extends:+,precedes:<,nbsp:+ | |
" Set history options per version of vim | |
if has('nvim') | |
set shada=!,%,h,'20,<50,s10 | |
else | |
set viminfo=!,'10,<1000,%,h " use a viminfo file to save environment | |
set viminfo+=n~/.viminfo | |
endif | |
set whichwrap=b,s,h,l,<,>,[,] " permit certain movements to wrap to next/previous line | |
set virtualedit=block " For editing tables, code | |
" For editing in no-wrap mode | |
set linebreak showbreak=+++ | |
set wildignore+=*.o,*.obj,*.a,*.class,*.pyc,*.bmp,*.gif,*.jpg,*.png,*.ico,*.pdf,node_modules,node_modules/*,bower_components/*,.tox/*,.ropeproject/* | |
set wildmenu | |
set visualbell " avoid beeping | |
" Make the mouse behave like an xterm in gvim | |
behave xterm | |
" Enable syntax highlighting | |
syntax enable | |
" Config for editing .vimrc and other vimscript files | |
" Setup ripgrep as the ack program | |
if executable('rg') | |
let g:ackprg = 'rg --vimgrep' | |
let g:rg_derive_root = 'true' | |
let g:rg_highlight = 'true' | |
set grepprg=rg\ --vimgrep | |
endif | |
" Automatically fix my common spelling errors and typos | |
iabbrev fro for | |
iabbrev adn and | |
iabbrev teh the | |
iabbrev throught through | |
iabbrev usefule useful | |
iabbrev accross across | |
iabbrev acommodate accommodate | |
iabbrev reccomend recommend | |
iabbrev reccommend recommend | |
iabbrev memoery memory | |
iabbrev memeory memory | |
" Make the accidental q: actually do just : | |
nnoremap q: : | |
" Key Mappings | |
" Prefix all macros with backslash | |
let mapleader="\\" | |
" Allow W! to save files as sudo when I forgot to start vim with sudo | |
cmap W! w !sudo tee > /dev/null % | |
" From http://vim.wikia.com/, execute command without the silly prompt | |
" afterward | |
command! -nargs=1 Silent | |
\ | execute ':silent !'.<q-args> | |
\ | execute ':redraw!' | |
" Use ctrl-j, et. al, to move between windows, including across tmux windows | |
nnoremap <C-k> <C-w>k | |
nnoremap <C-j> <C-w>j | |
nnoremap <C-l> <C-w>l | |
nnoremap <C-h> <C-w>h | |
nnoremap <Leader>- :split<cr> | |
nnoremap <Leader><Bar> :vsplit<cr> | |
nnoremap <Leader><Bslash> :vsplit<cr> | |
nnoremap Y y$ | |
" Use \g to grep for selected text | |
vnoremap <Leader>g y:Rg\<C-R>"<CR> | |
" In normal mode, \g will search for whatever the cursor is on | |
nnoremap <Leader>g :Rg<CR> | |
" Toggle list mode | |
nnoremap <F9> :set list!<CR> | |
map <Leader>f :NERDTreeToggle<cr> | |
let g:NERDTreeChDirMode = 2 | |
let g:NERDTreeQuitOnOpen = 0 | |
let g:NERDTreeIgnore = ['\~$', 'node_modules', '__pycache__'] | |
let g:netrw_banner = 0 | |
" Limit tree to 15% of width | |
let g:netrw_winsize=15 | |
" Open file in previous window | |
" let g:netrw_browse_split = 4 | |
" Hide dotfiles by default | |
let g:netrw_hide = 1 | |
" let g:netrw_list_hide='\.vim$,\~$,lib,libs,\.jpg$,\.gif$,\.png$,\.pyc$,target' | |
let g:netrw_list_hide='^\.,\~$,\.jpg$,\.gif$,\.png$,\.pyc$,target' | |
let g:netrw_alitv = 1 | |
" Tell gist plugin to get password from .gitconfig | |
let g:gist_use_password_in_gitconfig = 1 | |
" Tidy up json text | |
nnoremap <Leader>j :%!python -mjson.tool<CR> | |
vnoremap <Leader>j :!python -mjson.tool<CR> | |
" Turn on horizontal scroll | |
nnoremap <F11> :set scb guioptions+=b<CR> | |
" Turn off horizontal scroll | |
nnoremap <F12> :set guioptions-=b<CR> | |
" Toggle search higlighting | |
nnoremap <F2> :set hlsearch!<cr> | |
" Use <C-L> to clear highlighting of hlsearch | |
if maparg('<C-L>', 'n') ==# '' | |
nnoremap <silent> <C-L> :nohlsearch<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L> | |
endif | |
" Sum, avg numeric lines by hitting + in visual mode | |
vnoremap <silent><expr> + VMATH_YankAndAnalyse() | |
" Move visual blocks around with arrow keys | |
vmap <expr> <LEFT> DVB_Drag('left') | |
vmap <expr> <RIGHT> DVB_Drag('right') | |
vmap <expr> <DOWN> DVB_Drag('down') | |
vmap <expr> <UP> DVB_Drag('up') | |
vmap <expr> D DVB_Duplicate() | |
" Filetype-specific settings | |
augroup code_settings | |
" Reset this group | |
autocmd! | |
" Common for all code files | |
autocmd Filetype c,java,python,make,javascript,xml,css,html,scss,vim,sh setlocal number | |
autocmd Filetype rst setlocal textwidth=80 | |
" Config the delete trailing whitespace plugin | |
" autocmd Filetype c,java,python,make,rst,javascript,xml,css,html,scss,vim let b:DeleteTrailingWhitespace=1 | |
" autocmd Filetype c,java,python,make,rst,javascript,xml,css,html,scss,vim let b:DeleteTrailingWhitespace_Action='delete' | |
autocmd Filetype c,java,python,make,rst,javascript,xml,css,html,scss,vim autocmd BufWritePre <buffer> %s/\s\+$//e | |
" Makefiles should never use expandtabs, since TABs are required | |
autocmd Filetype make setlocal noexpandtab | |
" Python-specific settings | |
autocmd Filetype python setlocal textwidth=79 number expandtab foldlevel=5 | |
autocmd Filetype python let python_space_error_highlight=1 | |
" Web files tend to have lots of indenting and need a smaller tabstop | |
autocmd Filetype javascript,xml,css,html,scss,less,vim setlocal tabstop=2 | |
autocmd Filetype javascript setlocal textwidth=120 | |
" Use wrapping in markdown files, where entire paragraphs need to be on a | |
" single line | |
autocmd Filetype markdown setlocal wrap | |
autocmd Filetype text setlocal fo+=t | |
" Check for external changes whenever entering the buffer | |
autocmd FocusGained,BufEnter * :checktime | |
" Automatically reformat specific json files | |
autocmd BufReadPost CloudModel.json %!python -m json.tool | |
augroup END | |
if exists('g:loaded_history') | |
augroup auto_save | |
" Reset this group | |
autocmd! | |
" For vim-history | |
autocmd BufWritePost *.py,*.js HistorySave | |
augroup END | |
endif | |
" Use 256 Colors | |
set t_Co=256 | |
" My color scheme | |
" colorscheme gary | |
" Create temp dir if it doesn't exist | |
if exists('*mkdir') | |
if !isdirectory('/tmp/swap') | |
call mkdir("/tmp/swap", "p", 0700) | |
endif | |
endif | |
" NERD tree settings | |
let NERDTreeIgnore=['\~$', 'lib', 'libs', '\.jpg$', '\.gif$', '\.png$', '\.pyc$', 'target'] | |
" syntastic settings | |
let g:syntastic_mode_map = { 'mode': 'active', | |
\ 'active_filetypes': ['javascript', 'python'], | |
\ 'passive_filetypes': [] } | |
let g:syntastic_javascript_checkers = ['eslint'] | |
let g:syntastic_python_checkers = ['flake8'] | |
set statusline+=%#warningmsg# | |
set statusline+=%{SyntasticStatuslineFlag()} | |
set statusline+=%* | |
" let g:syntastic_always_populate_loc_list = 0 | |
let g:syntastic_auto_loc_list = 0 | |
let g:syntastic_check_on_open = 1 | |
" Jump to first syntax error when opening | |
let g:syntastic_auto_jump = 1 | |
" let g:syntastic_check_on_wq = 0 | |
" Ignore checking on files that cannot handle angular and/or ES6 | |
" let g:syntastic_ignore_files=['html', 'javascript'] | |
" vim-pymode settings | |
" pymode settings for pep8, to match tox.ini | |
let g:pymode = 1 | |
let g:pymode_options_max_line_length = 79 | |
let g:pymode_options_colorcolumn = 1 | |
let g:pymode_indent = 1 | |
let g:pymode_options = 1 " Use default python options | |
let g:pymode_lint_ignore="E123,E125,H803,I201,D101,D102" | |
let g:pymode_lint_checkers=['pep8'] | |
" Use syntastic for checking pep8 violations instead of doing it twice. See :help syntastic-pymode | |
let g:pymode_lint_on_write = 0 | |
let g:pymode_breakpoint_bind = '<leader>B' " avoid conflicting with buffer list, <leader>b | |
" Various plugin options | |
let g:ctrlp_working_path_mode = 'ra' " Search within this git repo | |
let g:tig_default_command = '' " Use the normal | |
let g:gitgutter_map_keys = 0 " Prevent git-gutter from remapping my keys | |
" Use Alt-ed j/k to traverse through matches | |
nnoremap <M-k> :cprev<cr> | |
nnoremap <M-j> :cnext<cr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment