442 lines
9.0 KiB
VimL
442 lines
9.0 KiB
VimL
" General {{{
|
|
|
|
" use indentation for folds
|
|
set foldmethod=indent
|
|
set foldnestmax=5
|
|
set foldlevelstart=99
|
|
set foldcolumn=0
|
|
|
|
|
|
" Sets how many lines of history VIM has to remember
|
|
set history=700
|
|
|
|
" Set to auto read when a file is changed from the outside
|
|
set autoread
|
|
|
|
" With a map leader it's possible to do extra key combinations
|
|
" like <leader>w saves the current file
|
|
let mapleader = ","
|
|
let g:mapleader = ","
|
|
|
|
" Leader key timeout
|
|
set tm=2000
|
|
|
|
" Allow the normal use of "," by pressing it twice
|
|
noremap ,, ,
|
|
|
|
" Use par for prettier line formatting
|
|
set formatprg="PARINIT='rTbgqR B=.,?_A_a Q=_s>|' par\ -w72"
|
|
|
|
" Use stylish haskell instead of par for haskell buffers
|
|
augroup haskell_file
|
|
autocmd!
|
|
autocmd FileType haskell let &formatprg="stylish-haskell"
|
|
augroup END
|
|
|
|
" Kill the damned Ex mode.
|
|
nnoremap Q <nop>
|
|
|
|
" }}}
|
|
|
|
" Vundle {{{
|
|
|
|
set nocompatible
|
|
filetype off
|
|
set rtp+=~/.vim/bundle/vundle
|
|
call vundle#rc()
|
|
|
|
" let Vundle manage Vundle
|
|
" required!
|
|
Bundle 'gmarik/vundle'
|
|
|
|
" Support bundles
|
|
Bundle 'scrooloose/syntastic'
|
|
|
|
" Git
|
|
Bundle 'tpope/vim-fugitive'
|
|
|
|
" Bars, panels, and files
|
|
"Bundle 'scrooloose/nerdtree'
|
|
Bundle 'bling/vim-airline'
|
|
|
|
" Haskell
|
|
Bundle 'raichoo/haskell-vim'
|
|
|
|
" Other programming languages
|
|
Bundle 'zepto-lang/zepto-vim'
|
|
Bundle 'hellerve/carp-vim'
|
|
Bundle 'tikhomirov/vim-glsl'
|
|
Plugin 'rust-lang/rust.vim'
|
|
Plugin 'isRuslan/vim-es6'
|
|
Plugin 'JuliaEditorSupport/julia-vim'
|
|
|
|
" Extra
|
|
Plugin 'editorconfig/editorconfig-vim'
|
|
|
|
" Custom bundles
|
|
if filereadable(expand("~/.vim.local/bundles.vim"))
|
|
source ~/.vim.local/bundles.vim
|
|
endif
|
|
|
|
" }}}
|
|
|
|
" VIM user interface {{{
|
|
|
|
" Set 7 lines to the cursor - when moving vertically using j/k
|
|
set so=7
|
|
|
|
" Turn on the WiLd menu
|
|
set wildmenu
|
|
" Tab-complete files up to longest unambiguous prefix
|
|
set wildmode=list:longest,full
|
|
|
|
" Always show current position
|
|
set ruler
|
|
|
|
" Show trailing whitespace
|
|
set list
|
|
" But only interesting whitespace
|
|
if &listchars ==# 'eol:$'
|
|
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
|
|
endif
|
|
|
|
" Height of the command bar
|
|
set cmdheight=1
|
|
|
|
" Configure backspace so it acts as it should act
|
|
set backspace=eol,start,indent
|
|
set whichwrap+=<,>,h,l
|
|
|
|
" Ignore case when searching
|
|
set ignorecase
|
|
|
|
" When searching try to be smart about cases
|
|
set smartcase
|
|
|
|
" Highlight search results
|
|
set hlsearch
|
|
|
|
" Makes search act like search in modern browsers
|
|
set incsearch
|
|
|
|
" Don't redraw while executing macros (good performance config)
|
|
set lazyredraw
|
|
|
|
" For regular expressions turn magic on
|
|
set magic
|
|
|
|
" Show matching brackets when text indicator is over them
|
|
set showmatch
|
|
" How many tenths of a second to blink when matching brackets
|
|
set mat=2
|
|
|
|
" No annoying sound on errors
|
|
set noerrorbells
|
|
set vb t_vb=
|
|
|
|
if &term =~ '256color'
|
|
" disable Background Color Erase (BCE) so that color schemes
|
|
" render properly when inside 256-color tmux and GNU screen.
|
|
" see also http://snk.tuxfamily.org/log/vim-256color-bce.html
|
|
set t_ut=
|
|
endif
|
|
|
|
" Force redraw
|
|
map <silent> <leader>r :redraw!<CR>
|
|
|
|
" Turn mouse mode on
|
|
nnoremap <leader>ma :set mouse=a<cr>
|
|
|
|
" Turn mouse mode off
|
|
nnoremap <leader>mo :set mouse=<cr>
|
|
|
|
" Default to mouse mode on
|
|
set mouse=a
|
|
" }}}
|
|
|
|
" Enable syntax highlighting
|
|
syntax enable
|
|
|
|
" Adjust signscolumn and syntastic to match wombat
|
|
hi! link SignColumn LineNr
|
|
hi! link SyntasticErrorSign ErrorMsg
|
|
hi! link SyntasticWarningSign WarningMsg
|
|
|
|
" Enable filetype plugins
|
|
filetype plugin on
|
|
filetype indent on
|
|
|
|
" Use same color behind concealed unicode characters
|
|
hi clear Conceal
|
|
|
|
" Set paste mode and use system clipboard
|
|
set paste
|
|
set clipboard=unnamed
|
|
|
|
set t_Co=256
|
|
|
|
" Set utf8 as standard encoding and en_US as the standard language
|
|
set encoding=utf8
|
|
|
|
" Use Unix as the standard file type
|
|
set ffs=unix,dos,mac
|
|
|
|
" Use large font by default in MacVim
|
|
set gfn=Monaco:h19
|
|
|
|
" }}}
|
|
|
|
" Files, backups and undo {{{
|
|
|
|
" Turn backup off, since most stuff is in Git anyway...
|
|
set nobackup
|
|
set nowb
|
|
set noswapfile
|
|
|
|
" Source the vimrc file after saving it
|
|
augroup sourcing
|
|
autocmd!
|
|
autocmd bufwritepost .vimrc source $MYVIMRC
|
|
augroup END
|
|
|
|
" Open file prompt with current path
|
|
nmap <leader>e :e <C-R>=expand("%:p:h") . '/'<CR>
|
|
|
|
" Show undo tree
|
|
nmap <silent> <leader>u :GundoToggle<CR>
|
|
|
|
" Fuzzy find files
|
|
nnoremap <silent> <Leader><space> :CtrlP<CR>
|
|
let g:ctrlp_max_files=0
|
|
let g:ctrlp_show_hidden=1
|
|
let g:ctrlp_custom_ignore = { 'dir': '\v[\/](.git)$' }
|
|
|
|
" }}}
|
|
|
|
" Text, tab and indent related {{{
|
|
|
|
" Use spaces instead of tabs
|
|
set expandtab
|
|
|
|
" Be smart when using tabs ;)
|
|
set smarttab
|
|
|
|
" 1 tab == 2 spaces
|
|
set shiftwidth=2
|
|
set tabstop=2
|
|
|
|
" Linebreak on 500 characters
|
|
set lbr
|
|
set tw=500
|
|
|
|
set ai "Auto indent
|
|
set si "Smart indent
|
|
set wrap "Wrap lines
|
|
|
|
" Pretty unicode haskell symbols
|
|
let g:haskell_conceal_wide = 1
|
|
let g:haskell_conceal_enumerations = 1
|
|
|
|
" }}}
|
|
|
|
" Visual mode related {{{
|
|
|
|
" Visual mode pressing * or # searches for the current selection
|
|
" Super useful! From an idea by Michael Naumann
|
|
vnoremap <silent> * :call VisualSelection('f', '')<CR>
|
|
vnoremap <silent> # :call VisualSelection('b', '')<CR>
|
|
|
|
" }}}
|
|
|
|
" Moving around, tabs, windows and buffers {{{
|
|
|
|
" Treat long lines as break lines (useful when moving around in them)
|
|
nnoremap j gj
|
|
nnoremap k gk
|
|
|
|
noremap <c-h> <c-w>h
|
|
noremap <c-k> <c-w>k
|
|
noremap <c-j> <c-w>j
|
|
noremap <c-l> <c-w>l
|
|
|
|
" Return to last edit position when opening files (You want this!)
|
|
augroup last_edit
|
|
autocmd!
|
|
autocmd BufReadPost *
|
|
\ if line("'\"") > 0 && line("'\"") <= line("$") |
|
|
\ exe "normal! g`\"" |
|
|
\ endif
|
|
augroup END
|
|
" Remember info about open buffers on close
|
|
set viminfo^=%
|
|
|
|
" don't close buffers when you aren't displaying them
|
|
set hidden
|
|
|
|
" }}}
|
|
|
|
" Status line {{{
|
|
|
|
" Always show the status line
|
|
set laststatus=2
|
|
|
|
" }}}
|
|
|
|
" Editing mappings {{{
|
|
|
|
" Delete trailing white space on save
|
|
func! DeleteTrailingWS()
|
|
exe "normal mz"
|
|
%s/\s\+$//ge
|
|
exe "normal `z"
|
|
endfunc
|
|
|
|
augroup whitespace
|
|
autocmd!
|
|
autocmd BufWrite *.hs :call DeleteTrailingWS()
|
|
augroup END
|
|
|
|
" }}}
|
|
|
|
" Spell checking {{{
|
|
|
|
" Pressing ,ss will toggle and untoggle spell checking
|
|
map <leader>ss :setlocal spell!<cr>
|
|
|
|
" }}}
|
|
|
|
" Helper functions {{{
|
|
|
|
function! CmdLine(str)
|
|
exe "menu Foo.Bar :" . a:str
|
|
emenu Foo.Bar
|
|
unmenu Foo
|
|
endfunction
|
|
|
|
function! VisualSelection(direction, extra_filter) range
|
|
let l:saved_reg = @"
|
|
execute "normal! vgvy"
|
|
|
|
let l:pattern = escape(@", '\\/.*$^~[]')
|
|
let l:pattern = substitute(l:pattern, "\n$", "", "")
|
|
|
|
if a:direction == 'b'
|
|
execute "normal ?" . l:pattern . "^M"
|
|
elseif a:direction == 'gv'
|
|
call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.' . a:extra_filter)
|
|
elseif a:direction == 'replace'
|
|
call CmdLine("%s" . '/'. l:pattern . '/')
|
|
elseif a:direction == 'f'
|
|
execute "normal /" . l:pattern . "^M"
|
|
endif
|
|
|
|
let @/ = l:pattern
|
|
let @" = l:saved_reg
|
|
endfunction
|
|
|
|
" }}}
|
|
|
|
" NERDTree {{{
|
|
|
|
" Close nerdtree after a file is selected
|
|
let NERDTreeQuitOnOpen = 1
|
|
|
|
function! IsNERDTreeOpen()
|
|
return exists("t:NERDTreeBufName") && (bufwinnr(t:NERDTreeBufName) != -1)
|
|
endfunction
|
|
|
|
function! ToggleFindNerd()
|
|
if IsNERDTreeOpen()
|
|
exec ':NERDTreeToggle'
|
|
else
|
|
exec ':NERDTreeFind'
|
|
endif
|
|
endfunction
|
|
|
|
" If nerd tree is closed, find current file, if open, close it
|
|
nmap <silent> <leader>f <ESC>:call ToggleFindNerd()<CR>
|
|
nmap <silent> <leader>F <ESC>:NERDTreeToggle<CR>
|
|
|
|
" }}}
|
|
|
|
" Alignment {{{
|
|
|
|
" Stop Align plugin from forcing its mappings on us
|
|
let g:loaded_AlignMapsPlugin=1
|
|
" Align on equal signs
|
|
map <Leader>a= :Align =<CR>
|
|
" Align on commas
|
|
map <Leader>a, :Align ,<CR>
|
|
" Align on pipes
|
|
map <Leader>a<bar> :Align <bar><CR>
|
|
" Prompt for align character
|
|
map <leader>ap :Align
|
|
|
|
" Enable some tabular presets for Haskell
|
|
let g:haskell_tabular = 1
|
|
|
|
" }}}
|
|
|
|
" Tags {{{
|
|
|
|
set tags=tags;/,codex.tags;/
|
|
|
|
" }}}
|
|
|
|
" Git {{{
|
|
|
|
let g:extradite_width = 60
|
|
" Hide messy Ggrep output and copen automatically
|
|
function! NonintrusiveGitGrep(term)
|
|
execute "copen"
|
|
" Map 't' to open selected item in new tab
|
|
execute "nnoremap <silent> <buffer> t <C-W><CR><C-W>T"
|
|
execute "silent! Ggrep " . a:term
|
|
execute "redraw!"
|
|
endfunction
|
|
|
|
function! CommittedFiles()
|
|
" Clear quickfix list
|
|
let qf_list = []
|
|
" Find files committed in HEAD
|
|
let git_output = system("git diff-tree --no-commit-id --name-only -r HEAD\n")
|
|
for committed_file in split(git_output, "\n")
|
|
let qf_item = {'filename': committed_file}
|
|
call add(qf_list, qf_item)
|
|
endfor
|
|
" Fill quickfix list with them
|
|
call setqflist(qf_list, '')
|
|
endfunction
|
|
|
|
" }}}
|
|
|
|
" Haskell Interrogation {{{
|
|
|
|
set completeopt+=longest
|
|
|
|
" Use buffer words as default tab completion
|
|
let g:SuperTabDefaultCompletionType = '<c-x><c-p>'
|
|
|
|
" Haskell Lint
|
|
let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['haskell'] }
|
|
nmap <silent> <leader>hl :SyntasticCheck hlint<CR>
|
|
|
|
" }}}
|
|
|
|
" Conversion {{{
|
|
|
|
function! Pointfree()
|
|
call setline('.', split(system('pointfree '.shellescape(join(getline(a:firstline, a:lastline), "\n"))), "\n"))
|
|
endfunction
|
|
vnoremap <silent> <leader>h. :call Pointfree()<CR>
|
|
|
|
function! Pointful()
|
|
call setline('.', split(system('pointful '.shellescape(join(getline(a:firstline, a:lastline), "\n"))), "\n"))
|
|
endfunction
|
|
vnoremap <silent> <leader>h> :call Pointful()<CR>
|
|
|
|
" }}}
|
|
|
|
let g:syntastic_carp_checkers = ['carp']
|
|
command Cr !carp -x %
|