CLI config/dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

238 lines
7.6 KiB

  1. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2. " .vimrc
  3. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. " User-specified ~/.vimrc, compatible with vim on GNU/Linux and Apple OS X
  5. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7. " Functionality setup
  8. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  9. " Source a global configuration file if available
  10. if filereadable("/etc/vim/vimrc.local")
  11. source /etc/vim/vimrc.local
  12. endif
  13. " Uncomment the following to have Vim jump to the last position when reopening
  14. " a file
  15. if has("autocmd")
  16. au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
  17. endif
  18. " Uncomment the following to have Vim load indentation rules and plugins
  19. " according to the detected filetype.
  20. if has("autocmd")
  21. filetype plugin indent on
  22. endif
  23. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  24. " Syntax highlighting
  25. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  26. if has("syntax")
  27. set t_Co=256
  28. syntax on
  29. " Uncomment the following 'let' lines if using xter16 color scheme
  30. " Select colormap: 'soft', 'softlight', 'standard', or 'allblue'
  31. let xterm16_colormap = 'allblue'
  32. " Select brightness: 'low', 'med', 'high', 'default', or custom levels
  33. let xterm16_brightness = 'high'
  34. "Other override options:
  35. let xterm16fg_Cursor = '555'
  36. let xterm16bg_Normal = 'none'
  37. "Set color scheme
  38. colorscheme xterm16
  39. endif
  40. " If using a dark background within the editing area and syntax highlighting
  41. " turn on this option as well
  42. set background=dark
  43. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  44. " General options selection
  45. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  46. set showcmd " Show (partial) command in status line.
  47. set showmatch " Show matching brackets.
  48. set ignorecase " Do case insensitive matching
  49. set smartcase " Do smart case matching
  50. set mouse=a " Enable mouse usage (all modes)
  51. set hlsearch " Turn on search highlighting
  52. set shiftwidth=4 " Auto-indent amount when using cindent, <<, >>, etc.
  53. set softtabstop=4 " How many spaces represent a tab
  54. set tabstop=4 " Real tab size
  55. set autoindent " Indent level of new line set by previous line
  56. set cindent " Attempt to intelligently guess level of indent for new line
  57. set cinkeys-=0# " Don't un-indent comments
  58. set indentkeys-=0# " Don't un-indent comments
  59. set nf=octal,hex,alpha " additional ctrl-a increments
  60. set spell spelllang=en_us " Set spell check language
  61. set scrolloff=5 " Add visible lines beyond cursor at top or bottom of window
  62. set linebreak " Soft wrap whole words together
  63. set breakindent " Indent linebreaks to match
  64. set showbreak=\ \ \ ⇲ " Visual linebreak indicator
  65. set updatetime=100 " Make some plugins snappier
  66. set backspace=indent,eol,start " Fix OS X backspace behavior
  67. set ruler " Fix OS X missing ruler
  68. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  69. " Filetype-specific options
  70. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  71. autocmd FileType plaintex,tex,latex syntax spell toplevel
  72. autocmd FileType plaintex,tex,latex set tw=80
  73. autocmd FileType tex,latex let g:tex_flavor = 'latex'
  74. autocmd FileType pug,jade set tw=80
  75. autocmd FileType text set tw=80 nocindent
  76. autocmd BufNewFile,BufRead *.cu set filetype=c
  77. autocmd BufNewFile,BufRead *.tp set filetype=taskpaper
  78. aug python
  79. " to override ftype/python.vim
  80. autocmd FileType python setlocal ts=4 sts=4 sw=4 noexpandtab
  81. aug end
  82. syntax spell toplevel
  83. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  84. " Key mapping customizations
  85. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  86. " Turn off search highlighting with Enter
  87. nnoremap <silent> <CR> :nohlsearch<CR><CR>
  88. " Center page on search
  89. noremap n nzz
  90. noremap N Nzz
  91. noremap * *zz
  92. noremap # #zz
  93. noremap g* g*zz
  94. noremap g# g#zz
  95. " Better scrolling keys
  96. noremap <C-n> <C-e>
  97. noremap <C-p> <C-y>
  98. inoremap <C-n> <C-o><C-e>
  99. inoremap <C-p> <C-o><C-y>
  100. " Allow saving files with sudo after starting vim
  101. cmap w!! w !sudo tee > /dev/null %
  102. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  103. " Plugin helper functions
  104. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  105. " Build script when installing/updating YouCompleteMe
  106. function! BuildYCM(info)
  107. " info is a dictionary with 3 fields
  108. " - name: name of the plugin
  109. " - status: 'installed', 'updated', or 'unchanged'
  110. " - force: set on PlugInstall! or PlugUpdate!
  111. if a:info.status == 'installed' || a:info.force
  112. " YCM dependencies for --all option:
  113. " gcc, make, cmake, python3, clang, mono, go, node.js, npm, rust, jdk8
  114. !./install.py --all
  115. endif
  116. endfunction
  117. " Pick a more convenient spot for the latency from loading YCM
  118. let g:YouCompleteMeLazyLoaded = 0
  119. function! LazyLoadingYMC()
  120. if g:YouCompleteMeLazyLoaded == 0
  121. let g:YouCompleteMeLazyLoaded = 1
  122. call plug#load('YouCompleteMe') | call youcompleteme#Enable()
  123. endif
  124. endfunction
  125. autocmd BufRead * call timer_start(1, {id->execute('call LazyLoadingYMC()')} )
  126. " (also try BufWinEnter, InsertEnter, or CursorHold and CursorHoldI events)
  127. " Enable vimtex completions for YCM
  128. if !exists('g:ycm_semantic_triggers')
  129. let g:ycm_semantic_triggers = {}
  130. endif
  131. autocmd VimEnter * let g:ycm_semantic_triggers.tex=g:vimtex#re#youcompleteme
  132. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  133. " Plugin setup with vim-plug
  134. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  135. " Use with :PlugInstall and :PlugUpdate
  136. " Set custom plugin directory
  137. call plug#begin('~/.vim/vim-plug')
  138. Plug 'ycm-core/YouCompleteMe', { 'do': function('BuildYCM'), 'on': [] }
  139. Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
  140. Plug 'dense-analysis/ale'
  141. Plug 'airblade/vim-gitgutter'
  142. Plug 'godlygeek/tabular'
  143. Plug 'tpope/vim-surround'
  144. Plug 'tpope/vim-unimpaired'
  145. Plug 'tpope/vim-speeddating'
  146. Plug 'tpope/vim-repeat'
  147. Plug 'lervag/vimtex'
  148. call plug#end()
  149. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  150. " Plugin options
  151. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  152. " Close the YCM preview window automatically
  153. let g:ycm_autoclose_preview_window_after_insertion = 1
  154. let g:ycm_autoclose_preview_window_after_completion = 1
  155. " Start with ale linting disabled
  156. let g:ale_enabled = 0
  157. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  158. " Plugin key mappings
  159. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  160. " (optionally press / instead of _ for :NERDTreeToggle)
  161. nnoremap <C-_> :NERDTreeToggle<CR>
  162. nnoremap <F2> :ALEToggle<CR>
  163. nmap <silent> [W <Plug>(ale_first)
  164. nmap <silent> ]W <Plug>(ale_last)
  165. nmap <silent> [w <Plug>(ale_previous_wrap)
  166. nmap <silent> ]w <Plug>(ale_next_wrap)
  167. nmap <silent> [e <Plug>(ale_previous_wrap_error)
  168. nmap <silent> ]e <Plug>(ale_next_wrap_error)
  169. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  170. " End
  171. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~