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.

337 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. "set nowrap
  79. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  80. " Filetype-specific options
  81. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  82. autocmd FileType plaintex,tex,latex syntax spell toplevel
  83. autocmd FileType plaintex,tex,latex set tw=80
  84. autocmd FileType tex,latex let g:tex_flavor = 'latex'
  85. autocmd FileType pug,jade set tw=80
  86. autocmd FileType text,markdown set tw=80 nocindent
  87. autocmd FileType swift set noexpandtab
  88. autocmd BufNewFile,BufRead *.cu set filetype=c
  89. autocmd BufNewFile,BufRead *.tp set filetype=taskpaper
  90. aug python
  91. " to override ftype/python.vim
  92. autocmd FileType python setlocal ts=4 sts=4 sw=4 noexpandtab
  93. aug end
  94. syntax spell toplevel
  95. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  96. " Key mapping customizations
  97. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  98. " Turn off search highlighting with Enter
  99. nnoremap <silent> <C-@> :nohlsearch<CR>
  100. nnoremap <silent> <C-l> :GitGutter<CR>:nohlsearch<CR><C-l>
  101. nnoremap <silent> <CR> :nohlsearch<CR><CR>
  102. " Center page on search (breaks 'search hit bottom...' message)
  103. "noremap n nzz
  104. "noremap N Nzz
  105. "noremap * *zz
  106. "noremap # #zz
  107. "noremap g* g*zz
  108. "noremap g# g#zz
  109. " Better scrolling keys
  110. noremap <C-n> <C-e>
  111. noremap <C-p> <C-y>
  112. inoremap <C-n> <C-o><C-e>
  113. inoremap <C-p> <C-o><C-y>
  114. " Allow saving files with sudo after starting vim
  115. cmap w!! w !sudo tee > /dev/null %
  116. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  117. " Plugin helper functions
  118. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  119. " Build script when installing/updating YouCompleteMe
  120. function! BuildYCM(info)
  121. " info is a dictionary with 3 fields
  122. " - name: name of the plugin
  123. " - status: 'installed', 'updated', or 'unchanged'
  124. " - force: set on PlugInstall! or PlugUpdate!
  125. if a:info.status == 'installed' || a:info.force
  126. " YCM dependencies for --all option:
  127. " gcc, make, cmake, python3, clang, mono, go, node.js, npm, rust, jdk8
  128. !./install.py --all
  129. endif
  130. endfunction
  131. " Pick a more convenient spot for the latency from loading YCM
  132. let g:YouCompleteMeLazyLoaded = 0
  133. function! LazyLoadingYMC()
  134. if g:YouCompleteMeLazyLoaded == 0
  135. let g:YouCompleteMeLazyLoaded = 1
  136. call plug#load('YouCompleteMe') | call youcompleteme#Enable()
  137. endif
  138. endfunction
  139. if g:use_pluggin_manager == 1
  140. autocmd BufRead * call timer_start(1, {id->execute('call LazyLoadingYMC()')} )
  141. " (also try BufWinEnter, InsertEnter, or CursorHold and CursorHoldI events)
  142. endif
  143. " Enable vimtex completions for YCM
  144. function! VimtexYCMSetup()
  145. if !exists('g:ycm_semantic_triggers')
  146. let g:ycm_semantic_triggers = {}
  147. endif
  148. if exists('g:vimtex#re#youcompleteme')
  149. let g:ycm_semantic_triggers.tex=g:vimtex#re#youcompleteme
  150. endif
  151. endfunction
  152. if has("autocmd")
  153. autocmd VimEnter * call VimtexYCMSetup()
  154. endif
  155. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  156. " Plugin setup with vim-plug
  157. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  158. " Use with :PlugInstall and :PlugUpdate
  159. "if exists('g:use_pluggin_manager') && g:use_pluggin_manager
  160. if g:use_pluggin_manager == 1
  161. " Set custom plugin directory
  162. call plug#begin('~/.vim/vim-plug')
  163. "Plug 'ycm-core/YouCompleteMe', { 'do': function('BuildYCM'), 'on': [] }
  164. Plug 'ycm-core/YouCompleteMe', { 'do': function('BuildYCM') }
  165. Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
  166. Plug 'dense-analysis/ale'
  167. Plug 'airblade/vim-gitgutter'
  168. Plug 'godlygeek/tabular'
  169. Plug 'tpope/vim-surround'
  170. Plug 'tpope/vim-unimpaired'
  171. Plug 'tpope/vim-speeddating'
  172. Plug 'tpope/vim-repeat'
  173. Plug 'lervag/vimtex'
  174. Plug 'junegunn/goyo.vim'
  175. Plug 'junegunn/limelight.vim'
  176. Plug 'joshdick/onedark.vim', { 'branch': 'main' }
  177. call plug#end()
  178. endif
  179. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  180. " Plugin options
  181. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  182. " Close the YCM preview window automatically
  183. let g:ycm_autoclose_preview_window_after_insertion = 1
  184. let g:ycm_autoclose_preview_window_after_completion = 1
  185. " Suggest language keywords
  186. let g:ycm_seed_identifiers_with_syntax = 1
  187. " Start with ale linting disabled
  188. let g:ale_enabled = 0
  189. " Activate Limelight with Goyo and fix colors
  190. autocmd! User GoyoEnter Limelight
  191. autocmd! User GoyoLeave Limelight!
  192. let g:limelight_conceal_ctermfg = 'gray'
  193. let g:limelight_conceal_guifg = 'DarkGray'
  194. " Set up color scheme for onedark.vim
  195. let s:colors = onedark#GetColors()
  196. let g:onedark_terminal_italics = 0
  197. let g:onedark_color_overrides = {
  198. \ "comment_grey": { "gui": "#8888A2", "cterm": "59", "cterm16": "7" }
  199. \}
  200. "Use 24-bit (true-color) mode in Vim/Neovim when outside tmux.
  201. "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
  202. "(see < http://sunaku.github.io/tmux-24bit-color.html#usage > for more information.)
  203. if (empty($TMUX))
  204. if (has("nvim"))
  205. "For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >
  206. let $NVIM_TUI_ENABLE_TRUE_COLOR=1
  207. endif
  208. "For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
  209. "Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
  210. " < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
  211. if (has("termguicolors"))
  212. set termguicolors
  213. endif
  214. endif
  215. if (has("autocmd"))
  216. augroup colorextend
  217. autocmd!
  218. " Override the `Identifier` background color in GUI mode
  219. autocmd ColorScheme * call onedark#extend_highlight("String", { "fg": s:colors.cyan })
  220. "autocmd ColorScheme * call onedark#extend_highlight("String", { "fg": { "gui": "#AAFFFF" } })
  221. augroup END
  222. augroup colorset
  223. autocmd!
  224. autocmd ColorScheme * call onedark#set_highlight("SpellBad", { "gui": "underline", "cterm": "underline" })
  225. autocmd ColorScheme * call onedark#set_highlight("SpellCap", { "gui": "italic", "cterm": "italic" })
  226. autocmd ColorScheme * call onedark#set_highlight("SpellRare", { "gui": "italic", "cterm": "italic" })
  227. autocmd ColorScheme * call onedark#set_highlight("SpellLocal", { })
  228. autocmd ColorScheme * call onedark#set_highlight("Keyword", { "fg": s:colors.blue })
  229. autocmd ColorScheme * call onedark#set_highlight("Identifier", { "fg": s:colors.blue })
  230. augroup END
  231. endif
  232. " onedark.vim override: Don't set a background color when running in a terminal;
  233. " `gui` is the hex color code used in GUI mode/nvim true-color mode
  234. " `cterm` is the color code used in 256-color mode
  235. " `cterm16` is the color code used in 16-color mode
  236. if (has("autocmd") && !has("gui_running"))
  237. augroup colorsetdefault
  238. autocmd!
  239. "let s:white = { "gui": "#ABB2BF", "cterm": "145", "cterm16" : "7" }
  240. let s:white = { "gui": "#FFFFFF", "cterm": "255", "cterm16" : "15" }
  241. autocmd ColorScheme * call onedark#set_highlight("Normal", { "fg": s:white }) " `bg` will not be styled since there is no `bg` setting
  242. augroup END
  243. endif
  244. syntax on
  245. colorscheme onedark
  246. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  247. " Plugin key mappings
  248. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  249. " (optionally press / instead of _ for :NERDTreeToggle)
  250. nnoremap <C-_> :NERDTreeToggle<CR>
  251. nnoremap <F2> :ALEToggle<CR>
  252. nmap <silent> [W <Plug>(ale_first)
  253. nmap <silent> ]W <Plug>(ale_last)
  254. nmap <silent> [w <Plug>(ale_previous_wrap)
  255. nmap <silent> ]w <Plug>(ale_next_wrap)
  256. nmap <silent> [e <Plug>(ale_previous_wrap_error)
  257. nmap <silent> ]e <Plug>(ale_next_wrap_error)
  258. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  259. " End
  260. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~