Skip to content

Instantly share code, notes, and snippets.

@jeffiar
Created August 3, 2020 22:56
Show Gist options
  • Save jeffiar/81270ec1e62ba550600cc77e25b267de to your computer and use it in GitHub Desktop.
Save jeffiar/81270ec1e62ba550600cc77e25b267de to your computer and use it in GitHub Desktop.
" jeffjar's .vimrc
" PLUGIN MANAGER =========================================
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim' " itself
Plugin 'tpope/vim-commentary' " commenting with gc
Plugin 'Raimondi/delimitMate' " automatic () completion
Plugin 'itchyny/lightline.vim' " light cool-looking status line
Plugin 'lervag/vimtex' "for latex
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-repeat'
Plugin 'tpope/vim-fugitive'
Plugin 'vim-pandoc/vim-pandoc-syntax'
Plugin 'peterbjorgensen/sved' " synctex
Plugin 'arcticicestudio/nord-vim'
Plugin 'altercation/vim-colors-solarized'
Plugin 'junegunn/goyo.vim'
call vundle#end()
" BASIC SETTINGS ========================================
set cindent tabstop=4 softtabstop=4 expandtab shiftwidth=4
filetype plugin indent on
syntax on
set backspace=indent,eol,start
set history=999
set mouse=a
set incsearch
set wildmode=list:full
set noswapfile
set gdefault " No need to :s/foo/bar/g
color nord
" tmux sets $TERM so vim knows it can use 256 colors, other terminals might not.
if empty($TMUX)
set t_Co=256
endif
" GVIM SETTINGS =================================
if has('gui_running')
set guifont=Fira\ Code\ Medium\ 14
set guioptions-=r " No right scroll bar
set guioptions-=L " No left scroll bar
set guioptions-=T " No toolbar
set guioptions-=m " No menu
color nord
let g:tex_flavor='xelatex'
" let g:vimtex_view_general_viewer = '"C:\Program Files (x86)\SumatraPDF\SumatraPDF.exe"'
endif
" MORE SETTINGS ========================================
" Line cursor in insert mode; Block otherwise.
let &t_SI = "\e[6 q"
let &t_EI = "\e[2 q"
set tabstop=4
set laststatus=2 " always display status line
set ruler " show cursor position on status line
set showcmd " Show keystrokes being entered onto the screen
set noshowmode " Since we use powerline, no need to show `--INSERT--`
set nowarn " no [file not changed] shit
set noequalalways " window size doesn't change when resizing things
set diffopt+=vertical " vimdiff runs a vertical split
set lazyredraw " no redraw during macros for faster stuff
set number " show line number on left
set relativenumber " Relative line numbers so we can do stuff like `4j` easier
set virtualedit+=block " In visual block mode, we're not restricted to text
set display=lastline " If last line is too long, don't cut it off and put @'s
set linebreak " Break lines at word boundaries, and ...
set showbreak=... " next line begins with ... to clear it's a continuation
" Settings for netrw, vim's built-in plugin for browsing directories
let g:netrw_banner = 0 " Don't show their banner cuz it takes up space
let g:netrw_liststyle = 3 " Display directories as trees, it's pretty
let g:netrw_sizestyle = "h" " Show 1M instead of 1024 when displaying filesize
let g:netrw_browsex_viewer= "xdg-open" " gx opens files in default viewer
" KEY MAPPINGS ===========================
" Escape key is far away, remap to kj. Cancel insert with C-c, just like in bash.
inoremap kj <ESC>
inoremap <C-c> <ESC>u
nnoremap U <C-R>
nnoremap <up> 5<C-Y>
nnoremap <down> 5<C-E>
" We don't want too 'hop' wrapped too-long lines when we press j/k.
" We also want to maintain default j/k functionality.
noremap j gj
noremap k gk
noremap <M-j> j
noremap <M-k> k
" End-of-line ($) and beginning-of-line (^) are too far away.
noremap H g^
noremap L g$
onoremap H ^
onoremap L $
" Switch windows with CTRL-<direction> to save some keypresses.
nnoremap <C-j> <C-w>j
nnoremap <C-h> <C-w>h
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" 'qq' starts recording macro, 'q' stops, 'Q' plays the macro.
" We can play macro (Q) or repeat (.) on a visual selection of lines too.
nnoremap Q @q
vnoremap Q :normal Q<CR>
vnoremap . :normal .<CR>
" Just like in bash, press C-p to search through past commands matching prefix.
cnoremap <C-p> <UP>
cnoremap <C-n> <down>
" Our leader is backslash. Here we set some basic leader-key mappings.
let mapleader="\\"
nnoremap <space> :
nnoremap <leader>w :w<cr>
nnoremap <leader>\ :set hlsearch!<cr>
nnoremap <leader>ev :e $MYVIMRC<cr>
nnoremap <leader>sv :so $MYVIMRC<cr>
nnoremap <leader>ya mxggVG"+y'x
nnoremap <leader>] :bp<cr>
nnoremap <leader>[ :bn<cr>
nnoremap <leader>r :set wrap!<cr>
nnoremap <leader>v :set paste!<cr>
" Yank/paste to the system clipboard with \y or \p
noremap <Leader>P "+P
noremap <Leader>p "+p
noremap <Leader>y "+y
" Open up the directory browser on the left side in a new buffer.
nnoremap <Leader>d :25Lex<cr>
" Comment out lines with \c (commentary plugin)
map <Leader>c gc
imap <tab><tab> <plug>delimitMateS-Tab
" Quickfix window open/close
nnoremap <Leader>= :copen<cr>
nnoremap <Leader>- :cclose<cr>
" FILETYPE SETTINGS ============================
" These should really be functions but whatever
augroup pandoc_syntax
au BufNewFile,BufFilePre,BufRead *.md set filetype=markdown.pandoc
augroup END
augroup filetypedetect
autocmd BufRead,BufNewFile *mutt-* setfiletype mail
autocmd BufRead,BufNewFile *mutt-* setlocal fo=wtqc
autocmd BufRead,BufNewFile *mutt-* setlocal nojs
autocmd BufRead,BufNewFile *mutt-* setlocal nosmartindent
autocmd BufRead,BufNewFile *mutt-* match ErrorMsg '\s\+$'
" autocmd BufRead,BufNewFile *mutt-* set background=light
" autocmd BufRead,BufNewFile *mutt-* color solarized
augroup END
augroup texmappings
autocmd Filetype tex nmap <Leader>se VS\equation*<CR>
autocmd Filetype tex nmap <Leader>sa VS\align*<CR>
autocmd Filetype tex vmap <Leader>sc S}i\cancel<esc>
autocmd Filetype tex vmap <Leader>su S}i\underbrace<esc>l%a_{}<esc>
autocmd Filetype tex nmap <Leader>k I\includegraphics[width=0.5\textwidth]{<esc>Ea}<esc>h:silent exec '!kolourpaint %:h/<cfile>'<cr>:redraw!<cr>
" autocmd Filetype tex setlocal fo=watqc
augroup END
" PLUGIN SETTINGS ==============================
" When we type {<cr>, we want the {} to open up like we expect.
let delimitMate_expand_cr = 1
" We have a patched font, so make the status line look pretty
let g:lightline = {
\ 'colorscheme' : 'nord',
\ 'separator': { 'left': '', 'right': '' },
\ 'subseparator': { 'left': '', 'right': '' }
\ }
" let g:pandoc#syntax#conceal#urls = 1
nnoremap <leader>z :Goyo<CR>
let g:vimtex_quickfix_latexlog = {'default' : 0}
" let g:vimtex_quickfix_latexlog = {
" \ 'overfull' : 0,
" \ 'underfull' : 0,
" \ 'packages' : {
" \ 'default' : 0,
" \ },
" \}
let g:vimtex_view_general_options = '--unique file:@pdf\#src:@line@tex'
let g:vimtex_view_general_options_latexmk = '--unique'
nnoremap <F4> :call SVED_Sync()<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment