[add] vim configuration

This commit is contained in:
Max Bucknell 2014-10-18 20:47:06 +01:00
parent 3a852b966f
commit bf41472ef0
6 changed files with 266 additions and 0 deletions

@ -0,0 +1 @@
Subproject commit 223092c178c45a2d0597f611667603e24f01f954

@ -0,0 +1 @@
Subproject commit ec39927fcbb53a77e628b2d138e0a43caa945a3b

@ -0,0 +1 @@
Subproject commit fa433e0b7330753688f715f3be5d10dc480f20e5

@ -0,0 +1 @@
Subproject commit 0b28e334e65b6628b0a61c412fcb45204a2f2bab

View file

@ -0,0 +1,61 @@
set background=dark
hi clear
if exists("syntax_on")
syntax reset
endif
" Terminal colours cheatsheet
"
" 0: black
" 1: red
" 2: green
" 3: yellow
" 4: blue
" 5: magenta
" 6: cyan
" 7: white
"
" +8 for bright colours.
let g:colors_name = "maxbucknell"
" Basic settings
hi Normal cterm=NONE ctermfg=7 ctermbg=NONE
hi Type cterm=NONE ctermfg=7 ctermbg=NONE
hi Keyword cterm=NONE ctermfg=7 ctermbg=NONE
hi Operator cterm=NONE ctermfg=7 ctermbg=NONE
hi String cterm=NONE ctermfg=7 ctermbg=NONE
hi Number cterm=NONE ctermfg=7 ctermbg=NONE
hi Special cterm=NONE ctermfg=7 ctermbg=NONE
hi Boolean cterm=NONE ctermfg=7 ctermbg=NONE
hi Statement cterm=NONE ctermfg=7 ctermbg=NONE
hi Identifier cterm=NONE ctermfg=7 ctermbg=NONE
hi Constant cterm=NONE ctermfg=7 ctermbg=NONE
hi Define cterm=NONE ctermfg=7 ctermbg=NONE
hi Include cterm=NONE ctermfg=7 ctermbg=NONE
" Status Line
hi StatusLine cterm=bold ctermfg=1 ctermbg=NONE
" Vim settings
hi VimSet cterm=NONE ctermfg=7 ctermbg=NONE
hi VimOption cterm=NONE ctermfg=7 ctermbg=NONE
hi VimHiAttrib cterm=NONE ctermfg=7 ctermbg=NONE
" Comments are important
hi Comment cterm=NONE ctermfg=2 ctermbg=NONE
hi PreProc cterm=NONE ctermfg=2 ctermbg=NONE
" Invisibles are less important
hi SpecialKey cterm=NONE ctermfg=0 ctermbg=NONE
" Make current line bold
hi CursorLine cterm=bold ctermfg=NONE ctermbg=NONE
" Current search result
hi Search cterm=bold ctermfg=7 ctermbg=0
" Next search result
hi MBSearchNExt cterm=bold ctermfg=7 ctermbg=5

201
vim/vimrc.symlink Normal file
View file

@ -0,0 +1,201 @@
" Max's .vimrc
" Honourary mention to Gary Bernhardt
""""""""""""""""""""""""""""""""""""""
" Vundle, for all my beautiful plugins
""""""""""""""""""""""""""""""""""""""
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'wincent/command-t'
Bundle 'tpope/vim-rsi'
Bundle 'tpope/vim-surround'
""""""""""""""""""""""
" Basic editing config
""""""""""""""""""""""
colorscheme maxbucknell
" Tab config options
" I will probably want to change these for different projects.
set expandtab
set tabstop=2
set shiftwidth=2
set softtabstop=2
set autoindent
" I am lazy and I don't like holding shift.
map ; :
noremap ;; ;
" Show me when my lines are too long
call matchadd('ColorColumn', '\%81v', 100)
" Search options
" Show partial matches while searching
set incsearch
" Highlight other matches in the file
set hlsearch
" Show the next search result.
" By Damian Conway.
"
" This rewires n and N to do the highlighing...
nnoremap <silent> n n:call HLNext(0.2)<cr>
nnoremap <silent> N N:call HLNext(0.2)<cr>
" Blink the next match
function! HLNext (blinktime)
let [bufnum, lnum, col, off] = getpos('.')
let matchlen = strlen(matchstr(strpart(getline('.'),col-1),@/))
let target_pat = '\c\%#'.@/
let ring = matchadd('MBSearchNext', target_pat, 101)
redraw
exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm'
call matchdelete(ring)
redraw
endfunction
" Make searches case sensitive only if an upper case character has been typed
set ignorecase smartcase
" Prevent Vim from clobbering the scrollback buffer. See
" http://www.shallowsky.com/linux/noaltscreen.html
set t_ti= t_te=
" Highlight current line
set cursorline
" Ensure that the cursor never touches top or bottom of screen
set scrolloff=10
" Allow backspacing over everything in insert mode
set backspace=indent,eol,start
" display incomplete commands
set showcmd
" Allow hidden buffers
set hidden
" Enable highlighting for syntax
syntax on
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Change leader to , rather than \
let mapleader=","
" Insert only one space when joining lines that contain sentence-terminating
" punctuation like `.`.
set nojoinspaces
" If a file is changed outside of vim, automatically reload it without asking
set autoread
" Show trailing whitespace, since it's a crime
set list
set listchars=trail:·,tab:‣\
" Turn off code folding
set nofoldenable
let g:vim_markdown_folding_disabled=1
" Always show status bar
set laststatus=2
" Swap v and ctrl-v because visual block mode rules
nnoremap v <C-V>
nnoremap <C-V> v
vnoremap v <C-V>
vnoremap <C-V> v
" Dragvisuals key mappings
vmap <expr> <LEFT> DVB_Drag('left')
vmap <expr> <RIGHT> DVB_Drag('right')
vmap <expr> <DOWN> DVB_Drag('down')
vmap <expr> <UP> DVB_Drag('up')
vmap <expr> D DVB_Duplicate()
" Pastetoggle to let Vim paste things without auto stuff
set pastetoggle=<F2>
"""""""""""""""""
" Custom autocmds
"""""""""""""""""
augroup vimrcEx
" Clear all autocmds in the group
autocmd!
autocmd FileType text setlocal textwidth=78
" Jump to last cursor position unless it's invalid or in an event handler
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
" Language whitespace settings
autocmd FileType json,c,xml,java,php,python setlocal shiftwidth=4 softtabstop=4
autocmd FileType ruby,haml,eruby,yaml,html,javascript,sass,cucumber setlocal ai sw=2 sts=2 et
autocmd FileType make setlocal noet sw=8 sts=8 ts=8
augroup END
"""""""""""""
" STATUS LINE
"""""""""""""
:set statusline=%<[%n]:\ %f\ %5l,%3c\ (%{&ft})
"""""""""""""""
" MISC KEY MAPS
"""""""""""""""
map <leader>y "*y
nmap <leader>. <c-^>
" Move around splits with <c-hjkl>
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" MULTIPURPOSE TAB KEY
" Indent if we're at the beginning of a line. Else, do completion.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
inoremap <s-tab> <c-n>
" I don't like the quote concealing
let g:vim_json_syntax_conceal = 0
" Show syntax highlighting groups for word under cursor
nmap <C-S-P> :call <SID>SynStack()<CR>
function! <SID>SynStack()
if !exists("*synstack")
return
endif
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val,"name")')
endfunc