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.

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