.vimrc 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. " In the name of Allah, the most Gracious, the most Merciful.
  2. "
  3. " ▓▓▓▓▓▓▓▓▓▓
  4. " ░▓ Author ▓ Abdullah <https://abdullah.today>
  5. " ░▓▓▓▓▓▓▓▓▓▓
  6. " ░░░░░░░░░░
  7. "
  8. " ░█░█░▀█▀░█▄█
  9. " ░▀▄▀░░█░░█░█
  10. " ░░▀░░▀▀▀░▀░▀
  11. set ruler
  12. let g:zenburn_old_Visual = 1
  13. let g:zenburn_high_contrast = 1
  14. let g:zenburn_force_dark_Background = 1
  15. set fo+=w
  16. colorscheme vim-hardaway
  17. cmap w!! %!sudo tee > /dev/null %
  18. " Set relative number but also show current line number (no zero for current
  19. " line)
  20. set number relativenumber
  21. if exists('g:loaded_translate_plugin')
  22. finish
  23. endif
  24. let g:loaded_translate_plugin = 1
  25. command! -nargs=* Translate call translate#run(<q-args>)
  26. command! -nargs=* -range TranslateVisual call translate#visual(<q-args>)
  27. command! -nargs=* -range TranslateReplace call translate#replace(<q-args>)
  28. command! TranslateOpen call translate#open_trans_buf('')
  29. command! TranslateClear call translate#clear_trans_buf()
  30. set hlsearch
  31. autocmd! bufwritepost ~/.Xresources !xrdb -load ~/.Xresources && urxvtc
  32. autocmd! bufwritepost ~/.zshrc !source ~/.zshrc
  33. autocmd! bufwritepost ~/.config/sxhkd/sxhkdrc !pkill -USR1 -x sxhkd
  34. autocmd! bufwritepost ~/cfg/sxhkd/.config/sxhkd/sxhkdrc !pkill -USR1 -x sxhkd
  35. autocmd! bufwritepost ~/.zsh/custom-alias !source ~/.zsh/custom-alias
  36. autocmd! bufwritepost ~/cfg/zsh/.zsh/custom-alias !source ~/cfg/zsh/.zsh/custom-alias
  37. set nocp
  38. filetype on
  39. set bg=dark
  40. au BufNewFile,BufRead *Pkgfile set filetype=sh
  41. set textwidth=80
  42. if !&scrolloff
  43. set scrolloff=1
  44. endif
  45. if !&sidescrolloff
  46. set sidescrolloff=5
  47. endif
  48. set fileencoding=utf-8
  49. filetype plugin indent on
  50. set showmode
  51. set ai
  52. set sc
  53. set noincsearch
  54. set completeopt=menuone
  55. set ignorecase
  56. set smartcase
  57. set cursorline
  58. set cursorcolumn
  59. set noexpandtab
  60. set backspace=indent,eol,start
  61. syntax on
  62. if has('mouse') | set mouse=a | endif
  63. let mapleader=" "
  64. set hidden
  65. set history=10000
  66. filetype indent on
  67. filetype plugin on
  68. set linebreak
  69. set wrap
  70. set tabstop=2
  71. set shiftwidth=2
  72. set expandtab
  73. set clipboard=unnamed,unnamedplus
  74. set ttyfast
  75. set smartindent
  76. set wildmenu
  77. set autoindent
  78. set nohlsearch
  79. set lazyredraw
  80. set showmatch
  81. set noshowmode
  82. set undofile
  83. set undodir=~/.vim/undodir
  84. set viminfo='10,\"100,:20,%,n~/.viminfo
  85. set nobackup
  86. set showcmd
  87. set whichwrap=b,s,<,>,[,]
  88. set laststatus=2
  89. let g:colors_name = 'vim-hardaway'
  90. let g:airline_theme = 'vim_hardaway'
  91. let g:instant_markdown_browser = "/usr/bin/google-chrome-stable --new-window"
  92. let g:instant_markdown_logfile = '/tmp/instant_markdown.log'
  93. let g:instant_markdown_port = 47479
  94. let g:powerline_pycmd = 'py3'
  95. let g:airline#extensions#tabline#enabled = 1
  96. let g:airline#extensions#tabline#formatter = 'default'
  97. let g:airline_powerline_fonts = 1
  98. if !exists('g:airline_symbols')
  99. let g:airline_symbols = {}
  100. endif
  101. " unicode symbols
  102. let g:airline_left_sep = '»'
  103. let g:airline_left_sep = '▶'
  104. let g:airline_right_sep = '«'
  105. let g:airline_right_sep = '◀'
  106. let g:airline_symbols.linenr = '␊'
  107. let g:airline_symbols.linenr = '␤'
  108. let g:airline_symbols.linenr = '¶'
  109. let g:airline_symbols.branch = '⎇'
  110. let g:airline_symbols.paste = 'ρ'
  111. let g:airline_symbols.paste = 'Þ'
  112. let g:airline_symbols.paste = '∥'
  113. let g:airline_symbols.whitespace = 'Ξ'
  114. " airline symbols
  115. let g:airline_left_sep = ''
  116. let g:airline_left_alt_sep = ''
  117. let g:airline_right_sep = ''
  118. let g:airline_right_alt_sep = ''
  119. let g:airline_symbols.branch = ''
  120. let g:airline_symbols.readonly = ''
  121. let g:airline_symbols.linenr = ''
  122. :noremap <leader>u :w<Home>silent <End> !urlview<CR>
  123. autocmd BufEnter *.md exe 'noremap <F5> :!google-chrome-stable %:p<CR>'
  124. autocmd BufReadPost *
  125. \ if line("'\"") > 0 && line("'\"") <= line("$") |
  126. \ exe "normal! g`\"" |
  127. \ endif
  128. function! ResCur()
  129. if line("'\"") <= line("$")
  130. normal! g`"
  131. return 1
  132. endif
  133. endfunction
  134. function! DeleteFunctionUnderCursor()
  135. let line = getline('.')
  136. normal diwxml
  137. let i = 1
  138. let c = 1
  139. while i <= strlen(line)
  140. let char = getline('.')[col('.') - 1]
  141. if (char == '(')
  142. let c += 1
  143. elseif (char == ')')
  144. let c -= 1
  145. endif
  146. if (c == 0)
  147. normal x`l
  148. break
  149. endif
  150. normal l
  151. let i += 1
  152. endwhile
  153. endfunc
  154. command! -range=% DeleteFunctionUnderCursor <line1>,<line2>call DeleteFunctionUnderCursor()
  155. function! ToggleNumber()
  156. if(&relativenumber == 1)
  157. set norelativenumber
  158. set number
  159. else
  160. set relativenumber
  161. endif
  162. endfunc
  163. command! ToggleNumber call ToggleNumber()
  164. if !exists(":DiffOrig")
  165. command DiffOrig vert new | set bt=nofile | r ++edit | 0d_ | diffthis
  166. \ wincmd p | diffthis
  167. endif
  168. if &t_Co == 8 && $TERM !~# '^linux\|^Eterm|^screen-*'
  169. set t_Co=16
  170. endif
  171. " duplicate lines
  172. function! HighlightRepeats() range
  173. let lineCounts = {}
  174. let lineNum = a:firstline
  175. while lineNum <= a:lastline
  176. let lineText = getline(lineNum)
  177. if lineText != ""
  178. let lineCounts[lineText] = (has_key(lineCounts, lineText) ? lineCounts[lineText] : 0) + 1
  179. endif
  180. let lineNum = lineNum + 1
  181. endwhile
  182. exe 'syn clear Repeat'
  183. for lineText in keys(lineCounts)
  184. if lineCounts[lineText] >= 2
  185. exe 'syn match Repeat "^' . escape(lineText, '".\^$*[]') . '$"'
  186. endif
  187. endfor
  188. endfunction
  189. command! -range=% HighlightRepeats <line1>,<line2>call HighlightRepeats()
  190. autocmd FileType python set breakindentopt=shift:4
  191. " comfortable navigation
  192. noremap <buffer> j gj
  193. noremap <buffer> k gk
  194. noremap <buffer> gj j
  195. noremap <buffer> gk k
  196. " some pastebins commands
  197. " for GUI apps like browsers, paste the URL with CTRL+v
  198. command! -range=% CL <line1>,<line2>w !curl -F 'clbin=<-' https://clbin.com | tr -d '\n' | xclip -i -selection clipboard
  199. " Another good pastebin same as CTRL+v paste.
  200. command! -range=% VP <line1>,<line2>w !curl -F 'text=<-' http://vpaste.net | tr -d '\n' | xclip -i -selection clipboard
  201. " pastebin ptpb is now down but is the best pastebin ever
  202. command! -range=% PB <line1>,<line2>w !curl -F 'c=@-' https://ptpb.pw/ | sed -n 's/^url: //p' | xclip
  203. command! -range=% TB <line1>,<line2>w !fb
  204. command! -range=% GT <line1>,<line2>w !gist -c -p -f %
  205. map <F3> :! ( urxvt & ) &>/dev/null &<CR><CR>
  206. " Run python code without exiting vim
  207. nmap <silent> <Leader>m :w<CR>:!clear && python % > /tmp/vim-py.out && cat /tmp/vim-py.out && rm -f /tmp/vim-py.out<CR>
  208. " Run bash code without exiting vim
  209. nmap <silent> <Leader>b :w<CR>:!clear && bash % > /tmp/vim-bash.out && cat /tmp/vim-bash.out && rm -f /tmp/vim-bash.out<CR>
  210. " vim: set ft=vim :