-
-
Save georgiybykov/4b12767c8c254988d595e6bfe6daf818 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
" vim-bootstrap | |
"***************************************************************************** | |
"" Vim-PLug core | |
"***************************************************************************** | |
let vimplug_exists=expand('~/.config/nvim/autoload/plug.vim') | |
let g:vim_bootstrap_langs = "elixir,erlang,html,javascript,ruby" | |
let g:vim_bootstrap_editor = "nvim" " nvim or vim | |
if !filereadable(vimplug_exists) | |
if !executable("curl") | |
echoerr "You have to install curl or first install vim-plug yourself!" | |
execute "q!" | |
endif | |
echo "Installing Vim-Plug..." | |
echo "" | |
silent exec "!\curl -fLo " . vimplug_exists . " --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" | |
let g:not_finish_vimplug = "yes" | |
autocmd VimEnter * PlugInstall | |
endif | |
" Required: | |
call plug#begin(expand('~/.config/nvim/plugged')) | |
"***************************************************************************** | |
"" Plug install packages | |
"***************************************************************************** | |
Plug 'scrooloose/nerdtree' | |
Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
Plug 'amiralies/coc-elixir', {'do': 'yarn install --frozen-lockfile && yarn run build'} | |
"" Plug 'neoclide/coc-tabnine' | |
Plug 'chaoren/vim-wordmotion' | |
Plug 'dracula/vim', { 'as': 'dracula' } | |
Plug 'tpope/vim-fugitive' | |
Plug 'sodapopcan/vim-twiggy' | |
Plug 'idanarye/vim-merginal' | |
Plug 'tpope/vim-endwise' | |
let g:endwise_no_mappings=1 | |
inoremap <expr> <Plug>CustomCocCR pumvisible() ? coc#_select_confirm() : "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>" | |
imap <CR> <Plug>CustomCocCR<Plug>DiscretionaryEndPlug 'preservim/nerdcommenter' | |
Plug 'christoomey/vim-tmux-navigator' | |
if isdirectory('/usr/local/opt/fzf') | |
Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim' | |
else | |
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' } | |
Plug 'junegunn/fzf.vim' | |
endif | |
let g:make = 'gmake' | |
if exists('make') | |
let g:make = 'make' | |
endif | |
"***************************************************************************** | |
"" Custom bundles | |
"***************************************************************************** | |
Plug 'honza/vim-snippets' | |
Plug 'tpope/vim-surround' | |
Plug 'preservim/nerdcommenter' | |
Plug 'tpope/vim-repeat' | |
Plug 'Lokaltog/vim-easymotion' | |
Plug 'vim-airline/vim-airline' | |
let g:airline#extensions#tabline#enabled = 1 | |
Plug 'airblade/vim-rooter' | |
Plug 'stsewd/fzf-checkout.vim' | |
"Tmux | |
Plug 'benmills/vimux' | |
Plug 'spiegela/vimix' | |
" elixir | |
Plug 'elixir-lang/vim-elixir' | |
Plug 'carlosgaldino/elixir-snippets' | |
Plug 'mhinz/vim-mix-format' | |
let g:mix_format_on_save = 1 | |
let g:mix_format_silent_errors = 1 | |
" | |
Plug 'junegunn/goyo.vim' | |
let g:goyo_width = 140 | |
" ruby | |
Plug 'tpope/vim-rails' | |
Plug 'tpope/vim-rake' | |
Plug 'tpope/vim-projectionist' | |
Plug 'thoughtbot/vim-rspec' | |
Plug 'ecomba/vim-ruby-refactoring' | |
Plug 'depuracao/vim-rdoc' | |
Plug 'danchoi/ri.vim' | |
let g:ri_no_mappings=1 | |
Plug 'kchmck/vim-coffee-script' | |
" tests | |
Plug 'vim-test/vim-test' | |
" let test#strategy = "vimux" | |
Plug 'tpope/vim-dispatch' | |
Plug 'vim-scripts/vim-auto-save' | |
" file management | |
Plug 'francoiscabrol/ranger.vim' | |
Plug 'rbgrouleff/bclose.vim' | |
Plug 'sunaku/vim-dasht' | |
Plug 'ianding1/leetcode.vim' | |
" md | |
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' } | |
let g:mkdp_auto_start = 0 | |
let g:mkdp_auto_close = 0 | |
"***************************************************************************** | |
"***************************************************************************** | |
call plug#end() | |
"" Required: | |
""***************************************************************************** | |
""" Basic Setup | |
""*****************************************************************************" | |
""" Encoding | |
set encoding=utf-8 | |
set fileencoding=utf-8 | |
set fileencodings=utf-8 | |
set nu rnu | |
""" Fix backspace indent | |
set backspace=indent,eol,start | |
""" Tabs. May be overridden by autocmd rules | |
set tabstop=4 | |
set softtabstop=0 | |
set shiftwidth=4 | |
set expandtab | |
""" Map leader to , | |
let mapleader=' ' | |
""" set leetcode | |
"let g:leetcode_browser = 'firefox' | |
"let g:leetcode_solution_filetype = 'ruby' | |
""" Enable hidden buffers | |
set hidden | |
""" Searching | |
set hlsearch | |
set incsearch | |
set ignorecase | |
set smartcase | |
set fileformats=unix,dos,mac | |
if exists('$SHELL') | |
set shell=$SHELL | |
else | |
set shell=/bin/sh | |
endif | |
"" session management | |
let g:session_directory = "~/.config/nvim/session" | |
let g:session_autoload = "yes" | |
let g:session_autosave = "yes" | |
let g:session_command_aliases = 1 | |
""***************************************************************************** | |
""" Visual Settings | |
""***************************************************************************** | |
syntax on | |
set ruler | |
set number | |
filetype plugin indent on | |
filetype on | |
filetype indent on | |
let no_buffers_menu=1 | |
set mousemodel=popup | |
set t_Co=256 | |
set guioptions=egmrti | |
set guifont=Source\ Code\ Pro\ 40 | |
""***************************************************************************** | |
""" Abbreviations | |
""***************************************************************************** | |
""" no one is really happy until you have this shortcuts | |
cnoreabbrev W! w! | |
cnoreabbrev Q! q! | |
cnoreabbrev Qall! qall! | |
cnoreabbrev Wq wq | |
cnoreabbrev Wa wa | |
cnoreabbrev wQ wq | |
cnoreabbrev WQ wq | |
cnoreabbrev W w | |
cnoreabbrev Q q | |
cnoreabbrev Qall qall | |
"" terminal emulation | |
nnoremap <silent> <leader>pt :terminal<CR> | |
set path+=** " Searches current directory recursively. | |
set wildmenu " Display all matches when tab complete. | |
set incsearch " Incremental search | |
set hidden " Needed to keep multiple buffers open | |
set nobackup " No auto backups | |
set noswapfile " No swap | |
set t_Co=256 " Set if term supports 256 colors. | |
set clipboard=unnamedplus " Copy/paste between vim and other programs. | |
syntax enable | |
let g:rehash256 = 1 | |
""" Commands | |
""***************************************************************************** | |
""***************************************************************************** | |
""" Functions | |
""***************************************************************************** | |
""***************************************************************************** | |
""" Autocmd Rules | |
""***************************************************************************** | |
""" The PC is fast enough, do syntax highlight syncing from start unless 200 lines | |
augroup vimrc-sync-fromstart | |
autocmd! | |
autocmd BufEnter * :syntax sync maxlines=200 | |
augroup END | |
""" Remember cursor position | |
augroup vimrc-remember-cursor-position | |
autocmd! | |
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif | |
augroup END | |
"" txt | |
augroup vimrc-wrapping | |
autocmd! | |
autocmd BufRead,BufNewFile *.txt call s:setupWrapping() | |
augroup END | |
"" make/cmake | |
augroup vimrc-make-cmake | |
autocmd! | |
autocmd FileType make setlocal noexpandtab | |
autocmd BufNewFile,BufRead CMakeLists.txt setlocal filetype=cmake | |
augroup END | |
set autoread | |
""***************************************************************************** | |
""" Mappings | |
""***************************************************************************** | |
""" Split | |
noremap <Leader>h :<C-u>split<CR> | |
noremap <Leader>v :<C-u>vsplit<CR> | |
set splitbelow splitright | |
noremap <silent> <C-Left> :vertical resize +3<CR> | |
noremap <silent> <C-Right> :vertical resize -3<CR> | |
noremap <silent> <C-Up> :resize +3<CR> | |
noremap <silent> <C-Down> :resize -3<CR> | |
""" Tabs | |
nnoremap <Tab> gt | |
nnoremap <S-Tab> gT | |
nnoremap <S-t> :tabnew<CR> | |
nnoremap <leader>gb :GBranches<CR> | |
""" fzf.vim | |
set wildmode=list:longest,list:full | |
set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__ | |
let $FZF_DEFAULT_COMMAND = "find * -path '*/\.*' -prune -o -path 'node_modules/**' -prune -o -path 'target/**' -prune -o -path 'dist/**' -prune -o -type f -print -o -type l -print 2> /dev/null" | |
"" The Silver Searcher | |
if executable('ag') | |
let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -g ""' | |
set grepprg=ag\ --nogroup\ --nocolor | |
endif | |
"" ripgrep | |
if executable('rg') | |
let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"' | |
set grepprg=rg\ --vimgrep | |
command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>).'| tr -d "\017"', 1, <bang>0) | |
endif | |
command! -bang Directories call fzf#run(fzf#wrap({'source': 'find * -type d'})) | |
nnoremap <silent> <leader>bb :Buffers<CR> | |
nnoremap <silent> <leader>pf :Files!<CR> | |
nnoremap <silent> <leader>pd :Directories <CR> | |
nnoremap <silent> <leader>ps :Rg!<CR> | |
""Recovery commands from history through FZF | |
nmap <leader>y :History:<CR> | |
nmap <leader>gl :GFiles?<CR> | |
"" snippets | |
let g:UltiSnipsExpandTrigger="<tab>" | |
let g:UltiSnipsJumpForwardTrigger="<tab>" | |
let g:UltiSnipsJumpBackwardTrigger="<c-b>" | |
let g:UltiSnipsEditSplit="vertical" | |
"" Disable visualbell | |
set noerrorbells visualbell t_vb= | |
if has('autocmd') | |
autocmd GUIEnter * set visualbell t_vb= | |
endif | |
""" Copy/Paste/Cut | |
if has('unnamedplus') | |
set clipboard=unnamed,unnamedplus | |
endif | |
noremap YY "+y<CR> | |
noremap <leader>p "+gP<CR> | |
noremap XX "+x<CR> | |
"if has('macunix') | |
"" pbcopy for OSX copy/paste | |
"vmap <C-x> :!pbcopy<CR> | |
"vmap <C-c> :w !pbcopy<CR><CR> | |
"endif | |
""" Buffer nav | |
noremap <leader>z :bp<CR> | |
noremap <leader>q :bp<CR> | |
noremap <leader>x :bn<CR> | |
noremap <leader>w :bn<CR> | |
""" Close buffer | |
noremap <leader>c :bd<CR> | |
""" Clean search (highlight) | |
nnoremap <silent> <leader><ESC> :noh<cr> | |
""" Switching windows | |
noremap <C-j> <C-w>j | |
noremap <C-k> <C-w>k | |
noremap <C-l> <C-w>l | |
noremap <C-h> <C-w>h | |
""" Vmap for maintain Visual Mode after shifting > and < | |
vmap < <gv | |
vmap > >gv | |
""" Move visual block | |
vnoremap J :m '>+1<CR>gv=gv | |
vnoremap K :m '<-2<CR>gv=gv | |
""" Open current line on GitHub | |
""***************************************************************************** | |
""" Custom configs | |
""***************************************************************************** | |
"" javascript | |
let g:javascript_enable_domhtmlcss = 1 | |
"" vim-javascript | |
augroup vimrc-javascript | |
autocmd! | |
autocmd FileType javascript setl tabstop=4|setl shiftwidth=4|setl expandtab softtabstop=4 | |
augroup END | |
"" ruby | |
let g:rubycomplete_buffer_loading = 1 | |
let g:rubycomplete_classes_in_global = 1 | |
let g:rubycomplete_rails = 1 | |
augroup vimrc-ruby | |
autocmd! | |
autocmd BufNewFile,BufRead *.rb,*.rbw,*.gemspec setlocal filetype=ruby | |
autocmd FileType ruby set tabstop=2|set shiftwidth=2|set expandtab softtabstop=2 | |
augroup END | |
let g:tagbar_type_ruby = { | |
\ 'kinds' : [ | |
\ 'm:modules', | |
\ 'c:classes', | |
\ 'd:describes', | |
\ 'C:contexts', | |
\ 'f:methods', | |
\ 'F:singleton methods' | |
\ ] | |
\ } | |
" RSpec.vim mappings | |
map <Leader>t :call RunCurrentSpecFile()<CR> | |
map <Leader>s :call RunNearestSpec()<CR> | |
map <Leader>l :call RunLastSpec()<CR> | |
map <Leader>a :call RunAllSpecs()<CR> | |
" For ruby refactory | |
if has('nvim') | |
runtime! macros/matchit.vim | |
else | |
packadd! matchit | |
endif | |
" Ruby refatoring | |
nnoremap <leader>rap :RAddParameter<cr> | |
nnoremap <leader>rcpc :RConvertPostConditional<cr> | |
nnoremap <leader>rel :RExtractLet<cr> | |
vnoremap <leader>rec :RExtractConstant<cr> | |
vnoremap <leader>relv :RExtractLocalVariable<cr> | |
nnoremap <leader>rit :RInlineTemp<cr> | |
vnoremap <leader>rrlv :RRenameLocalVariable<cr> | |
vnoremap <leader>rriv :RRenameInstanceVariable<cr> | |
vnoremap <leader>rem :RExtractMethod<cr> | |
""***************************************************************************** | |
""***************************************************************************** | |
""" Include user's local vim config | |
"if filereadable(expand("~/.config/nvim/local_init.vim")) | |
"source ~/.config/nvim/local_init.vim | |
"endif | |
""***************************************************************************** | |
""" Convenience variables | |
""***************************************************************************** | |
""#################################### | |
nnoremap <leader>fs :update<cr> | |
map <leader>ff :Ranger<CR> | |
let g:NERDTreeHijackNetrw = 0 | |
let g:ranger_replace_netrw = 1 | |
nmap <silent> <leader>tt :TestNearest<CR> | |
nmap <silent> <leader>tf :TestFile<CR> | |
nmap <silent> <leader>tp :TestSuite<CR> | |
nmap <silent> t<C-l> :TestLast<CR> | |
nmap <silent> t<C-g> :TestVisit<CR> | |
"" 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) | |
"" format | |
xmap <leader>ff <Plug>(coc-format-selected) | |
nmap <leader>ff <Plug>(coc-format-selected) | |
" Applying codeAction to the selected region. | |
" Example: `<leader>aap` for current paragraph | |
xmap <leader>a <Plug>(coc-codeaction-selected) | |
nmap <leader>a <Plug>(coc-codeaction-selected) | |
" Remap keys for applying codeAction to the current buffer. | |
nmap <leader>ac <Plug>(coc-codeaction) | |
" Apply AutoFix to problem on the current line. | |
nmap <leader>qf <Plug>(coc-fix-current) | |
" Map function and class text objects | |
" NOTE: Requires 'textDocument.documentSymbol' support from the language server. | |
xmap if <Plug>(coc-funcobj-i) | |
omap if <Plug>(coc-funcobj-i) | |
xmap af <Plug>(coc-funcobj-a) | |
omap af <Plug>(coc-funcobj-a) | |
xmap ic <Plug>(coc-classobj-i) | |
omap ic <Plug>(coc-classobj-i) | |
xmap ac <Plug>(coc-classobj-a) | |
omap ac <Plug>(coc-classobj-a) | |
imap ii <Esc> | |
nnoremap <leader>gs :Git <CR> | |
nnoremap <leader>gc :Git commit <CR> | |
nnoremap <leader>gp :Git push <CR> | |
nnoremap <leader>gd :Git diff <CR> | |
nnoremap <leader>gw :Git blame <CR> | |
nnoremap <leader>gg :GBrowse <CR> | |
nnoremap <leader>gh :diffget //3 <CR> | |
nnoremap <leader>ga :diffget //2 <CR> | |
nnoremap <silent> <leader>hh :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 | |
autocmd CursorHold * silent call CocActionAsync('highlight') | |
"" 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 | |
" Use <c-space> to trigger completion. | |
inoremap <silent><expr> <c-space> coc#refresh() | |
if exists('*complete_info') | |
inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>" | |
else | |
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" | |
endif | |
"" Use `[g` and `]g` to navigate diagnostics | |
nmap <silent> [g <Plug>(coc-diagnostic-prev) | |
nmap <silent> ]g <Plug>(coc-diagnostic-next) | |
if has('nvim') | |
tmap <C-o> <C-\><C-n> | |
endif | |
set noswapfile | |
colorscheme dracula | |
set termguicolors | |
set background=dark | |
hi Comment guifg=#dbe9ff | |
set t_Co=256 | |
" The Silver Searcher | |
if executable('ag') | |
" Use ag over grep | |
set grepprg=ag\ --nogroup\ --nocolor | |
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore | |
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""' | |
" ag is fast enough that CtrlP doesn't need to cache | |
let g:ctrlp_use_caching = 0 | |
endif | |
" <Leader>f{char} to move to {char} | |
map <Leader>jc <Plug>(easymotion-bd-f) | |
nmap <Leader>jc <Plug>(easymotion-overwin-f) | |
" s{char}{char} to move to {char}{char} | |
" Move to line | |
map <Leader>jl <Plug>(easymotion-bd-jk) | |
nmap <Leader>jl <Plug>(easymotion-overwin-line) | |
" Move to word | |
map <Leader>jw <Plug>(easymotion-bd-w) | |
nmap <Leader>jw <Plug>(easymotion-overwin-w) | |
nnoremap <Leader>d :Dispatch<Space> | |
nmap <leader>rr <Plug>(coc-rename) | |
nnoremap <leader>prw :CocSearch <C-R>=expand("<cword>")<CR><CR> | |
"" nnoremap <leader>ps :Rg! <C-R>=expand("<cword>")<CR><CR> | |
"" EASY CONFIG ACCESS AND EASY REALOD | |
nnoremap <leader><leader>cc :e $MYVIMRC<CR> | |
autocmd BufWritePost .init.vim source $MYVIMRC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment