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.

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