Dotfiles for my tiling window manager + terminal workflow.
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.

434 lines
13 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. " vim: fdm=marker ft=vim.go-template
  2. " set x=y [[[ "
  3. set autoindent
  4. set autoread
  5. set background=dark
  6. " set colorcolumn=80
  7. set clipboard+=unnamedplus
  8. set diffopt=filler,context:3
  9. set encoding=utf-8
  10. set expandtab
  11. " set foldmethod=indent
  12. set foldmethod=marker
  13. set hlsearch
  14. set linebreak
  15. set linespace=5
  16. set mouse=a
  17. " set mouse=c
  18. " set noswapfile
  19. set relativenumber
  20. set shiftwidth=4
  21. set tabstop=4
  22. " set t_Co=256
  23. " set termguicolors
  24. " set timeoutlen=500
  25. set timeoutlen=350
  26. " set tw=80
  27. set tw=75
  28. set undodir=~/.vim/undo
  29. set undofile
  30. " set updatetime=1000
  31. set updatetime=500
  32. autocmd VimResized * wincmd =
  33. filetype plugin on
  34. filetype indent on
  35. syntax on
  36. au CursorHold * checktime
  37. " cursor indicator [[[ "
  38. " set listchars=tab:\|\
  39. " set list
  40. " set cursorcolumn
  41. " set cursorline
  42. " ]]] cursor indicator "
  43. " ]]] set x=y "
  44. " commands for file types [[[ "
  45. autocmd BufNewFile,BufRead .* set syntax=sh
  46. autocmd FileType *css,htmldjango,html,javascript,json,markdown,tex,text,yaml set tabstop=2 shiftwidth=2
  47. " autocmd BufNewFile,BufRead *.md set filetype=markdown
  48. " autocmd Filetype markdown set textwidth=0
  49. " autocmd Filetype html set foldmarker=0
  50. autocmd BufNewFile,BufRead *.gd set expandtab!
  51. autocmd Filetype go set expandtab! sw=4
  52. autocmd Filetype markdown map <F8> :LivedownToggle<CR>
  53. autocmd Filetype markdown nnoremap <Tab> <Esc>>>A
  54. autocmd Filetype markdown inoremap <S-Tab> <Esc><<A
  55. autocmd Filetype markdown inoremap > <Esc>>>A
  56. autocmd Filetype markdown inoremap >> >
  57. autocmd FileType markdown,tex,text set spell spelllang=en_us
  58. autocmd Filetype json nnoremap <leader>j :%!python -m json.tool<CR>
  59. autocmd Filetype json set foldmethod=marker
  60. autocmd FileType sh map <F8> :!clear && shellcheck %<CR>
  61. autocmd FileType tex set updatetime=3000
  62. autocmd FileType tex map <F8> :VimtexCompile<CR>
  63. autocmd VimEnter *.tex VimtexCompile
  64. autocmd VimLeave *.tex !tex-clean %:p
  65. autocmd BufNewFile,BufRead *.tmpl set tw=0 sw=2 ft=go-template fmr=[[[,]]]
  66. " " auto-reload vimrc [[[ "
  67. " augroup myvimrc
  68. " au!
  69. " au BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif
  70. " augroup END
  71. " " ]]] auto-reload vimrc "
  72. " ]]] commands for file types "
  73. " commands for specific files [[[ "
  74. autocmd BufNewFile,BufRead watson*.fish set tabstop=2 shiftwidth=2 expandtab
  75. autocmd BufWritePost config.def.h silent !cd %:p:h; sudo rm config.h; sudo bear make install
  76. " autocmd BufRead config.def.h map <F8> :silent !cd %:p:h; sudo rm config.h; sudo bear make install<CR>
  77. autocmd BufRead config.def.h map <F10> :silent !cd %:p:h<CR>:!sudo rm config.h; sudo bear make install<CR>
  78. autocmd BufRead config.def.h set updatetime=3000
  79. autocmd BufRead commit-msg.txt set filetype=gitcommit tw=72
  80. " autocmd BufWritePost key_* !sync-shortcuts
  81. autocmd BufNewFile,BufRead key_* map <F1> :w<CR>:silent !sync-shortcuts<CR>
  82. " map <F1> :silent !scp %:p k@192.168.0.17:/home/k/a1<CR>
  83. " map <F2> :silent !scp -P 2222 e1.html e1_style.css kevin@127.0.0.1:/home/kevin/Downloads/e1<CR>
  84. " map <F6> :make -C ~/Documents/resume cv<CR>
  85. " ]]] commands for specific files "
  86. " vim-plug [[[
  87. " plug auto-install
  88. if empty(glob('~/.vim/autoload/plug.vim'))
  89. silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
  90. \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  91. autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
  92. endif
  93. call plug#begin('~/.vim/plugged')
  94. " prequisite for other plugins
  95. Plug 'vim-scripts/L9'
  96. " find files from within Vim
  97. " Plug 'vim-scripts/FuzzyFinder'
  98. " Gotham color scheme
  99. " Plug 'whatyouhide/vim-gotham'
  100. " " collection of Vim color schemes
  101. " Plug 'flazz/vim-colorschemes'
  102. " " preview Vim color scheme easily within Vim
  103. " Plug 'xolox/vim-colorscheme-switcher'
  104. " " prerequisite for above plugin
  105. " Plug 'xolox/vim-misc'
  106. " automatically save buffers upon returning to normal mode
  107. Plug '907th/vim-auto-save'
  108. let g:auto_save = 1
  109. let g:auto_save_events = ["CursorHold", "CursorHoldI"]
  110. " autocmd VimEnter *.tex let g:auto_save = 0
  111. " provides various functionality for writing LaTeX in Vim
  112. Plug 'lervag/vimtex'
  113. " au BufWritePost *.tex silent call Tex_RunLaTeX()
  114. au BufWritePost *.tex silent !pkill -USR1 xdvi.bin
  115. let g:vimtex_view_general_viewer = 'zathura'
  116. let g:vimtex_quickfix_latexlog = {
  117. \ 'overfull' : 0,
  118. \ 'underfull' : 0,
  119. \ 'global' : 0,
  120. \ 'unused' : 0,
  121. \}
  122. " let g:vimtex_compiler_latexmk = {
  123. " \ 'continuous' : 0,
  124. " \}
  125. {{ if not (eq .chezmoi.username "root") }}
  126. " auto-completion for various languages
  127. Plug 'Valloric/YouCompleteMe'
  128. let g:ycm_filetype_blacklist = {
  129. \ 'tagbar': 1,
  130. \ 'qf': 1,
  131. \ 'notes': 1,
  132. \ 'unite': 1,
  133. \ 'vimwiki': 1,
  134. \ 'pandoc': 1,
  135. \ 'infolog': 1,
  136. \ 'mail': 1
  137. \}
  138. {{ end }}
  139. " wrote short bits of text that expand into whatever you want
  140. " demo: https://www.youtube.com/watch?v=Zik6u0klD40
  141. Plug 'SirVer/ultisnips'
  142. " better key bindings for UltiSnipsExpandTrigger
  143. let g:UltiSnipsExpandTrigger = "<tab>"
  144. let g:UltiSnipsJumpForwardTrigger = "<tab>"
  145. let g:UltiSnipsJumpBackwardTrigger = "<C-tab>"
  146. let g:ultisnips_javascript = {
  147. \ 'keyword-spacing': 'always',
  148. \ 'semi': 'never',
  149. \ 'space-before-function-paren': 'never',
  150. \ }
  151. " custom snippets
  152. Plug 'Kevin-Mok/vim-snippets'
  153. " to make YouCompleteMe work with UltiSnips (both use Tab)
  154. Plug 'ervandew/supertab'
  155. " make YCM compatible with UltiSnips (using supertab)
  156. let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
  157. let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
  158. let g:SuperTabDefaultCompletionType = '<C-n>'
  159. " easily comment/uncomment lines
  160. Plug 'scrooloose/nerdcommenter'
  161. let g:NERDTrimTrailingWhitespace = 1
  162. let g:NERDSpaceDelims = 1
  163. " add quotes/brackets around chunks of text easily
  164. Plug 'tpope/vim-surround'
  165. nmap S ys
  166. " navigate around file easily and precisely
  167. Plug 'easymotion/vim-easymotion'
  168. map <Space> <Plug>(easymotion-prefix)
  169. " status bar displaying various info about the current buffer
  170. Plug 'vim-airline/vim-airline'
  171. let g:airline_section_c = '%F'
  172. Plug 'vim-airline/vim-airline-themes'
  173. let g:airline_powerline_fonts = 1
  174. " continue Markdown lists when started
  175. Plug 'dkarter/bullets.vim'
  176. " coordinate Vim color scheme with terminal color scheme
  177. Plug 'dylanaraps/wal.vim'
  178. " repeat plugin commands
  179. Plug 'tpope/vim-repeat'
  180. " better Django support
  181. Plug 'tweekmonster/django-plus.vim'
  182. " auto-close brackets
  183. Plug 'jiangmiao/auto-pairs'
  184. let g:AutoPairsMapSpace = 0
  185. Plug 'henrik/vim-indexed-search'
  186. Plug 'PotatoesMaster/i3-vim-syntax'
  187. " vim file explorer
  188. Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
  189. Plug 'terryma/vim-multiple-cursors'
  190. " let g:multi_cursor_select_all_word_key='<C-a>'
  191. let g:multi_cursor_exit_from_visual_mode=0
  192. let g:multi_cursor_exit_from_insert_mode=0
  193. Plug 'dag/vim-fish'
  194. Plug 'shime/vim-livedown'
  195. Plug 'tpope/vim-fugitive'
  196. " auto reload file
  197. Plug 'djoshea/vim-autoread'
  198. " Plug 'mustache/vim-mustache-handlebars'
  199. " Plug 'trapd00r/vim-syntax-vidir-ls'
  200. Plug 'calviken/vim-gdscript3'
  201. " display hex colors in Vim
  202. Plug 'RRethy/vim-hexokinase'
  203. " ]]] vim-plug "
  204. " Mappings [[[ "
  205. call plug#end()
  206. " colorscheme gotham256
  207. colorscheme wal
  208. nnoremap v <C-V>
  209. nnoremap > >>
  210. nnoremap < <<
  211. inoremap << <Esc><<A
  212. " function keys [[[ "
  213. map <F3> :wa<CR>
  214. map <F4> :xa<CR>
  215. map <F5> :q!<CR>
  216. map <F6> :qa!<CR>
  217. map <F7> :AutoSaveToggle<CR>
  218. " reload file
  219. nnoremap <F9> :e<CR>
  220. nnoremap <F10> :set paste<CR>"+p:set nopaste<CR>
  221. nnoremap <F11> :set paste<CR>"*p:set nopaste<CR>
  222. " ]]] function keys "
  223. map <S-Enter> O<ESC>
  224. " swap text visually
  225. vnoremap <C-P> <Esc>`.``gvP``P
  226. ino <C-A> <C-O>yiW<End>=<C-R>=<C-R>0<CR>
  227. " splits [[[ "
  228. nnoremap <C-Down> <C-W><C-J>
  229. nnoremap <C-Up> <C-W><C-K>
  230. nnoremap <C-Right> <C-W><C-L>
  231. nnoremap <C-Left> <C-W><C-H>
  232. " Maximize height/width.
  233. nnoremap <C-g> <C-W>_
  234. nnoremap <C-w> <C-W>|
  235. " ]]] splits "
  236. " leader mappings [[[ "
  237. let mapleader="\<Space>"
  238. " find alias
  239. nnoremap <leader>a /^ <Left>
  240. " replace until end of line
  241. nnoremap <leader>c c$
  242. " delete entire buffer
  243. nnoremap <leader>d d$
  244. " delete entire buffer
  245. nnoremap <leader>dg ggdG
  246. " delete line into system clipboard
  247. nnoremap <leader>D "+dd
  248. " delete entire buffer into system clipboard
  249. nnoremap <leader>DA "+ggdG
  250. " find copied text
  251. nnoremap <leader>f q/p<CR>
  252. " find merge conflicts
  253. nnoremap <leader>fc /[<>=\|]\{7\}<CR>
  254. " reload folds
  255. nnoremap <leader>fmi :set foldmethod=indent<CR> zM
  256. nnoremap <leader>fmm :set foldmethod=marker<CR> zM
  257. " add marker foldmethod modeline
  258. nnoremap <leader>fi :YcmCompleter FixIt<CR>
  259. " find copied text
  260. nnoremap <leader>ft /TODO<CR>
  261. nnoremap <leader>g :YcmCompleter GoTo<CR>
  262. " vimdiff split
  263. nnoremap <leader>gd :Gvdiff
  264. nnoremap <leader>gdh :Gvdiff HEAD~
  265. nnoremap <leader>gdm :Gvdiff master<CR>
  266. " toggle search highlighting
  267. nnoremap <leader>h :set hlsearch! hlsearch?<CR>
  268. " help
  269. nnoremap <leader>he :help
  270. nnoremap <leader>ht :set tabstop=2 shiftwidth=2 expandtab<CR>
  271. nnoremap <leader>vhe :vert help
  272. " format current line
  273. nnoremap <leader>l Vgq
  274. " format this and next line
  275. nnoremap <leader>ll Vjgq
  276. " move cursor to middle of line
  277. nnoremap <leader>m :call cursor(0, len(getline('.'))/2)<CR>
  278. " apply normal command to selection
  279. vnoremap <leader>n q:anorm
  280. " don't wrap lines
  281. nnoremap <leader>nw :set nowrap<CR>
  282. " check if in neovim
  283. nnoremap <leader>nv :echo has('nvim')<CR>
  284. " Plug commands
  285. nnoremap <leader>p "*p
  286. nnoremap <leader>pli :PlugInstall<CR>
  287. nnoremap <leader>plc :PlugClean<CR>
  288. nnoremap <leader>plu :PlugUpdate<CR>
  289. " don't break lines
  290. nnoremap <leader>py :set tw=0<CR>
  291. " replace in next x lines
  292. nnoremap <leader>r q:i.,.+s///g<ESC>Fsi
  293. " replace in line
  294. nnoremap <leader>rl q:i.s///g<left><left><left>
  295. " replace in visual selection
  296. vnoremap <leader>r q:is///g<ESC>3ha
  297. " reload vim config
  298. nnoremap <leader>rv :source $MYVIMRC<CR>
  299. " replace in entire file
  300. nnoremap <leader>R q:i%s///g<ESC>2F/i
  301. vnoremap <leader>s :sort<CR>
  302. nnoremap <leader>sc :set spell spelllang=en_us<CR>
  303. " run current file in shell
  304. nnoremap <leader>sh :!%:p
  305. " sort lines until end of file
  306. nnoremap <leader>so q:i.,$sort<CR>
  307. " sort lines
  308. nnoremap <leader>sol q:i.,.+sort<ESC>Fsi
  309. " set syntax to shell (for dotfiles)
  310. nnoremap <leader>sys :set syn=sh<CR>
  311. vnoremap <leader>t :!tac<CR>
  312. " capitalize letter
  313. nnoremap <leader>u vU
  314. " open vimrc in vertical split
  315. nnoremap <leader>vv :vsp ~/.vimrc<CR>
  316. " copy next thing to system clipboard
  317. " nnoremap <leader>y "+
  318. " nnoremap <leader>Y "+Y
  319. nnoremap <leader>y y$
  320. " yank entire buffer
  321. nnoremap <leader>yg ggyG
  322. " toggle fold
  323. nnoremap <leader>z za
  324. " ]]] leader mappings "
  325. " ]]] Mappings "
  326. " Local Mappings [[[ "
  327. let maplocalleader="\\"
  328. " tex [[[ "
  329. autocmd Filetype tex inoremap <localleader>bt \bowtie
  330. autocmd Filetype tex inoremap <localleader>c \checkmark
  331. autocmd Filetype tex inoremap <localleader>d \delta
  332. autocmd Filetype tex inoremap <localleader>D \Delta
  333. autocmd Filetype tex inoremap <localleader>e \exists
  334. autocmd Filetype tex inoremap <localleader>ep \epsilon
  335. autocmd Filetype tex inoremap <localleader>fa \forall
  336. autocmd Filetype tex inoremap <localleader>g \geq
  337. autocmd Filetype tex inoremap <localleader>i \in
  338. autocmd Filetype tex inoremap <localleader>l \leq
  339. autocmd Filetype tex inoremap <localleader>lr \Leftrightarrow
  340. " autocmd Filetype tex inoremap <localleader>n \neg
  341. autocmd Filetype tex inoremap <localleader>n \neq
  342. autocmd Filetype tex inoremap <localleader>N \mathbb{N}
  343. autocmd Filetype tex inoremap <localleader>q \qquad
  344. autocmd Filetype tex inoremap <localleader>r \rightarrow
  345. autocmd Filetype tex inoremap <localleader>R \Rightarrow
  346. autocmd Filetype tex inoremap <localleader>s \subset
  347. autocmd Filetype tex inoremap <localleader>st such that
  348. autocmd Filetype tex inoremap <localleader>S \Sigma
  349. autocmd Filetype tex inoremap <localleader>t \times
  350. " autocmd Filetype tex inoremap <localleader>T $T$
  351. autocmd Filetype tex inoremap <localleader>T \Theta
  352. " replace bars/underscores in URL
  353. autocmd Filetype tex inoremap <localleader>url :.s/\([-_]\)/\\\1/g<CR>
  354. autocmd Filetype tex inoremap <localleader>v \vee
  355. autocmd Filetype tex inoremap <localleader>w \wedge
  356. autocmd Filetype tex inoremap <localleader>x $x$-axis
  357. autocmd Filetype tex inoremap <localleader>y $y$-axis
  358. autocmd Filetype tex inoremap <localleader>Z \mathbb{Z}
  359. " par3
  360. autocmd Filetype tex inoremap <localleader>wx $w(x)$
  361. autocmd Filetype tex inoremap <localleader>tx $t(x)$
  362. " ]]] tex "
  363. autocmd Filetype c inoremap <localleader>uc unsigned char
  364. autocmd BufNewFile,BufRead *.h nnoremap <localleader>x 0iextern <Esc>f{hc$;<Esc>
  365. autocmd Filetype fish inoremap <localleader>1 $argv[1]
  366. autocmd Filetype fish inoremap <localleader>2 $argv[2]
  367. autocmd Filetype javascript inoremap <localleader>x process.exit()
  368. autocmd Filetype markdown nnoremap <localleader>x 0f[lrx
  369. " nnoremap <localleader>x 0f[lrx
  370. autocmd Filetype go-template inoremap <localleader>e {{"{{ else }}"}}
  371. autocmd Filetype go-template inoremap <localleader>hd {{"{{ .chezmoi.homedir }}"}}
  372. autocmd Filetype go-template nnoremap <localleader>fp :%s/{{"{{{"}}/[[[/g<CR>:%s/}}}/]]]/g<CR>
  373. " ]]] Local Mappings "