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

"vim:ft=vim
filetype plugin indent on
filetype on
syntax on
let g:mapleader=" "
let g:just_installed = 0
set backspace=indent,eol,start
function! InstallPlug()
if !filereadable(expand("~/.vim/autoload/plug.vim"))
" try to install plug using curl and wget
" If installation succeeds, we should source vim plug.
if !executable('git')
echom 'git not found.'
finish
endif
if executable('curl')
let result = system('curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim')
if v:shell_error == 0
let g:just_installed = 1
return
endif
endif
echom 'curl failed, trying wget. ' . result
if executable('wget') && executable('mkdir')
let result = system('mkdir -p ~/.vim/autoload && wget -O ~/.vim/autoload/plug.vim https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim')
if v:shell_error == 0
let g:just_installed = 1
return
endif
endif
echom 'wget failed too. ' . result
finish
endif
endfu
call InstallPlug()
if g:just_installed == 1
source ~/.vim/autoload/plug.vim
endif
call plug#begin()
Plug 'catppuccin/vim'
Plug 'junegunn/seoul256.vim'
Plug 'Townk/vim-autoclose'
Plug 'tpope/vim-fugitive'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'junegunn/goyo.vim'
Plug 'junegunn/limelight.vim'
call plug#end()
" options
set nu
set rnu
set mouse+=a
set linebreak
set shiftwidth=2
set tabstop=2
set softtabstop=2
set expandtab
set smarttab
set shiftround
set autoindent
set textwidth=80
set colorcolumn=80
set nowrap
set undodir=~/.vim/undofiles
set undofile nohlsearch incsearch
set scrolloff=7
set wildmode=longest,list,full
set wildmenu
autocmd FileType tex,text set nosmarttab autoindent
autocmd Filetype python set textwidth=0 formatprg=autopep8 shiftwidth=4 tabstop=4 softtabstop=4
autocmd FileType c,cpp,slang set nosmarttab autoindent
autocmd Filetype markdown set nosmarttab shiftwidth=4 tabstop=4 softtabstop=4 autoindent
autocmd BufReadPost *
\ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
\ | exe "normal! g`\""
\ | endif
" Remaps
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
inoremap <A-a> ā
inoremap <A-e> ē
inoremap <A-i> ī
inoremap <A-o> ō
inoremap <A-u> ū
nnoremap <F12> :w<BAR>:!texbld run compile<CR>
nnoremap <F5> :w<BAR>:!./test.sh<CR>
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
nnoremap J mzJ`z
nnoremap <C-d> <C-d>zz
nnoremap <C-u> <C-u>zz
nnoremap n nzzzv
nnoremap N Nzzzv
xnoremap <leader>p _dP
vnoremap <leader>y +y
nnoremap <leader>y +y
nnoremap <leader>Y +Y
nnoremap <leader>x :!chmod +x %:p<CR>
nnoremap <leader>X :!chmod -x %<CR>
nnoremap <leader>e :! %:p<CR>
nnoremap <leader>1 1gt
nnoremap <leader>2 2gt
nnoremap <leader>3 3gt
nnoremap <leader>4 4gt
nnoremap <leader>5 5gt
nnoremap <leader>6 6gt
nnoremap <leader>7 7gt
nnoremap <leader>8 8gt
nnoremap <leader>9 9gt
nnoremap <leader>b :wprev<CR>
nnoremap <leader>n :wnext<CR>
"netrw
nnoremap <C-n> :20Lexplore<CR>
nnoremap <leader>pv :Explore<CR>
" tmux
let s:tmux=$TMUX
if s:tmux != ''
nnoremap <C-f> <cmd>!tmuxs<CR>
endif
" disable ex mode
nnoremap Q <nop>
" Plugin options must go at the bottom of the file.
" install plugins
if g:just_installed == 1
echom 'Installing Plugins...'
PlugInstall
endif
if has('gui')
set guifont=JetBrainsMono\ Nerd\ Font\ 13
endif
if has('termguicolors')
set termguicolors
set background=dark
colorscheme catppuccin_mocha
let g:airline_theme = "catppuccin_mocha"
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
else
echo 'no termguicolors, falling back to seoul256'
let g:seoul256_background = 234
let g:airline_theme = "seoul256"
set background=dark
colorscheme seoul256
endif
autocmd! User GoyoEnter Limelight
autocmd! User GoyoLeave Limelight!
let g:airline#extensions#tabline#enabled = 1
nnoremap <leader>z :Goyo <CR>
nnoremap <leader>gs :Git <CR>