dots

git clone git://mattcarlson.org/repos/dots.git
Log | Files | Refs

vimrc (4624B)


      1 " better safe than sorry
      2 set nocompatible
      3 
      4 " xdg base directory support
      5 set runtimepath^=${XDG_CONFIG_HOME}/vim
      6 set runtimepath+=${XDG_DATA_HOME}/vim
      7 set runtimepath+=${XDG_CONFIG_HOME}/vim/after
      8 set packpath^=${XDG_DATA_HOME}/vim,${XDG_CONFIG_HOME}/vim
      9 set packpath+=${XDG_CONFIG_HOME}/vim/after,${XDG_DATA_HOME}/vim/after
     10 let g:netrw_home = $XDG_DATA_HOME."/vim"
     11 call mkdir($XDG_DATA_HOME."/vim/spell", 'p')
     12 set viewdir=${XDG_DATA_HOME}/vim/view      | call mkdir(&viewdir, 'p')
     13 set backupdir=${XDG_CACHE_HOME}/vim/backup | call mkdir(&backupdir, 'p')
     14 set directory=${XDG_CACHE_HOME}/vim/swap   | call mkdir(&directory, 'p')
     15 set undodir=${XDG_CACHE_HOME}/vim/undo     | call mkdir(&undodir,   'p')
     16 if !has('nvim') | set viminfofile=${XDG_CACHE_HOME}/vim/viminfo | endif
     17 
     18 " enable detection, plugin, and indent
     19 filetype plugin indent on
     20 
     21 " vim-plug: a minimalist vim plugin manager
     22 call plug#begin('~/.config/vim/plugged')
     23 Plug 'vim-airline/vim-airline'
     24 Plug 'vim-airline/vim-airline-themes'
     25 Plug 'cormacrelf/vim-colors-github'
     26 Plug 'fxn/vim-monochrome'
     27 Plug 'Valloric/YouCompleteMe'
     28 call plug#end()
     29 
     30 " proper colors in st
     31 set t_Co=256
     32 set termguicolors
     33 let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
     34 let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
     35 
     36 " enable github color scheme (dark)
     37 let g:github_colors_soft = 1
     38 set background=dark
     39 let g:github_colors_block_diffmark = 0
     40 colorscheme github
     41 
     42 " enable github color scheme for airline
     43 let g:airline_theme = "github"
     44 let g:lightline = { 'colorscheme': 'github' }
     45 
     46 " transparent background if compositor is running
     47 autocmd vimenter * hi Normal       guibg=NONE ctermbg=NONE
     48 autocmd vimenter * hi LineNr       guibg=NONE ctermbg=NONE
     49 autocmd vimenter * hi NonText      guibg=NONE ctermbg=NONE
     50 autocmd vimenter * hi EndOfBuffer  guibg=NONE ctermbg=NONE
     51 autocmd vimenter * hi Folded       guibg=NONE ctermbg=NONE
     52 autocmd vimenter * hi FoldColumn   guibg=NONE ctermbg=NONE
     53 autocmd vimenter * hi SpecialKey   guibg=NONE ctermbg=NONE
     54 autocmd vimenter * hi CursorLineNr guibg=NONE ctermbg=NONE
     55 
     56 " highlight current line and bold current line number
     57 set cursorline
     58 hi CursorLineNR cterm=bold
     59 
     60 " remove chars from split bar
     61 highlight VertSplit cterm=NONE
     62 
     63 " recognize syntax
     64 syntax on
     65 
     66 " useful information to display by default
     67 set laststatus=2
     68 set ruler
     69 set showcmd
     70 set cmdheight=1
     71 
     72 " get rid of thanks for flying vim
     73 set notitle
     74 
     75 " relative line numbers
     76 set number relativenumber
     77 
     78 " use system clipboard
     79 set clipboard=unnamedplus
     80 
     81 " fix backspace not working in insert mode
     82 set backspace=indent,eol,start
     83 
     84 " better searching
     85 set incsearch
     86 set hlsearch
     87 set ignorecase smartcase
     88 
     89 " utf-8 encoding without bom
     90 set encoding=utf-8 nobomb
     91 
     92 " use english (us) for spell checker
     93 set spelllang=en_us
     94 
     95 " tabs
     96 set tabstop=4
     97 set softtabstop=4
     98 set expandtab
     99 
    100 " wild menu
    101 set wildmenu
    102 set wildmode=list:longest
    103 set wildignore=*.o
    104 
    105 " show matching brackets/parentheses
    106 set showmatch
    107 
    108 " make splits open to the right
    109 set splitbelow splitright
    110 
    111 " auto indent on new line
    112 set autoindent
    113 
    114 " unsaved work that's not on screen
    115 set hidden
    116 
    117 " disable annoying swap file
    118 set noswapfile
    119 
    120 " disable backups
    121 set nobackup
    122 set nowritebackup
    123 
    124 " increase history and undo levels
    125 set history=10000
    126 set undolevels=10000
    127 
    128 " read file if changed outside vim
    129 set autoread
    130 
    131 " disable modeline support
    132 set nomodeline
    133 
    134 " remove trailing whitespace on save/exit
    135 autocmd BufWritePre * %s/\s\+$//e
    136 
    137 " disable auto-commenting behaviour
    138 autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
    139 
    140 " regular expressions
    141 set magic
    142 
    143 " default file systems
    144 set ffs=unix,dos,mac
    145 
    146 " keep current line in middle of screen when navigating up/down
    147 set scrolloff=1215752191
    148 
    149 " some settings to improve performance
    150 set lazyredraw
    151 set ttyfast
    152 set complete-=i
    153 
    154 " enable mouse support in vim
    155 set mouse=a
    156 
    157 " set leader key to accessible Space
    158 nnoremap <SPACE> <Nop>
    159 let mapleader=" "
    160 
    161 " redo to just r
    162 nnoremap r <C-R>
    163 
    164 " faster save and quit
    165 nnoremap <leader>s :w!<CR>
    166 nnoremap <leader>q :q!<CR>
    167 
    168 " replace all
    169 nnoremap <leader>r :%s//g<Left><Left>
    170 
    171 " spell checker
    172 map <leader>ss :setlocal spell!<cr>
    173 
    174 " navigate between splits using shift+hjkl
    175 nnoremap <S-h> <C-w>h
    176 nnoremap <S-j> <C-w>j
    177 nnoremap <S-k> <C-w>k
    178 nnoremap <S-l> <C-w>l
    179 
    180 " resize splits using shift+arrows
    181 noremap <S-Left> :vertical resize +1<CR>
    182 noremap <S-Right> :vertical resize -1<CR>
    183 noremap <S-Up> :resize +1<CR>
    184 noremap <S-Down> :resize -1<CR>
    185 
    186 " remove highlight from searched text
    187 nnoremap <CR> :noh<CR><CR>
    188 
    189 " basic compiler
    190 map <leader>c :w! \| !compile.sh <c-r>%<CR>
    191 map <leader>o :w! \| !compile.sh -o <c-r>%<CR><CR>
    192 map <leader>x :w! \| !compile.sh -c %<CR>