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.

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