Skip to content

Instantly share code, notes, and snippets.

@expipiplus1
Created March 18, 2015 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save expipiplus1/5beb53afbbed82e02b8c to your computer and use it in GitHub Desktop.
Save expipiplus1/5beb53afbbed82e02b8c to your computer and use it in GitHub Desktop.
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'Chiel92/vim-autoformat'
Plugin 'Shougo/neocomplete.vim'
Plugin 'Shougo/unite.vim'
Plugin 'Shougo/vimproc.vim'
Plugin 'Twinside/vim-hoogle'
Plugin 'altercation/vim-colors-solarized'
" Plugin 'bitc/vim-hdevtools'
Plugin 'beyondmarc/hlsl.vim'
Plugin 'dag/vim2hs'
Plugin 'eagletmt/ghcmod-vim'
Plugin 'eagletmt/neco-ghc'
Plugin 'eagletmt/unite-haddock'
Plugin 'gibiansky/vim-textobj-haskell'
Plugin 'itchyny/lightline.vim'
Plugin 'kana/vim-textobj-user'
Plugin 'kien/ctrlp.vim'
Plugin 'scrooloose/syntastic'
" Plugin 'pydave/AsyncCommand'
" Plugin 'stgpetrovic/syntastic-async'
Plugin 'tpope/vim-abolish'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-rhubarb'
Plugin 'tpope/vim-sensible'
Plugin 'tpope/vim-unimpaired'
Plugin 'vim-scripts/Align'
Plugin 'xolox/vim-easytags'
Plugin 'xolox/vim-misc'
call vundle#end()
" End of vundle stuff
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Misc options
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
syntax on
filetype on
filetype plugin on
filetype indent on
set ignorecase
set smartcase
set title
set history=1000
set tags=./.tags;
" Save your backups to a less annoying place than the current directory.
" If you have .vim-backup in the current directory, it'll use that.
" Otherwise it saves it to ~/.vim/backup or . if all else fails.
if isdirectory($HOME . '/.vim/backup') == 0
:silent !mkdir -p ~/.vim/backup >/dev/null 2>&1
endif
set backupdir-=.
set backupdir+=.
set backupdir-=~/
set backupdir^=~/.vim/backup/
set backupdir^=./.vim-backup/
set backup
" Save your swp files to a less annoying place than the current directory.
" If you have .vim-swap in the current directory, it'll use that.
" Otherwise it saves it to ~/.vim/swap, ~/tmp or .
if isdirectory($HOME . '/.vim/swap') == 0
:silent !mkdir -p ~/.vim/swap >/dev/null 2>&1
endif
set directory=./.vim-swap//
set directory+=~/.vim/swap//
set directory+=~/tmp//
set directory+=.
if exists("+undofile")
" undofile - This allows you to use undos after exiting and restarting
" This, like swap and backups, uses .vim-undo first, then ~/.vim/undo
" :help undo-persistence
" This is only present in 7.3+
if isdirectory($HOME . '/.vim/undo') == 0
:silent !mkdir -p ~/.vim/undo > /dev/null 2>&1
endif
set undodir=./.vim-undo//
set undodir+=~/.vim/undo//
set undofile
endif
set hidden
set tabpagemax=1000
set ffs=unix,dos
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Interface
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set ruler
set scrolloff=8
" Open all folds by default
set foldlevelstart=20
set novisualbell
set shortmess=atI
" Highlight current line
if empty($CONEMUBUILD)
set cursorline
endif
if has("gui_running")
" GUI is running or is about to start.
" Maximize gvim window (for an alternative on Windows, see simalt below).
set lines=999 columns=999
else
" This is console Vim.
if exists("+lines")
set lines=50
endif
if exists("+columns")
set columns=100
endif
endif
" For statusline
set encoding=utf-8 " Necessary to show Unicode glyphs
set laststatus=2 " Always show the statusline
set term=xterm
if !has("gui_running")
set t_Co=256
endif
let &t_AB="\e[48;5;%dm"
let &t_AF="\e[38;5;%dm"
" no scrollbars
set guioptions-=m
set guioptions-=T
set guioptions-=l
set guioptions-=L
set guioptions-=r
set guioptions-=R
" Color scheme
if has("gui_running")
set background=dark
colorscheme solarized
endif
" Search highlighting
hi Search term=bold,underline ctermfg=9 ctermbg=3 gui=bold,underline guifg=#dc322f guibg=#073642
" Split vertically by default
cnoreabbrev sb vert sb
cnoreabbrev hsb sb
" To get the preview window at the bottom
set splitbelow
set splitright
" Less odd highlighting
autocmd BufEnter * :syntax sync fromstart
" Make quickfix at the bottom
autocmd FileType qf wincmd J
" Close quickfix if it's the last window
au BufEnter * call MyLastWindow()
function! MyLastWindow()
" if the window is quickfix go on
if &buftype=="quickfix"
" if this window is last on screen quit without warning
if winbufnr(2) == -1
quit
endif
endif
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Github Stuff
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let github_username='expipiplus1'
let github_password='a'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Saving
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Tell vim to remember certain things when we exit
" '10 : marks will be remembered for up to 10 previously edited files
" "100 : will save up to 100 lines for each register
" :20 : up to 20 lines of command-line history will be remembered
" % : saves and restores the buffer list
" n... : where to save the viminfo files
set viminfo='10,\"100,:20,%,n~/.viminfo
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Keymapping
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set all the mouse options
set mouse=a
" Split navigation
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" no Ex mode
nnoremap Q <Nop>
set backspace=indent,eol,start
let mapleader=" "
nnoremap ' `
nnoremap ` '
command Wq wq
command WQ wq
command Qw wq
command QW wq
command W w
command Q q
" sort
vnoremap <leader>r :sort<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Searching
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set wildmode=list:longest
" Highlight search terms...
" set hlsearch
set incsearch " ...dynamically as they are typed.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" CtrlP
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ctrlp find files
let g:ctrlp_by_filename = 1
set wildignore+=*/dist/*,*/tmp/*,*.so,*.swp,*.zip,*.hi,*.o
let g:ctrlp_extensions = ['tag']
noremap <C-T> :CtrlPTag<CR>
let g:ctrlp_switch_buffer = 0
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git|hg|svn)$',
\ 'file': '\v\.(exe|so|dll)$',
\ }
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Align
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
vnoremap a= :Align =<CR>
vnoremap a- :Align -><CR>
vnoremap a: :Align ::<CR>
vnoremap a\| :Align \| \| =<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Lightline
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if has("mac")
" Menlo as a MacOSX Font
set guifont=Menlo:h13
elseif has("unix")
set guifont=DejaVu\ Sans\ Mono\ for\ Powerline\ 12
elseif has("win32")
set guifont=DejaVu\ Sans\ Mono\ for\ Powerline:h11
endif
set noruler
set noshowmode
let g:lightline = {
\ 'colorscheme': 'solarized',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'readonly', 'filename'], ['ctrlpmark'] ],
\ 'right': [ [ 'syntastic', 'lineinfo' ], ['percent'], [ 'fileformat', 'fileencoding', 'filetype' ] ]
\ },
\ 'inactive': {
\ 'left': [ [ 'fugitive', 'readonly', 'filename'] ],
\ 'right': [ [ 'lineinfo' ], ['percent'], [ 'fileformat', 'fileencoding', 'filetype' ] ]
\ },
\ 'component_function': {
\ 'fugitive': 'MyFugitive',
\ 'filename': 'MyFilename',
\ 'fileformat': 'MyFileformat',
\ 'filetype': 'MyFiletype',
\ 'fileencoding': 'MyFileencoding',
\ 'mode': 'MyMode',
\ 'ctrlpmark': 'CtrlPMark',
\ },
\ 'component_expand': {
\ 'syntastic': 'SyntasticStatuslineFlag',
\ },
\ 'component_type': {
\ 'syntastic': 'error',
\ },
\ 'component': {
\ 'readonly': '%{&readonly?"":""}',
\ },
\ 'separator': { 'left': '', 'right': '' },
\ 'subseparator': { 'left': '', 'right': '' }
\ }
function! MyModified()
return &ft =~ 'help' ? '' : &modified ? '+' : &modifiable ? '' : '-'
endfunction
function! MyReadonly()
return &ft !~? 'help' && &readonly ? 'RO' : ''
endfunction
function! MyFilename()
let fname = expand('%:t')
return fname == 'ControlP' ? g:lightline.ctrlp_item :
\ fname == '__Tagbar__' ? g:lightline.fname :
\ fname =~ '__Gundo\|NERD_tree' ? '' :
\ &ft == 'vimfiler' ? vimfiler#get_status_string() :
\ &ft == 'unite' ? unite#get_status_string() :
\ &ft == 'vimshell' ? vimshell#get_status_string() :
\ ('' != MyReadonly() ? MyReadonly() . ' ' : '') .
\ ('' != fname ? fname : '[No Name]') .
\ ('' != MyModified() ? ' ' . MyModified() : '')
endfunction
function! MyFugitive()
try
if expand('%:t') !~? 'Tagbar\|Gundo\|NERD' && &ft !~? 'vimfiler' && exists('*fugitive#head')
let mark = '' " edit here for cool mark
let _ = fugitive#head()
return strlen(_) ? mark._ : ''
endif
catch
endtry
return ''
endfunction
function! MyFileformat()
return winwidth(0) > 100 ? &fileformat : ''
endfunction
function! MyFiletype()
return winwidth(0) > 100 ? (strlen(&filetype) ? &filetype : 'no ft') : ''
endfunction
function! MyFileencoding()
return winwidth(0) > 100 ? (strlen(&fenc) ? &fenc : &enc) : ''
endfunction
function! MyMode()
let fname = expand('%:t')
return fname == '__Tagbar__' ? 'Tagbar' :
\ fname == 'ControlP' ? 'CtrlP' :
\ fname == '__Gundo__' ? 'Gundo' :
\ fname == '__Gundo_Preview__' ? 'Gundo Preview' :
\ fname =~ 'NERD_tree' ? 'NERDTree' :
\ &ft == 'unite' ? 'Unite' :
\ &ft == 'vimfiler' ? 'VimFiler' :
\ &ft == 'vimshell' ? 'VimShell' :
\ winwidth(0) > 60 ? lightline#mode() : ''
endfunction
function! CtrlPMark()
if expand('%:t') =~ 'ControlP'
call lightline#link('iR'[g:lightline.ctrlp_regex])
return lightline#concatenate([g:lightline.ctrlp_prev, g:lightline.ctrlp_item
\ , g:lightline.ctrlp_next], 0)
else
return ''
endif
endfunction
let g:ctrlp_status_func = {
\ 'main': 'CtrlPStatusFunc_1',
\ 'prog': 'CtrlPStatusFunc_2',
\ }
function! CtrlPStatusFunc_1(focus, byfname, regex, prev, item, next, marked)
let g:lightline.ctrlp_regex = a:regex
let g:lightline.ctrlp_prev = a:prev
let g:lightline.ctrlp_item = a:item
let g:lightline.ctrlp_next = a:next
return lightline#statusline(0)
endfunction
function! CtrlPStatusFunc_2(str)
return lightline#statusline(0)
endfunction
let g:tagbar_status_func = 'TagbarStatusFunc'
function! TagbarStatusFunc(current, sort, fname, ...) abort
let g:lightline.fname = a:fname
return lightline#statusline(0)
endfunction
augroup AutoSyntastic
autocmd!
autocmd BufWritePost *.c,*.cpp call s:syntastic()
augroup END
function! s:syntastic()
SyntasticCheck
call lightline#update()
endfunction
let g:unite_force_overwrite_statusline = 0
let g:vimfiler_force_overwrite_statusline = 0
let g:vimshell_force_overwrite_statusline = 0
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" hlsl
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
autocmd BufNewFile,BufRead *.fx,*.fxc,*.fxh,*.hlsl set ft=hlsl
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Neocomplete
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use neocomplete.
let g:neocomplete#enable_at_startup = 1
" Use smartcase.
let g:neocomplete#enable_smart_case = 1
" Set minimum syntax keyword length.
let g:neocomplete#sources#syntax#min_keyword_length = 3
let g:neocomplete#lock_buffer_name_pattern = '\*ku\*'
" Plugin key-mappings.
inoremap <expr><C-g> neocomplete#undo_completion()
inoremap <expr><C-l> neocomplete#complete_common_string()
" Recommended key-mappings.
" <CR>: close popup and save indent.
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
return neocomplete#close_popup() . "\<CR>"
" For no inserting <CR> key.
"return pumvisible() ? neocomplete#close_popup() : "\<CR>"
endfunction
" <TAB>: completion.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><C-y> neocomplete#close_popup()
inoremap <expr><C-e> neocomplete#cancel_popup()
inoremap <expr><C-Space> "<C-x><C-o><C-p>"
"inoremap <expr><C-Space> neocomplete#start_manual_complete()
" Enable heavy omni completion.
if !exists('g:neocomplete#sources#omni#input_patterns')
let g:neocomplete#sources#omni#input_patterns = {}
endif
let g:neocomplete#sources#omni#input_patterns.haskell = '[^.[:digit:] *\t]\%(\.\)'
set completeopt=longest,menuone
" smartcase
let g:neocomplete#enable_camel_case = 1
let g:neocomplete#enable_fuzzy_completion = 1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set tabstop=2
set softtabstop=2
set expandtab
set shiftwidth=2
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" easytags
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:easytags_suppress_ctags_warning = 1
let g:easytags_dynamic_files = 1
let g:easytags_cmd = ""
let g:easytags_updatetime_warn = 0
let g:easytags_async = 1
let g:easytags_ctags_version = ""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Syntastic
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Unimpared
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! <SID>LocationPrevious()
try
lprev
catch /^Vim\%((\a\+)\)\=:E553/
llast
endtry
endfunction
function! <SID>LocationNext()
try
lnext
catch /^Vim\%((\a\+)\)\=:E553/
lfirst
endtry
endfunction
nnoremap <silent> <Plug>LocationPrevious :<C-u>exe 'call <SID>LocationPrevious()'<CR>
nnoremap <silent> <Plug>LocationNext :<C-u>exe 'call <SID>LocationNext()'<CR>
nmap <silent> <S-F8> <Plug>LocationPrevious
nmap <silent> <F8> <Plug>LocationNext
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" vim2hs
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:haskell_conceal = 0
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Haskell stuff
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:necoghc_enable_detailed_browse = 1
let $PATH = $PATH . ':' . expand("~/.cabal/bin")
"
" ghc mod
"
let &l:statusline = '%{empty(getqflist()) ? "[No Errors]" : "[Errors Found]"}' . (empty(&l:statusline) ? &statusline : &l:statusline)
" autocmd BufWritePost *.hs GhcModCheckAndLintAsync
" autocmd BufWritePost *.lhs GhcModCheckAndLintAsync
let g:ghcmod_hlint_options = ['--hint=HLint', '--hint=Default', '--hint=Dollar', '--cpp-define=HLINT', '--color']
autocmd Filetype haskell nnoremap <buffer> <leader>i :GhcModInfo!<CR>
autocmd Filetype haskell nnoremap <buffer> <leader>c :GhcModTypeClear<CR>
autocmd Filetype haskell nnoremap <buffer> <leader>t :GhcModType!<CR>
autocmd Filetype haskell nnoremap <buffer> <leader>T :GhcModTypeInsert!<CR>
" autocmd FileType haskell map <leader>i :HdevtoolsInfo<CR>
" autocmd FileType haskell map <leader>t :HdevtoolsType<CR>
" autocmd FileType haskell map <leader>T :HdevtoolsClear<CR>
" highlight long columns
au FileType haskell let &colorcolumn=join(range(101,999),",")
highlight ColorColumn ctermbg=7 guibg=#2c2d27
" Strip trailing whitespace
autocmd FileType haskell,lhaskell autocmd BufWritePre <buffer> :%s/\s\+$//e
autocmd FileType haskell let b:easytags_auto_highlight = 1
"let g:easytags_languages = {
" \ 'haskell': {
" \ 'cmd': 'hasktags',
" \ 'args': ['-c'],
" \ 'fileoutput_opt': '-f',
" \ 'stdout_opt': '-f-',
" \ 'recurse_flag': ''
" \ }
" \}
let g:easytags_languages = {
\ 'haskell': {
\ 'cmd': '~/.cabal/bin/lushtags',
\ 'args': [],
\ 'fileoutput_opt': '-f',
\ 'stdout_opt': '-f-',
\ 'recurse_flag': '-R'
\ }
\}
function! Preserve(command)
let w = winsaveview()
execute a:command
call winrestview(w)
endfunction
" Format current function
autocmd FileType haskell map <leader>f :call Preserve("normal gqah")<CR>
let g:hindent_style="gibiansky"
let g:formatprg_haskell = "hindent"
let g:formatprg_args_haskell = "--style " . g:hindent_style . " --line-length 100"
autocmd Filetype haskell setlocal omnifunc=necoghc#omnifunc
autocmd Filetype haskell setlocal iskeyword+=39
function! s:get_cabal_sandbox()
if filereadable('cabal.sandbox.config')
let l:output = system('cat cabal.sandbox.config | grep local-repo')
let l:dir = matchstr(substitute(l:output, '\n', ' ', 'g'), 'local-repo: \zs\S\+\ze\/packages')
return l:dir
else
return ''
endif
endfunction
" Configuration for syntastic
let g:syntastic_haskell_checkers=['ghc_mod', 'hlint']
" let g:syntastic_haskell_checkers=['hdevtools', 'hlint']
let ghc_args = ["Wall", "fno-warn-name-shadowing", "fno-warn-type-defaults"]
let sandbox = s:get_cabal_sandbox()
if len(sandbox) != 0
let package_db = split(globpath(sandbox, "*-packages.conf.d"), '\n')[0]
call add(ghc_args, 'package-db=' . package_db)
endif
call map(ghc_args, '"-g-" . v:val')
let ghc_args_string = join(ghc_args, ' ')
let g:syntastic_haskell_ghc_mod_args=ghc_args_string
let g:syntastic_haskell_hdevtools_args=ghc_args_string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment