.vimrc 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. " vim-bootstrap 2021-07-25 06:45:02
  2. "*****************************************************************************
  3. "" Vim-Plug core
  4. "*****************************************************************************
  5. let vimplug_exists=expand('~/.vim/autoload/plug.vim')
  6. let curl_exists=expand('curl')
  7. let g:vim_bootstrap_langs = "c,elixir,go,javascript,lua,perl,php,python,ruby"
  8. let g:vim_bootstrap_editor = "vim" " nvim or vim
  9. let g:vim_bootstrap_theme = "dracula"
  10. let g:vim_bootstrap_frams = ""
  11. if !filereadable(vimplug_exists)
  12. if !executable(curl_exists)
  13. echoerr "You have to install curl or first install vim-plug yourself!"
  14. execute "q!"
  15. endif
  16. echo "Installing Vim-Plug..."
  17. echo ""
  18. silent exec "!"curl_exists" -fLo " . shellescape(vimplug_exists) . " --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
  19. let g:not_finish_vimplug = "yes"
  20. autocmd VimEnter * PlugInstall
  21. endif
  22. " Required:
  23. call plug#begin(expand('~/.vim/plugged'))
  24. "*****************************************************************************
  25. "" Plug install packages
  26. "*****************************************************************************
  27. Plug 'scrooloose/nerdtree'
  28. Plug 'jistr/vim-nerdtree-tabs'
  29. Plug 'tpope/vim-commentary'
  30. Plug 'tpope/vim-fugitive'
  31. Plug 'vim-airline/vim-airline'
  32. Plug 'vim-airline/vim-airline-themes'
  33. Plug 'airblade/vim-gitgutter'
  34. Plug 'vim-scripts/grep.vim'
  35. Plug 'vim-scripts/CSApprox'
  36. Plug 'Raimondi/delimitMate'
  37. Plug 'majutsushi/tagbar'
  38. Plug 'dense-analysis/ale'
  39. Plug 'Yggdroot/indentLine'
  40. Plug 'editor-bootstrap/vim-bootstrap-updater'
  41. Plug 'tpope/vim-rhubarb' " required by fugitive to :Gbrowse
  42. Plug 'dracula/vim', { 'as': 'dracula' }
  43. Plug 'ajorgensen/vim-markdown-toc'
  44. if isdirectory('/usr/local/opt/fzf')
  45. Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim'
  46. else
  47. Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
  48. Plug 'junegunn/fzf.vim'
  49. endif
  50. let g:make = 'gmake'
  51. if exists('make')
  52. let g:make = 'make'
  53. endif
  54. Plug 'Shougo/vimproc.vim', {'do': g:make}
  55. "" Vim-Session
  56. Plug 'xolox/vim-misc'
  57. Plug 'xolox/vim-session'
  58. "" Snippets
  59. Plug 'SirVer/ultisnips'
  60. Plug 'honza/vim-snippets'
  61. "*****************************************************************************
  62. "" Custom bundles
  63. "*****************************************************************************
  64. " c
  65. Plug 'vim-scripts/c.vim', {'for': ['c', 'cpp']}
  66. Plug 'ludwig/split-manpage.vim'
  67. " elixir
  68. Plug 'elixir-lang/vim-elixir'
  69. Plug 'carlosgaldino/elixir-snippets'
  70. " go
  71. "" Go Lang Bundle
  72. Plug 'fatih/vim-go', {'do': ':GoInstallBinaries'}
  73. " javascript
  74. "" Javascript Bundle
  75. Plug 'jelera/vim-javascript-syntax'
  76. " lua
  77. "" Lua Bundle
  78. Plug 'xolox/vim-lua-ftplugin'
  79. Plug 'xolox/vim-lua-inspect'
  80. " perl
  81. "" Perl Bundle
  82. Plug 'vim-perl/vim-perl'
  83. Plug 'c9s/perlomni.vim'
  84. " php
  85. "" PHP Bundle
  86. Plug 'phpactor/phpactor', {'for': 'php', 'do': 'composer install --no-dev -o'}
  87. Plug 'stephpy/vim-php-cs-fixer'
  88. " python
  89. "" Python Bundle
  90. Plug 'davidhalter/jedi-vim'
  91. Plug 'raimon49/requirements.txt.vim', {'for': 'requirements'}
  92. " ruby
  93. Plug 'tpope/vim-rails'
  94. Plug 'tpope/vim-rake'
  95. Plug 'tpope/vim-projectionist'
  96. Plug 'thoughtbot/vim-rspec'
  97. Plug 'ecomba/vim-ruby-refactoring', {'tag': 'main'}
  98. "*****************************************************************************
  99. "*****************************************************************************
  100. "" Include user's extra bundle
  101. if filereadable(expand("~/.vimrc.local.bundles"))
  102. source ~/.vimrc.local.bundles
  103. endif
  104. call plug#end()
  105. " Required:
  106. filetype plugin indent on
  107. "*****************************************************************************
  108. "" Basic Setup
  109. "*****************************************************************************"
  110. "" Encoding
  111. set encoding=utf-8
  112. set fileencoding=utf-8
  113. set fileencodings=utf-8
  114. set ttyfast
  115. "" Fix backspace indent
  116. set backspace=indent,eol,start
  117. "" Tabs. May be overridden by autocmd rules
  118. set tabstop=4
  119. set softtabstop=0
  120. set shiftwidth=4
  121. set expandtab
  122. "" Map leader to ,
  123. let mapleader=','
  124. "" Enable hidden buffers
  125. set hidden
  126. "" Searching
  127. set hlsearch
  128. set incsearch
  129. set ignorecase
  130. set smartcase
  131. set fileformats=unix,dos,mac
  132. if exists('$SHELL')
  133. set shell=$SHELL
  134. else
  135. set shell=/bin/sh
  136. endif
  137. " session management
  138. let g:session_directory = "~/.vim/session"
  139. let g:session_autoload = "no"
  140. let g:session_autosave = "no"
  141. let g:session_command_aliases = 1
  142. "*****************************************************************************
  143. "" Visual Settings
  144. "*****************************************************************************
  145. syntax on
  146. set ruler
  147. set number
  148. let no_buffers_menu=1
  149. colorscheme dracula
  150. set mousemodel=popup
  151. set t_Co=256
  152. set guioptions=egmrti
  153. set gfn=Monospace\ 10
  154. if has("gui_running")
  155. if has("gui_mac") || has("gui_macvim")
  156. set guifont=Menlo:h12
  157. set transparency=7
  158. endif
  159. else
  160. let g:CSApprox_loaded = 1
  161. " IndentLine
  162. let g:indentLine_enabled = 1
  163. let g:indentLine_concealcursor = 'n'
  164. let g:indentLine_char = '┆'
  165. let g:indentLine_faster = 1
  166. if $COLORTERM == 'gnome-terminal'
  167. set term=gnome-256color
  168. else
  169. if $TERM == 'xterm'
  170. set term=xterm-256color
  171. endif
  172. endif
  173. endif
  174. if &term =~ '256color'
  175. set t_ut=
  176. endif
  177. "" Disable the blinking cursor.
  178. set gcr=a:blinkon0
  179. set scrolloff=3
  180. "" Status bar
  181. set laststatus=2
  182. "" Use modeline overrides
  183. set modeline
  184. set modelines=10
  185. set title
  186. set titleold="Terminal"
  187. set titlestring=%F
  188. set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\
  189. " Search mappings: These will make it so that going to the next one in a
  190. " search will center on the line it's found in.
  191. nnoremap n nzzzv
  192. nnoremap N Nzzzv
  193. if exists("*fugitive#statusline")
  194. set statusline+=%{fugitive#statusline()}
  195. endif
  196. " vim-airline
  197. let g:airline_theme = 'powerlineish'
  198. let g:airline#extensions#branch#enabled = 1
  199. let g:airline#extensions#ale#enabled = 1
  200. let g:airline#extensions#tabline#enabled = 1
  201. let g:airline#extensions#tagbar#enabled = 1
  202. let g:airline_skip_empty_sections = 1
  203. "*****************************************************************************
  204. "" Abbreviations
  205. "*****************************************************************************
  206. "" no one is really happy until you have this shortcuts
  207. cnoreabbrev W! w!
  208. cnoreabbrev Q! q!
  209. cnoreabbrev Qall! qall!
  210. cnoreabbrev Wq wq
  211. cnoreabbrev Wa wa
  212. cnoreabbrev wQ wq
  213. cnoreabbrev WQ wq
  214. cnoreabbrev W w
  215. cnoreabbrev Q q
  216. cnoreabbrev Qall qall
  217. "" NERDTree configuration
  218. let g:NERDTreeChDirMode=2
  219. let g:NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '__pycache__']
  220. let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$']
  221. let g:NERDTreeShowBookmarks=1
  222. let g:nerdtree_tabs_focus_on_files=1
  223. let g:NERDTreeMapOpenInTabSilent = '<RightMouse>'
  224. let g:NERDTreeWinSize = 50
  225. set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.db,*.sqlite
  226. nnoremap <silent> <F2> :NERDTreeFind<CR>
  227. nnoremap <silent> <F3> :NERDTreeToggle<CR>
  228. " grep.vim
  229. nnoremap <silent> <leader>f :Rgrep<CR>
  230. let Grep_Default_Options = '-IR'
  231. let Grep_Skip_Files = '*.log *.db'
  232. let Grep_Skip_Dirs = '.git node_modules'
  233. " terminal emulation
  234. nnoremap <silent> <leader>sh :terminal<CR>
  235. "*****************************************************************************
  236. "" Commands
  237. "*****************************************************************************
  238. " remove trailing whitespaces
  239. command! FixWhitespace :%s/\s\+$//e
  240. "*****************************************************************************
  241. "" Functions
  242. "*****************************************************************************
  243. if !exists('*s:setupWrapping')
  244. function s:setupWrapping()
  245. set wrap
  246. set wm=2
  247. set textwidth=79
  248. endfunction
  249. endif
  250. "*****************************************************************************
  251. "" Autocmd Rules
  252. "*****************************************************************************
  253. "" The PC is fast enough, do syntax highlight syncing from start unless 200 lines
  254. augroup vimrc-sync-fromstart
  255. autocmd!
  256. autocmd BufEnter * :syntax sync maxlines=200
  257. augroup END
  258. "" Remember cursor position
  259. augroup vimrc-remember-cursor-position
  260. autocmd!
  261. autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
  262. augroup END
  263. "" txt
  264. augroup vimrc-wrapping
  265. autocmd!
  266. autocmd BufRead,BufNewFile *.txt call s:setupWrapping()
  267. augroup END
  268. "" make/cmake
  269. augroup vimrc-make-cmake
  270. autocmd!
  271. autocmd FileType make setlocal noexpandtab
  272. autocmd BufNewFile,BufRead CMakeLists.txt setlocal filetype=cmake
  273. augroup END
  274. set autoread
  275. "*****************************************************************************
  276. "" Mappings
  277. "*****************************************************************************
  278. "" Split
  279. noremap <Leader>h :<C-u>split<CR>
  280. noremap <Leader>v :<C-u>vsplit<CR>
  281. "" Git
  282. noremap <Leader>ga :Gwrite<CR>
  283. noremap <Leader>gc :Git commit --verbose<CR>
  284. noremap <Leader>gsh :Gpush<CR>
  285. noremap <Leader>gll :Gpull<CR>
  286. noremap <Leader>gs :Gstatus<CR>
  287. noremap <Leader>gb :Gblame<CR>
  288. noremap <Leader>gd :Gvdiff<CR>
  289. noremap <Leader>gr :Gremove<CR>
  290. " session management
  291. nnoremap <leader>so :OpenSession<Space>
  292. nnoremap <leader>ss :SaveSession<Space>
  293. nnoremap <leader>sd :DeleteSession<CR>
  294. nnoremap <leader>sc :CloseSession<CR>
  295. "" Tabs
  296. nnoremap <Tab> gt
  297. nnoremap <S-Tab> gT
  298. nnoremap <silent> <S-t> :tabnew<CR>
  299. "" Set working directory
  300. nnoremap <leader>. :lcd %:p:h<CR>
  301. "" Opens an edit command with the path of the currently edited file filled in
  302. noremap <Leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
  303. "" Opens a tab edit command with the path of the currently edited file filled
  304. noremap <Leader>te :tabe <C-R>=expand("%:p:h") . "/" <CR>
  305. "" fzf.vim
  306. set wildmode=list:longest,list:full
  307. set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__
  308. 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"
  309. " The Silver Searcher
  310. if executable('ag')
  311. let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -g ""'
  312. set grepprg=ag\ --nogroup\ --nocolor
  313. endif
  314. " ripgrep
  315. if executable('rg')
  316. let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"'
  317. set grepprg=rg\ --vimgrep
  318. 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)
  319. endif
  320. cnoremap <C-P> <C-R>=expand("%:p:h") . "/" <CR>
  321. nnoremap <silent> <leader>b :Buffers<CR>
  322. nnoremap <silent> <leader>e :FZF -m<CR>
  323. "Recovery commands from history through FZF
  324. nmap <leader>y :History:<CR>
  325. " snippets
  326. let g:UltiSnipsExpandTrigger="<tab>"
  327. let g:UltiSnipsJumpForwardTrigger="<tab>"
  328. let g:UltiSnipsJumpBackwardTrigger="<c-b>"
  329. let g:UltiSnipsEditSplit="vertical"
  330. " ale
  331. let g:ale_linters = {}
  332. " Tagbar
  333. nmap <silent> <F4> :TagbarToggle<CR>
  334. let g:tagbar_autofocus = 1
  335. " Disable visualbell
  336. set noerrorbells visualbell t_vb=
  337. if has('autocmd')
  338. autocmd GUIEnter * set visualbell t_vb=
  339. endif
  340. "" Copy/Paste/Cut
  341. if has('unnamedplus')
  342. set clipboard=unnamed,unnamedplus
  343. endif
  344. noremap YY "+y<CR>
  345. noremap <leader>p "+gP<CR>
  346. noremap XX "+x<CR>
  347. if has('macunix')
  348. " pbcopy for OSX copy/paste
  349. vmap <C-x> :!pbcopy<CR>
  350. vmap <C-c> :w !pbcopy<CR><CR>
  351. endif
  352. "" Buffer nav
  353. noremap <leader>z :bp<CR>
  354. noremap <leader>q :bp<CR>
  355. noremap <leader>x :bn<CR>
  356. noremap <leader>w :bn<CR>
  357. "" Close buffer
  358. noremap <leader>c :bd<CR>
  359. "" Clean search (highlight)
  360. nnoremap <silent> <leader><space> :noh<cr>
  361. "" Switching windows
  362. noremap <C-j> <C-w>j
  363. noremap <C-k> <C-w>k
  364. noremap <C-l> <C-w>l
  365. noremap <C-h> <C-w>h
  366. "" Vmap for maintain Visual Mode after shifting > and <
  367. vmap < <gv
  368. vmap > >gv
  369. "" Move visual block
  370. vnoremap J :m '>+1<CR>gv=gv
  371. vnoremap K :m '<-2<CR>gv=gv
  372. "" Open current line on GitHub
  373. nnoremap <Leader>o :.Gbrowse<CR>
  374. "*****************************************************************************
  375. "" Custom configs
  376. "*****************************************************************************
  377. " c
  378. autocmd FileType c setlocal tabstop=4 shiftwidth=4 expandtab
  379. autocmd FileType cpp setlocal tabstop=4 shiftwidth=4 expandtab
  380. " elixir
  381. " go
  382. " vim-go
  383. " run :GoBuild or :GoTestCompile based on the go file
  384. function! s:build_go_files()
  385. let l:file = expand('%')
  386. if l:file =~# '^\f\+_test\.go$'
  387. call go#test#Test(0, 1)
  388. elseif l:file =~# '^\f\+\.go$'
  389. call go#cmd#Build(0)
  390. endif
  391. endfunction
  392. let g:go_list_type = "quickfix"
  393. let g:go_fmt_command = "goimports"
  394. let g:go_fmt_fail_silently = 1
  395. let g:go_highlight_types = 1
  396. let g:go_highlight_fields = 1
  397. let g:go_highlight_functions = 1
  398. let g:go_highlight_methods = 1
  399. let g:go_highlight_operators = 1
  400. let g:go_highlight_build_constraints = 1
  401. let g:go_highlight_structs = 1
  402. let g:go_highlight_generate_tags = 1
  403. let g:go_highlight_space_tab_error = 0
  404. let g:go_highlight_array_whitespace_error = 0
  405. let g:go_highlight_trailing_whitespace_error = 0
  406. let g:go_highlight_extra_types = 1
  407. autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 softtabstop=4
  408. augroup completion_preview_close
  409. autocmd!
  410. if v:version > 703 || v:version == 703 && has('patch598')
  411. autocmd CompleteDone * if !&previewwindow && &completeopt =~ 'preview' | silent! pclose | endif
  412. endif
  413. augroup END
  414. augroup go
  415. au!
  416. au Filetype go command! -bang A call go#alternate#Switch(<bang>0, 'edit')
  417. au Filetype go command! -bang AV call go#alternate#Switch(<bang>0, 'vsplit')
  418. au Filetype go command! -bang AS call go#alternate#Switch(<bang>0, 'split')
  419. au Filetype go command! -bang AT call go#alternate#Switch(<bang>0, 'tabe')
  420. au FileType go nmap <Leader>dd <Plug>(go-def-vertical)
  421. au FileType go nmap <Leader>dv <Plug>(go-doc-vertical)
  422. au FileType go nmap <Leader>db <Plug>(go-doc-browser)
  423. au FileType go nmap <leader>r <Plug>(go-run)
  424. au FileType go nmap <leader>t <Plug>(go-test)
  425. au FileType go nmap <Leader>gt <Plug>(go-coverage-toggle)
  426. au FileType go nmap <Leader>i <Plug>(go-info)
  427. au FileType go nmap <silent> <Leader>l <Plug>(go-metalinter)
  428. au FileType go nmap <C-g> :GoDecls<cr>
  429. au FileType go nmap <leader>dr :GoDeclsDir<cr>
  430. au FileType go imap <C-g> <esc>:<C-u>GoDecls<cr>
  431. au FileType go imap <leader>dr <esc>:<C-u>GoDeclsDir<cr>
  432. au FileType go nmap <leader>rb :<C-u>call <SID>build_go_files()<CR>
  433. augroup END
  434. " ale
  435. :call extend(g:ale_linters, {
  436. \"go": ['golint', 'go vet'], })
  437. " javascript
  438. let g:javascript_enable_domhtmlcss = 1
  439. " vim-javascript
  440. augroup vimrc-javascript
  441. autocmd!
  442. autocmd FileType javascript setl tabstop=4|setl shiftwidth=4|setl expandtab softtabstop=4
  443. augroup END
  444. " lua
  445. " perl
  446. " php
  447. " Phpactor plugin
  448. " Include use statement
  449. nmap <Leader>u :call phpactor#UseAdd()<CR>
  450. " Invoke the context menu
  451. nmap <Leader>mm :call phpactor#ContextMenu()<CR>
  452. " Invoke the navigation menu
  453. nmap <Leader>nn :call phpactor#Navigate()<CR>
  454. " Goto definition of class or class member under the cursor
  455. nmap <Leader>oo :call phpactor#GotoDefinition()<CR>
  456. nmap <Leader>oh :call phpactor#GotoDefinitionHsplit()<CR>
  457. nmap <Leader>ov :call phpactor#GotoDefinitionVsplit()<CR>
  458. nmap <Leader>ot :call phpactor#GotoDefinitionTab()<CR>
  459. " Show brief information about the symbol under the cursor
  460. nmap <Leader>K :call phpactor#Hover()<CR>
  461. " Transform the classes in the current file
  462. nmap <Leader>tt :call phpactor#Transform()<CR>
  463. " Generate a new class (replacing the current file)
  464. nmap <Leader>cc :call phpactor#ClassNew()<CR>
  465. " Extract expression (normal mode)
  466. nmap <silent><Leader>ee :call phpactor#ExtractExpression(v:false)<CR>
  467. " Extract expression from selection
  468. vmap <silent><Leader>ee :<C-U>call phpactor#ExtractExpression(v:true)<CR>
  469. " Extract method from selection
  470. vmap <silent><Leader>em :<C-U>call phpactor#ExtractMethod()<CR>
  471. " python
  472. " vim-python
  473. augroup vimrc-python
  474. autocmd!
  475. autocmd FileType python setlocal expandtab shiftwidth=4 tabstop=8 colorcolumn=79
  476. \ formatoptions+=croq softtabstop=4
  477. \ cinwords=if,elif,else,for,while,try,except,finally,def,class,with
  478. augroup END
  479. " jedi-vim
  480. let g:jedi#popup_on_dot = 0
  481. let g:jedi#goto_assignments_command = "<leader>g"
  482. let g:jedi#goto_definitions_command = "<leader>d"
  483. let g:jedi#documentation_command = "K"
  484. let g:jedi#usages_command = "<leader>n"
  485. let g:jedi#rename_command = "<leader>r"
  486. let g:jedi#show_call_signatures = "0"
  487. let g:jedi#completions_command = "<C-Space>"
  488. let g:jedi#smart_auto_mappings = 0
  489. " ale
  490. :call extend(g:ale_linters, {
  491. \'python': ['flake8'], })
  492. " vim-airline
  493. let g:airline#extensions#virtualenv#enabled = 1
  494. " Syntax highlight
  495. let python_highlight_all = 1
  496. " ruby
  497. let g:rubycomplete_buffer_loading = 1
  498. let g:rubycomplete_classes_in_global = 1
  499. let g:rubycomplete_rails = 1
  500. augroup vimrc-ruby
  501. autocmd!
  502. autocmd BufNewFile,BufRead *.rb,*.rbw,*.gemspec setlocal filetype=ruby
  503. autocmd FileType ruby set tabstop=2|set shiftwidth=2|set expandtab softtabstop=2
  504. augroup END
  505. let g:tagbar_type_ruby = {
  506. \ 'kinds' : [
  507. \ 'm:modules',
  508. \ 'c:classes',
  509. \ 'd:describes',
  510. \ 'C:contexts',
  511. \ 'f:methods',
  512. \ 'F:singleton methods'
  513. \ ]
  514. \ }
  515. " RSpec.vim mappings
  516. map <Leader>t :call RunCurrentSpecFile()<CR>
  517. map <Leader>s :call RunNearestSpec()<CR>
  518. map <Leader>l :call RunLastSpec()<CR>
  519. map <Leader>a :call RunAllSpecs()<CR>
  520. " For ruby refactory
  521. if has('nvim')
  522. runtime! macros/matchit.vim
  523. else
  524. packadd! matchit
  525. endif
  526. " Ruby refactory
  527. nnoremap <leader>rap :RAddParameter<cr>
  528. nnoremap <leader>rcpc :RConvertPostConditional<cr>
  529. nnoremap <leader>rel :RExtractLet<cr>
  530. vnoremap <leader>rec :RExtractConstant<cr>
  531. vnoremap <leader>relv :RExtractLocalVariable<cr>
  532. nnoremap <leader>rit :RInlineTemp<cr>
  533. vnoremap <leader>rrlv :RRenameLocalVariable<cr>
  534. vnoremap <leader>rriv :RRenameInstanceVariable<cr>
  535. vnoremap <leader>rem :RExtractMethod<cr>
  536. "*****************************************************************************
  537. "*****************************************************************************
  538. "" Include user's local vim config
  539. if filereadable(expand("~/.vimrc.local"))
  540. source ~/.vimrc.local
  541. endif
  542. "*****************************************************************************
  543. "" Convenience variables
  544. "*****************************************************************************
  545. " vim-airline
  546. if !exists('g:airline_symbols')
  547. let g:airline_symbols = {}
  548. endif
  549. if !exists('g:airline_powerline_fonts')
  550. let g:airline#extensions#tabline#left_sep = ' '
  551. let g:airline#extensions#tabline#left_alt_sep = '|'
  552. let g:airline_left_sep = '▶'
  553. let g:airline_left_alt_sep = '»'
  554. let g:airline_right_sep = '◀'
  555. let g:airline_right_alt_sep = '«'
  556. let g:airline#extensions#branch#prefix = '⤴' "➔, ➥, ⎇
  557. let g:airline#extensions#readonly#symbol = '⊘'
  558. let g:airline#extensions#linecolumn#prefix = '¶'
  559. let g:airline#extensions#paste#symbol = 'ρ'
  560. let g:airline_symbols.linenr = '␊'
  561. let g:airline_symbols.branch = '⎇'
  562. let g:airline_symbols.paste = 'ρ'
  563. let g:airline_symbols.paste = 'Þ'
  564. let g:airline_symbols.paste = '∥'
  565. let g:airline_symbols.whitespace = 'Ξ'
  566. else
  567. let g:airline#extensions#tabline#left_sep = ''
  568. let g:airline#extensions#tabline#left_alt_sep = ''
  569. " powerline symbols
  570. let g:airline_left_sep = ''
  571. let g:airline_left_alt_sep = ''
  572. let g:airline_right_sep = ''
  573. let g:airline_right_alt_sep = ''
  574. let g:airline_symbols.branch = ''
  575. let g:airline_symbols.readonly = ''
  576. let g:airline_symbols.linenr = ''
  577. endif
  578. hi Normal guibg=NONE ctermbg=NONE
  579. au VimEnter * NERDTree
  580. let g:mdtoc_starting_header_level = 1