Guest User

Untitled

a guest
Mar 10th, 2020
529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 6.30 KB | None | 0 0
  1. """ Nakrule vimrc
  2. " It work the same way in neovim, except that eclim is not supported as far as I know.
  3. " Depedency:
  4. " - Install exuberant-ctags (sudo apt install exuberant-ctags) for vim-tagbar plugin
  5. " - Run the python installer for YouCompleteMe
  6. " - If you want eclim for code completion from eclipse, install eclipse and then follow the eclim
  7. "   documentation.
  8.  
  9. " Specify a directory for plugins
  10. " - For Neovim: ~/.local/share/nvim/plugged
  11. " - Avoid using standard Vim directory names like 'plugin'
  12. call plug#begin('~/.vim/plugged')
  13.  
  14. " Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
  15. Plug 'junegunn/vim-easy-align'
  16.  
  17. " Nice start page when starting VIM without a file
  18. Plug 'mhinz/vim-startify'
  19.  
  20. " Search file to open with :CtrlP
  21. Plug 'ctrlpvim/ctrlp.vim'
  22.  
  23. " Better syntax file for better colorisation for a lot of languages
  24. Plug 'sheerun/vim-polyglot'
  25.  
  26. " NERDtree and the tab extension to keep nerdtree sync between all tabs.
  27. Plug 'scrooloose/nerdtree'
  28. Plug 'jistr/vim-nerdtree-tabs'
  29.  
  30. " Shell in NeoVim
  31. Plug 'Shougo/deol.nvim'
  32.  
  33. " Networking syntax
  34. Plug 'momota/cisco.vim'
  35. Plug 'momota/junos.vim'
  36.  
  37. " Nice status bar
  38. Plug 'vim-airline/vim-airline'
  39. Plug 'vim-airline/vim-airline-themes'
  40.  
  41. Plug 'airblade/vim-gitgutter' " Show github add/delete in the margin
  42.  
  43. " Auto complete
  44. Plug 'Valloric/YouCompleteMe'
  45. Plug 'SirVer/ultisnips'         " The snippet engine
  46. Plug 'honza/vim-snippets'       " The snippets
  47. Plug 'ervandew/supertab'        " Needed to use tab to expand trigger with youcompleteme
  48.  
  49. " Themes
  50. Plug 'sjl/badwolf'
  51. Plug 'dracula/vim', { 'as': 'dracula' }
  52. Plug 'morhetz/gruvbox'
  53.  
  54. " To use tagbar, exuberant-ctags should be installed
  55. " sudo apt install exuberant-ctags
  56. Plug 'majutsushi/tagbar' " For tag bar list in the windows
  57.  
  58. Plug 'tpope/vim-fugitive' " Git integration
  59. Plug 'psliwka/vim-smoothie' " Super smooth scrooling in VIM with CTRL-U/D
  60.  
  61. call plug#end()
  62.  
  63. " Use fd as escape
  64. :imap fd <Esc>
  65.  
  66. " set the backspace to delete normally
  67. set backspace=indent,eol,start
  68.  
  69. autocmd BufWritePre * %s/\s\+$//e " Remove all white space at the end of each line when saving a file
  70. autocmd BufWritePre * retab       " Replace all tab with spaces
  71. autocmd BufWritePre * set fileformat=unix  " Replace CRLF to LF (windows to linux line ending)
  72.  
  73. " Colorscheme configuration
  74. colorscheme gruvbox
  75. set background=dark
  76. let g:gruvbox_contrast_dark = 'hard'
  77.  
  78. set number
  79. set expandtab "use space instead of tab
  80. set shiftwidth=2 "number of space char inserted for identation
  81. set tabstop=2
  82.  
  83. " make YCM compatible with UltiSnips (using supertab)
  84. let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
  85. let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
  86. let g:SuperTabDefaultCompletionType = '<C-n>'
  87. " Use tab to expand trigger with ultisnips
  88. let g:UltiSnipsExpandTrigger="<tab>"
  89. let g:UltiSnipsJumpForwardTrigger="<tab>"
  90. let g:UltiSnipsJumpBackwardTrigger="<S-tab>"
  91.  
  92. " map escape key to leave terminal mode with deol
  93. :tnoremap <Esc> <C-\><C-n>
  94.  
  95. " resize window using 7, 8, 9 and 0 keys
  96. nmap 6 :res +2<CR> " increase pane by 2
  97. nmap 7 :res -2<CR> " decrease pane by 2
  98. nmap 8 :vertical res +2<CR> " vertical increase pane by 2
  99. nmap 9 :vertical res -2<CR> " vertical decrease pane by 2
  100.  
  101. " relative line number with auto switch to normal in insert mode and without pane focus
  102. :set number relativenumber
  103. :augroup numbertoggle
  104. :  autocmd!
  105. :  autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
  106. :  autocmd BufLeave,FocusLost,InsertEnter   * set norelativenumber
  107. :augroup END
  108.  
  109. " Reduce update to 0.1s (from 4s) so the plugin VIM-gitgutter work better
  110. set updatetime=100
  111.  
  112. " Auto close NERDTree when exiting latest opened file in VIM
  113. autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
  114. autocmd VimEnter * wincmd p
  115.  
  116. " Need this if using both Eclim and YouCompletMe
  117. let g:EclimCompletionMethod = 'omnifunc'
  118.  
  119. " Share the VIM clipboard with the X11 clipboard
  120. if has("clipboard")
  121.   set clipboard=unnamed " copy to the system clipboard
  122.  
  123.   if has("unnamedplus") " X11 support
  124.     set clipboard+=unnamedplus
  125.   endif
  126. endif
  127.  
  128. " Set ruler at 100 char
  129. set colorcolumn=100
  130.  
  131. " Set auto line return after 100 char
  132. set tw=100
  133.  
  134. """"""""""" VIM-Airline configuration
  135. let g:airline_powerline_fonts = 1
  136. " Make airline looks like powerline
  137. let g:airline_section_z = airline#section#create(['windowswap', '%3p%% ', 'linenr', ':%3v'])
  138.  
  139. " The following 8 lines place the windows number is the left of vim-airline
  140. function! WindowNumber(...)
  141.   let builder = a:1
  142.   let context = a:2
  143.   call builder.add_section('airline_b', '%{tabpagewinnr(tabpagenr())}')
  144.   return 0
  145. endfunction
  146. call airline#add_statusline_func('WindowNumber')
  147. call airline#add_inactive_statusline_func('WindowNumber')
  148.  
  149.  
  150. """"" SPACE mapping
  151.  
  152. " Switch buffer with SPACE + <number> (like in spacevim)
  153. nnoremap <space>1 1<C-w>w
  154. nnoremap <space>2 2<C-w>w
  155. nnoremap <space>3 3<C-w>w
  156. nnoremap <space>4 4<C-w>w
  157. nnoremap <space>5 5<C-w>w
  158. nnoremap <space>6 6<C-w>w
  159. nnoremap <space>7 7<C-w>w
  160. nnoremap <space>8 8<C-w>w
  161. nnoremap <space>9 9<C-w>w
  162.  
  163. " Open and close NERDTree with SPACE+n
  164. "nnoremap <space>n :NERDTreeToggle<CR>
  165. nnoremap <space>n :NERDTreeTabsToggle<CR>
  166.  
  167. " Buffer configuration
  168. " SPACE-K     Toggle between last two active buffer
  169. " SPACE-H/L   Go to next/previous buffer
  170. " SPACE-B     Open a new buffer (tab)
  171. " SPACE-T     Toggle Tagbar
  172. nnoremap <space>b     :tabnew<CR>
  173. nnoremap <space>b     <Esc>:tabnew<CR>
  174. " move to the previous/next tabpage.
  175. nnoremap <space>h gT
  176. nnoremap <space>l gt
  177. " Go to last active tab
  178. au TabLeave * let g:lasttab = tabpagenr()
  179. nnoremap <silent> <space>k :exe "tabn ".g:lasttab<cr>
  180. "vnoremap <silent> <space>l :exe "tabn ".g:lasttab<cr>
  181. " Toggle tagbar
  182. nnoremap <space>t :TagbarToggle<CR>
  183.  
  184. """"""" Tagbar configuration
  185.  
  186. " Auto open Tagbar when editing Java files
  187. autocmd FileType java call SetJavaOptions()
  188. function! SetJavaOptions()
  189.   :call tagbar#autoopen(0)
  190.   let java_highlight_functions = 1
  191.   let java_highlight_all = 1
  192. endfunction
  193.  
  194. " Remape Tagbar show prototype to o (default is space, but it fuck up SPACE + number)
  195. let g:tagbar_map_showproto = "o"
  196.  
  197. " Remove some clipboard stuff to start VIM faster. See
  198. " https://stackoverflow.com/questions/14635295/vim-takes-a-very-long-time-to-start-up
  199. ""set clipboard=exclude:.*
Advertisement
Add Comment
Please, Sign In to add comment