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.

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