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.

439 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. autocmd CursorHold * if !bufexists("[Command Line]") | checktime | endif
  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 VimLeave /etc/default/grub !sudo grub-mkconfig -o /boot/grub/grub.cfg
  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. Plug 'junegunn/goyo.vim'
  205. " ]]] vim-plug "
  206. " Mappings [[[ "
  207. call plug#end()
  208. " colorscheme gotham256
  209. colorscheme wal
  210. nnoremap v <C-V>
  211. nnoremap > >>
  212. nnoremap < <<
  213. inoremap << <Esc><<A
  214. " leader mappings [[[ "
  215. let mapleader="\<Space>"
  216. " find alias
  217. nnoremap <leader>a /^ <Left>
  218. " replace until end of line
  219. nnoremap <leader>c c$
  220. " delete entire buffer
  221. nnoremap <leader>d d$
  222. " delete entire buffer
  223. nnoremap <leader>dg ggdG
  224. " delete line into system clipboard
  225. nnoremap <leader>D "+dd
  226. " delete entire buffer into system clipboard
  227. nnoremap <leader>DA "+ggdG
  228. " find copied text
  229. nnoremap <leader>f q/p<CR>
  230. " find merge conflicts
  231. nnoremap <leader>fc /[<>=\|]\{7\}<CR>
  232. " reload folds
  233. nnoremap <leader>fmi :set foldmethod=indent<CR> zM
  234. nnoremap <leader>fmm :set foldmethod=marker<CR> zM
  235. " add marker foldmethod modeline
  236. nnoremap <leader>fi :YcmCompleter FixIt<CR>
  237. " find copied text
  238. nnoremap <leader>ft :se ft?
  239. nnoremap <leader>ftd /TODO<CR>
  240. nnoremap <leader>g :YcmCompleter GoTo<CR>
  241. " vimdiff split
  242. nnoremap <leader>gd :Gvdiff
  243. nnoremap <leader>gdh :Gvdiff HEAD~
  244. nnoremap <leader>gdm :Gvdiff master<CR>
  245. " toggle search highlighting
  246. nnoremap <leader>h :set hlsearch! hlsearch?<CR>
  247. " help
  248. nnoremap <leader>he :help
  249. nnoremap <leader>ht :set tabstop=2 shiftwidth=2 expandtab<CR>
  250. nnoremap <leader>vhe :vert help
  251. " format current line
  252. nnoremap <leader>l Vgq
  253. " format this and next line
  254. nnoremap <leader>ll Vjgq
  255. " move cursor to middle of line
  256. nnoremap <leader>m :call cursor(0, len(getline('.'))/2)<CR>
  257. " apply normal command to selection
  258. vnoremap <leader>n q:anorm
  259. " don't wrap lines
  260. nnoremap <leader>nw :set nowrap<CR>
  261. " check if in neovim
  262. nnoremap <leader>nv :echo has('nvim')<CR>
  263. " Plug commands
  264. nnoremap <leader>p "*p
  265. nnoremap <leader>pli :PlugInstall<CR>
  266. nnoremap <leader>plc :PlugClean<CR>
  267. nnoremap <leader>plu :PlugUpdate<CR>
  268. " don't break lines
  269. nnoremap <leader>py :set tw=0<CR>
  270. " replace in next x lines
  271. nnoremap <leader>r q:i.,.+s///g<ESC>Fsi
  272. " replace in line
  273. nnoremap <leader>rl q:i.s///g<left><left><left>
  274. " replace in visual selection
  275. vnoremap <leader>r q:is///g<ESC>3ha
  276. " reload vim config
  277. nnoremap <leader>rv :source $MYVIMRC<CR>
  278. " replace in entire file
  279. nnoremap <leader>R q:i%s///g<ESC>2F/i
  280. vnoremap <leader>s :sort<CR>
  281. nnoremap <leader>sc :set spell spelllang=en_us<CR>
  282. " run current file in shell
  283. nnoremap <leader>sh :!%:p
  284. " sort lines until end of file
  285. nnoremap <leader>so q:i.,$sort<CR>
  286. " sort lines
  287. nnoremap <leader>sol q:i.,.+sort<ESC>Fsi
  288. " set syntax to shell (for dotfiles)
  289. nnoremap <leader>sys :set syn=sh<CR>
  290. vnoremap <leader>t :!tac<CR>
  291. " capitalize letter
  292. nnoremap <leader>u vU
  293. " open vimrc in vertical split
  294. nnoremap <leader>vv :vsp ~/.vimrc<CR>
  295. " copy next thing to system clipboard
  296. " nnoremap <leader>y "+
  297. " nnoremap <leader>Y "+Y
  298. nnoremap <leader>y y$
  299. nnoremap <leader>yo :Goyo<CR>
  300. " yank entire buffer
  301. nnoremap <leader>yg ggyG
  302. " toggle fold
  303. nnoremap <leader>z za
  304. " ]]] leader mappings "
  305. " function keys [[[ "
  306. map <F3> :wa<CR>
  307. map <F4> :xa<CR>
  308. map <F5> :q!<CR>
  309. map <F6> :qa!<CR>
  310. map <F7> :AutoSaveToggle<CR>
  311. " reload file
  312. nnoremap <F9> :e<CR>
  313. nnoremap <F10> :set paste<CR>"+p:set nopaste<CR>
  314. nnoremap <F11> :set paste<CR>"*p:set nopaste<CR>
  315. " ]]] function keys "
  316. map <S-Enter> O<ESC>
  317. " swap text visually
  318. vnoremap <C-P> <Esc>`.``gvP``P
  319. ino <C-A> <C-O>yiW<End>=<C-R>=<C-R>0<CR>
  320. " splits [[[ "
  321. nnoremap <C-Down> <C-W><C-J>
  322. nnoremap <C-Up> <C-W><C-K>
  323. nnoremap <C-Right> <C-W><C-L>
  324. nnoremap <C-Left> <C-W><C-H>
  325. " Maximize height/width.
  326. nnoremap <C-g> <C-W>_
  327. nnoremap <C-w> <C-W>|
  328. " ]]] splits "
  329. " ]]] Mappings "
  330. " Local Mappings [[[ "
  331. let maplocalleader="\\"
  332. " tex [[[ "
  333. autocmd Filetype tex inoremap <localleader>bt \bowtie
  334. autocmd Filetype tex inoremap <localleader>c \checkmark
  335. autocmd Filetype tex inoremap <localleader>d \delta
  336. autocmd Filetype tex inoremap <localleader>D \Delta
  337. autocmd Filetype tex inoremap <localleader>e \exists
  338. autocmd Filetype tex inoremap <localleader>ep \epsilon
  339. autocmd Filetype tex inoremap <localleader>fa \forall
  340. autocmd Filetype tex inoremap <localleader>g \geq
  341. autocmd Filetype tex inoremap <localleader>i \in
  342. autocmd Filetype tex inoremap <localleader>l \leq
  343. autocmd Filetype tex inoremap <localleader>lr \Leftrightarrow
  344. " autocmd Filetype tex inoremap <localleader>n \neg
  345. autocmd Filetype tex inoremap <localleader>n \neq
  346. autocmd Filetype tex inoremap <localleader>N \mathbb{N}
  347. autocmd Filetype tex inoremap <localleader>q \qquad
  348. autocmd Filetype tex inoremap <localleader>r \rightarrow
  349. autocmd Filetype tex inoremap <localleader>R \Rightarrow
  350. autocmd Filetype tex inoremap <localleader>s \subset
  351. autocmd Filetype tex inoremap <localleader>st such that
  352. autocmd Filetype tex inoremap <localleader>S \Sigma
  353. autocmd Filetype tex inoremap <localleader>t \times
  354. " autocmd Filetype tex inoremap <localleader>T $T$
  355. autocmd Filetype tex inoremap <localleader>T \Theta
  356. " replace bars/underscores in URL
  357. autocmd Filetype tex inoremap <localleader>url :.s/\([-_]\)/\\\1/g<CR>
  358. autocmd Filetype tex inoremap <localleader>v \vee
  359. autocmd Filetype tex inoremap <localleader>w \wedge
  360. autocmd Filetype tex inoremap <localleader>x $x$-axis
  361. autocmd Filetype tex inoremap <localleader>y $y$-axis
  362. autocmd Filetype tex inoremap <localleader>Z \mathbb{Z}
  363. " par3
  364. autocmd Filetype tex inoremap <localleader>wx $w(x)$
  365. autocmd Filetype tex inoremap <localleader>tx $t(x)$
  366. " ]]] tex "
  367. autocmd Filetype c inoremap <localleader>uc unsigned char
  368. autocmd BufNewFile,BufRead *.h nnoremap <localleader>x 0iextern <Esc>f{hc$;<Esc>
  369. autocmd Filetype fish inoremap <localleader>1 $argv[1]
  370. autocmd Filetype fish inoremap <localleader>2 $argv[2]
  371. autocmd Filetype javascript inoremap <localleader>x process.exit()
  372. autocmd Filetype markdown inoremap <localleader>cb - [ ]
  373. autocmd Filetype markdown nnoremap <localleader>x 0f[lrx
  374. " nnoremap <localleader>x 0f[lrx
  375. autocmd Filetype go-template inoremap <localleader>e {{"{{ else }}"}}
  376. autocmd Filetype go-template inoremap <localleader>hd {{"{{ .chezmoi.homedir }}"}}
  377. autocmd Filetype go-template nnoremap <localleader>fp :%s/{{"{{{"}}/[[[/g<CR>:%s/}}}/]]]/g<CR>
  378. " ]]] Local Mappings "