The viminfofile is not always compiled into the available vim, leading to an error when trying to set it.
233 lines
7.4 KiB
VimL
233 lines
7.4 KiB
VimL
set nocompatible
|
||
|
||
" Options {{{
|
||
set autoindent
|
||
set autoread
|
||
let &background = $BACKGROUND ==# 'light' ? 'light' : 'dark'
|
||
set backspace=indent,eol,start
|
||
set nobackup
|
||
set clipboard=unnamed
|
||
set colorcolumn=80
|
||
set cursorline
|
||
set diffopt=filler,vertical
|
||
set encoding=utf8
|
||
set expandtab
|
||
set fileformats=unix,mac,dos
|
||
set foldenable
|
||
set foldlevelstart=100
|
||
set foldmethod=syntax
|
||
set foldnestmax=10
|
||
let &formatlistpat='^\s*\(\d\+[\]:.)}\t ]\|[-*]\|\[[ x]\]\|([ x])\)\s*'
|
||
set formatoptions-=t
|
||
set formatoptions+=jn
|
||
set hidden
|
||
set history=1000
|
||
set hlsearch
|
||
set incsearch
|
||
set nojoinspaces
|
||
set laststatus=2
|
||
set lazyredraw
|
||
set list
|
||
set modelines=0
|
||
set number
|
||
set scrolloff=5
|
||
set shiftwidth=4
|
||
set shortmess+=I
|
||
set showmatch
|
||
set noshowmode
|
||
set sidescrolloff=5
|
||
set nrformats-=octal
|
||
set smartindent
|
||
set smarttab
|
||
set splitbelow
|
||
set splitright
|
||
set noswapfile
|
||
set tabstop=4
|
||
set textwidth=79
|
||
set timeoutlen=1000
|
||
set ttimeoutlen=100
|
||
set ttyfast
|
||
" +--Disable hlsearch while loading viminfo
|
||
" | +--Remember marks for last 500 files
|
||
" | | +--Remember up to 10000 lines in each register
|
||
" | | | +--Remember up to 1MB in each register
|
||
" | | | | +--Remember last 1000 search patterns
|
||
" | | | | | +---Remember last 1000 commands
|
||
" | | | | | |
|
||
" v v v v v v
|
||
set viminfo=h,'500,<10000,s1000,/1000,:1000
|
||
if has('viminfofile')
|
||
set viminfofile=~/.vim/viminfo
|
||
endif
|
||
set virtualedit=block
|
||
set wildignore=*.o,*.obj,*.pyc,*.exe,*.so,*.dll
|
||
set wildmenu
|
||
set wrap
|
||
set writebackup
|
||
|
||
if has('multi_byte') && &encoding ==# 'utf-8'
|
||
set foldtext=VimrcFoldText()
|
||
set fillchars=vert:┃,fold:·
|
||
let &listchars = 'tab:▷ ,extends:»,precedes:«,trail:·'
|
||
let &showbreak = ' ⤷ '
|
||
else
|
||
let &listchars = 'tab:>~,extends:>,precedes:<,trail:-'
|
||
let &showbreak = '-> '
|
||
endif
|
||
" }}}
|
||
|
||
" Plugins {{{
|
||
call plug#begin('~/.vim/bundle')
|
||
Plug 'altercation/vim-colors-solarized'
|
||
Plug 'bronson/vim-trailing-whitespace'
|
||
Plug 'elzr/vim-json'
|
||
Plug 'godlygeek/tabular' | Plug 'plasticboy/vim-markdown'
|
||
Plug 'junegunn/rainbow_parentheses.vim'
|
||
Plug 'kien/ctrlp.vim'
|
||
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
|
||
Plug 'tpope/vim-commentary'
|
||
Plug 'tpope/vim-fugitive'
|
||
Plug 'vim-airline/vim-airline'
|
||
Plug 'vim-airline/vim-airline-themes'
|
||
Plug 'vim-scripts/srec.vim'
|
||
Plug 'keith/swift.vim'
|
||
Plug 'chr4/nginx.vim'
|
||
call plug#end()
|
||
|
||
let g:ctrlp_match_window = 'bottom,order:ttb'
|
||
let g:ctrlp_switch_buffer = 0 " open files in new buffer
|
||
let g:ctrlp_working_path_mode = 0 " use the current working directory
|
||
|
||
let g:rainbow#pairs = [['(',')'], ['[',']'], ['{','}']]
|
||
|
||
if has('multi_byte') && &encoding ==# 'utf-8'
|
||
let g:airline_section_z = airline#section#create(['ℓ%4l/%L 𝚌%3v'])
|
||
else " line / total : col
|
||
let g:airline_section_z = airline#section#create(['L%4l/%L c%3v'])
|
||
endif
|
||
|
||
if !exists('g:airline_symbols')
|
||
let g:airline_symbols = {}
|
||
endif
|
||
|
||
let g:airline_left_sep = ' '
|
||
let g:airline_left_alt_sep = ''
|
||
let g:airline_right_sep = ' '
|
||
let g:airline_right_alt_sep = ''
|
||
let g:airline_symbols.crypt = '🔒'
|
||
let g:airline_symbols.branch = '⎇'
|
||
let g:airline_symbols.paste = 'Ⓟ'
|
||
let g:airline_symbols.spell = '✔'
|
||
let g:airline_symbols.readonly = ' ⃠'
|
||
let g:airline_symbols.notexists = '∄'
|
||
let g:airline_symbols.whitespace = '✗'
|
||
|
||
highlight link srecStart Comment
|
||
highlight link srecType Comment
|
||
highlight link srecLength WarningMsg
|
||
highlight link srec16BitAddress Constant
|
||
highlight link srec24BitAddress Constant
|
||
highlight link srec32BitAddress Constant
|
||
highlight link srecChecksum Type
|
||
|
||
colorscheme solarized
|
||
filetype plugin indent on
|
||
syntax enable
|
||
" }}}
|
||
|
||
" Functions {{{
|
||
" Cycle through relativenumber + number, number (only), and no numbering.
|
||
function! VimrcCycleNumbers() abort
|
||
if exists('+relativenumber')
|
||
execute {
|
||
\ '00': 'set relativenumber | set number',
|
||
\ '01': 'set norelativenumber | set number',
|
||
\ '10': 'set norelativenumber | set nonumber',
|
||
\ '11': 'set norelativenumber | set number' }[&number . &relativenumber]
|
||
else
|
||
set number! " No relative numbering, just toggle numbers on and off.
|
||
endif
|
||
endfunction
|
||
|
||
" Turn fold text from this:
|
||
"
|
||
" +--- 2 lines: text of first line in fold --------------------------
|
||
"
|
||
" into this:
|
||
"
|
||
" ··· 2ℓ: text of first line in fold ······························
|
||
function! VimrcFoldText() abort
|
||
let l:level=substitute(v:folddashes, '-', '·', 'g')
|
||
let l:count=(v:foldend - v:foldstart + 1)
|
||
let l:title=substitute(getline(v:foldstart), '\v *', '', '')
|
||
return l:level . ' ' . l:count . 'ℓ: ' . l:title . ' '
|
||
endfunction
|
||
" }}}"
|
||
|
||
" Mappings {{{
|
||
let mapleader = "\<space>"
|
||
let maplocalleader = ","
|
||
|
||
" better navigation for wrapped lines
|
||
noremap j gj
|
||
noremap k gk
|
||
|
||
" quickly exit insert mode
|
||
inoremap jk <esc>
|
||
|
||
" retain selection when indenting/unindenting in visual mode
|
||
vnoremap > ><cr>gv
|
||
vnoremap < <<cr>gv
|
||
|
||
" better searching (case insensitive & expand on previous)
|
||
nnoremap // /\c
|
||
nnoremap /// /<C-R>/
|
||
|
||
" window resizing similar to the way I have tmux set up
|
||
nnoremap <c-w><c-k> 5<c-w>+
|
||
nnoremap <c-w><c-j> 5<c-w>-
|
||
nnoremap <c-w><c-h> 5<c-w><
|
||
nnoremap <c-w><c-l> 5<c-w>>
|
||
|
||
" easier tab navigation
|
||
nnoremap <c-j> :tabprevious<cr>
|
||
nnoremap <c-k> :tabnext<cr>
|
||
nnoremap <c-h> :tabfirst<cr>
|
||
nnoremap <c-l> :tablast<cr>
|
||
|
||
" quickly change background
|
||
nnoremap <leader>bg
|
||
\ :let &background = &background ==# 'light' ? 'dark' : 'light'<cr>
|
||
|
||
" turn off search highlight
|
||
nnoremap <leader>h :nohlsearch<cr>
|
||
|
||
" toggle NERDTree
|
||
nnoremap <leader>n :NERDTreeToggle<cr>
|
||
|
||
" toggle rainbow parens
|
||
nnoremap <leader>r :RainbowParentheses!!<cr>
|
||
|
||
" fix whitespace
|
||
nnoremap <leader>w :FixWhitespace<cr>
|
||
|
||
" cycle through line numbering modes
|
||
nnoremap <silent> <leader>r :call VimrcCycleNumbers()<CR>
|
||
|
||
" }}}"
|
||
|
||
augroup vimrc " {{{
|
||
autocmd!
|
||
autocmd BufNewFile,BufRead bash_profile,bashrc set filetype=sh
|
||
autocmd BufNewFile,BufRead gitconfig set filetype=gitconfig
|
||
autocmd BufNewFile,BufRead rcrc set filetype=sh
|
||
autocmd BufNewFile,BufRead *.sx,*.s19 set filetype=srec
|
||
|
||
autocmd FileType vim setlocal foldmethod=marker
|
||
autocmd FileType python setlocal foldmethod=indent foldignore=
|
||
autocmd FileType markdown,text,gitcommit setlocal formatoptions+=t spell
|
||
autocmd FileType gitcommit setlocal textwidth=72
|
||
augroup END " }}}
|
||
|
||
if filereadable(expand("~/.vimrc.local")) | source ~/.vimrc.local | endif
|
||
|