Created
September 8, 2021 14:20
-
-
Save dimanyc/243544dcc5b7454c037ee61efd7c20ad to your computer and use it in GitHub Desktop.
.vimrc 09/08/21
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 | |
filetype off " required | |
call plug#begin('~/.vim/plugged') | |
Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
Plug 'danilo-augusto/vim-afterglow' | |
Plug 'thoughtbot/vim-rspec' | |
Plug 'tomasr/molokai' | |
Plug 'tpope/vim-commentary' | |
Plug 'tpope/vim-dispatch' | |
Plug 'tpope/vim-fugitive' | |
Plug 'tpope/vim-repeat' | |
Plug 'tpope/vim-surround' | |
Plug 'vim-airline/vim-airline' | |
Plug 'junegunn/fzf', { 'do': './install --bin' } | |
Plug 'junegunn/fzf.vim' | |
call plug#end() | |
" https://gitter.im/neoclide/coc.nvim?at=601141d7ae4b9b27c17f311e | |
let g:coc_filetype_map = { | |
\ 'rspec.ruby': 'ruby', | |
\ } | |
" GoTo code navigation. | |
nmap <silent> gd <Plug>(coc-definition) | |
nmap <silent> gy <Plug>(coc-type-definition) | |
nmap <silent> gi <Plug>(coc-implementation) | |
nmap <silent> gr <Plug>(coc-references) | |
" CocConfig: | |
set encoding=utf-8 | |
" TextEdit might fail if hidden is not set. | |
set hidden | |
" Some servers have issues with backup files, see #649. | |
set nobackup | |
set nowritebackup | |
" Give more space for displaying messages. | |
set cmdheight=2 | |
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable | |
" delays and poor user experience. | |
set updatetime=300 | |
" Don't pass messages to |ins-completion-menu|. | |
set shortmess+=c | |
" Always show the signcolumn, otherwise it would shift the text each time | |
" diagnostics appear/become resolved. | |
if has("nvim-0.5.0") || has("patch-8.1.1564") | |
" Recently vim can merge signcolumn and number column into one | |
set signcolumn=number | |
else | |
set signcolumn=yes | |
endif | |
" Use tab for trigger completion with characters ahead and navigate. | |
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by | |
" other plugin before putting this into your config. | |
inoremap <silent><expr> <TAB> | |
\ pumvisible() ? "\<C-n>" : | |
\ <SID>check_back_space() ? "\<TAB>" : | |
\ coc#refresh() | |
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>" | |
function! s:check_back_space() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~# '\s' | |
endfunction | |
" Add `:Format` command to format current buffer. | |
command! -nargs=0 Format :call CocAction('format') | |
" Add `:Fold` command to fold current buffer. | |
command! -nargs=? Fold :call CocAction('fold', <f-args>) | |
" Add `:OR` command for organize imports of the current buffer. | |
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') | |
nnoremap <Leader>d :call CocAction('format') <CR> | |
let g:coc_global_extensions = ['coc-solargraph', 'coc-json'] | |
" FZF Config: | |
nnoremap <C-p> :Files<CR> | |
nnoremap <Leader>b :Buffers<CR> | |
nnoremap <Leader>h :History<CR> | |
" Colorscheme: | |
let g:molokai_original = 1 | |
let g:rehash256 = 1 | |
set background=dark | |
colorscheme afterglow | |
syntax enable | |
colorscheme molokai | |
set number | |
set noswapfile | |
set clipboard=unnamed | |
set cmdheight=1 | |
set backspace=indent,eol,start | |
" Indentation: | |
set autoindent | |
set tabstop=2 | |
set expandtab | |
set shiftwidth=2 | |
" Spelling: | |
set spelllang=en | |
set spellfile=$HOME/Dropbox/vim/spell/en.utf-8.add | |
set spell | |
" Parens: | |
autocmd FocusLost * :NoMatchParen | |
autocmd FocusGained * :DoMatchParen | |
hi MatchParen ctermfg=014 ctermbg=208 cterm=bold | |
nmap <silent> <Leader>e :Explore<CR> | |
autocmd FileType javascript.jsx setlocal commentstring={/*\ %s\ */} | |
" Whitespace: | |
let g:strip_whitespace_on_save=1 | |
let g:strip_whitespace_confirm=0 | |
" TestBindings: | |
function ApplyVimTestBindings() | |
nmap <leader>t :TestFile<CR> | |
nmap <leader>s :TestNearest<CR> | |
nmap <leader>l :TestLast<CR> | |
nmap <leader>a :TestSuite<CR> | |
endfunction | |
autocmd FileType python call ApplyVimTestBindings() | |
" Line length Column: | |
highlight ColorColumn ctermbg=0 guibg=purple | |
" Swap words around: | |
nmap <silent> gw "_yiw:s/\(\%#\w\+\)\(\_W\+\)\(\w\+\)/\3\2\1/<CR><C-o>:noh<CR> | |
" Debuggers: | |
autocmd FileType ruby map <leader>p orequire 'pry';binding.pry<ESC> | |
autocmd FileType python map <leader>p oimport pdb; pdb.set_trace()<ESC> | |
autocmd FileType javascript map <leader>p oconsole.log('a');<ESC> | |
" RSpec: | |
map <Leader>t :call RunCurrentSpecFile()<CR> | |
map <Leader>s :call RunNearestSpec()<CR> | |
map <Leader>l :call RunLastSpec()<CR> | |
map <Leader>a :call RunAllSpecs()<CR> | |
let g:rspec_command = "!bundle exec rspec {spec} " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment