Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.21 KB | None | 0 0
  1. "*****************************************************************************
  2. "" Vim-PLug core
  3. "*****************************************************************************
  4. if has('vim_starting')
  5. set nocompatible " Be iMproved
  6. endif
  7.  
  8. let vimplug_exists=expand('~/.vim/autoload/plug.vim')
  9.  
  10. let g:vim_bootstrap_langs = "c,html,javascript,lisp,perl,python"
  11. let g:vim_bootstrap_editor = "vim" " nvim or vim
  12.  
  13. if !filereadable(vimplug_exists)
  14. if !executable("curl")
  15. echoerr "You have to install curl or first install vim-plug yourself!"
  16. execute "q!"
  17. endif
  18. echo "Installing Vim-Plug..."
  19. echo ""
  20. silent !\curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  21. let g:not_finish_vimplug = "yes"
  22.  
  23. autocmd VimEnter * PlugInstall
  24. endif
  25.  
  26. " Required:
  27. call plug#begin(expand('~/.vim/plugged'))
  28.  
  29. "*****************************************************************************
  30. "" Plug install packages
  31. "*****************************************************************************
  32. Plug 'scrooloose/nerdtree'
  33. Plug 'jistr/vim-nerdtree-tabs'
  34. Plug 'tpope/vim-commentary'
  35. Plug 'tpope/vim-fugitive'
  36. Plug 'vim-airline/vim-airline'
  37. Plug 'vim-airline/vim-airline-themes'
  38. Plug 'airblade/vim-gitgutter'
  39. Plug 'vim-scripts/grep.vim'
  40. Plug 'vim-scripts/CSApprox'
  41. Plug 'bronson/vim-trailing-whitespace'
  42. Plug 'Raimondi/delimitMate'
  43. Plug 'majutsushi/tagbar'
  44. Plug 'scrooloose/syntastic'
  45. Plug 'Yggdroot/indentLine'
  46. Plug 'avelino/vim-bootstrap-updater'
  47. Plug 'sheerun/vim-polyglot'
  48. if isdirectory('/usr/local/opt/fzf')
  49. Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim'
  50. else
  51. Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
  52. Plug 'junegunn/fzf.vim'
  53. endif
  54. let g:make = 'gmake'
  55. if exists('make')
  56. let g:make = 'make'
  57. endif
  58. Plug 'Shougo/vimproc.vim', {'do': g:make}
  59.  
  60. "" Vim-Session
  61. Plug 'xolox/vim-misc'
  62. Plug 'xolox/vim-session'
  63.  
  64. if v:version >= 703
  65. Plug 'Shougo/vimshell.vim'
  66. endif
  67.  
  68. if v:version >= 704
  69. "" Snippets
  70. Plug 'SirVer/ultisnips'
  71. endif
  72.  
  73. Plug 'honza/vim-snippets'
  74.  
  75. "" Color
  76. Plug 'tomasr/molokai'
  77.  
  78. "*****************************************************************************
  79. "" Custom bundles
  80. "*****************************************************************************
  81.  
  82. " c
  83. Plug 'vim-scripts/c.vim', {'for': ['c', 'cpp']}
  84. Plug 'ludwig/split-manpage.vim'
  85.  
  86.  
  87. " html
  88. "" HTML Bundle
  89. Plug 'hail2u/vim-css3-syntax'
  90. Plug 'gorodinskiy/vim-coloresque'
  91. Plug 'tpope/vim-haml'
  92. Plug 'mattn/emmet-vim'
  93.  
  94.  
  95. " javascript
  96. "" Javascript Bundle
  97. Plug 'jelera/vim-javascript-syntax'
  98.  
  99.  
  100. " lisp
  101. "" Lisp Bundle
  102. Plug 'vim-scripts/slimv.vim'
  103.  
  104.  
  105. " perl
  106. "" Perl Bundle
  107. Plug 'vim-perl/vim-perl'
  108. Plug 'c9s/perlomni.vim'
  109.  
  110.  
  111. " python
  112. "" Python Bundle
  113. Plug 'davidhalter/jedi-vim'
  114. Plug 'raimon49/requirements.txt.vim', {'for': 'requirements'}
  115.  
  116.  
  117. "*****************************************************************************
  118. "*****************************************************************************
  119.  
  120. "" Include user's extra bundle
  121. if filereadable(expand("~/.vimrc.local.bundles"))
  122. source ~/.vimrc.local.bundles
  123. endif
  124.  
  125. call plug#end()
  126.  
  127. " Required:
  128. filetype plugin indent on
  129.  
  130.  
  131. "*****************************************************************************
  132. "" Basic Setup
  133. "*****************************************************************************"
  134. "" Encoding
  135. set encoding=utf-8
  136. set fileencoding=utf-8
  137. set fileencodings=utf-8
  138. set bomb
  139. set binary
  140. set ttyfast
  141.  
  142. "" Fix backspace indent
  143. set backspace=indent,eol,start
  144.  
  145. "" Tabs. May be overriten by autocmd rules
  146. set tabstop=4
  147. set softtabstop=0
  148. set shiftwidth=4
  149. set expandtab
  150.  
  151. "" Map leader to ,
  152. let mapleader=','
  153.  
  154. "" Enable hidden buffers
  155. set hidden
  156.  
  157. "" Searching
  158. set hlsearch
  159. set incsearch
  160. set ignorecase
  161. set smartcase
  162.  
  163. "" Directories for swp files
  164. set nobackup
  165. set noswapfile
  166.  
  167. set fileformats=unix,dos,mac
  168.  
  169. if exists('$SHELL')
  170. set shell=$SHELL
  171. else
  172. set shell=/bin/sh
  173. endif
  174.  
  175. " session management
  176. let g:session_directory = "~/.vim/session"
  177. let g:session_autoload = "no"
  178. let g:session_autosave = "no"
  179. let g:session_command_aliases = 1
  180.  
  181. "*****************************************************************************
  182. "" Visual Settings
  183. "*****************************************************************************
  184. syntax on
  185. set ruler
  186. set number
  187.  
  188. let no_buffers_menu=1
  189. if !exists('g:not_finish_vimplug')
  190. colorscheme molokai
  191. endif
  192.  
  193. set mousemodel=popup
  194. set t_Co=256
  195. set guioptions=egmrti
  196. set gfn=Monospace\ 10
  197.  
  198. if has("gui_running")
  199. if has("gui_mac") || has("gui_macvim")
  200. set guifont=Menlo:h12
  201. set transparency=7
  202. endif
  203. else
  204. let g:CSApprox_loaded = 1
  205.  
  206. " IndentLine
  207. let g:indentLine_enabled = 1
  208. let g:indentLine_concealcursor = 0
  209. let g:indentLine_char = '┆'
  210. let g:indentLine_faster = 1
  211.  
  212.  
  213. if $COLORTERM == 'gnome-terminal'
  214. set term=gnome-256color
  215. else
  216. if $TERM == 'xterm'
  217. set term=xterm-256color
  218. endif
  219. endif
  220.  
  221. endif
  222.  
  223.  
  224. if &term =~ '256color'
  225. set t_ut=
  226. endif
  227.  
  228.  
  229. "" Disable the blinking cursor.
  230. set gcr=a:blinkon0
  231. set scrolloff=3
  232.  
  233. "" Status bar
  234. set laststatus=2
  235.  
  236. "" Use modeline overrides
  237. set modeline
  238. set modelines=10
  239.  
  240. set title
  241. set titleold="Terminal"
  242. set titlestring=%F
  243.  
  244. set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\
  245.  
  246. " Search mappings: These will make it so that going to the next one in a
  247. " search will center on the line it's found in.
  248. nnoremap n nzzzv
  249. nnoremap N Nzzzv
  250.  
  251. if exists("*fugitive#statusline")
  252. set statusline+=%{fugitive#statusline()}
  253. endif
  254.  
  255. " vim-airline
  256. let g:airline_theme = 'powerlineish'
  257. let g:airline#extensions#syntastic#enabled = 1
  258. let g:airline#extensions#branch#enabled = 1
  259. let g:airline#extensions#tabline#enabled = 1
  260. let g:airline#extensions#tagbar#enabled = 1
  261. let g:airline_skip_empty_sections = 1
  262.  
  263. "*****************************************************************************
  264. "" Abbreviations
  265. "*****************************************************************************
  266. "" no one is really happy until you have this shortcuts
  267. cnoreabbrev W! w!
  268. cnoreabbrev Q! q!
  269. cnoreabbrev Qall! qall!
  270. cnoreabbrev Wq wq
  271. cnoreabbrev Wa wa
  272. cnoreabbrev wQ wq
  273. cnoreabbrev WQ wq
  274. cnoreabbrev W w
  275. cnoreabbrev Q q
  276. cnoreabbrev Qall qall
  277.  
  278. "" NERDTree configuration
  279. let g:NERDTreeChDirMode=2
  280. let g:NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '__pycache__']
  281. let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$']
  282. let g:NERDTreeShowBookmarks=1
  283. let g:nerdtree_tabs_focus_on_files=1
  284. let g:NERDTreeMapOpenInTabSilent = '<RightMouse>'
  285. let g:NERDTreeWinSize = 50
  286. set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.db,*.sqlite
  287. nnoremap <silent> <F2> :NERDTreeFind<CR>
  288. noremap <F3> :NERDTreeToggle<CR>
  289.  
  290. " grep.vim
  291. nnoremap <silent> <leader>f :Rgrep<CR>
  292. let Grep_Default_Options = '-IR'
  293. let Grep_Skip_Files = '*.log *.db'
  294. let Grep_Skip_Dirs = '.git node_modules'
  295.  
  296. " vimshell.vim
  297. let g:vimshell_user_prompt = 'fnamemodify(getcwd(), ":~")'
  298. let g:vimshell_prompt = '$ '
  299.  
  300. " terminal emulation
  301. if g:vim_bootstrap_editor == 'nvim'
  302. nnoremap <silent> <leader>sh :terminal<CR>
  303. else
  304. nnoremap <silent> <leader>sh :VimShellCreate<CR>
  305. endif
  306.  
  307. "*****************************************************************************
  308. "" Functions
  309. "*****************************************************************************
  310. if !exists('*s:setupWrapping')
  311. function s:setupWrapping()
  312. set wrap
  313. set wm=2
  314. set textwidth=79
  315. endfunction
  316. endif
  317.  
  318. "*****************************************************************************
  319. "" Autocmd Rules
  320. "*****************************************************************************
  321. "" The PC is fast enough, do syntax highlight syncing from start unless 200 lines
  322. augroup vimrc-sync-fromstart
  323. autocmd!
  324. autocmd BufEnter * :syntax sync maxlines=200
  325. augroup END
  326.  
  327. "" Remember cursor position
  328. augroup vimrc-remember-cursor-position
  329. autocmd!
  330. autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
  331. augroup END
  332.  
  333. "" txt
  334. augroup vimrc-wrapping
  335. autocmd!
  336. autocmd BufRead,BufNewFile *.txt call s:setupWrapping()
  337. augroup END
  338.  
  339. "" make/cmake
  340. augroup vimrc-make-cmake
  341. autocmd!
  342. autocmd FileType make setlocal noexpandtab
  343. autocmd BufNewFile,BufRead CMakeLists.txt setlocal filetype=cmake
  344. augroup END
  345.  
  346. set autoread
  347.  
  348. "*****************************************************************************
  349. "" Mappings
  350. "*****************************************************************************
  351.  
  352. "" Split
  353. noremap <Leader>h :<C-u>split<CR>
  354. noremap <Leader>v :<C-u>vsplit<CR>
  355.  
  356. "" Git
  357. noremap <Leader>ga :Gwrite<CR>
  358. noremap <Leader>gc :Gcommit<CR>
  359. noremap <Leader>gsh :Gpush<CR>
  360. noremap <Leader>gll :Gpull<CR>
  361. noremap <Leader>gs :Gstatus<CR>
  362. noremap <Leader>gb :Gblame<CR>
  363. noremap <Leader>gd :Gvdiff<CR>
  364. noremap <Leader>gr :Gremove<CR>
  365.  
  366. " session management
  367. nnoremap <leader>so :OpenSession<Space>
  368. nnoremap <leader>ss :SaveSession<Space>
  369. nnoremap <leader>sd :DeleteSession<CR>
  370. nnoremap <leader>sc :CloseSession<CR>
  371.  
  372. "" Tabs
  373. nnoremap <Tab> gt
  374. nnoremap <S-Tab> gT
  375. nnoremap <silent> <S-t> :tabnew<CR>
  376.  
  377. "" Set working directory
  378. nnoremap <leader>. :lcd %:p:h<CR>
  379.  
  380. "" Opens an edit command with the path of the currently edited file filled in
  381. noremap <Leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
  382.  
  383. "" Opens a tab edit command with the path of the currently edited file filled
  384. noremap <Leader>te :tabe <C-R>=expand("%:p:h") . "/" <CR>
  385.  
  386. "" fzf.vim
  387. set wildmode=list:longest,list:full
  388. set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__
  389. 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"
  390.  
  391. " The Silver Searcher
  392. if executable('ag')
  393. let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -g ""'
  394. set grepprg=ag\ --nogroup\ --nocolor
  395. endif
  396.  
  397. " ripgrep
  398. if executable('rg')
  399. let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"'
  400. set grepprg=rg\ --vimgrep
  401. 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)
  402. endif
  403.  
  404. cnoremap <C-P> <C-R>=expand("%:p:h") . "/" <CR>
  405. nnoremap <silent> <leader>b :Buffers<CR>
  406. nnoremap <silent> <leader>e :FZF -m<CR>
  407.  
  408. " snippets
  409. let g:UltiSnipsExpandTrigger="<tab>"
  410. let g:UltiSnipsJumpForwardTrigger="<tab>"
  411. let g:UltiSnipsJumpBackwardTrigger="<c-b>"
  412. let g:UltiSnipsEditSplit="vertical"
  413.  
  414. " syntastic
  415. let g:syntastic_always_populate_loc_list=1
  416. let g:syntastic_error_symbol='✗'
  417. let g:syntastic_warning_symbol='⚠'
  418. let g:syntastic_style_error_symbol = '✗'
  419. let g:syntastic_style_warning_symbol = '⚠'
  420. let g:syntastic_auto_loc_list=1
  421. let g:syntastic_aggregate_errors = 1
  422.  
  423. " Tagbar
  424. nmap <silent> <F4> :TagbarToggle<CR>
  425. let g:tagbar_autofocus = 1
  426.  
  427. " Disable visualbell
  428. set noerrorbells visualbell t_vb=
  429. if has('autocmd')
  430. autocmd GUIEnter * set visualbell t_vb=
  431. endif
  432.  
  433. "" Copy/Paste/Cut
  434. if has('unnamedplus')
  435. set clipboard=unnamed,unnamedplus
  436. endif
  437.  
  438. noremap YY "+y<CR>
  439. noremap <leader>p "+gP<CR>
  440. noremap XX "+x<CR>
  441.  
  442. if has('macunix')
  443. " pbcopy for OSX copy/paste
  444. vmap <C-x> :!pbcopy<CR>
  445. vmap <C-c> :w !pbcopy<CR><CR>
  446. endif
  447.  
  448. "" Buffer nav
  449. noremap <leader>z :bp<CR>
  450. noremap <leader>q :bp<CR>
  451. noremap <leader>x :bn<CR>
  452. noremap <leader>w :bn<CR>
  453.  
  454. "" Close buffer
  455. noremap <leader>c :bd<CR>
  456.  
  457. "" Clean search (highlight)
  458. nnoremap <silent> <leader><space> :noh<cr>
  459.  
  460. "" Switching windows
  461. noremap <C-j> <C-w>j
  462. noremap <C-k> <C-w>k
  463. noremap <C-l> <C-w>l
  464. noremap <C-h> <C-w>h
  465.  
  466. "" Vmap for maintain Visual Mode after shifting > and <
  467. vmap < <gv
  468. vmap > >gv
  469.  
  470. "" Move visual block
  471. vnoremap J :m '>+1<CR>gv=gv
  472. vnoremap K :m '<-2<CR>gv=gv
  473.  
  474. "" Open current line on GitHub
  475. nnoremap <Leader>o :.Gbrowse<CR>
  476.  
  477. "*****************************************************************************
  478. "" Custom configs
  479. "*****************************************************************************
  480.  
  481. " c
  482. autocmd FileType c setlocal tabstop=4 shiftwidth=4 expandtab
  483. autocmd FileType cpp setlocal tabstop=4 shiftwidth=4 expandtab
  484.  
  485.  
  486. " html
  487. " for html files, 2 spaces
  488. autocmd Filetype html setlocal ts=2 sw=2 expandtab
  489.  
  490.  
  491. " javascript
  492. let g:javascript_enable_domhtmlcss = 1
  493.  
  494. " vim-javascript
  495. augroup vimrc-javascript
  496. autocmd!
  497. autocmd FileType javascript set tabstop=4|set shiftwidth=4|set expandtab softtabstop=4
  498. augroup END
  499.  
  500.  
  501. " lisp
  502.  
  503.  
  504. " perl
  505.  
  506.  
  507. " python
  508. " vim-python
  509. augroup vimrc-python
  510. autocmd!
  511. autocmd FileType python setlocal expandtab shiftwidth=4 tabstop=8 colorcolumn=79
  512. \ formatoptions+=croq softtabstop=4
  513. \ cinwords=if,elif,else,for,while,try,except,finally,def,class,with
  514. augroup END
  515.  
  516. " jedi-vim
  517. let g:jedi#popup_on_dot = 0
  518. let g:jedi#goto_assignments_command = "<leader>g"
  519. let g:jedi#goto_definitions_command = "<leader>d"
  520. let g:jedi#documentation_command = "K"
  521. let g:jedi#usages_command = "<leader>n"
  522. let g:jedi#rename_command = "<leader>r"
  523. let g:jedi#show_call_signatures = "0"
  524. let g:jedi#completions_command = "<C-Space>"
  525. let g:jedi#smart_auto_mappings = 0
  526.  
  527. " syntastic
  528. let g:syntastic_python_checkers=['python', 'flake8']
  529.  
  530. " vim-airline
  531. let g:airline#extensions#virtualenv#enabled = 1
  532.  
  533. " Syntax highlight
  534. " Default highlight is better than polyglot
  535. let g:polyglot_disabled = ['python']
  536. let python_highlight_all = 1
  537.  
  538.  
  539. "*****************************************************************************
  540. "*****************************************************************************
  541.  
  542. "" Include user's local vim config
  543. if filereadable(expand("~/.vimrc.local"))
  544. source ~/.vimrc.local
  545. endif
  546.  
  547. "*****************************************************************************
  548. "" Convenience variables
  549. "*****************************************************************************
  550.  
  551. " vim-airline
  552. if !exists('g:airline_symbols')
  553. let g:airline_symbols = {}
  554. endif
  555.  
  556. if !exists('g:airline_powerline_fonts')
  557. let g:airline#extensions#tabline#left_sep = ' '
  558. let g:airline#extensions#tabline#left_alt_sep = '|'
  559. let g:airline_left_sep = '▶'
  560. let g:airline_left_alt_sep = '»'
  561. let g:airline_right_sep = '◀'
  562. let g:airline_right_alt_sep = '«'
  563. let g:airline#extensions#branch#prefix = '⤴' "➔, ➥, ⎇
  564. let g:airline#extensions#readonly#symbol = '⊘'
  565. let g:airline#extensions#linecolumn#prefix = '¶'
  566. let g:airline#extensions#paste#symbol = 'ρ'
  567. let g:airline_symbols.linenr = '␊'
  568. let g:airline_symbols.branch = '⎇'
  569. let g:airline_symbols.paste = 'ρ'
  570. let g:airline_symbols.paste = 'Þ'
  571. let g:airline_symbols.paste = '∥'
  572. let g:airline_symbols.whitespace = 'Ξ'
  573. else
  574. let g:airline#extensions#tabline#left_sep = ''
  575. let g:airline#extensions#tabline#left_alt_sep = ''
  576.  
  577. " powerline symbols
  578. let g:airline_left_sep = ''
  579. let g:airline_left_alt_sep = ''
  580. let g:airline_right_sep = ''
  581. let g:airline_right_alt_sep = ''
  582. let g:airline_symbols.branch = ''
  583. let g:airline_symbols.readonly = ''
  584. let g:airline_symbols.linenr = ''
  585. endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement