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.

336 lines
11 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. " Use plugin manager if available
  24. if (filereadable($HOME."/.vim/autoload/plug.vim")) || (filereadable("/usr/share/vim/vimfiles/autoload/plug.vim"))
  25. let g:use_pluggin_manager = 1
  26. else
  27. let g:use_pluggin_manager = 0
  28. endif
  29. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  30. " Syntax highlighting
  31. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  32. "if has("syntax")
  33. " set t_Co=256
  34. " syntax on
  35. " " Uncomment the following 'let' lines if using xter16 color scheme
  36. " " Select colormap: 'soft', 'softlight', 'standard', or 'allblue'
  37. " let xterm16_colormap = 'allblue'
  38. " " Select brightness: 'low', 'med', 'high', 'default', or custom levels
  39. " let xterm16_brightness = 'high'
  40. " "Other override options:
  41. " let xterm16fg_Cursor = '555'
  42. " let xterm16bg_Normal = 'none'
  43. " let xterm16fg_Normal = 'none'
  44. " "Set color scheme
  45. " colorscheme xterm16
  46. "endif
  47. " If using a dark background within the editing area and syntax highlighting
  48. " turn on this option as well
  49. set background=dark
  50. " Remove background color from sign column/gutter
  51. highlight clear SignColumn
  52. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  53. " General options selection
  54. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  55. set showcmd " Show (partial) command in status line.
  56. set showmatch " Show matching brackets.
  57. set ignorecase " Do case insensitive matching
  58. set smartcase " Do smart case matching
  59. set mouse=a " Enable mouse usage (all modes)
  60. set nohlsearch " Turn off search highlighting
  61. "set hlsearch " Turn on search highlighting
  62. set shiftwidth=4 " Auto-indent amount when using cindent, <<, >>, etc.
  63. set softtabstop=4 " How many spaces represent a tab
  64. set tabstop=4 " Real tab size
  65. set autoindent " Indent level of new line set by previous line
  66. set cindent " Attempt to intelligently guess level of indent for new line
  67. set cinkeys-=0# " Don't un-indent comments
  68. set indentkeys-=0# " Don't un-indent comments
  69. set nf=octal,hex,alpha " additional ctrl-a increments
  70. set spell spelllang=en_us " Set spell check language
  71. set scrolloff=5 " Add visible lines beyond cursor at top or bottom of window
  72. set linebreak " Soft wrap whole words together
  73. set breakindent " Indent linebreaks to match
  74. set showbreak=\ \ \ ⇲ " Visual linebreak indicator
  75. set updatetime=100 " Make some plugins snappier
  76. set backspace=indent,eol,start " Fix OS X backspace behavior
  77. set ruler " Fix OS X missing ruler
  78. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  79. " Filetype-specific options
  80. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  81. autocmd FileType plaintex,tex,latex syntax spell toplevel
  82. autocmd FileType plaintex,tex,latex set tw=80
  83. autocmd FileType tex,latex let g:tex_flavor = 'latex'
  84. autocmd FileType pug,jade set tw=80
  85. autocmd FileType text,markdown set tw=80 nocindent
  86. autocmd FileType swift set noexpandtab
  87. autocmd BufNewFile,BufRead *.cu set filetype=c
  88. autocmd BufNewFile,BufRead *.tp set filetype=taskpaper
  89. aug python
  90. " to override ftype/python.vim
  91. autocmd FileType python setlocal ts=4 sts=4 sw=4 noexpandtab
  92. aug end
  93. syntax spell toplevel
  94. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  95. " Key mapping customizations
  96. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  97. " Turn off search highlighting with Enter
  98. nnoremap <silent> <C-@> :nohlsearch<CR>
  99. nnoremap <silent> <C-l> :GitGutter<CR>:nohlsearch<CR><C-l>
  100. nnoremap <silent> <CR> :nohlsearch<CR><CR>
  101. " Center page on search (breaks 'search hit bottom...' message)
  102. "noremap n nzz
  103. "noremap N Nzz
  104. "noremap * *zz
  105. "noremap # #zz
  106. "noremap g* g*zz
  107. "noremap g# g#zz
  108. " Better scrolling keys
  109. noremap <C-n> <C-e>
  110. noremap <C-p> <C-y>
  111. inoremap <C-n> <C-o><C-e>
  112. inoremap <C-p> <C-o><C-y>
  113. " Allow saving files with sudo after starting vim
  114. cmap w!! w !sudo tee > /dev/null %
  115. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  116. " Plugin helper functions
  117. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  118. " Build script when installing/updating YouCompleteMe
  119. function! BuildYCM(info)
  120. " info is a dictionary with 3 fields
  121. " - name: name of the plugin
  122. " - status: 'installed', 'updated', or 'unchanged'
  123. " - force: set on PlugInstall! or PlugUpdate!
  124. if a:info.status == 'installed' || a:info.force
  125. " YCM dependencies for --all option:
  126. " gcc, make, cmake, python3, clang, mono, go, node.js, npm, rust, jdk8
  127. !./install.py --all
  128. endif
  129. endfunction
  130. " Pick a more convenient spot for the latency from loading YCM
  131. let g:YouCompleteMeLazyLoaded = 0
  132. function! LazyLoadingYMC()
  133. if g:YouCompleteMeLazyLoaded == 0
  134. let g:YouCompleteMeLazyLoaded = 1
  135. call plug#load('YouCompleteMe') | call youcompleteme#Enable()
  136. endif
  137. endfunction
  138. if g:use_pluggin_manager == 1
  139. autocmd BufRead * call timer_start(1, {id->execute('call LazyLoadingYMC()')} )
  140. " (also try BufWinEnter, InsertEnter, or CursorHold and CursorHoldI events)
  141. endif
  142. " Enable vimtex completions for YCM
  143. function! VimtexYCMSetup()
  144. if !exists('g:ycm_semantic_triggers')
  145. let g:ycm_semantic_triggers = {}
  146. endif
  147. if exists('g:vimtex#re#youcompleteme')
  148. let g:ycm_semantic_triggers.tex=g:vimtex#re#youcompleteme
  149. endif
  150. endfunction
  151. if has("autocmd")
  152. autocmd VimEnter * call VimtexYCMSetup()
  153. endif
  154. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  155. " Plugin setup with vim-plug
  156. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  157. " Use with :PlugInstall and :PlugUpdate
  158. "if exists('g:use_pluggin_manager') && g:use_pluggin_manager
  159. if g:use_pluggin_manager == 1
  160. " Set custom plugin directory
  161. call plug#begin('~/.vim/vim-plug')
  162. "Plug 'ycm-core/YouCompleteMe', { 'do': function('BuildYCM'), 'on': [] }
  163. Plug 'ycm-core/YouCompleteMe', { 'do': function('BuildYCM') }
  164. Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
  165. Plug 'dense-analysis/ale'
  166. Plug 'airblade/vim-gitgutter'
  167. Plug 'godlygeek/tabular'
  168. Plug 'tpope/vim-surround'
  169. Plug 'tpope/vim-unimpaired'
  170. Plug 'tpope/vim-speeddating'
  171. Plug 'tpope/vim-repeat'
  172. Plug 'lervag/vimtex'
  173. Plug 'junegunn/goyo.vim'
  174. Plug 'junegunn/limelight.vim'
  175. Plug 'joshdick/onedark.vim'
  176. call plug#end()
  177. endif
  178. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  179. " Plugin options
  180. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  181. " Close the YCM preview window automatically
  182. let g:ycm_autoclose_preview_window_after_insertion = 1
  183. let g:ycm_autoclose_preview_window_after_completion = 1
  184. " Suggest language keywords
  185. let g:ycm_seed_identifiers_with_syntax = 1
  186. " Start with ale linting disabled
  187. let g:ale_enabled = 0
  188. " Activate Limelight with Goyo and fix colors
  189. autocmd! User GoyoEnter Limelight
  190. autocmd! User GoyoLeave Limelight!
  191. let g:limelight_conceal_ctermfg = 'gray'
  192. let g:limelight_conceal_guifg = 'DarkGray'
  193. " Set up color scheme for onedark.vim
  194. let s:colors = onedark#GetColors()
  195. let g:onedark_terminal_italics = 0
  196. let g:onedark_color_overrides = {
  197. \ "comment_grey": { "gui": "#8888A2", "cterm": "59", "cterm16": "7" }
  198. \}
  199. "Use 24-bit (true-color) mode in Vim/Neovim when outside tmux.
  200. "If you're using tmux version 2.2 or later, you can remove the outermost $TMUX check and use tmux's 24-bit color support
  201. "(see < http://sunaku.github.io/tmux-24bit-color.html#usage > for more information.)
  202. if (empty($TMUX))
  203. if (has("nvim"))
  204. "For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >
  205. let $NVIM_TUI_ENABLE_TRUE_COLOR=1
  206. endif
  207. "For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
  208. "Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
  209. " < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
  210. if (has("termguicolors"))
  211. set termguicolors
  212. endif
  213. endif
  214. if (has("autocmd"))
  215. augroup colorextend
  216. autocmd!
  217. " Override the `Identifier` background color in GUI mode
  218. autocmd ColorScheme * call onedark#extend_highlight("String", { "fg": s:colors.cyan })
  219. "autocmd ColorScheme * call onedark#extend_highlight("String", { "fg": { "gui": "#AAFFFF" } })
  220. augroup END
  221. augroup colorset
  222. autocmd!
  223. autocmd ColorScheme * call onedark#set_highlight("SpellBad", { "gui": "underline", "cterm": "underline" })
  224. autocmd ColorScheme * call onedark#set_highlight("SpellCap", { "gui": "italic", "cterm": "italic" })
  225. autocmd ColorScheme * call onedark#set_highlight("SpellRare", { "gui": "italic", "cterm": "italic" })
  226. autocmd ColorScheme * call onedark#set_highlight("SpellLocal", { })
  227. autocmd ColorScheme * call onedark#set_highlight("Keyword", { "fg": s:colors.blue })
  228. autocmd ColorScheme * call onedark#set_highlight("Identifier", { "fg": s:colors.blue })
  229. augroup END
  230. endif
  231. " onedark.vim override: Don't set a background color when running in a terminal;
  232. " `gui` is the hex color code used in GUI mode/nvim true-color mode
  233. " `cterm` is the color code used in 256-color mode
  234. " `cterm16` is the color code used in 16-color mode
  235. if (has("autocmd") && !has("gui_running"))
  236. augroup colorsetdefault
  237. autocmd!
  238. "let s:white = { "gui": "#ABB2BF", "cterm": "145", "cterm16" : "7" }
  239. let s:white = { "gui": "#FFFFFF", "cterm": "255", "cterm16" : "15" }
  240. autocmd ColorScheme * call onedark#set_highlight("Normal", { "fg": s:white }) " `bg` will not be styled since there is no `bg` setting
  241. augroup END
  242. endif
  243. syntax on
  244. colorscheme onedark
  245. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  246. " Plugin key mappings
  247. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  248. " (optionally press / instead of _ for :NERDTreeToggle)
  249. nnoremap <C-_> :NERDTreeToggle<CR>
  250. nnoremap <F2> :ALEToggle<CR>
  251. nmap <silent> [W <Plug>(ale_first)
  252. nmap <silent> ]W <Plug>(ale_last)
  253. nmap <silent> [w <Plug>(ale_previous_wrap)
  254. nmap <silent> ]w <Plug>(ale_next_wrap)
  255. nmap <silent> [e <Plug>(ale_previous_wrap_error)
  256. nmap <silent> ]e <Plug>(ale_next_wrap_error)
  257. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  258. " End
  259. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~