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.

340 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 'lervag/vimtex'
  176. Plug 'junegunn/goyo.vim'
  177. Plug 'junegunn/limelight.vim'
  178. Plug 'joshdick/onedark.vim', { 'branch': 'main' }
  179. call plug#end()
  180. endif
  181. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  182. " Plugin options
  183. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  184. " Close the YCM preview window automatically
  185. let g:ycm_autoclose_preview_window_after_insertion = 1
  186. let g:ycm_autoclose_preview_window_after_completion = 1
  187. " Suggest language keywords
  188. let g:ycm_seed_identifiers_with_syntax = 1
  189. " Start with ale linting disabled
  190. let g:ale_enabled = 0
  191. " Activate Limelight with Goyo and fix colors
  192. autocmd! User GoyoEnter Limelight
  193. autocmd! User GoyoLeave Limelight!
  194. let g:limelight_conceal_ctermfg = 'gray'
  195. let g:limelight_conceal_guifg = 'DarkGray'
  196. " Set up color scheme for onedark.vim
  197. let s:colors = onedark#GetColors()
  198. let g:onedark_terminal_italics = 0
  199. let g:onedark_color_overrides = {
  200. \ "comment_grey": { "gui": "#8888A2", "cterm": "59", "cterm16": "7" }
  201. \}
  202. "Use 24-bit (true-color) mode in Vim/Neovim when outside tmux.
  203. "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
  204. "(see < http://sunaku.github.io/tmux-24bit-color.html#usage > for more information.)
  205. if (empty($TMUX))
  206. if (has("nvim"))
  207. "For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >
  208. let $NVIM_TUI_ENABLE_TRUE_COLOR=1
  209. endif
  210. "For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
  211. "Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
  212. " < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
  213. if (has("termguicolors"))
  214. set termguicolors
  215. endif
  216. endif
  217. if (has("autocmd"))
  218. augroup colorextend
  219. autocmd!
  220. " Override the `Identifier` background color in GUI mode
  221. autocmd ColorScheme * call onedark#extend_highlight("String", { "fg": s:colors.cyan })
  222. "autocmd ColorScheme * call onedark#extend_highlight("String", { "fg": { "gui": "#AAFFFF" } })
  223. augroup END
  224. augroup colorset
  225. autocmd!
  226. autocmd ColorScheme * call onedark#set_highlight("SpellBad", { "gui": "underline", "cterm": "underline" })
  227. autocmd ColorScheme * call onedark#set_highlight("SpellCap", { "gui": "italic", "cterm": "italic" })
  228. autocmd ColorScheme * call onedark#set_highlight("SpellRare", { "gui": "italic", "cterm": "italic" })
  229. autocmd ColorScheme * call onedark#set_highlight("SpellLocal", { })
  230. autocmd ColorScheme * call onedark#set_highlight("Keyword", { "fg": s:colors.blue })
  231. autocmd ColorScheme * call onedark#set_highlight("Identifier", { "fg": s:colors.blue })
  232. augroup END
  233. endif
  234. " onedark.vim override: Don't set a background color when running in a terminal;
  235. " `gui` is the hex color code used in GUI mode/nvim true-color mode
  236. " `cterm` is the color code used in 256-color mode
  237. " `cterm16` is the color code used in 16-color mode
  238. if (has("autocmd") && !has("gui_running"))
  239. augroup colorsetdefault
  240. autocmd!
  241. "let s:white = { "gui": "#ABB2BF", "cterm": "145", "cterm16" : "7" }
  242. let s:white = { "gui": "#FFFFFF", "cterm": "255", "cterm16" : "15" }
  243. autocmd ColorScheme * call onedark#set_highlight("Normal", { "fg": s:white }) " `bg` will not be styled since there is no `bg` setting
  244. augroup END
  245. endif
  246. syntax on
  247. colorscheme onedark
  248. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  249. " Plugin key mappings
  250. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  251. " (optionally press / instead of _ for :NERDTreeToggle)
  252. nnoremap <C-_> :NERDTreeToggle<CR>
  253. nnoremap <F2> :ALEToggle<CR>
  254. nmap <silent> [W <Plug>(ale_first)
  255. nmap <silent> ]W <Plug>(ale_last)
  256. nmap <silent> [w <Plug>(ale_previous_wrap)
  257. nmap <silent> ]w <Plug>(ale_next_wrap)
  258. nmap <silent> [e <Plug>(ale_previous_wrap_error)
  259. nmap <silent> ]e <Plug>(ale_next_wrap_error)
  260. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  261. " End
  262. "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~