Another copy of my dotfiles. Because I don't completely trust GitHub.
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.
 
 
 
 
 
 

226 lines
6.7 KiB

"" __ _______ _____ _____
"" \ \ / / ____| ____|_ _|
"" \ V /| _| | _| | |
"" | | | |___| |___ | |
"" |_| |_____|_____| |_|
"" Yeet's vim configuration
" XDG Base Directory Specification
set runtimepath^=$XDG_CONFIG_HOME/vim
set runtimepath+=$XDG_DATA_HOME/vim
set runtimepath+=$XDG_CONFIG_HOME/vim/after
set packpath^=$XDG_DATA_HOME/vim,$XDG_CONFIG_HOME/vim
set packpath+=$XDG_CONFIG_HOME/vim/after,$XDG_DATA_HOME/vim/after
let g:netrw_home = $XDG_DATA_HOME."/vim"
call mkdir($XDG_DATA_HOME."/vim/spell", 'p')
set viewdir=$XDG_DATA_HOME/vim/view | call mkdir(&viewdir, 'p')
set backupdir=$XDG_CACHE_HOME/vim/backup | call mkdir(&backupdir, 'p')
set directory=$XDG_CACHE_HOME/vim/swap | call mkdir(&directory, 'p')
set undodir=$XDG_CACHE_HOME/vim/undo | call mkdir(&undodir, 'p')
let s:MRU_File = $XDG_CACHE_HOME."/vim/mru"
if !has('nvim') | set viminfofile=$XDG_CACHE_HOME/vim/viminfo | endif
" Set leader
let mapleader = ","
" Leader Mappings
nnoremap <Leader>c :w! \| !compiler "<c-r>%"<CR>
map <Leader>w :update<CR>
map <Leader>q :qall<CR>
map <Leader>gs :Gstatus<CR>
" map Q to gq for line formatting cuz Q is useless
nnoremap Q gq
" Recently edited files
map <Leader>h :History<CR>
" CtrlP use FZF (faster!)
nnoremap <C-p> :Files<CR>
nnoremap <Leader>b :Buffers<CR>
noremap <Leader>u :w<Home>silent <End> !urlview<CR>
" System clipboard copy
nnoremap <Leader>y "+y
nnoremap <Leader>p "+p
vnoremap <Leader>y "+y
vnoremap <Leader>p "+p
nnoremap <Leader>Y "+Y
nnoremap <Leader>P "+P
vnoremap <Leader>d "+d
nnoremap <Leader>D "+D
if has('nvim')
source ~/.config/nvim/plugin/plugins.vim
endif
syntax on
filetype plugin on
set autoread " Auto reload changed files
set wildmenu " Tab autocomplete in command mode
set backspace=indent,eol,start " http://vi.stackexchange.com/a/2163
set laststatus=2 " Show status line on startup
set splitright " Open new splits to the right
set splitbelow " Open new splits to the bottom
set lazyredraw " Reduce the redraw frequency
set ttyfast " Send more characters in fast terminals
set nowrap " Don't wrap long lines
set listchars=extends:→ " Show arrow if line continues rightwards
set listchars+=precedes:← " Show arrow if line continues leftwards
set nobackup nowritebackup noswapfile " Turn off backup files
set noerrorbells novisualbell " Turn off visual and audible bells
set expandtab shiftwidth=2 tabstop=2 " Two spaces for tabs everywhere
set history=500
set hidden " Save buffers automatically
set ignorecase smartcase " Search queries intelligently set case
set incsearch " Show search results as you type
set timeoutlen=1000 ttimeoutlen=0 " Remove timeout when hitting escape
set showcmd " Show size of visual selection
set cmdheight=2
set t_Co=256
noh
" set clipboard=unnamedplus
set shortmess+=c
set updatetime=300
if has("patch-8.1.1564")
" Recently vim can merge signcolumn and number column into one
set signcolumn=number
else
set signcolumn=yes
endif
" Persistent undo
set undodir=~/.local/share/vim/undo/
set undofile
set undolevels=1000
set undoreload=10000
" Ignored files/directories from autocomplete (and CtrlP)
set wildignore+=*/tmp/*
set wildignore+=*.so
set wildignore+=*.zip
set wildignore+=*/vendor/bundle/*
set wildignore+=*/node_modules/
" Enable autocompletion:
set wildmode=longest,list,full
" Disables automatic commenting on newline:
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
vnoremap . :normal .<CR>
map <leader>f :Goyo \| set linebreak<CR>
map <leader>o :setlocal spell! spelllang=en_us<CR>
set splitbelow splitright
map <leader>s :!clear && shellcheck -x %<CR>
cnoremap w!! execute 'silent! write !sudo tee % >/dev/null' <bar> edit!
"-------------------------------------------------------------------------------
" Interface
"-------------------------------------------------------------------------------
set number " Enable line numbers
set scrolloff=5 " Leave 5 lines of buffer when scrolling
set sidescrolloff=10 " Leave 10 characters of horizontal buffer when scrolling
"-------------------------------------------------------------------------------
" Colors & Formatting
"-------------------------------------------------------------------------------
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
if (has("termguicolors"))
set termguicolors
endif
let g:material_theme_style='ocean-community'
set background=dark
try
colorscheme material
catch /^Vim\%((\a\+)\)\=:E185/
colorscheme default
endtry
" Showcase comments in italics
highlight Comment cterm=italic gui=italic
" Easy tab navigation
nnoremap <C-Left> :tabprevious<CR>
nnoremap <C-Right> :tabnext<CR>
" Find/replace
vnoremap <C-r> "hy:%s/<C-r>h//g<left><left><left>
" DON'T USE ARROWS NORMIE
nnoremap <C-c> :echoe "Use Esc"<CR>
nnoremap <Left> :echoe "Use h"<CR>
nnoremap <Right> :echoe "Use l"<CR>
nnoremap <Up> :echoe "Use k"<CR>
nnoremap <Down> :echoe "Use j"<CR>
" Split resize
nnoremap <silent> <Leader>+ :exe "resize " . (winheight(0) * 3/2)<CR>
nnoremap <silent> <Leader>- :exe "resize " . (winheight(0) * 2/3)<CR>
" Make vim obey transparency
hi! Normal ctermbg=NONE guibg=NONE
hi! NonText ctermbg=NONE guibg=NONE
"-------------------------------------------------------------------------------
" Neovim-specific configurations
if has('nvim')
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
set termguicolors
" Fix vim-tmux-navigator <C-h> https://git.io/viGRU
nmap <BS> <C-W>h
" Fix vim-tmux-navigator <C-h> https://git.io/vS5QH
nmap <BS> :<C-u>TmuxNavigateLeft<CR>
" The following require plugins to be loaded so they should only be set in neovim
let g:vimtex_view_general_viewer = 'zathura'
" Syntastic max file size for python
let g:syntastic_python_pylint_post_args="--max-line-length=120"
" Widths fot several plugins
let g:goyo_width = 120 " Goyo
let g:Tlist_WinWidth = 40 " Tlist
endif
" Don't clear clipboard on exit
autocmd VimLeave * call system("xsel -ib", getreg('+'))
" Useful for GDB debugging
packadd termdebug
" File Specific Settings
if has("autocmd")
" Use skeleton files
augroup templates
autocmd BufNewFile *.* silent! execute '0r ~/.config/vim/templates/skeleton.'.expand("<afile>:e")
autocmd BufNewFile * %substitute#\[:VIM_EVAL:\]\(.\{-\}\)\[:END_EVAL:\]#\=eval(submatch(1))#ge
augroup END
autocmd BufWinLeave *.tex !texclear %:p " Run texclear on exit
autocmd BufRead calcurse-note.* :set filetype=markdown " Use markdown for calcurse notes
endif