self-bootstrapping vimrc's
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.

197 lines
4.1 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. "vim:ft=vim
  2. filetype plugin indent on
  3. filetype on
  4. syntax on
  5. let g:mapleader=" "
  6. let g:just_installed = 0
  7. set backspace=indent,eol,start
  8. function! InstallPlug()
  9. if !filereadable(expand("~/.vim/autoload/plug.vim"))
  10. " try to install plug using curl and wget
  11. " If installation succeeds, we should source vim plug.
  12. if !executable('git')
  13. echom 'git not found.'
  14. finish
  15. endif
  16. if executable('curl')
  17. let result = system('curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim')
  18. if v:shell_error == 0
  19. let g:just_installed = 1
  20. return
  21. endif
  22. endif
  23. echom 'curl failed, trying wget. ' . result
  24. if executable('wget') && executable('mkdir')
  25. let result = system('mkdir -p ~/.vim/autoload && wget -O ~/.vim/autoload/plug.vim https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim')
  26. if v:shell_error == 0
  27. let g:just_installed = 1
  28. return
  29. endif
  30. endif
  31. echom 'wget failed too. ' . result
  32. finish
  33. endif
  34. endfu
  35. call InstallPlug()
  36. if g:just_installed == 1
  37. source ~/.vim/autoload/plug.vim
  38. endif
  39. call plug#begin()
  40. Plug 'catppuccin/vim'
  41. Plug 'junegunn/seoul256.vim'
  42. Plug 'Townk/vim-autoclose'
  43. Plug 'tpope/vim-fugitive'
  44. Plug 'vim-airline/vim-airline'
  45. Plug 'vim-airline/vim-airline-themes'
  46. Plug 'junegunn/goyo.vim'
  47. Plug 'junegunn/limelight.vim'
  48. call plug#end()
  49. " options
  50. set nu
  51. set rnu
  52. set mouse+=a
  53. set linebreak
  54. set shiftwidth=2
  55. set tabstop=2
  56. set softtabstop=2
  57. set expandtab
  58. set smarttab
  59. set shiftround
  60. set autoindent
  61. set textwidth=80
  62. set colorcolumn=80
  63. set nowrap
  64. set undodir=~/.vim/undofiles
  65. set undofile nohlsearch incsearch
  66. set scrolloff=7
  67. set wildmode=longest,list,full
  68. set wildmenu
  69. autocmd FileType tex,text set nosmarttab autoindent
  70. autocmd Filetype python set textwidth=0 formatprg=autopep8 shiftwidth=4 tabstop=4 softtabstop=4
  71. autocmd FileType c,cpp,slang set nosmarttab autoindent
  72. autocmd Filetype markdown set nosmarttab shiftwidth=4 tabstop=4 softtabstop=4 autoindent
  73. autocmd BufReadPost *
  74. \ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
  75. \ | exe "normal! g`\""
  76. \ | endif
  77. " Remaps
  78. nnoremap <C-h> <C-w>h
  79. nnoremap <C-j> <C-w>j
  80. nnoremap <C-k> <C-w>k
  81. nnoremap <C-l> <C-w>l
  82. nnoremap <C-h> <C-w>h
  83. nnoremap <C-j> <C-w>j
  84. nnoremap <C-k> <C-w>k
  85. nnoremap <C-l> <C-w>l
  86. inoremap <A-a> ā
  87. inoremap <A-e> ē
  88. inoremap <A-i> ī
  89. inoremap <A-o> ō
  90. inoremap <A-u> ū
  91. nnoremap <F12> :w<BAR>:!texbld run compile<CR>
  92. nnoremap <F5> :w<BAR>:!./test.sh<CR>
  93. vnoremap J :m '>+1<CR>gv=gv
  94. vnoremap K :m '<-2<CR>gv=gv
  95. nnoremap J mzJ`z
  96. nnoremap <C-d> <C-d>zz
  97. nnoremap <C-u> <C-u>zz
  98. nnoremap n nzzzv
  99. nnoremap N Nzzzv
  100. xnoremap <leader>p _dP
  101. vnoremap <leader>y +y
  102. nnoremap <leader>y +y
  103. nnoremap <leader>Y +Y
  104. nnoremap <leader>x :!chmod +x %:p<CR>
  105. nnoremap <leader>X :!chmod -x %<CR>
  106. nnoremap <leader>e :! %:p<CR>
  107. nnoremap <leader>1 1gt
  108. nnoremap <leader>2 2gt
  109. nnoremap <leader>3 3gt
  110. nnoremap <leader>4 4gt
  111. nnoremap <leader>5 5gt
  112. nnoremap <leader>6 6gt
  113. nnoremap <leader>7 7gt
  114. nnoremap <leader>8 8gt
  115. nnoremap <leader>9 9gt
  116. nnoremap <leader>b :wprev<CR>
  117. nnoremap <leader>n :wnext<CR>
  118. "netrw
  119. nnoremap <C-n> :20Lexplore<CR>
  120. nnoremap <leader>pv :Explore<CR>
  121. " tmux
  122. let s:tmux=$TMUX
  123. if s:tmux != ''
  124. nnoremap <C-f> <cmd>!tmuxs<CR>
  125. endif
  126. " disable ex mode
  127. nnoremap Q <nop>
  128. " Plugin options must go at the bottom of the file.
  129. " install plugins
  130. if g:just_installed == 1
  131. echom 'Installing Plugins...'
  132. PlugInstall
  133. endif
  134. if has('gui')
  135. set guifont=JetBrainsMono\ Nerd\ Font\ 13
  136. endif
  137. if has('termguicolors')
  138. set termguicolors
  139. set background=dark
  140. colorscheme catppuccin_mocha
  141. let g:airline_theme = "catppuccin_mocha"
  142. let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
  143. let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
  144. else
  145. echo 'no termguicolors, falling back to seoul256'
  146. let g:seoul256_background = 234
  147. let g:airline_theme = "seoul256"
  148. set background=dark
  149. colorscheme seoul256
  150. endif
  151. autocmd! User GoyoEnter Limelight
  152. autocmd! User GoyoLeave Limelight!
  153. let g:airline#extensions#tabline#enabled = 1
  154. nnoremap <leader>z :Goyo <CR>
  155. nnoremap <leader>gs :Git <CR>