Advertisement
Guest User

Celyes' vim configuration file

a guest
Jan 28th, 2020
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 10.04 KB | None | 0 0
  1. "vimrc file By celyes
  2. "GitHub: @celyes
  3.  
  4. " NOTE: you need to create 'backup', 'swap', 'undo' and undodir folders inside ~/.vim
  5. " NOTE: in order for airline to look good, you need to install and select powerline fonts pack
  6. " NOTE: markonm/traces.vim is incompatible with neovim - to make it work, turn off inccommand
  7. " NOTE: in order to make language client work, you need to execute:
  8. "      yarn global add javascript-typescript-langserver
  9. " That will install javascript-typescript-stdio
  10.  
  11. if empty(glob('~/.vim/tmp'))
  12.     silent !mkdir -p ~/.vim/tmp
  13. endif
  14. set directory=$HOME/.vim/tmp
  15.  
  16.  
  17. """""""""""""""""""""""""""""""""""""""""""""""""""""""""
  18. "             Vim-Plug auto installation                "
  19. "                                                       "
  20. """""""""""""""""""""""""""""""""""""""""""""""""""""""""
  21.  
  22. if empty(glob('~/.vim/autoload/plug.vim'))
  23.   silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
  24.     \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  25.   autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
  26. endif
  27.  
  28. """""""""""""""""""""""""""""""""""""""""""""""""""""""""
  29. "                   Plugins area                        "
  30. "                                                       "
  31. """""""""""""""""""""""""""""""""""""""""""""""""""""""""
  32.  
  33. call plug#begin('~/.vim/plugged')
  34.  
  35. """"""" Vim appearance """""""
  36.  
  37. Plug 'vim-airline/vim-airline'
  38. Plug 'vim-airline/vim-airline-themes'
  39.  
  40. """"""""""""""""""""""""""""""""""""""
  41.  
  42. """"""" Search """""""
  43. " File fuzzy search
  44. Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
  45. Plug 'junegunn/fzf.vim'
  46. " AMAZING plugin for searching text inside project
  47. Plug 'mhinz/vim-grepper'
  48.  
  49. """"""""""""""""""""""
  50.  
  51. """"""" Syntax highlighters/indents """""""
  52.  
  53. Plug 'jelera/vim-javascript-syntax'
  54. Plug 'pangloss/vim-javascript'
  55. Plug 'mxw/vim-jsx'
  56. Plug 'othree/javascript-libraries-syntax.vim'
  57. " Language pack for many languages
  58. Plug 'sheerun/vim-polyglot'
  59.  
  60. """""""""""""""""""""""""""""""""""""""""""
  61.  
  62. """"""" Utility """""""
  63.  
  64. " Project tree explorer
  65. " Easy commenting plugin, press gc to comment a line in visual mode or gcc in normal mode
  66. Plug 'tpope/vim-commentary'
  67. " autoclosing brackets
  68. Plug 'Raimondi/delimitMate'
  69. " autoclosing html tags
  70. Plug 'alvan/vim-closetag'
  71. " changing surroundings of the selection, cs"' changes " to ', ds" deletes ", cst" adds "
  72. Plug 'tpope/vim-surround'
  73.  
  74. " To make tsuguyomi work
  75. Plug 'Shougo/vimproc.vim', {'do' : 'make'}
  76. " Async intellisense for typescript (as well as error highlighting
  77. Plug 'Quramy/tsuquyomi'
  78. " Async linter
  79. Plug 'w0rp/ale'
  80. " Dispatching actions
  81. Plug 'tpope/vim-dispatch'
  82. " Changing root to project dir on every file open
  83. Plug 'airblade/vim-rooter'
  84. " Tmuxline
  85. Plug 'edkolev/tmuxline.vim'
  86. " Git integration for vim (installed to see branch name on vim-airline), useful for :GitBlame
  87. Plug 'tpope/vim-fugitive'
  88. " For testing integration
  89. Plug 'janko-m/vim-test'
  90. " For integrating tmux with vim (for janko-m/vim-test)
  91. Plug 'benmills/vimux'
  92. " An amazing plugin for live preview when executing substitute command
  93. Plug 'markonm/traces.vim'
  94. " Highlights new/mofified/deleted lines in the "gutter"
  95. Plug 'mhinz/vim-signify'
  96. " If you prefer Ctrl+h/j/k/l for navigating across vim/tmux splits,
  97. " this plugin will integrate Vim and Tmux, so that you can seamlessly
  98. " Jump across the border of a vim/tmux split
  99. Plug 'christoomey/vim-tmux-navigator'
  100.  
  101. """""""""""""""""""""""
  102.  
  103. call plug#end()
  104.  
  105. """""""""""""""""""""""""""""""""""""""""""""""""""""""""
  106. "                   Settings area                       "
  107. "                                                       "
  108. """""""""""""""""""""""""""""""""""""""""""""""""""""""""
  109.  
  110. filetype indent plugin on
  111. syntax on
  112.  
  113. "solarized color scheme
  114. syntax enable
  115.  
  116. " To make colors work, note that you need to change ^[ to actual esc, so do
  117. " <C-v><ESC>
  118. " set t_8f=[38;2;%lu;%lu;%lum
  119. " set t_8b=[48;2;%lu;%lu;%lum
  120.  
  121. set termguicolors "to enable true colors
  122. set background=dark
  123.  
  124. " set t_Co=256     "needed to work in ubuntu terminal
  125.  
  126. set wildignore+=*/tmp/*,*.so,*.swp,*.zip     " MacOSX/Linux
  127. set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe  " Windows
  128.  
  129. set completeopt-=preview
  130.  
  131. "Must have options, highly recommended by community
  132. set hidden
  133. set wildmenu
  134.  
  135. set showcmd
  136.  
  137. set hlsearch
  138. set incsearch
  139.  
  140. set nocursorcolumn
  141.  
  142. "Smart options, good for programming
  143. set ignorecase
  144. set smartcase
  145.  
  146. set backspace=indent,eol,start
  147. set smarttab autoindent
  148.  
  149. set ruler
  150.  
  151. set laststatus=2
  152. set confirm
  153.  
  154. set cmdheight=2
  155. set shortmess=a
  156. "show line numbers
  157. set number
  158.  
  159. " fzf
  160. set rtp+=/usr/local/opt/fzf
  161.  
  162. " yank to clipboard
  163. if has("clipboard")
  164.   set clipboard=unnamed " copy to the system clipboard
  165.  
  166.   if has("unnamedplus") " X11 support
  167.     set clipboard+=unnamedplus
  168.   endif
  169. endif
  170.  
  171. "for webpack to catch all writes
  172. set backupcopy=yes
  173.  
  174. " disable auto break long lines
  175. set textwidth=0
  176. set nowrap
  177.  
  178. "Indentation options
  179. set expandtab
  180. set shiftwidth=4
  181. set softtabstop=4
  182. "Vim will store undo externally, so after closing and reopening file you can undo changes
  183. set undofile
  184.  
  185. "Setting .swp files to be centralized, not clutter the edit folder
  186. set backupdir=~/.vim/backup//
  187. set directory=~/.vim/swap//
  188. set undodir=~/.vim/undo//
  189.  
  190. set pastetoggle=<F5>
  191.  
  192. ""Display a faint line at 150 chars
  193. "set colorcolumn=150
  194.  
  195. " More natural splits
  196. set splitbelow
  197. set splitright
  198.  
  199.  
  200. """""""""""""""""""""""""""""""""""""""""""""""""""""""""
  201. "                   Plugins settings area               "
  202. "                                                       "
  203. """""""""""""""""""""""""""""""""""""""""""""""""""""""""
  204. """"""" arcticicestudio/nord-vim """""""
  205.  
  206.  
  207. """"""" vim-airline/vim-airline """""""
  208. let g:airline_powerline_fonts = 1
  209. let g:airline_theme = "dark"
  210. let g:airline#extensions#tabline#enabled = 1
  211. let g:airline#extensions#tabline#formatter = 'unique_tail'
  212. if !exists('g:airline_symbols')
  213.     let g:airline_symbols = {}
  214. endif
  215.  
  216. """"""" pangloss/vim-javascript """""""
  217. let g:javascript_plugin_jsdoc = 1
  218.  
  219. """"""" othree/javascript-libraries-syntax.vim """""""
  220. let g:used_javascript_libs = 'underscore,jquery,react'
  221.  
  222. """"""" ternjs/tern_for_vim """""""
  223. " enable keyboard shortcuts
  224. let g:tern_map_keys=1
  225. " show argument hints
  226. let g:tern_show_argument_hints='on_hold'
  227.  
  228. """"""" junegunn/fzf """""""
  229.  
  230.  
  231. """"""" alvan/vim-closetag """""""
  232. let g:closetag_filenames = '*.html,*.jsx,*.js'
  233.  
  234. """"""" Raimondi/delimitMate """""""
  235. let delimitMate_matchpairs = "(:),[:],{:}"
  236.  
  237. """"""" w0rp/ale """""""
  238. let g:ale_lint_on_text_changed = 'never'
  239.  
  240. """"""" Quramy/tsuquyomi """""""
  241. let g:tsuquyomi_javascript_support = 1
  242. let g:tsuquyomi_disable_quickfix = 1
  243.  
  244. """"""" mhinz/vim-grepper """""""
  245. let g:grepper = {}
  246. let g:grepper.ag = {}
  247. " let g:grepper.ag.grepprg = 'ag --vimgrep $* 'FindProjectRoot('.git')
  248.  
  249. """"""" mxw/vim-jsx """""""
  250. let g:jsx_ext_required = 0
  251.  
  252. """"""" edkolev/tmuxline """""""
  253.  
  254. " For tmuxline + vim-airline integration
  255. let g:airline#extensions#tmuxline#enabled = 1
  256. " Start tmuxline even without vim running
  257. let airline#extensions#tmuxline#snapshot_file = "~/.tmux-status.conf"
  258. " To make it nice
  259. let g:tmuxline_preset = {
  260.       \'a'    : '#S',
  261.       \'b'    : '#W',
  262.       \'c'    : '#H',
  263.       \'win'  : '#I #W',
  264.       \'cwin' : '#I #W',
  265.       \'x'    : '%a',
  266.       \'y'    : '#W %R',
  267.       \'z'    : '#H'}
  268.  
  269.  
  270. """"""" janko-m/vim-test """""""
  271. let test#strategy = "vimux"
  272. let g:test#javascript#jest#file_pattern = '.*\.spec\.js'
  273.  
  274.  
  275. """"""" mhinz/vim-signify """""""
  276. let g:signify_vcs_list = [ 'git' ]
  277.  
  278. """""""""""""""""""""""""""""""""""""""""""""""""""""""""
  279. "                   Remaps area                         "
  280. "                                                       "
  281. """""""""""""""""""""""""""""""""""""""""""""""""""""""""
  282. " I said write it!
  283. cmap w!! w !sudo tee > /dev/null %
  284.  
  285. " Used for mhinz/vim-grepper
  286. nmap gs  <plug>(GrepperOperator)
  287. xmap gs  <plug>(GrepperOperator)
  288.  
  289. " remap ctrl+p to :FZF
  290. map <C-p> :Files<cr>
  291. nmap <C-p> :Files<cr>
  292.  
  293. nnoremap <leader>ev :split $MYVIMRC<cr>
  294. nnoremap <leader>sv :source $MYVIMRC<cr>
  295. noremap <silent> <C-h> <c-w>h
  296. noremap <silent> <C-l> <c-W>l
  297. noremap <silent> <C-k> <c-w>k
  298. noremap <silent> <C-j> <c-w>j
  299.  
  300. cnoremap tabnew :tabnew<cr>:Vexplore<cr>
  301. nnoremap <F5> :set invpaste paste?<Enter>
  302. imap <F5> <C-O><F5>
  303.  
  304. " This is a quick way to call search-and-replace on a current word
  305. nnoremap <Leader>s :%s/\<<C-r><C-w>\>//g<Left><Left>
  306.  
  307. " To make  n to always search forward and N backward
  308. nnoremap <expr> n  'Nn'[v:searchforward]
  309. nnoremap <expr> N  'nN'[v:searchforward]
  310.  
  311. if executable('javascript-typescript-stdio')
  312.   " <leader>ld to go to definition
  313.   autocmd FileType javascript nnoremap <buffer>
  314.     \ <leader>ld :call LanguageClient_textDocument_definition()<cr>
  315.   " <leader>lh for type info under cursor
  316.   autocmd FileType javascript nnoremap <buffer>
  317.     \ <leader>lh :call LanguageClient_textDocument_hover()<cr>
  318.   " <leader>lr to rename variable under cursor
  319.   autocmd FileType javascript nnoremap <buffer>
  320.     \ <leader>lr :call LanguageClient_textDocument_rename()<cr>
  321. endif
  322.  
  323. """""""""""""""""""""""""""""""""""""""""""""""""""""""""
  324. "                   Groups area                         "
  325. "                                                       "
  326. """""""""""""""""""""""""""""""""""""""""""""""""""""""""
  327.  
  328. augroup general
  329.     autocmd!
  330.     " autocmd VimEnter * :Vexplore
  331.     " autocmd vimenter * NERDTree
  332.     " autocmd FileType netrw setl bufhidden=delete
  333. augroup END
  334.  
  335. augroup js_files
  336.     autocmd!
  337.     autocmd FileType javascript let maplocalleader = ";"
  338.     autocmd FileType javascript nnoremap <buffer> <localleader>c I//<esc>
  339.     autocmd FileType javascript setlocal commentstring=//%s
  340. augroup END
  341.  
  342. "Suffixes for 'gf' command to associate filetypes with extensions (for files jumping)
  343. augroup suffixes
  344.     autocmd!
  345.     let associations = [
  346.         \["javascript", ".js,.jsx"],
  347.         \]
  348.  
  349.     for ft in associations
  350.         execute "autocmd FileType " . ft[0] . " setlocal suffixesadd=" . ft[1]
  351.     endfor
  352. augroup END
  353.  
  354. "set termguicolors
  355. "syntax on
  356. "color molokai
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement