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.

519 lines
15 KiB

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