Advertisement
Guest User

Untitled

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