-
-
Save MilesCranmer/47353e8a915c18e0cdef3eb62a374183 to your computer and use it in GitHub Desktop.
vimrc july 2020
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
set nocompatible " be iMproved, required | |
let g:python3_host_prog = '/usr/local/opt/[email protected]/bin/python3.8' | |
if empty(glob('~/.vim/autoload/plug.vim')) | |
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs | |
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC | |
endif | |
call plug#begin('~/.vim/plugged') | |
Plug 'scrooloose/nerdcommenter' | |
Plug 'scrooloose/nerdtree' | |
Plug 'tpope/vim-fugitive' | |
Plug 'tpope/vim-surround' | |
Plug 'flazz/vim-colorschemes' | |
Plug 'fboender/bexec' | |
Plug 'vim-scripts/matchit.zip' | |
Plug 'wellle/targets.vim' | |
Plug 'michaeljsmith/vim-indent-object' | |
Plug 'yggdroot/indentline' | |
Plug 'simnalamburt/vim-mundo' | |
Plug 'dbakker/vim-projectroot' | |
Plug 'itchyny/lightline.vim' | |
Plug 'tpope/vim-eunuch' | |
Plug 'vim-scripts/LargeFile' | |
Plug 'kshenoy/vim-signature' | |
Plug 'christoomey/vim-tmux-navigator' | |
Plug 'wesQ3/vim-windowswap' | |
Plug 'rbong/vim-flog' | |
Plug 'airblade/vim-gitgutter' | |
"Plug 'jiangmiao/auto-pairs' | |
Plug 'pangloss/vim-javascript' | |
Plug 'maxmellon/vim-jsx-pretty' | |
if !has('nvim') | |
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } | |
Plug 'junegunn/fzf.vim' | |
Plug 'vim-scripts/indentpython.vim' | |
Plug 'scrooloose/syntastic' | |
Plug 'davidhalter/jedi-vim' | |
Plug 'dense-analysis/ale' | |
else | |
Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
Plug 'Shougo/denite.nvim' | |
Plug 'voldikss/vim-floaterm' | |
Plug 'psliwka/vim-smoothie' | |
Plug 'mhinz/vim-startify' | |
endif | |
call plug#end() | |
syntax on | |
set number | |
set relativenumber | |
set tabstop=4 | |
set softtabstop=4 | |
set shiftwidth=4 | |
set shiftround | |
set expandtab | |
set ai | |
set smartindent | |
set hlsearch | |
set incsearch | |
set encoding=utf-8 | |
set smartcase | |
if !has('nvim') | |
set term=screen-256color | |
endif | |
set t_Co=256 | |
set background=dark | |
colorscheme vividchalk | |
hi Normal ctermbg=none | |
set laststatus=2 | |
"let g:Powerline_symbols = 'unicode' | |
set tags=./tags,tags; | |
set autochdir | |
"au BufRead * normal zR | |
set backspace=2 | |
" Disable line/column number in status line | |
" Shows up in preview window when airline is disabled if not | |
set noruler | |
" Only one line for command line | |
set cmdheight=1 | |
" === Completion Settings === " | |
" Don't give completion messages like 'match 1 of 2' | |
" or 'The only match' | |
set shortmess+=c | |
"split navigation | |
nnoremap <C-J> <C-W><C-J> | |
nnoremap <C-K> <C-W><C-K> | |
nnoremap <C-L> <C-W><C-L> | |
nnoremap <C-H> <C-W><C-H> | |
"tab navigation | |
nnoremap <S-H> gT | |
nnoremap <S-L> gt | |
set complete=.,w,b,u,t,i,kspell | |
let g:closetag_filenames = "*.html,*.xhtml,*.phtml" | |
set lazyredraw | |
set ttyfast | |
set nocuc nocul | |
set cursorline | |
:hi CursorLine cterm=None ctermbg=darkgray ctermfg=white guibg=darkgray guifg=white | |
ab ipdb import IPython ; IPython.embed() ; exit(1) | |
" Make a simple "search" text object. | |
vnoremap <silent> s //e<C-r>=&selection=='exclusive'?'+1':''<CR><CR> | |
\:<C-u>call histdel('search',-1)<Bar>let @/=histget('search',-1)<CR>gv | |
omap s :normal vs<CR> | |
nmap <silent> ,/ :nohlsearch<CR> | |
cmap w!! w !sudo tee % >/dev/null | |
set pastetoggle=<F2> | |
" Move visual selection | |
vnoremap J :m '>+1<cr>gv=gv | |
vnoremap K :m '<-2<cr>gv=gv | |
set noshowmode | |
nmap <leader>n :NERDTreeToggle<CR> | |
nmap <leader>N :NERDTreeFind<CR> | |
let NERDTreeIgnore = ['\.pyc$','\.o$','\.obj$', 'bazel-'] | |
" Quit when open file | |
let NERDTreeQuitOnOpen = 1 | |
" Auto delete buffers if delete file | |
let NERDTreeAutoDeleteBuffer = 1 | |
" UI | |
let NERDTreeMinimalUI = 1 | |
let NERDTreeDirArrows = 1 | |
"" Open NerdTree on startup | |
"autocmd StdinReadPre * let s:std_in=1 | |
"autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif | |
" Close tab if only nerdtree remains | |
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif | |
let g:SCMDiffCommand='git' | |
let g:LargeFile=2 | |
nnoremap <Leader>u :MundoToggle<CR> | |
" Enable persistent undo so that undo history persists across vim sessions | |
set undofile | |
set undodir=~/.vim/undo | |
set splitbelow | |
nnoremap <leader>bb :BexecCloseOut<CR> | |
nnoremap <C-e> :Bexec<CR>:redraw<CR>:sleep 2250m<CR>:BexecCloseOut<CR> | |
nnoremap =oe :setlocal conceallevel=<c-r>=&conceallevel == 0 ? '2' : '0'<cr><cr> | |
nnoremap coe :setlocal conceallevel=<c-r>=&conceallevel == 0 ? '2' : '0'<cr><cr> | |
nnoremap [oe :setlocal conceallevel=<c-r>=&conceallevel > 0 ? &conceallevel - 1 : 0<cr><cr> | |
nnoremap ]oe :setlocal conceallevel=<c-r>=&conceallevel < 2 ? &conceallevel + 1 : 2<cr><cr> | |
nmap <leader>F :Flog<CR> | |
nnoremap <space> za | |
vnoremap <space> zf | |
augroup remember_folds | |
autocmd! | |
autocmd BufWinLeave * silent! mkview | |
autocmd BufWinEnter * silent! loadview | |
augroup END | |
if !has('nvim') | |
" Mapping selecting mappings | |
nmap <leader><tab> <plug>(fzf-maps-n) | |
xmap <leader><tab> <plug>(fzf-maps-x) | |
omap <leader><tab> <plug>(fzf-maps-o) | |
" Insert mode completion | |
imap <c-x><c-k> <plug>(fzf-complete-word) | |
imap <c-x><c-f> <plug>(fzf-complete-path) | |
imap <c-x><c-j> <plug>(fzf-complete-file-ag) | |
imap <c-x><c-l> <plug>(fzf-complete-line) | |
let $FZF_DEFAULT_COMMAND = 'ag -g ""' | |
nnoremap <c-p> :ProjectRootExe Files<CR> | |
nnoremap <leader>p :ProjectRootExe Ag<CR> | |
" FORMATTERS | |
" npm install -g prettier | |
au FileType javascript setlocal formatprg=prettier | |
au FileType javascript.jsx setlocal formatprg=prettier | |
au FileType typescript setlocal formatprg=prettier\ --parser\ typescript | |
au FileType html setlocal formatprg=js-beautify\ --type\ html | |
au FileType scss setlocal formatprg=prettier\ --parser\ css | |
au FileType css setlocal formatprg=prettier\ --parser\ css | |
"let g:syntastic_debug=1 | |
"let g:syntastic_enable_signs=0 | |
let g:syntastic_cpp_compiler = 'clang++' | |
let g:syntastic_cpp_compiler_options = ' -std=c++11 -stdlib=libstdc++' | |
let g:syntastic_c_config_file=".vim_config" | |
let g:syntastic_cpp_config_file=".vim_config" | |
let g:syntastic_cpp_check_header=1 | |
"let g:syntastic_python_python_exec='python3' | |
"let g:syntastic_python_checkers = ['flake8'] | |
let g:syntastic_python_checkers = ['flake8'] | |
"let g:syntastic_python_pylint_exec='pylint3' | |
"let g:syntastic_python_pylint_args=['--ignore=E501'] | |
"let g:syntastic_python_flake8_exec='python3' | |
"let g:syntastic_python_flake8_args=['-m', 'flake8', '--ignore=E501,E124,E126,E127,E128,E121,E131,E116,E261',] | |
"let g:syntastic_python_flake8_args=['-m', 'flake8', '--ignore=E501'] | |
let g:syntastic_python_flake8_args='--ignore=E501,E226' | |
let g:syntastic_always_populate_loc_list = 1 | |
"let g:syntastic_auto_loc_list = 1 | |
let g:syntastic_check_on_open = 1 | |
let g:syntastic_check_on_wq = 0 | |
let g:syntastic_typescript_checkers=[] | |
"let g:syntastic_ignore_files = ['\.py$'] | |
" eslint | |
" npm install -g eslint | |
" npm install -g babel-eslint | |
" npm install -g eslint-plugin-react | |
let g:syntastic_javascript_checkers = ['eslint'] | |
autocmd FileType python let b:syntastic_python_python_exec = syntastic#util#parseShebang(bufnr(''))['exe'] | |
"let g:jedi#use_tabs_not_buffers = 1 | |
let g:jedi#usages_command = "<leader><S-g>" | |
let g:jedi#force_py_version = 3 | |
let g:python3_host_prog = '/usr/local/bin/python3' | |
let g:ale_linters = { | |
\ 'python': ['flake8', 'pylint'], | |
\ 'javascript': ['eslint'], | |
\ 'vue': ['eslint'] | |
\} | |
let g:ale_fixers = { | |
\ 'javascript': ['eslint'], | |
\ 'typescript': ['prettier', 'tslint'], | |
\ 'vue': ['eslint'], | |
\ 'scss': ['prettier'], | |
\ 'html': ['prettier'], | |
\ 'reason': ['refmt'] | |
\} | |
let g:ale_fix_on_save = 1 | |
nnoremap ]r :ALENextWrap<CR> " move to the next ALE warning / error | |
nnoremap [r :ALEPreviousWrap<CR> " move to the previous ALE warning / error | |
else | |
" Wrap in try/catch to avoid errors on initial install before plugin is available | |
try | |
" === Denite setup ===" | |
" Use ripgrep for searching current directory for files | |
" By default, ripgrep will respect rules in .gitignore | |
" --files: Print each file that would be searched (but don't search) | |
" --glob: Include or exclues files for searching that match the given glob | |
" (aka ignore .git files) | |
" | |
call denite#custom#var('file/rec', 'command', ['rg', '--files', '--glob', '!.git']) | |
" Use ripgrep in place of "grep" | |
call denite#custom#var('grep', 'command', ['rg']) | |
" Custom options for ripgrep | |
" --vimgrep: Show results with every match on it's own line | |
" --hidden: Search hidden directories and files | |
" --heading: Show the file name above clusters of matches from each file | |
" --S: Search case insensitively if the pattern is all lowercase | |
call denite#custom#var('grep', 'default_opts', ['--hidden', '--vimgrep', '--heading', '-S']) | |
" Recommended defaults for ripgrep via Denite docs | |
call denite#custom#var('grep', 'recursive_opts', []) | |
call denite#custom#var('grep', 'pattern_opt', ['--regexp']) | |
call denite#custom#var('grep', 'separator', ['--']) | |
call denite#custom#var('grep', 'final_opts', []) | |
" Remove date from buffer list | |
call denite#custom#var('buffer', 'date_format', '') | |
" Open file commands | |
call denite#custom#map('insert,normal', "<C-t>", '<denite:do_action:tabopen>') | |
call denite#custom#map('insert,normal', "<C-v>", '<denite:do_action:vsplit>') | |
call denite#custom#map('insert,normal', "<C-h>", '<denite:do_action:split>') | |
" Custom options for Denite | |
" auto_resize - Auto resize the Denite window height automatically. | |
" prompt - Customize denite prompt | |
" direction - Specify Denite window direction as directly below current pane | |
" winminheight - Specify min height for Denite window | |
" highlight_mode_insert - Specify h1-CursorLine in insert mode | |
" prompt_highlight - Specify color of prompt | |
" highlight_matched_char - Matched characters highlight | |
" highlight_matched_range - matched range highlight | |
let s:denite_options = {'default' : { | |
\ 'split': 'floating', | |
\ 'start_filter': 1, | |
\ 'auto_resize': 1, | |
\ 'source_names': 'short', | |
\ 'prompt': 'λ:', | |
\ 'statusline': 0, | |
\ 'highlight_matched_char': 'WildMenu', | |
\ 'highlight_matched_range': 'Visual', | |
\ 'highlight_window_background': 'Visual', | |
\ 'highlight_filter_background': 'StatusLine', | |
\ 'highlight_prompt': 'StatusLine', | |
\ 'winrow': 1, | |
\ 'vertical_preview': 1 | |
\ }} | |
" Loop through denite options and enable them | |
function! s:profile(opts) abort | |
for l:fname in keys(a:opts) | |
for l:dopt in keys(a:opts[l:fname]) | |
call denite#custom#option(l:fname, l:dopt, a:opts[l:fname][l:dopt]) | |
endfor | |
endfor | |
endfunction | |
call s:profile(s:denite_options) | |
catch | |
echo 'Denite not installed. It should work after running :PlugInstall' | |
endtry | |
" === Denite shorcuts === " | |
" ; - Browser currently open buffers | |
" <leader>t - Browse list of files in current directory | |
" <leader>g - Search current directory for occurences of given term and close window if no results | |
" <leader>j - Search current directory for occurences of word under cursor | |
nmap ; :Denite buffer<CR> | |
nmap <C-p> :DeniteProjectDir file/rec<CR> | |
nnoremap <leader>g :<C-u>Denite grep:. -no-empty<CR> | |
nnoremap <leader>j :<C-u>DeniteCursorWord grep:.<CR> | |
" Define mappings while in 'filter' mode | |
" <C-o> - Switch to normal mode inside of search results | |
" <Esc> - Exit denite window in any mode | |
" <CR> - Open currently selected file in any mode | |
autocmd FileType denite-filter call s:denite_filter_my_settings() | |
function! s:denite_filter_my_settings() abort | |
imap <silent><buffer> <C-o> | |
\ <Plug>(denite_filter_quit) | |
inoremap <silent><buffer><expr> <Esc> | |
\ denite#do_map('quit') | |
nnoremap <silent><buffer><expr> <C-c> | |
\ denite#do_map('quit') | |
inoremap <silent><buffer><expr> <CR> | |
\ denite#do_map('do_action') | |
endfunction | |
" Define mappings while in denite window | |
" <CR> - Opens currently selected file | |
" q or <Esc> - Quit Denite window | |
" d - Delete currenly selected file | |
" p - Preview currently selected file | |
" <C-o> or i - Switch to insert mode inside of filter prompt | |
autocmd FileType denite call s:denite_my_settings() | |
function! s:denite_my_settings() abort | |
nnoremap <silent><buffer><expr> <CR> | |
\ denite#do_map('do_action') | |
nnoremap <silent><buffer><expr> q | |
\ denite#do_map('quit') | |
nnoremap <silent><buffer><expr> <Esc> | |
\ denite#do_map('quit') | |
nnoremap <silent><buffer><expr> d | |
\ denite#do_map('do_action', 'delete') | |
nnoremap <silent><buffer><expr> p | |
\ denite#do_map('do_action', 'preview') | |
nnoremap <silent><buffer><expr> i | |
\ denite#do_map('open_filter_buffer') | |
nnoremap <silent><buffer><expr> <C-o> | |
\ denite#do_map('open_filter_buffer') | |
endfunction | |
" === Coc.nvim === " | |
" use <tab> for trigger completion and navigate to next complete item | |
function! s:check_back_space() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~ '\s' | |
endfunction | |
inoremap <silent><expr> <TAB> | |
\ pumvisible() ? "\<C-n>" : | |
\ <SID>check_back_space() ? "\<TAB>" : | |
\ coc#refresh() | |
"Close preview window when completion is done. | |
autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif | |
" === coc.nvim === " | |
nmap <silent> <leader>dd <Plug>(coc-definition) | |
nmap <silent> <leader>dr <Plug>(coc-references) | |
nmap <silent> <leader>dj <Plug>(coc-implementation) | |
" Use K to show documentation in preview window. | |
nnoremap <silent> K :call <SID>show_documentation()<CR> | |
function! s:show_documentation() | |
if (index(['vim','help'], &filetype) >= 0) | |
execute 'h '.expand('<cword>') | |
else | |
call CocAction('doHover') | |
endif | |
endfunction | |
let g:coc_user_config = {} | |
"let g:coc_user_config['coc.preferences.jumpCommand'] = ':sp' | |
let g:floaterm_keymap_new = '<F7>' | |
let g:floaterm_keymap_prev = '<F8>' | |
let g:floaterm_keymap_next = '<F9>' | |
let g:floaterm_keymap_toggle = '<F12>' | |
endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment