Created
July 8, 2020 16:25
-
-
Save vinniefranco/f8adca4b9ab882a5a8ce4cff6ab12b7c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
let mapleader="," | |
set encoding=utf-8 | |
scriptencoding utf-8 | |
set showmatch | |
set showmode | |
set relativenumber | |
set number | |
set textwidth=0 | |
set softtabstop=2 | |
set shiftwidth=2 | |
set expandtab | |
set noerrorbells | |
set linespace=0 | |
set nojoinspaces | |
set history=100 " Store a ton of history (default is 20) | |
set hidden " allow buffer switching without saving | |
set nowrap | |
set colorcolumn=80 | |
set cursorline " highlight current line | |
set autoindent " indent at the same level of the previous line | |
set inccommand=split " live replace preview | |
" Tell Vim which characters to show for expanded TABs, | |
" trailing whitespace, and end-of-lines. VERY useful! | |
set listchars=tab:``,trail:`,extends:#,nbsp:` " Highlight problematic whitespace" | |
set list " Show problematic characters. | |
set hlsearch " Highlight search results. | |
set ignorecase " Make searching case insensitive | |
set smartcase " ... unless the query has capital letters. | |
set incsearch " Incremental search. | |
set gdefault " Use 'g' flag by default with :s/foo/bar/. | |
set magic " Use 'magic' patterns (extended regular expressions). | |
" Setting up the directories | |
set backup " backups are nice ... | |
if has('persistent_undo') | |
set undofile "so is persistent undo ... | |
set undolevels=500 "maximum number of changes that can be undone | |
set undoreload=500 "maximum number lines to save for undo on a buffer reload | |
endif | |
set updatetime=300 " You will have bad experience for diagnostic messages when it's default 4000. | |
set shortmess+=c " don't give |ins-completion-menu| messages. | |
set signcolumn=yes " always show signcolumns | |
" *sigh* Eventbrite... | |
autocmd Filetype python setlocal expandtab tabstop=4 shiftwidth=4 softtabstop=4 | |
autocmd Filetype javascript setlocal expandtab tabstop=4 shiftwidth=4 softtabstop=4 | |
" Also highlight all tabs and trailing whitespace characters. | |
highlight ExtraWhitespace ctermbg=darkgreen guibg=darkgreen | |
match ExtraWhitespace /\s\+$\|\t/ | |
let g:python3_host_prog = '/usr/bin/python3' | |
let g:python_host_prog = '/usr/bin/python2' | |
" plugins are good... | |
call plug#begin('~/.local/share/nvim/plugged') | |
" Aesthetics | |
Plug 'bling/vim-airline' | |
Plug 'ryanoasis/vim-devicons' | |
Plug 'drewtempelmeyer/palenight.vim' | |
Plug 'vim-airline/vim-airline-themes' | |
" Navigation / Search / Editing | |
Plug 'scrooloose/nerdtree' | |
Plug 'rbgrouleff/bclose.vim' | |
Plug 'tpope/vim-eunuch' | |
Plug 'AndrewRadev/splitjoin.vim' | |
Plug 'Lokaltog/vim-easymotion' | |
Plug 'Raimondi/delimitMate' | |
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } | |
Plug 'fishbullet/deoplete-ruby' | |
Plug 'inside/vim-grep-operator' | |
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } | |
Plug 'junegunn/fzf.vim' | |
Plug 'kana/vim-textobj-user' | |
Plug 'mattn/emmet-vim' | |
Plug 'rizzatti/dash.vim' | |
Plug 'rking/ag.vim' | |
Plug 'tpope/vim-endwise' | |
Plug 'tpope/vim-projectionist' | |
Plug 'tpope/vim-surround' | |
" Framework / Language specific | |
Plug 'sheerun/vim-polyglot' | |
Plug 'avdgaag/vim-phoenix' | |
Plug 'elixir-editors/vim-elixir' | |
Plug 'nelstrom/vim-textobj-rubyblock' | |
Plug 'tpope/vim-rails' | |
Plug 'dense-analysis/ale' | |
"Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
" Test runners / Tmux integration | |
Plug 'christoomey/vim-tmux-navigator' | |
Plug 'christoomey/vim-tmux-runner' | |
Plug 'janko-m/vim-test' | |
Plug 'scrooloose/nerdcommenter' | |
Plug 'tpope/vim-fugitive' | |
Plug 'tpope/vim-rake' | |
call plug#end() | |
" search buffer for word under cursor | |
nmap // viwy/<c-r>"<cr>" <F37> | |
" clearing highlighted search | |
nmap <silent> <leader>/ :nohlsearch<CR> | |
" Easier moving in tabs, windows, and terminals | |
tnoremap <C-h> <C-\><C-n><C-w>h | |
tnoremap <C-j> <C-\><C-n><C-w>j | |
tnoremap <C-k> <C-\><C-n><C-w>k | |
tnoremap <C-l> <C-\><C-n><C-w>l | |
nnoremap <C-h> <C-w>h | |
nnoremap <C-j> <C-w>j | |
nnoremap <C-k> <C-w>k | |
nnoremap <C-l> <C-w>l | |
" Break comma delimited strings to newline at cursor | |
nmap <silent> <Leader>br :s/, /\=",\r " . substitute(substitute(getline('.'), " :.*$", "", "g"), ".", " ", "g")/g<CR>" | |
" Make splits a bit more manageable. | |
nnoremap <Leader>1 :vs<CR><C-w>l | |
nnoremap <Leader>2 :split<CR><C-w>j | |
nnoremap <Right> :bn<CR> | |
nnoremap <Left> :bp<CR> | |
" visual shifting (does not exit Visual mode) | |
vnoremap < <gv | |
vnoremap > >gv | |
nmap <Leader>pd oimport ipdb; ipdb.set_trace()<Esc> | |
" Replace all occurrences of word under cursor | |
nnoremap <Leader>r :%s/\<<C-r><C-w>\>/ | |
" Replace visually selected word | |
vnoremap <C-r> "hy:%s/<C-r>h//gc<left><left><left> | |
" Adjust viewports to the same size | |
map <Leader>= <C-w>= | |
let g:airline_theme='palenight' | |
let g:airline_powerline_fonts=1 | |
let g:airline#extensions#tabline#fnamecollapse=1 | |
let g:airline#extensions#tabline#enabled = 1 | |
set laststatus=2 | |
let g:VtrClearSequence = 'clear' | |
" vim-test setup | |
let test#javascript#jest#executable = 'yarn' | |
let test#python#runner = 'pytest' | |
let test#python#rspec#executable = 'pytest' | |
let test#ruby#rspec#executable = 'bundle exec rspec' | |
let test#strategy = 'vtr' | |
function! YakTransform(cmd) abort | |
let l:args = split(a:cmd) | |
if l:args[0] == "pipenv" | |
if !exists("w:container") | |
" Ooops. We haven't set a container to execute tests through. | |
" Let's set that now | |
let w:container = input('Enter container name: ') | |
endif | |
let l:cmd = join([l:args[2], l:args[3]], ' ') | |
return 'yak exec ' . w:container . ' ' . shellescape(l:cmd) | |
else | |
return a:cmd | |
endif | |
endfunction | |
let g:test#custom_transformations = {'yak': function('YakTransform')} | |
let g:test#transformation = 'yak' | |
nmap - :NERDTreeToggle<CR> | |
nmap <leader>t :TestFile<CR> | |
nmap <leader>s :TestNearest<CR> | |
nmap <leader>a :TestSuite<CR> | |
" VtrRunner | |
nmap <leader>p :VtrKillRunner<CR> | |
nmap <leader>o :VtrOpenRunner({'orientation': 'h', 'percentage': 30})<CR> | |
" Use deoplete. | |
let g:deoplete#enable_at_startup = 1 | |
set grepprg=rg\ --vimgrep | |
let g:grep_operator = 'rg' | |
nmap <Leader>g <Plug>GrepOperatorOnCurrentDirectory | |
vmap <Leader>g <Plug>GrepOperatorOnCurrentDirectory | |
nmap <Leader><Leader>g <Plug>GrepOperatorWithFilenamePrompt | |
vmap <Leader><Leader>g <Plug>GrepOperatorWithFilenamePrompt | |
" ======================================== | |
" FZF setup | |
" ======================================== | |
let g:fzf_nvim_statusline=0 | |
nnoremap <silent> <leader>f :Files<CR> | |
nnoremap <silent> <leader>b :Buffers<CR> | |
nnoremap <silent> <leader>. :Lines<CR> | |
nnoremap <silent> K :call SearchWordWithAg()<CR> | |
vnoremap <silent> K :call SearchVisualSelectionWithAg()<CR> | |
nnoremap <silent> <leader>gl :Commits<CR> | |
nnoremap <silent> <leader>ga :BCommits<CR> | |
function! SearchWordWithAg() | |
execute 'Ag' expand('<cword>') | |
endfunction | |
function! SearchVisualSelectionWithAg() range | |
let old_reg = getreg('"') | |
let old_regtype = getregtype('"') | |
let old_clipboard = &clipboard | |
set clipboard& | |
normal! ""gvy | |
let selection = getreg('"') | |
call setreg('"', old_reg, old_regtype) | |
let &clipboard = old_clipboard | |
execute 'Ag' selection | |
endfunction | |
set wildignore+=*/tmp/*,*.pyc,*.so,*.swp,*.zip,*.map,.mypy_cache/ | |
set wildignore+=*/doc/*,*/public/assets/*,*/node_modules/*,*/client/components/* | |
let g:jsx_ext_required = 0 | |
function! InitializeDirectories() | |
let separator = "." | |
let parent = $HOME | |
let prefix = '.nvim' | |
let dir_list = { | |
\ 'backup': 'backupdir', | |
\ 'views': 'viewdir', | |
\ 'swap': 'directory' } | |
if has('persistent_undo') | |
let dir_list['undo'] = 'undodir' | |
endif | |
for [dirname, settingname] in items(dir_list) | |
let directory = parent . '/' . prefix . dirname . "/" | |
if exists("*mkdir") | |
if !isdirectory(directory) | |
call mkdir(directory) | |
endif | |
endif | |
if !isdirectory(directory) | |
echo "Warning: Unable to create backup directory: " . directory | |
echo "Try: mkdir -p " . directory | |
else | |
let directory = substitute(directory, " ", "\\\\ ", "g") | |
exec "set " . settingname . "=" . directory | |
endif | |
endfor | |
endfunction | |
call InitializeDirectories() | |
" let g:dirvish_mode = ':g/^.*$/s!.*!\=WebDevIconsGetFileTypeSymbol(submatch(0)) . " " . submatch(0)!' | |
let g:ctrlp_user_command = 'ag %s -i --nocolor --nogroup --hidden | |
\ --ignore .DS_Store | |
\ --ignore .git | |
\ --ignore .hg | |
\ --ignore .mypy_cache | |
\ --ignore .svn | |
\ --ignore "**/*.beam" | |
\ --ignore "**/*.pyc" | |
\ -g ""' | |
set wildignore+=*/tmp/*,*.beam,*.so,*.swp,*.zip,*.map,.mypy_cache/ | |
set wildignore+=*/doc/*,*/public/assets/* | |
"For Neovim 0.1.5+ and Vim 7.4.1799+ | |
if (has("termguicolors")) | |
set termguicolors | |
endif | |
"let base16colorspace=256 " Access colors present in 256 colorspace | |
set background=dark | |
colorscheme palenight | |
set guifont=Inconsolata\ Nerd\ Font\ Mono:h12 | |
hi LineNr guibg=bg | |
set foldcolumn=1 | |
hi foldcolumn guibg=bg | |
hi VertSplit guibg=bg guifg=bg | |
let g:palenight_terminal_italics=1 | |
set spell | |
set spelllang=en_us | |
hi SpellBad guisp=#FF0000 gui=undercurl | |
hi SpellCap guisp=#7070F0 gui=undercurl | |
hi SpellLocal guisp=#70F0F0 gui=undercurl | |
hi SpellRare guisp=#FFFFFF gui=undercurl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment