Commit 83e7172d authored by Murukesh Mohanan's avatar Murukesh Mohanan

merge colorscheme

parents a9cddabf 9256db4c
"
" utility functions for haskellmode plugins
"
" (Claus Reinke; last modified: 22/06/2010)
"
" part of haskell plugins: http://projects.haskell.org/haskellmode-vim
" please send patches to <claus.reinke@talk21.com>
" find start/extent of name/symbol under cursor;
" return start, symbolic flag, qualifier, unqualified id
" (this is used in both haskell_doc.vim and in GHC.vim)
function! haskellmode#GetNameSymbol(line,col,off)
let name = "[a-zA-Z0-9_']"
let symbol = "[-!#$%&\*\+/<=>\?@\\^|~:.]"
"let [line] = getbufline(a:buf,a:lnum)
let line = a:line
" find the beginning of unqualified id or qualified id component
let start = (a:col - 1) + a:off
if line[start] =~ name
let pattern = name
elseif line[start] =~ symbol
let pattern = symbol
else
return []
endif
while start > 0 && line[start - 1] =~ pattern
let start -= 1
endwhile
let id = matchstr(line[start :],pattern.'*')
" call confirm(id)
" expand id to left and right, to get full id
let idPos = id[0] == '.' ? start+2 : start+1
let posA = match(line,'\<\(\([A-Z]'.name.'*\.\)\+\)\%'.idPos.'c')
let start = posA>-1 ? posA+1 : idPos
let posB = matchend(line,'\%'.idPos.'c\(\([A-Z]'.name.'*\.\)*\)\('.name.'\+\|'.symbol.'\+\)')
let end = posB>-1 ? posB : idPos
" special case: symbolic ids starting with .
if id[0]=='.' && posA==-1
let start = idPos-1
let end = posB==-1 ? start : end
endif
" classify full id and split into qualifier and unqualified id
let fullid = line[ (start>1 ? start-1 : 0) : (end-1) ]
let symbolic = fullid[-1:-1] =~ symbol " might also be incomplete qualified id ending in .
let qualPos = matchend(fullid, '\([A-Z]'.name.'*\.\)\+')
let qualifier = qualPos>-1 ? fullid[ 0 : (qualPos-2) ] : ''
let unqualId = qualPos>-1 ? fullid[ qualPos : -1 ] : fullid
" call confirm(start.'/'.end.'['.symbolic.']:'.qualifier.' '.unqualId)
return [start,symbolic,qualifier,unqualId]
endfunction
function! haskellmode#GatherImports()
let imports={0:{},1:{}}
let i=1
while i<=line('$')
let res = haskellmode#GatherImport(i)
if !empty(res)
let [i,import] = res
let prefixPat = '^import\s*\%({-#\s*SOURCE\s*#-}\)\?\(qualified\)\?\s\+'
let modulePat = '\([A-Z][a-zA-Z0-9_''.]*\)'
let asPat = '\(\s\+as\s\+'.modulePat.'\)\?'
let hidingPat = '\(\s\+hiding\s*\((.*)\)\)\?'
let listPat = '\(\s*\((.*)\)\)\?'
let importPat = prefixPat.modulePat.asPat.hidingPat.listPat ".'\s*$'
let ml = matchlist(import,importPat)
if ml!=[]
let [_,qualified,module,_,as,_,hiding,_,explicit;x] = ml
let what = as=='' ? module : as
let hidings = split(hiding[1:-2],',')
let explicits = split(explicit[1:-2],',')
let empty = {'lines':[],'hiding':hidings,'explicit':[],'modules':[]}
let entry = has_key(imports[1],what) ? imports[1][what] : deepcopy(empty)
let imports[1][what] = haskellmode#MergeImport(deepcopy(entry),i,hidings,explicits,module)
if !(qualified=='qualified')
let imports[0][what] = haskellmode#MergeImport(deepcopy(entry),i,hidings,explicits,module)
endif
else
echoerr "haskellmode#GatherImports doesn't understand: ".import
endif
endif
let i+=1
endwhile
if !has_key(imports[1],'Prelude')
let imports[0]['Prelude'] = {'lines':[],'hiding':[],'explicit':[],'modules':[]}
let imports[1]['Prelude'] = {'lines':[],'hiding':[],'explicit':[],'modules':[]}
endif
return imports
endfunction
function! haskellmode#ListElem(list,elem)
for e in a:list | if e==a:elem | return 1 | endif | endfor
return 0
endfunction
function! haskellmode#ListIntersect(list1,list2)
let l = []
for e in a:list1 | if index(a:list2,e)!=-1 | let l += [e] | endif | endfor
return l
endfunction
function! haskellmode#ListUnion(list1,list2)
let l = []
for e in a:list2 | if index(a:list1,e)==-1 | let l += [e] | endif | endfor
return a:list1 + l
endfunction
function! haskellmode#ListWithout(list1,list2)
let l = []
for e in a:list1 | if index(a:list2,e)==-1 | let l += [e] | endif | endfor
return l
endfunction
function! haskellmode#MergeImport(entry,line,hiding,explicit,module)
let lines = a:entry['lines'] + [ a:line ]
let hiding = a:explicit==[] ? haskellmode#ListIntersect(a:entry['hiding'], a:hiding)
\ : haskellmode#ListWithout(a:entry['hiding'],a:explicit)
let explicit = haskellmode#ListUnion(a:entry['explicit'], a:explicit)
let modules = haskellmode#ListUnion(a:entry['modules'], [ a:module ])
return {'lines':lines,'hiding':hiding,'explicit':explicit,'modules':modules}
endfunction
" collect lines belonging to a single import statement;
" return number of last line and collected import statement
" (assume opening parenthesis, if any, is on the first line)
function! haskellmode#GatherImport(lineno)
let lineno = a:lineno
let import = getline(lineno)
if !(import=~'^import\s') | return [] | endif
let open = strlen(substitute(import,'[^(]','','g'))
let close = strlen(substitute(import,'[^)]','','g'))
while open!=close
let lineno += 1
let linecont = getline(lineno)
let open += strlen(substitute(linecont,'[^(]','','g'))
let close += strlen(substitute(linecont,'[^)]','','g'))
let import .= linecont
endwhile
return [lineno,import]
endfunction
function! haskellmode#UrlEncode(string)
let pat = '\([^[:alnum:]]\)'
let code = '\=printf("%%%02X",char2nr(submatch(1)))'
let url = substitute(a:string,pat,code,'g')
return url
endfunction
" TODO: we could have buffer-local settings, at the expense of
" reconfiguring for every new buffer.. do we want to?
function! haskellmode#GHC()
if (!exists("g:ghc") || !executable(g:ghc))
if !executable('ghc')
echoerr s:scriptname.": can't find ghc. please set g:ghc, or extend $PATH"
return 0
else
let g:ghc = 'ghc'
endif
endif
return 1
endfunction
function! haskellmode#GHC_Version()
if !exists("g:ghc_version")
let g:ghc_version = substitute(system(g:ghc . ' --numeric-version'),'\n','','')
endif
return g:ghc_version
endfunction
function! haskellmode#GHC_VersionGE(target)
let current = split(haskellmode#GHC_Version(), '\.' )
let target = a:target
for i in current
if ((target==[]) || (i>target[0]))
return 1
elseif (i==target[0])
let target = target[1:]
else
return 0
endif
endfor
return 1
endfunction
airline @ 1b8e4b96
Subproject commit e2a120869ba36da5d26df74fb23ef4052d55b6f0 Subproject commit 1b8e4b965adc97af623bf71c046c7d7408aba725
syntastic @ 272fc7df
Subproject commit a7758aa188a2a1979070c704ff721216bdd68bc8 Subproject commit 272fc7df3a87876eb2ebd69d29c93920ef8c57c1
" Vim Compiler File
" Compiler: GHC
" Maintainer: Claus Reinke <claus.reinke@talk21.com>
" Last Change: 22/06/2010
"
" part of haskell plugins: http://projects.haskell.org/haskellmode-vim
" ------------------------------ paths & quickfix settings first
"
if exists("current_compiler") && current_compiler == "ghc"
finish
endif
let current_compiler = "ghc"
let s:scriptname = "ghc.vim"
if !haskellmode#GHC() | finish | endif
if (!exists("b:ghc_staticoptions"))
let b:ghc_staticoptions = ''
endif
" set makeprg (for quickfix mode)
execute 'setlocal makeprg=' . g:ghc . '\ ' . escape(b:ghc_staticoptions,' ') .'\ -e\ :q\ %'
"execute 'setlocal makeprg=' . g:ghc .'\ -e\ :q\ %'
"execute 'setlocal makeprg=' . g:ghc .'\ --make\ %'
" quickfix mode:
" fetch file/line-info from error message
" TODO: how to distinguish multiline errors from warnings?
" (both have the same header, and errors have no common id-tag)
" how to get rid of first empty message in result list?
setlocal errorformat=
\%-Z\ %#,
\%W%f:%l:%c:\ Warning:\ %m,
\%E%f:%l:%c:\ %m,
\%E%>%f:%l:%c:,
\%+C\ \ %#%m,
\%W%>%f:%l:%c:,
\%+C\ \ %#%tarning:\ %m,
" oh, wouldn't you guess it - ghc reports (partially) to stderr..
setlocal shellpipe=2>
" ------------------------- but ghc can do a lot more for us..
"
" allow map leader override
if !exists("maplocalleader")
let maplocalleader='_'
endif
" initialize map of identifiers to their types
" associate type map updates to changedtick
if !exists("b:ghc_types")
let b:ghc_types = {}
let b:my_changedtick = b:changedtick
endif
if exists("g:haskell_functions")
finish
endif
let g:haskell_functions = "ghc"
" avoid hit-enter prompts
set cmdheight=3
" edit static GHC options
" TODO: add completion for options/packages?
command! GHCStaticOptions call GHC_StaticOptions()
function! GHC_StaticOptions()
let b:ghc_staticoptions = input('GHC static options: ',b:ghc_staticoptions)
execute 'setlocal makeprg=' . g:ghc . '\ ' . escape(b:ghc_staticoptions,' ') .'\ -e\ :q\ %'
let b:my_changedtick -=1
endfunction
map <LocalLeader>T :call GHC_ShowType(1)<cr>
map <LocalLeader>t :call GHC_ShowType(0)<cr>
function! GHC_ShowType(addTypeDecl)
let namsym = haskellmode#GetNameSymbol(getline('.'),col('.'),0)
if namsym==[]
redraw
echo 'no name/symbol under cursor!'
return 0
endif
let [_,symb,qual,unqual] = namsym
let name = qual=='' ? unqual : qual.'.'.unqual
let pname = ( symb ? '('.name.')' : name )
call GHC_HaveTypes()
if !has_key(b:ghc_types,name)
redraw
echo pname "type not known"
else
redraw
for type in split(b:ghc_types[name],' -- ')
echo pname "::" type
if a:addTypeDecl
call append( line(".")-1, pname . " :: " . type )
endif
endfor
endif
endfunction
" show type of identifier under mouse pointer in balloon
" TODO: it isn't a good idea to tie potentially time-consuming tasks
" (querying GHCi for the types) to cursor movements (#14). Currently,
" we ask the user to call :GHCReload explicitly. Should there be an
" option to reenable the old implicit querying?
if has("balloon_eval")
set ballooneval
set balloondelay=600
set balloonexpr=GHC_TypeBalloon()
function! GHC_TypeBalloon()
if exists("b:current_compiler") && b:current_compiler=="ghc"
let [line] = getbufline(v:beval_bufnr,v:beval_lnum)
let namsym = haskellmode#GetNameSymbol(line,v:beval_col,0)
if namsym==[]
return ''
endif
let [start,symb,qual,unqual] = namsym
let name = qual=='' ? unqual : qual.'.'.unqual
let pname = name " ( symb ? '('.name.')' : name )
if b:ghc_types == {}
redraw
echo "no type information (try :GHGReload)"
elseif (b:my_changedtick != b:changedtick)
redraw
echo "type information may be out of date (try :GHGReload)"
endif
" silent call GHC_HaveTypes()
if b:ghc_types!={}
if has("balloon_multiline")
return (has_key(b:ghc_types,pname) ? split(b:ghc_types[pname],' -- ') : '')
else
return (has_key(b:ghc_types,pname) ? b:ghc_types[pname] : '')
endif
else
return ''
endif
else
return ''
endif
endfunction
endif
map <LocalLeader>si :call GHC_ShowInfo()<cr>
function! GHC_ShowInfo()
let namsym = haskellmode#GetNameSymbol(getline('.'),col('.'),0)
if namsym==[]
redraw
echo 'no name/symbol under cursor!'
return 0
endif
let [_,symb,qual,unqual] = namsym
let name = qual=='' ? unqual : (qual.'.'.unqual)
let output = GHC_Info(name)
pclose | new
setlocal previewwindow
setlocal buftype=nofile
setlocal noswapfile
put =output
wincmd w
"redraw
"echo output
endfunction
" fill the type map, unless nothing has changed since the last attempt
function! GHC_HaveTypes()
if b:ghc_types == {} && (b:my_changedtick != b:changedtick)
let b:my_changedtick = b:changedtick
return GHC_BrowseAll()
endif
endfunction
" update b:ghc_types after successful make
au QuickFixCmdPost make if GHC_CountErrors()==0 | silent call GHC_BrowseAll() | endif
" count only error entries in quickfix list, ignoring warnings
function! GHC_CountErrors()
let c=0
for e in getqflist() | if e.type=='E' && e.text !~ "^[ \n]*Warning:" | let c+=1 | endif | endfor
return c
endfunction
command! GHCReload call GHC_BrowseAll()
function! GHC_BrowseAll()
" let imports = haskellmode#GatherImports()
" let modules = keys(imports[0]) + keys(imports[1])
let b:my_changedtick = b:changedtick
let imports = {} " no need for them at the moment
let current = GHC_NameCurrent()
let module = current==[] ? 'Main' : current[0]
if haskellmode#GHC_VersionGE([6,8,1])
return GHC_BrowseBangStar(module)
else
return GHC_BrowseMultiple(imports,['*'.module])
endif
endfunction
function! GHC_NameCurrent()
let last = line("$")
let l = 1
while l<last
let ml = matchlist( getline(l), '^module\s*\([^ (]*\)')
if ml != []
let [_,module;x] = ml
return [module]
endif
let l += 1
endwhile
redraw
echo "cannot find module header for file " . expand("%")
return []
endfunction
function! GHC_BrowseBangStar(module)
redraw
echo "browsing module " a:module
let command = ":browse! *" . a:module
let orig_shellredir = &shellredir
let &shellredir = ">" " ignore error/warning messages, only output or lack of it
let output = system(g:ghc . ' ' . b:ghc_staticoptions . ' -v0 --interactive ' . expand("%") , command )
let &shellredir = orig_shellredir
return GHC_ProcessBang(a:module,output)
endfunction
function! GHC_BrowseMultiple(imports,modules)
redraw
echo "browsing modules " a:modules
let command = ":browse " . join( a:modules, " \n :browse ")
let command = substitute(command,'\(:browse \(\S*\)\)','putStrLn "-- \2" \n \1','g')
let output = system(g:ghc . ' ' . b:ghc_staticoptions . ' -v0 --interactive ' . expand("%") , command )
return GHC_Process(a:imports,output)
endfunction
function! GHC_Info(what)
" call GHC_HaveTypes()
let output = system(g:ghc . ' ' . b:ghc_staticoptions . ' -v0 --interactive ' . expand("%"), ":info ". a:what)
return output
endfunction
function! GHC_ProcessBang(module,output)
let module = a:module
let b = a:output
let linePat = '^\(.\{-}\)\n\(.*\)'
let contPat = '\s\+\(.\{-}\)\n\(.*\)'
let typePat = '^\(\)\(\S*\)\s*::\(.*\)'
let commentPat = '^-- \(\S*\)'
let definedPat = '^-- defined locally'
let importedPat = '^-- imported via \(.*\)'
if !(b=~commentPat)
echo s:scriptname.": GHCi reports errors (try :make?)"
return 0
endif
let b:ghc_types = {}
let ml = matchlist( b , linePat )
while ml != []
let [_,l,rest;x] = ml
let mlDecl = matchlist( l, typePat )
if mlDecl != []
let [_,indent,id,type;x] = mlDecl
let ml2 = matchlist( rest , '^'.indent.contPat )
while ml2 != []
let [_,c,rest;x] = ml2
let type .= c
let ml2 = matchlist( rest , '^'.indent.contPat )
endwhile
let id = substitute( id, '^(\(.*\))$', '\1', '')
let type = substitute( type, '\s\+', " ", "g" )
" using :browse! *<current>, we get both unqualified and qualified ids
let qualified = (id =~ '\.') && (id =~ '[A-Z]')
let b:ghc_types[id] = type
if !qualified
for qual in qualifiers
let b:ghc_types[qual.'.'.id] = type
endfor
endif
else
let mlImported = matchlist( l, importedPat )
let mlDefined = matchlist( l, definedPat )
if mlImported != []
let [_,modules;x] = mlImported
let qualifiers = split( modules, ', ' )
elseif mlDefined != []
let qualifiers = [module]
endif
endif
let ml = matchlist( rest , linePat )
endwhile
return 1
endfunction
function! GHC_Process(imports,output)
let b = a:output
let imports = a:imports
let linePat = '^\(.\{-}\)\n\(.*\)'
let contPat = '\s\+\(.\{-}\)\n\(.*\)'
let typePat = '^\(\s*\)\(\S*\)\s*::\(.*\)'
let modPat = '^-- \(\S*\)'
" add '-- defined locally' and '-- imported via ..'
if !(b=~modPat)
echo s:scriptname.": GHCi reports errors (try :make?)"
return 0
endif
let b:ghc_types = {}
let ml = matchlist( b , linePat )
while ml != []
let [_,l,rest;x] = ml
let mlDecl = matchlist( l, typePat )
if mlDecl != []
let [_,indent,id,type;x] = mlDecl
let ml2 = matchlist( rest , '^'.indent.contPat )
while ml2 != []
let [_,c,rest;x] = ml2
let type .= c
let ml2 = matchlist( rest , '^'.indent.contPat )
endwhile
let id = substitute(id, '^(\(.*\))$', '\1', '')
let type = substitute( type, '\s\+', " ", "g" )
" using :browse *<current>, we get both unqualified and qualified ids
if current_module " || has_key(imports[0],module)
if has_key(b:ghc_types,id) && !(matchstr(b:ghc_types[id],escape(type,'[].'))==type)
let b:ghc_types[id] .= ' -- '.type
else
let b:ghc_types[id] = type
endif
endif
if 0 " has_key(imports[1],module)
let qualid = module.'.'.id
let b:ghc_types[qualid] = type
endif
else
let mlMod = matchlist( l, modPat )
if mlMod != []
let [_,module;x] = mlMod
let current_module = module[0]=='*'
let module = current_module ? module[1:] : module
endif
endif
let ml = matchlist( rest , linePat )
endwhile
return 1
endfunction
let s:ghc_templates = ["module _ () where","class _ where","class _ => _ where","instance _ where","instance _ => _ where","type family _","type instance _ = ","data _ = ","newtype _ = ","type _ = "]
" use ghci :browse index for insert mode omnicompletion (CTRL-X CTRL-O)
function! GHC_CompleteImports(findstart, base)
if a:findstart
let namsym = haskellmode#GetNameSymbol(getline('.'),col('.'),-1) " insert-mode: we're 1 beyond the text
if namsym==[]
redraw
echo 'no name/symbol under cursor!'
return -1
endif
let [start,symb,qual,unqual] = namsym
return (start-1)
else " find keys matching with "a:base"
let res = []
let l = len(a:base)-1
call GHC_HaveTypes()
for key in keys(b:ghc_types)
if key[0 : l]==a:base
let res += [{"word":key,"menu":":: ".b:ghc_types[key],"dup":1}]
endif
endfor
return res
endif
endfunction
set omnifunc=GHC_CompleteImports
"
" Vim's default completeopt is menu,preview
" you probably want at least menu, or you won't see alternatives listed
" setlocal completeopt+=menu
" menuone is useful, but other haskellmode menus will try to follow your choice here in future
" setlocal completeopt+=menuone
" longest sounds useful, but doesn't seem to do what it says, and interferes with CTRL-E
" setlocal completeopt-=longest
map <LocalLeader>ct :call GHC_CreateTagfile()<cr>
function! GHC_CreateTagfile()
redraw
echo "creating tags file"
let output = system(g:ghc . ' ' . b:ghc_staticoptions . ' -e ":ctags" ' . expand("%"))
" for ghcs older than 6.6, you would need to call another program
" here, such as hasktags
echo output
endfunction
command! -nargs=1 GHCi redraw | echo system(g:ghc. ' ' . b:ghc_staticoptions .' '.expand("%").' -e "'.escape(<f-args>,'"').'"')
" use :make 'not in scope' errors to explicitly list imported ids
" cursor needs to be on import line, in correctly loadable module
map <LocalLeader>ie :call GHC_MkImportsExplicit()<cr>
function! GHC_MkImportsExplicit()
let save_cursor = getpos(".")
let line = getline('.')
let lineno = line('.')
let ml = matchlist(line,'^import\(\s*qualified\)\?\s*\([^( ]\+\)')
if ml!=[]
let [_,q,mod;x] = ml
silent make
if getqflist()==[]
if line=~"import[^(]*Prelude"
call setline(lineno,substitute(line,"(.*","","").'()')
else
call setline(lineno,'-- '.line)
endif
silent write
silent make
let qflist = getqflist()
call setline(lineno,line)
silent write
let ids = {}
for d in qflist
let ml = matchlist(d.text,'Not in scope: \([^`]*\)`\([^'']*\)''')
if ml!=[]
let [_,what,qid;x] = ml
let id = ( qid =~ "^[A-Z]" ? substitute(qid,'.*\.\([^.]*\)$','\1','') : qid )
let pid = ( id =~ "[a-zA-Z0-9_']\\+" ? id : '('.id.')' )
if what =~ "data"
call GHC_HaveTypes()
if has_key(b:ghc_types,id)
let pid = substitute(b:ghc_types[id],'^.*->\s*\(\S*\).*$','\1','').'('.pid.')'
else
let pid = '???('.pid.')'
endif
endif
let ids[pid] = 1
endif
endfor
call setline(lineno,'import'.q.' '.mod.'('.join(keys(ids),',').')')
else
copen
endif
endif
call setpos('.', save_cursor)
endfunction
" no need to ask GHC about its supported languages and
" options with every editing session. cache the info in
" ~/.vim/haskellmode.config
" TODO: should we store more info (see haskell_doc.vim)?
" move to autoload?
" should we keep a history of GHC versions encountered?
function! GHC_SaveConfig()
let vimdir = expand('~').'/'.'.vim'
let config = vimdir.'/haskellmode.config'
if !isdirectory(vimdir)
call mkdir(vimdir)
endif
let entries = ['-- '.g:ghc_version]
for l in s:ghc_supported_languages
let entries += [l]
endfor
let entries += ['--']
for l in s:opts
let entries += [l]
endfor
call writefile(entries,config)
endfunction
" reuse cached GHC configuration info, if using the same
" GHC version.
function! GHC_LoadConfig()
let vimdir = expand('~').'/'.'.vim'
let config = vimdir.'/haskellmode.config'
if filereadable(config)
let lines = readfile(config)
if lines[0]=='-- '.g:ghc_version
let i=1
let s:ghc_supported_languages = []
while i<len(lines) && lines[i]!='--'
let s:ghc_supported_languages += [lines[i]]
let i+=1
endwhile
let i+=1
let s:opts = []
while i<len(lines)
let s:opts += [lines[i]]
let i+=1
endwhile
return 1
else
return 0
endif
else
return 0
endif
endfunction
let s:GHC_CachedConfig = haskellmode#GHC_VersionGE([6,8]) && GHC_LoadConfig()
if haskellmode#GHC_VersionGE([6,8,2])
if !s:GHC_CachedConfig
let s:opts = filter(split(substitute(system(g:ghc . ' -v0 --interactive', ':set'), ' ', '','g'), '\n'), 'v:val =~ "-f"')
endif
else
let s:opts = ["-fglasgow-exts","-fallow-undecidable-instances","-fallow-overlapping-instances","-fno-monomorphism-restriction","-fno-mono-pat-binds","-fno-cse","-fbang-patterns","-funbox-strict-fields"]
endif
let s:opts = sort(s:opts)
amenu ]OPTIONS_GHC.- :echo '-'<cr>
aunmenu ]OPTIONS_GHC
for o in s:opts
exe 'amenu ]OPTIONS_GHC.'.o.' :call append(0,"{-# OPTIONS_GHC '.o.' #-}")<cr>'
endfor
if has("gui_running")
map <LocalLeader>opt :popup ]OPTIONS_GHC<cr>
else
map <LocalLeader>opt :emenu ]OPTIONS_GHC.
endif
amenu ]LANGUAGES_GHC.- :echo '-'<cr>
aunmenu ]LANGUAGES_GHC
if haskellmode#GHC_VersionGE([6,8])
if !s:GHC_CachedConfig
let s:ghc_supported_languages = sort(split(system(g:ghc . ' --supported-languages'),'\n'))
endif
for l in s:ghc_supported_languages
exe 'amenu ]LANGUAGES_GHC.'.l.' :call append(0,"{-# LANGUAGE '.l.' #-}")<cr>'
endfor
if has("gui_running")
map <LocalLeader>lang :popup ]LANGUAGES_GHC<cr>
else
map <LocalLeader>lang :emenu ]LANGUAGES_GHC.
endif
endif
if !s:GHC_CachedConfig
call GHC_SaveConfig()
endif
a4paper
a5paper
aa
AA
abbrv
abovedisplayshortskip
abovedisplayskip
abstract
abstractname
acute
addcontentsline
address
addtime
addtocontents
addtocounter
addtolength
addvspace
ae
AE
aleph
align
alph
Alph
alpha
amalg
amsmath
amsthm
and
angle
Ankh
appendix
appendixname
approx
approxeq
aquarius
Aquarius
arabic
aries
Aries
array
arraycolsep
arrayrulewidth
arraystretch
article
ascnode
ast
astrosun
asymp
ataribox
author
b5paper
backepsilon
backmatter
backprime
backsim
backsimeq
backslash
bar
barwedge
baselineskip
baselinestretch
Bat
batchmode
Bbbk
because
begin
bell
belowdisplayshortskip
belowdisplayskip
beta
between
bezier
bf
bfseries
bibindent
bibitem
bibliography
bibliographystyle
bibname
big
Big
bigcap
bigcirc
bigcup
bigg
Bigg
biggl
Biggl
biggm
Biggm
biggr
Biggr
bigl
Bigl
bigm
Bigm
bigodot
bigoplus
bigotimes
bigr
Bigr
bigskip
bigskipamount
bigsqcup
bigstar
bigtriangledown
bigtriangleup
biguplus
bigvee
bigwedge
binom
blacklozenge
blacksmiley
blacksquare
blacktriangle
blacktriangledown
blacktriangleleft
blacktriangleright
blg
boldmath
boldsymbol
book
bot
botfigrule
bottmofraction
bottomnumber
Bouquet
bowtie
Bowtie
Box
boxdot
boxedminipage
boxminus
boxplus
boxtimes
bp
breve
brokenvert
bullet
bumpeq
Bumpeq
calc
cancer
Cancer
cap
Cap
Capricorn
capricornus
caption
caption2
capt-of
cases
cc
ccaption
ccname
cdot
cdotp
cdots
cdotscenter
celsius
Celtcross
cent
centerdot
centering
cercle
cfrac
changebar
chapter
chapterbib
chaptername
check
checked
checkmark
chi
circ
circeq
circlearrowleft
circlearrowright
CircledA
circledast
circledcirc
circleddash
circledR
circledS
cite
cleardoublepage
clearpage
cline
clock
closing
clubsuit
cm
colon
COLON
columnsep
columnseprule
columnwidth
complement
cong
conjunction
contentsline
contentsname
coprod
copyright
Cross
cup
Cup
curlyeqprec
curlyeqsucc
curlyvee
curlywedge
currency
curvearrowleft
curvearrowright
dag
dagger
dashbox
dashleftarrow
dashrightarrow
dashv
date
dbinom
dblfigure
dblfloatpage
dblfloatsep
dbltextfloatsep
dbltopfraction
dbltopnumber
dcolumn
dd
ddag
ddagger
ddot
ddots
DeclareMathOperator
degree
delta
Delta
Denarius
depth
descnode
description
dfrac
dh
DH
diagdown
diagup
diameter
diamond
Diamond
diamondsuit
digamma
displaylimits
displaymath
displaystyle
div
divideontimes
dj
DJ
document
documentclass
dot
doteq
doteqdot
dotfill
dotplus
dots
dotsb
dotsc
dotsi
dotsint
dotsm
dotso
doublebarwedge
doublerulesep
downarrow
Downarrow
DOWNarrow
downbracefill
downdownarrows
downharpoonleft
downharpoonright
draft
dropping
dywiz
earth
Earth
Ecommerce
ell
em
Email
Emailct
emph
empty
emptyset
encl
enclname
end
endfloat
enlargethispage
enskip
enspace
ensuremath
enumerate
enumi
enumii
enumiii
enumiv
epsilon
eqcirc
eqnarray
eqslantgtr
eqslantless
equation
equiv
errorstopmode
eta
eth
eucal
eufrak
EUR
EURcr
EURdig
EURhv
EURtm
evensidemargin
everyship
ex
executivepaper
exists
expdlist
extracolsep
extramark
EyesDollar
fallingdotseq
fancybox
fancyhdr
fax
FAX
Faxmachine
fbox
fboxrule
fboxsep
female
FHBOlogo
FHBOLOGO
figure
figurename
file
filecontents
final
fint
Finv
flafter
flat
fleqn
floatflt
floatpagefraction
floatsep
flushbottom
flushleft
flushright
fn2end
fnpara
fnsymbol
fontenc
footheight
footmisc
footnote
footnotemark
footnoterule
footnotesep
footnotesize
footnotetext
footnpag
footskip
forall
frac
frame
framebox
frenchspacing
frontmatter
frown
frownie
Frowny
ftnright
FullFHBO
fullmoon
fussy
Game
gamma
Gamma
gather
gemini
Gemini
genfrac
geometry
geq
geqq
geqslant
gg
ggg
glossary
glossaryentry
gnapprox
gneq
gneqq
gnsim
graphicx
graphpaper
grave
gtrapprox
gtrdot
gtreqless
gtreqqless
gtrless
gtrsim
guillemotleft
guillemotright
guilsinglleft
guilsinglright
gvertneqq
hat
hbar
hbox
headheihgt
headings
headsep
Heart
heartsuit
height
helvet
hfill
hhline
hline
hookleftarrow
hookrightarrow
hrulefill
hslash
hspace
huge
Huge
HUGE
hyperref
hyphenation
iddots
idotsint
ifthen
iiiint
iiint
iint
Im
imath
in
include
includeonly
indent
indentfirst
index
indexentry
indexname
indexspace
infty
inplus
input
inputenc
int
intercal
intertext
intextsep
invdiameter
invisible
iota
it
item
itemindent
itemize
itemsep
itshape
jmath
Join
jot
jupiter
Jupiter
kappa
kill
kreuz
label
labelenumi
labelenumii
labelenumiii
labelenumiv
labelitemi
labelitemii
labelitemiii
labelitemiv
labelsep
labelwidth
lambda
Lambda
landdownint
landscape
landupint
langle
large
Large
LARGE
LaTeX
LaTeXe
latexsym
lbag
Lbag
lceil
ldotp
ldots
leadsto
left
leftarrow
Leftarrow
LEFTarrow
leftarrowfill
leftarrowtail
leftarrowtriangle
lefteqn
leftharpoondown
leftharpoonup
leftleftarrows
leftmargin
leftmargini
leftmarginii
leftmarginiii
leftmarginiv
leftmarginv
leftmarginvi
leftmark
leftmoon
leftrightarrow
Leftrightarrow
leftrightarroweq
leftrightarrows
leftrightarrowtriangle
leftrightharpoons
leftrightsquigarrow
leftthreetimes
legalpaper
leo
Leo
leq
leqno
leqq
leqslant
lessapprox
lessdot
lesseqgtr
lesseqqgtr
lessgtr
lesssim
letter
Letter
letterpaper
letterspace
lfloor
lhd
LHD
lhead
libra
Libra
lightning
Lightning
limits
line
linebreak
linethickness
linewidth
list
listfigurename
listfiles
listoffigures
listoftables
listparindent
ll
llbracket
llceil
Lleftarrow
llfloor
lll
llparenthesis
lnapprox
lneq
lneqq
lnsim
location
longleftarrow
Longleftarrow
longleftrightarrow
Longleftrightarrow
longmapsfrom
Longmapsfrom
longmapsto
Longmapsto
longrightarrow
Longrightarrow
longtable
looparrowleft
looparrowright
lozenge
lq
lrbox
lscape
Lsh
ltimes
lvertneqq
mainmatter
makeatletter
makeatother
makebox
makeglossary
makeidx
makeindex
makelabel
maketitle
male
maltese
manyfoot
mapsfrom
Mapsfrom
mapsto
Mapsto
marginpar
marginparpush
marginparsep
marginparwidth
markboth
markleft
markright
mars
Mars
MartinVogel
math
mathbb
mathbf
mathbin
mathcal
mathclose
mathdollar
mathds
mathellipsis
mathfrak
mathindent
mathit
mathnormal
mathop
mathopen
mathord
mathparagraph
mathpunct
mathrel
mathrm
mathscr
mathsection
mathsf
mathsterling
mathstrut
mathtt
mathunderscore
mathversion
mbox
mdseries
measuredangle
medmuskip
medskip
medskipamount
mercury
Mercury
mho
micro
mid
minipage
minitoc
minus
mkern
mm
Mobilefone
models
Moon
moreverbatim
mp
mpfootnote
mu
multicol
multicolumn
multilanguage
multimap
multiput
multirow
Mundus
MVAt
MVRightarrow
myheadings
nabla
name
natural
ncong
nearrow
NeedsTeXFormat
neg
neptune
Neptune
neq
newcommand
newcounter
newenvironment
newfont
newlength
newline
newmoon
newpage
newsavebox
newtheorem
nexists
ng
NG
ngeq
ngeqq
ngeqslant
ngtr
ni
niplus
nleftarrow
nLeftarrow
nleftrightarrow
nLeftrightarrow
nleq
nleqq
nleqslant
nless
nmid
nnearrow
nnwarrow
nocite
nofiles
noindent
nolimits
nolinebreak
nomathsymbols
nonfrenchspacing
nonumber
nopagebreak
normalfont
normalsize
not
notag
note
notin
notitlepage
nparallel
nprec
npreceq
nrightarrow
nRightarrow
nshortmid
nshortparallel
nsim
nsubseteq
nsucc
nsucceq
nsupseteq
nsupseteqq
ntriangleleft
ntrianglelefteq
ntriangleright
ntrianglerighteq
nu
numberline
numline
numprint
nvdash
nvDash
nVDash
nwarrow
ocircle
oddsidemargin
odot
oe
OE
ohm
ohorn
OHORN
oiint
oint
ointclockwise
ointctrclockwise
oldstyle
omega
Omega
ominus
onecolumn
oneside
onlynotes
onlyslides
openany
openbib
opening
openright
operatorname
oplus
opposition
oslash
otimes
oval
overbrace
overlay
overleftarrow
overline
overrightarrow
page
pagebreak
pagenumbering
pageref
pagestyle
paperheight
paperwidth
par
paragraph
parallel
parbox
parindent
parr
parsep
parskip
part
partial
partname
partopsep
pauza
pc
permil
perp
perthousand
Pfund
phi
Phi
phone
pi
Pi
Pickup
picture
pisces
Pisces
pitchfork
plain
PLdateending
plmath
PLSlash
plus
pluto
Pluto
pm
pmb
pmod
pointer
polski
poptabs
pounds
ppauza
prec
precapprox
preccurlyeq
preceq
precnapprox
precnsim
precsim
prefixing
prime
printindex
prod
propto
protect
providecommand
ps
psi
Psi
pt
pushtabs
put
qbezier
qbeziermax
qquad
quad
quotation
quote
quotedblbase
quotesinglbase
ragged2e
raggedbottom
raggedleft
raggedright
raisebox
rangle
ratio
rbag
Rbag
rceil
Re
real
recorder
ref
refname
refstepcounter
relsize
renewcommand
renewenvironment
report
reversemarginpar
rfloor
rhd
RHD
rhead
rho
right
rightarrow
Rightarrow
RIGHTarrow
rightarrowfill
rightarrowtail
rightarrowtriangle
rightharpoondown
rightharpoonup
rightleftarrows
rightleftharpoons
rightmargin
rightmark
rightmoon
rightrightarrows
rightsquigarrow
rightthreetimes
risingdotseq
rm
rmfamily
roman
Roman
rotate
rotating
rq
rrbracket
rrceil
rrfloor
Rrightarrow
rrparenthesis
Rsh
rtimes
rule
sagittarius
Sagittarius
samepage
saturn
Saturn
savebox
sb
sbox
sc
scorpio
Scorpio
scriptscriptstyle
scriptsize
scriptstyle
scrollmode
scshape
searrow
secnumdepth
section
sectionmark
see
seename
selectfont
selectlanguage
setcounter
setlength
setminus
settime
settodepth
settoheight
settowidth
sf
sffamily
shadethm
shadow
shapepar
sharp
Shilling
shortdownarrow
shortleftarrow
shortmid
shortparallel
shortrightarrow
shortstack
shortuparrow
showlabels
sidecap
sigma
Sigma
signature
sim
simeq
sin
skull
sl
slide
slides
sloppy
sloppybar
slshape
small
smallfrown
smallsetminus
smallskip
smallskipamount
smallsmile
smile
smiley
Smiley
soul
sp
space
spadesuit
sphericalangle
sqcap
sqcup
sqiint
sqint
sqrt
sqsubset
sqsubseteq
sqsupset
sqsupseteq
square
ss
SS
ssearrow
sswarrow
stackrel
star
startbreaks
stepcounter
stop
stopbreaks
stretch
strut
subfigure
subitem
subparagraph
subsection
subset
Subset
subseteq
subseteqq
subsetneq
subsetneqq
subsubitem
subsubsection
succ
succapprox
succcurlyeq
succeq
succnapprox
succnsim
succsim
sum
sun
Sun
supressfloats
supset
Supset
supseteq
supseteqq
supsetneq
supsetneqq
surd
swarrow
symbol
tabbing
tabcolsep
table
tablename
tableofcontents
tabular
tabularx
tag
tan
tau
taurus
Taurus
tbinom
Telefon
telephone
TeX
textaolig
textasciicircum
textasciitilde
textasteriskcentered
textbabygamma
textbackslash
textbaht
textbar
textbarb
textbarc
textbard
textbardbl
textbardotlessj
textbarg
textbarglotstop
textbari
textbarl
textbaro
textbarrevglotstop
textbaru
textbeltl
textbenttailyogh
textbeta
textbf
textbigcircle
textbktailgamma
textblank
textbraceleft
textbraceright
textbrokenbar
textbullet
textbullseye
textceltpal
textcent
textcentoldstyle
textchi
textcircled
textcircledP
textcloseepsilon
textcloseomega
textcloserevepsilon
textcolonmonetary
textcommatailz
textcompwordmark
textcopyleft
textcopyright
textcorner
textcrb
textcrd
textcrg
textcrh
textcrinvglotstop
textcrlambda
textcrtwo
textctc
textctd
textctdctzlig
textctesh
textctinvglotstop
textctj
textctjvar
textctn
textctstretchc
textctstretchcvar
textctt
textcttctclig
textctturnt
textctyogh
textctz
textcurrency
textdagger
textdaggerdbl
textdblhyphen
textdblhyphenchar
textdblig
textdctzlig
textdegree
textdiscount
textdiv
textdollar
textdollaroldstyle
textdong
textdoublebaresh
textdoublebarpipe
textdoublebarpipevar
textdoublebarslash
textdoublepipe
textdoublepipevar
textdoublevertline
textdownarrow
textdownfullarrow
textdownstep
textdyoghlig
textdzlig
textellipsis
textemdash
textendash
textepsilon
textesh
textestimated
texteuro
textexclamdown
textfemale
textfishhookr
textfloatsep
textflorin
textfraction
textfractionsolidus
textfrbarn
textfrhookd
textfrhookdvar
textfrhookt
textfrtailgamma
textg
textgamma
textglobfall
textglobrise
textglotstop
textglotstopvari
textglotstopvarii
textglotstopvariii
textgreater
textgrgamma
textguarani
texthalflength
texthardsign
textheight
textheng
texthmlig
texthooktop
texthtb
texthtbardotlessj
texthtbardotlessjvar
texthtc
texthtd
texthtg
texthth
texththeng
texthtk
texthtp
texthtq
texthtrtaild
texthtscg
texthtt
texthvlig
textinterrobang
textinterrobangdown
textinvglotstop
textinvomega
textinvsca
textinvscr
textinvscripta
textiota
textit
textlambda
textlangle
textlbrackdbl
textleftarrow
textlengthmark
textless
textlfishhookrlig
textlhookfour
textlhookp
textlhookt
textlhti
textlhtlongi
textlhtlongy
textlira
textlnot
textlonglegr
textlooptoprevesh
textlptr
textlquill
textltailm
textltailn
textltilde
textlyoghlig
textmd
textminus
textmusicalnote
textnaira
textnormal
textnrleg
textnumero
textObardotlessj
textObullseye
textOlyoghlig
textomega
textonehalf
textonequarter
textonesuperior
textopenbullet
textopencorner
textopeno
textordfeminine
textordmasculine
textpalhook
textpalhooklong
textpalhookvar
textparagraph
textperiodcenter
textperiodcentered
textpertenthousand
textperthousand
textpeso
textphi
textpilcrow
textpipe
textpipevar
textpm
textprimstress
textqplig
textquestiondown
textquotedbl
textquotedblleft
textquotedblright
textquoteleft
textquoteright
textquotesingle
textquotestraightbase
textquotestraightdblbase
textraiseglotstop
textraisevibyi
textramshorns
textrangle
textrbrackdbl
textrecipe
textrectangle
textreferencemark
textregistered
textretractingvar
textrevapostrophe
textreve
textrevepsilon
textrevglotstop
textrevscl
textrevscr
textrevyogh
textrhooka
textrhooke
textrhookepsilon
textrhookopeno
textrhookrevepsilon
textrhookschwa
textrhoticity
textrightarrow
textrm
textrptr
textrquill
textrtaild
textrtailhth
textrtaill
textrtailn
textrtailr
textrtails
textrtailt
textrtailz
textrthook
textrthooklong
textsc
textsca
textscaolig
textscb
textscdelta
textsce
textscf
textscg
textsch
textschwa
textsci
textscj
textsck
textscl
textscm
textscn
textscoelig
textscomega
textscp
textscq
textscr
textscripta
textscriptg
textscriptv
textscu
textscy
textsecstress
textsection
textservicemark
textsf
textsl
textsoftsign
textspleftarrow
textsterling
textstretchc
textstretchcvar
textstyle
textsubdoublearrow
textsubrightarrow
textsuperscript
textsurd
texttctclig
textteshlig
texttheta
textthorn
textthornvari
textthornvarii
textthornvariii
textthornvariv
textthreequarters
textthreequartersemdash
textthreesuperior
texttildelow
texttimes
texttoneletterstem
texttrademark
texttslig
texttt
textturna
textturncelig
textturnglotstop
textturnh
textturnk
textturnlonglegr
textturnm
textturnmrleg
textturnr
textturnrrtail
textturnsck
textturnscripta
textturnscu
textturnt
textturnthree
textturntwo
textturnv
textturnw
textturny
texttwelveudash
texttwosuperior
textuncrfemale
textunderscore
textup
textuparrow
textupfullarrow
textupsilon
textupstep
textvertline
textvibyi
textvibyy
textvisiblespace
textwidth
textwon
textwynn
textyen
textyogh
tfrac
th
TH
thanks
the
thebibliography
theindex
theorem
thepage
therefore
thesection
theta
Theta
thickapprox
thicklines
thickmuskip
thicksim
thinlines
thispagestyle
threeparttable
tilde
time
times
tiny
title
titlepage
tocdepth
today
top
topfigrule
topfraction
topmargin
topsep
topskip
totalheight
totalnumber
triangle
triangledown
triangleleft
trianglelefteq
triangleq
triangleright
trianglerighteq
trivlist
tt
ttfamily
twocolumn
twoheadleftarrow
twoheadrightarrow
twoside
typein
typeout
uhorn
UHORN
ulem
unboldmath
underbrace
underline
unlhd
unrhd
unsort
unsrt
upalpha
uparrow
Uparrow
UParrow
upbeta
upbracefill
upchi
updelta
Updelta
updownarrow
Updownarrow
upepsilon
upeta
upgamma
Upgamma
upharpoonleft
upharpoonright
upiota
upkappa
uplambda
Uplambda
uplus
upmu
upnu
upomega
Upomega
upphi
Upphi
uppi
Uppi
uppsi
Uppsi
uprho
upshape
upsigma
Upsigma
upsilon
Upsilon
uptau
uptheta
Uptheta
upuparrows
upupsilon
Upupsilon
upvarepsilon
upvarphi
upvarpi
upvarrho
upvarsigma
upvartheta
upxi
Upxi
upzeta
uranus
Uranus
usebox
usecounter
usefont
usepackage
value
varepsilon
varkappa
varnothing
varoiint
varointclockwise
varointctrclockwise
varphi
varpi
varpropto
varrho
varsigma
varsubsetneq
varsubsetneqq
varsupsetneq
varsupsetneqq
vartheta
vartriangle
vartriangleleft
vartriangleright
vbox
vdash
vDash
Vdash
vdots
vec
vector
vee
veebar
venus
Venus
verb
verbatim
vernal
verse
vfill
virgo
Virgo
visible
vline
vmargin
voffset
vspace
Vvdash
wasylozenge
wedge
widehat
widetilde
width
with
Womanface
wp
wr
wrapfig
xi
Xi
xleftarrow
xrightarrow
Yinyang
zeta
"
" general Haskell source settings
" (shared functions are in autoload/haskellmode.vim)
"
" (Claus Reinke, last modified: 28/04/2009)
"
" part of haskell plugins: http://projects.haskell.org/haskellmode-vim
" please send patches to <claus.reinke@talk21.com>
" try gf on import line, or ctrl-x ctrl-i, or [I, [i, ..
setlocal include=^import\\s*\\(qualified\\)\\?\\s*
setlocal includeexpr=substitute(v:fname,'\\.','/','g').'.'
setlocal suffixesadd=hs,lhs,hsc
" Haskell Cuteness for Vim.
" Inspired by emacs-haskell-cuteness.
" Based on unilatex.vim by Jos van den Oever <oever@fenk.wau.nl>
"
" Changelog
" 0.1.3 - added more mappings and fixed bug in HaskellSrcToUTF8, thanks
" to edwardkmett at Reddit
" 0.1.2 - added syntax highlighting as suggested by sfvisser at Reddit
" 0.1.1 - fixed stupid bug with haskell lambda expression
" 0.1 - initial release
"
" Version: 0.1.2
" Last Changed: 7 April 2009
" Maintainer: Andrey Popp <andrey.popp@braintrace.ru>
" Map to unicode symbols
imap <buffer> \ λ
imap <buffer> <-
imap <buffer> ->
imap <buffer> <=
imap <buffer> >=
imap <buffer> ==
imap <buffer> /=
imap <buffer> =>
imap <buffer> >> »
imap <buffer> .<space><space>
imap <buffer> forall<space>
" Turn syntax highlight on for new symbols
syn match hsVarSym "(\|λ\|←\|→\|≲\|≳\|≡\|≠\| )"
if exists("s:loaded_unihaskell")
finish
endif
let s:loaded_unihaskell = 1
augroup HaskellC
autocmd BufReadPost *.hs cal s:HaskellSrcToUTF8()
autocmd BufWritePre *.hs cal s:UTF8ToHaskellSrc()
autocmd BufWritePost *.hs cal s:HaskellSrcToUTF8()
augroup END
" function to convert ''fancy haskell source'' to haskell source
function s:UTF8ToHaskellSrc()
let s:line = line(".")
let s:column = col(".")
silent %s/λ/\\/eg
silent %s/←/<-/eg
silent %s/→/->/eg
silent %s/≲/<=/eg
silent %s/≳/>=/eg
silent %s/≡/==/eg
silent %s/≠/\/=/eg
silent %s/⇒/=>/eg
silent %s/»/>>/eg
silent %s/∙ /. /eg
silent %s/∀/forall /eg
let &l:fileencoding = s:oldencoding
call cursor(s:line,s:column)
endfunction
" function to convert haskell source to ''fancy haskell source''
function s:HaskellSrcToUTF8()
let s:line = line(".")
let s:column = col(".")
let s:oldencoding = &l:fileencoding
set fileencoding=utf-8
silent %s/[^λ←→≲≳≡≠⇒»∙∀\\\-!#$%&*+/<=>?@\^|~.]\@<=\\\([^λ←→≲≳≡≠⇒»∙∀\\\-!#$%&*+/<=>\?@\^|~.]\)/λ\1/eg
silent %s/[^λ←→≲≳≡≠⇒»∙∀\\\-!#$%&*+/<=>?@\^|~.]\@<=->\([^λ←→≲≳≡≠⇒»∙∀\\\-!#$%&*+/<=>\?@\^|~.]\)/→\1/eg
silent %s/[^λ←→≲≳≡≠⇒»∙∀\\\-!#$%&*+/<=>?@\^|~.]\@<=<-\([^λ←→≲≳≡≠⇒»∙∀\\\-!#$%&*+/<=>\?@\^|~.]\)/←\1/eg
silent %s/[^λ←→≲≳≡≠⇒»∙∀\\\-!#$%&*+/<=>?@\^|~.]\@<=<=\([^λ←→≲≳≡≠⇒»∙∀\\\-!#$%&*+/<=>\?@\^|~.]\)/≲\1/eg
silent %s/[^λ←→≲≳≡≠⇒»∙∀\\\-!#$%&*+/<=>?@\^|~.]\@<=>=\([^λ←→≲≳≡≠⇒»∙∀\\\-!#$%&*+/<=>\?@\^|~.]\)/≳\1/eg
silent %s/[^λ←→≲≳≡≠⇒»∙∀\\\-!#$%&*+/<=>?@\^|~.]\@<===\([^λ←→≲≳≡≠⇒»∙∀\\\-!#$%&*+/<=>\?@\^|~.]\)/≡\1/eg
silent %s/[^λ←→≲≳≡≠⇒»∙∀\\\-!#$%&*+/<=>?@\^|~.]\@<=\/=\([^λ←→≲≳≡≠⇒»∙∀\\\-!#$%&*+/<=>\?@\^|~.]\)/≠\1/eg
silent %s/[^λ←→≲≳≡≠⇒»∙∀\\\-!#$%&*+/<=>?@\^|~.]\@<==>\([^λ←→≲≳≡≠⇒»∙∀\\\-!#$%&*+/<=>\?@\^|~.]\)/⇒\1/eg
silent %s/[^λ←→≲≳≡≠⇒»∙∀\\\-!#$%&*+/<=>?@\^|~.]\@<=>>\([^λ←→≲≳≡≠⇒»∙∀\\\-!#$%&*+/<=>\?@\^|~.]\)/»\1/eg
silent %s/forall /∀/eg
silent %s/ \@<=\. /∙ /eg
let &l:fileencoding = s:oldencoding
call cursor(s:line,s:column)
endfunction
do HaskellC BufRead
"
" use haddock docs and index files
" show documentation, complete & qualify identifiers
"
" (Claus Reinke; last modified: 17/06/2009)
"
" part of haskell plugins: http://projects.haskell.org/haskellmode-vim
" please send patches to <claus.reinke@talk21.com>
" :Doc <name> and :IDoc <name> open haddocks for <name> in opera
"
" :Doc needs qualified name (default Prelude) and package (default base)
" :IDoc needs unqualified name, looks up possible links in g:haddock_index
"
" :DocIndex populates g:haddock_index from haddock's index files
" :ExportDocIndex saves g:haddock_index to cache file
" :ImportDocIndex reloads g:haddock_index from cache file
"
" all the following use the haddock index (g:haddock_index)
"
" _? opens haddocks for unqualified name under cursor,
" suggesting alternative full qualifications in popup menu
"
" _. fully qualifies unqualified name under cursor,
" suggesting alternative full qualifications in popup menu
"
" _i add import <module>(<name>) statement for unqualified <name> under cursor,
" _im add import <module> statement for unqualified <name> under cursor,
" suggesting alternative full qualifications in popup menu
" (this currently adds one statement per call, instead of
" merging into existing import statements, but it's a start;-)
"
" CTRL-X CTRL-U (user-defined insert mode completion)
" suggests completions of unqualified names in popup menu
let s:scriptname = "haskell_doc.vim"
" script parameters
" g:haddock_browser *mandatory* which browser to call
" g:haddock_browser_callformat [optional] how to call browser
" g:haddock_indexfiledir [optional] where to put 'haddock_index.vim'
" g:haddock_docdir [optional] where to find html docs
" g:ghc [optional] which ghc to call
" g:ghc_pkg [optional] which ghc_pkg to call
" been here before?
if exists("g:haddock_index")
finish
endif
" initialise nested dictionary, to be populated
" - from haddock index files via :DocIndex
" - from previous cached version via :ImportDocIndex
let g:haddock_index = {}
" initialise dictionary, mapping modules with haddocks to their packages,
" populated via MkHaddockModuleIndex() or HaveModuleIndex()
let g:haddock_moduleindex = {}
" program to open urls, please set this in your vimrc
"examples (for windows):
"let g:haddock_browser = "C:/Program Files/Opera/Opera.exe"
"let g:haddock_browser = "C:/Program Files/Mozilla Firefox/firefox.exe"
"let g:haddock_browser = "C:/Program Files/Internet Explorer/IEXPLORE.exe"
if !exists("g:haddock_browser")
echoerr s:scriptname." WARNING: please set g:haddock_browser!"
endif
if !haskellmode#GHC() | finish | endif
if (!exists("g:ghc_pkg") || !executable(g:ghc_pkg))
let g:ghc_pkg = substitute(g:ghc,'\(.*\)ghc','\1ghc-pkg','')
endif
if exists("g:haddock_docdir") && isdirectory(g:haddock_docdir)
let s:docdir = g:haddock_docdir
elseif executable(g:ghc_pkg)
" try to figure out location of html docs
" first choice: where the base docs are (from the first base listed)
let [field;x] = split(system(g:ghc_pkg . ' field base haddock-html'),'\n')
" path changes in ghc-6.12.*
" let field = substitute(field,'haddock-html: \(.*\)libraries.base','\1','')
let field = substitute(field,'haddock-html: \(.*\)lib\(raries\)\?.base.*$','\1','')
let field = substitute(field,'\\','/','g')
" let alternate = substitute(field,'html','doc/html','')
" changes for ghc-6.12.*: check for doc/html/ first
let alternate = field.'doc/html/'
if isdirectory(alternate)
let s:docdir = alternate
elseif isdirectory(field)
let s:docdir = field
endif
else
echoerr s:scriptname." can't find ghc-pkg (set g:ghc_pkg ?)."
endif
" second choice: try some known suspects for windows/unix
if !exists('s:docdir') || !isdirectory(s:docdir)
let s:ghc_libdir = substitute(system(g:ghc . ' --print-libdir'),'\n','','')
let location1a = s:ghc_libdir . '/doc/html/'
let location1b = s:ghc_libdir . '/doc/'
let location2 = '/usr/share/doc/ghc-' . haskellmode#GHC_Version() . '/html/'
if isdirectory(location1a)
let s:docdir = location1a
elseif isdirectory(location1b)
let s:docdir = location1b
elseif isdirectory(location2)
let s:docdir = location2
else " give up
echoerr s:scriptname." can't find locaton of html documentation (set g:haddock_docdir)."
finish
endif
endif
" todo: can we turn s:docdir into a list of paths, and
" include docs for third-party libs as well?
let s:libraries = s:docdir . 'libraries/'
let s:guide = s:docdir . 'users_guide/'
let s:index = 'index.html'
if exists("g:haddock_indexfiledir") && filewritable(g:haddock_indexfiledir)
let s:haddock_indexfiledir = g:haddock_indexfiledir
elseif filewritable(s:libraries)
let s:haddock_indexfiledir = s:libraries
elseif filewritable($HOME)
let s:haddock_indexfiledir = $HOME.'/'
else "give up
echoerr s:scriptname." can't locate index file. please set g:haddock_indexfiledir"
finish
endif
let s:haddock_indexfile = s:haddock_indexfiledir . 'haddock_index.vim'
" different browser setups require different call formats;
" you might want to call the browser synchronously or
" asynchronously, and the latter is os-dependent;
"
" by default, the browser is started in the background when on
" windows or if running in a gui, and in the foreground otherwise
" (eg, console-mode for remote sessions, with text-mode browsers).
"
" you can override these defaults in your vimrc, via a format
" string including 2 %s parameters (the first being the browser
" to call, the second being the url).
if !exists("g:haddock_browser_callformat")
if has("win32") || has("win64")
let g:haddock_browser_callformat = 'start %s "%s"'
else
if has("gui_running")
let g:haddock_browser_callformat = '%s %s '.printf(&shellredir,'/dev/null').' &'
else
let g:haddock_browser_callformat = '%s %s'
endif
endif
endif
" allow map leader override
if !exists("maplocalleader")
let maplocalleader='_'
endif
command! DocSettings call DocSettings()
function! DocSettings()
for v in ["g:haddock_browser","g:haddock_browser_callformat","g:haddock_docdir","g:haddock_indexfiledir","s:ghc_libdir","g:ghc_version","s:docdir","s:libraries","s:guide","s:haddock_indexfile"]
if exists(v)
echo v '=' eval(v)
else
echo v '='
endif
endfor
endfunction
function! DocBrowser(url)
"echomsg "DocBrowser(".url.")"
if (!exists("g:haddock_browser") || !executable(g:haddock_browser))
echoerr s:scriptname." can't find documentation browser. please set g:haddock_browser"
return
endif
" start browser to open url, according to specified format
let url = a:url=~'^\(file://\|http://\)' ? a:url : 'file://'.a:url
silent exe '!'.printf(g:haddock_browser_callformat,g:haddock_browser,escape(url,'#%'))
endfunction
"Doc/Doct are an old interface for documentation lookup
"(that is the reason they are not documented!-)
"
"These uses are still fine at the moment, and are the reason
"that this command still exists at all
"
" :Doc -top
" :Doc -libs
" :Doc -guide
"
"These uses may or may not work, and shouldn't be relied on anymore
"(usually, you want _?/_?1/_?2 or :MDoc; there is also :IDoc)
"
" :Doc length
" :Doc Control.Monad.when
" :Doc Data.List.
" :Doc Control.Monad.State.runState mtl
command! -nargs=+ Doc call Doc('v',<f-args>)
command! -nargs=+ Doct call Doc('t',<f-args>)
function! Doc(kind,qualname,...)
let suffix = '.html'
let relative = '#'.a:kind.'%3A'
if a:qualname=="-top"
call DocBrowser(s:docdir . s:index)
return
elseif a:qualname=="-libs"
call DocBrowser(s:libraries . s:index)
return
elseif a:qualname=="-guide"
call DocBrowser(s:guide . s:index)
return
endif
if a:0==0 " no package specified
let package = 'base/'
else
let package = a:1 . '/'
endif
if match(a:qualname,'\.')==-1 " unqualified name
let [qual,name] = [['Prelude'],a:qualname]
let file = join(qual,'-') . suffix . relative . name
elseif a:qualname[-1:]=='.' " module qualifier only
let parts = split(a:qualname,'\.')
let quallen = len(parts)-1
let [qual,name] = [parts[0:quallen],parts[-1]]
let file = join(qual,'-') . suffix
else " qualified name
let parts = split(a:qualname,'\.')
let quallen = len(parts)-2
let [qual,name] = [parts[0:quallen],parts[-1]]
let file = join(qual,'-') . suffix . relative . name
endif
let path = s:libraries . package . file
call DocBrowser(path)
endfunction
" TODO: add commandline completion for :IDoc
" switch to :emenu instead of inputlist?
" indexed variant of Doc, looking up links in g:haddock_index
" usage:
" 1. :IDoc length
" 2. click on one of the choices, or select by number (starting from 0)
command! -nargs=+ IDoc call IDoc(<f-args>)
function! IDoc(name,...)
let choices = HaddockIndexLookup(a:name)
if choices=={} | return | endif
if a:0==0
let keylist = map(deepcopy(keys(choices)),'substitute(v:val,"\\[.\\]","","")')
let choice = inputlist(keylist)
else
let choice = a:1
endif
let path = values(choices)[choice] " assumes same order for keys/values..
call DocBrowser(path)
endfunction
let s:flagref = s:guide . 'flag-reference.html'
if filereadable(s:flagref)
" extract the generated fragment ids for the
" flag reference sections
let s:headerPat = '.\{-}<h3 class="title"><a name="\([^"]*\)"><\/a>\([^<]*\)<\/h3>\(.*\)'
let s:flagheaders = []
let s:flagheaderids = {}
let s:contents = join(readfile(s:flagref))
let s:ml = matchlist(s:contents,s:headerPat)
while s:ml!=[]
let [_,s:id,s:title,s:r;s:x] = s:ml
let s:flagheaders = add(s:flagheaders, s:title)
let s:flagheaderids[s:title] = s:id
let s:ml = matchlist(s:r,s:headerPat)
endwhile
command! -nargs=1 -complete=customlist,CompleteFlagHeaders FlagReference call FlagReference(<f-args>)
function! FlagReference(section)
let relativeUrl = a:section==""||!exists("s:flagheaderids['".a:section."']") ?
\ "" : "#".s:flagheaderids[a:section]
call DocBrowser(s:flagref.relativeUrl)
endfunction
function! CompleteFlagHeaders(al,cl,cp)
let s:choices = s:flagheaders
return CompleteAux(a:al,a:cl,a:cp)
endfunction
endif
command! -nargs=1 -complete=customlist,CompleteHaddockModules MDoc call MDoc(<f-args>)
function! MDoc(module)
let suffix = '.html'
call HaveModuleIndex()
if !has_key(g:haddock_moduleindex,a:module)
echoerr a:module 'not found in haddock module index'
return
endif
let package = g:haddock_moduleindex[a:module]['package']
let file = substitute(a:module,'\.','-','g') . suffix
" let path = s:libraries . package . '/' . file
let path = g:haddock_moduleindex[a:module]['html']
call DocBrowser(path)
endfunction
function! CompleteHaddockModules(al,cl,cp)
call HaveModuleIndex()
let s:choices = keys(g:haddock_moduleindex)
return CompleteAux(a:al,a:cl,a:cp)
endfunction
" create a dictionary g:haddock_index, containing the haddoc index
command! DocIndex call DocIndex()
function! DocIndex()
let files = split(globpath(s:libraries,'doc-index*.html'),'\n')
let g:haddock_index = {}
if haskellmode#GHC_VersionGE([7,0,0])
call ProcessHaddockIndexes3(s:libraries,files)
else
call ProcessHaddockIndexes2(s:libraries,files)
endif
if haskellmode#GHC_VersionGE([6,8,2])
if &shell =~ 'sh' " unix-type shell
let s:addon_libraries = split(system(g:ghc_pkg . ' field \* haddock-html'),'\n')
else " windows cmd.exe and the like
let s:addon_libraries = split(system(g:ghc_pkg . ' field * haddock-html'),'\n')
endif
for addon in s:addon_libraries
let ml = matchlist(addon,'haddock-html: \("\)\?\(file:///\)\?\([^"]*\)\("\)\?')
if ml!=[]
let [_,quote,file,addon_path;x] = ml
let addon_path = substitute(addon_path,'\(\\\\\|\\\)','/','g')
let addon_files = split(globpath(addon_path,'doc-index*.html'),'\n')
if haskellmode#GHC_VersionGE([7,0,0])
call ProcessHaddockIndexes3(addon_path,addon_files)
else
call ProcessHaddockIndexes2(addon_path,addon_files)
endif
endif
endfor
endif
return 1
endfunction
function! ProcessHaddockIndexes(location,files)
let entryPat= '.\{-}"indexentry"[^>]*>\([^<]*\)<\(\%([^=]\{-}TD CLASS="\%(indexentry\)\@!.\{-}</TD\)*\)[^=]\{-}\(\%(="indexentry\|TABLE\).*\)'
let linkPat = '.\{-}HREF="\([^"]*\)".>\([^<]*\)<\(.*\)'
redraw
echo 'populating g:haddock_index from haddock index files in ' a:location
for f in a:files
echo f[len(a:location):]
let contents = join(readfile(f))
let ml = matchlist(contents,entryPat)
while ml!=[]
let [_,entry,links,r;x] = ml
"echo entry links
let ml2 = matchlist(links,linkPat)
let link = {}
while ml2!=[]
let [_,l,m,links;x] = ml2
"echo l m
let link[m] = a:location . '/' . l
let ml2 = matchlist(links,linkPat)
endwhile
let g:haddock_index[DeHTML(entry)] = deepcopy(link)
"echo entry g:haddock_index[entry]
let ml = matchlist(r,entryPat)
endwhile
endfor
endfunction
" concatenating all lines is too slow for a big file, process lines directly
function! ProcessHaddockIndexes2(location,files)
let entryPat= '^>\([^<]*\)</'
let linkPat = '.\{-}A HREF="\([^"]*\)"'
let kindPat = '#\(.\)'
" redraw
echo 'populating g:haddock_index from haddock index files in ' a:location
for f in a:files
echo f[len(a:location):]
let isEntry = 0
let isLink = ''
let link = {}
let entry = ''
for line in readfile(f)
if line=~'CLASS="indexentry'
if (link!={}) && (entry!='')
if has_key(g:haddock_index,DeHTML(entry))
let dict = extend(g:haddock_index[DeHTML(entry)],deepcopy(link))
else
let dict = deepcopy(link)
endif
let g:haddock_index[DeHTML(entry)] = dict
let link = {}
let entry = ''
endif
let isEntry=1
continue
endif
if isEntry==1
let ml = matchlist(line,entryPat)
if ml!=[] | let [_,entry;x] = ml | let isEntry=0 | continue | endif
endif
if entry!=''
let ml = matchlist(line,linkPat)
if ml!=[] | let [_,isLink;x]=ml | continue | endif
endif
if isLink!=''
let ml = matchlist(line,entryPat)
if ml!=[]
let [_,module;x] = ml
let [_,kind;x] = matchlist(isLink,kindPat)
let last = a:location[strlen(a:location)-1]
let link[module."[".kind."]"] = a:location . (last=='/'?'':'/') . isLink
let isLink=''
continue
endif
endif
endfor
if link!={}
if has_key(g:haddock_index,DeHTML(entry))
let dict = extend(g:haddock_index[DeHTML(entry)],deepcopy(link))
else
let dict = deepcopy(link)
endif
let g:haddock_index[DeHTML(entry)] = dict
endif
endfor
endfunction
function! ProcessHaddockIndexes3(location,files)
let entryPat= '>\(.*\)$'
let linkPat = '<a href="\([^"]*\)"'
let kindPat = '#\(.\)'
" redraw
echo 'populating g:haddock_index from haddock index files in ' a:location
for f in a:files
echo f[len(a:location):]
let isLink = ''
let link = {}
let entry = ''
let lines = split(join(readfile(f,'b')),'\ze<')
for line in lines
if (line=~'class="src') || (line=~'/table')
if (link!={}) && (entry!='')
if has_key(g:haddock_index,DeHTML(entry))
let dict = extend(g:haddock_index[DeHTML(entry)],deepcopy(link))
else
let dict = deepcopy(link)
endif
let g:haddock_index[DeHTML(entry)] = dict
let link = {}
let entry = ''
endif
let ml = matchlist(line,entryPat)
if ml!=[] | let [_,entry;x] = ml | continue | endif
continue
endif
if entry!=''
let ml = matchlist(line,linkPat)
if ml!=[]
let [_,isLink;x]=ml
let ml = matchlist(line,entryPat)
if ml!=[]
let [_,module;x] = ml
let [_,kind;x] = matchlist(isLink,kindPat)
let last = a:location[strlen(a:location)-1]
let link[module."[".kind."]"] = a:location . (last=='/'?'':'/') . isLink
let isLink=''
endif
continue
endif
endif
endfor
if link!={}
if has_key(g:haddock_index,DeHTML(entry))
let dict = extend(g:haddock_index[DeHTML(entry)],deepcopy(link))
else
let dict = deepcopy(link)
endif
let g:haddock_index[DeHTML(entry)] = dict
endif
endfor
endfunction
command! ExportDocIndex call ExportDocIndex()
function! ExportDocIndex()
call HaveIndex()
let entries = []
for key in keys(g:haddock_index)
let entries += [key,string(g:haddock_index[key])]
endfor
call writefile(entries,s:haddock_indexfile)
redir end
endfunction
command! ImportDocIndex call ImportDocIndex()
function! ImportDocIndex()
if filereadable(s:haddock_indexfile)
let lines = readfile(s:haddock_indexfile)
let i=0
while i<len(lines)
let [key,dict] = [lines[i],lines[i+1]]
sandbox let g:haddock_index[key] = eval(dict)
let i+=2
endwhile
return 1
else
return 0
endif
endfunction
function! HaveIndex()
return (g:haddock_index!={} || ImportDocIndex() || DocIndex() )
endfunction
function! MkHaddockModuleIndex()
let g:haddock_moduleindex = {}
call HaveIndex()
for key in keys(g:haddock_index)
let dict = g:haddock_index[key]
for module in keys(dict)
let html = dict[module]
let html = substitute(html ,'#.*$','','')
let module = substitute(module,'\[.\]','','')
let ml = matchlist(html,'libraries/\([^\/]*\)[\/]')
if ml!=[]
let [_,package;x] = ml
let g:haddock_moduleindex[module] = {'package':package,'html':html}
endif
let ml = matchlist(html,'/\([^\/]*\)\/html/[A-Z]')
if ml!=[]
let [_,package;x] = ml
let g:haddock_moduleindex[module] = {'package':package,'html':html}
endif
endfor
endfor
endfunction
function! HaveModuleIndex()
return (g:haddock_moduleindex!={} || MkHaddockModuleIndex() )
endfunction
" decode HTML symbol encodings (are these all we need?)
function! DeHTML(entry)
let res = a:entry
let decode = { '&lt;': '<', '&gt;': '>', '&amp;': '\\&' }
for enc in keys(decode)
exe 'let res = substitute(res,"'.enc.'","'.decode[enc].'","g")'
endfor
return res
endfunction
" find haddocks for word under cursor
" also lists possible definition sites
" - needs to work for both qualified and unqualified items
" - for 'import qualified M as A', consider M.item as source of A.item
" - offer sources from both type [t] and value [v] namespaces
" - for unqualified items, list all possible sites
" - for qualified items, list imported sites only
" keep track of keys with and without namespace tags:
" the former are needed for lookup, the latter for matching against source
map <LocalLeader>? :call Haddock()<cr>
function! Haddock()
amenu ]Popup.- :echo '-'<cr>
aunmenu ]Popup
let namsym = haskellmode#GetNameSymbol(getline('.'),col('.'),0)
if namsym==[]
redraw
echo 'no name/symbol under cursor!'
return 0
endif
let [start,symb,qual,unqual] = namsym
let imports = haskellmode#GatherImports()
let asm = has_key(imports[1],qual) ? imports[1][qual]['modules'] : []
let name = unqual
let dict = HaddockIndexLookup(name)
if dict=={} | return | endif
" for qualified items, narrow results to possible imports that provide qualifier
let filteredKeys = filter(copy(keys(dict))
\ ,'match(asm,substitute(v:val,''\[.\]'','''',''''))!=-1')
let keys = (qual!='') ? filteredKeys : keys(dict)
if (keys==[]) && (qual!='')
echoerr qual.'.'.unqual.' not found in imports'
return 0
endif
" use 'setlocal completeopt+=menuone' if you always want to see menus before
" anything happens (I do, but many users don't..)
if len(keys)==1 && (&completeopt!~'menuone')
call DocBrowser(dict[keys[0]])
elseif has("gui_running")
for key in keys
exe 'amenu ]Popup.'.escape(key,'\.').' :call DocBrowser('''.dict[key].''')<cr>'
endfor
popup ]Popup
else
let s:choices = keys
let key = input('browse docs for '.name.' in: ','','customlist,CompleteAux')
if key!=''
call DocBrowser(dict[key])
endif
endif
endfunction
if !exists("g:haskell_search_engines")
let g:haskell_search_engines =
\ {'hoogle':'http://www.haskell.org/hoogle/?hoogle=%s'
\ ,'hayoo!':'http://holumbus.fh-wedel.de/hayoo/hayoo.html?query=%s'
\ }
endif
map <LocalLeader>?? :let es=g:haskell_search_engines
\ \|echo "g:haskell_search_engines"
\ \|for e in keys(es)
\ \|echo e.' : '.es[e]
\ \|endfor<cr>
map <LocalLeader>?1 :call HaskellSearchEngine('hoogle')<cr>
map <LocalLeader>?2 :call HaskellSearchEngine('hayoo!')<cr>
" query one of the Haskell search engines for the thing under cursor
" - unqualified symbols need to be url-escaped
" - qualified ids need to be fed as separate qualifier and id for
" both hoogle (doesn't handle qualified symbols) and hayoo! (no qualified
" ids at all)
" - qualified ids referring to import-qualified-as qualifiers need to be
" translated to the multi-module searches over the list of original modules
function! HaskellSearchEngine(engine)
amenu ]Popup.- :echo '-'<cr>
aunmenu ]Popup
let namsym = haskellmode#GetNameSymbol(getline('.'),col('.'),0)
if namsym==[]
redraw
echo 'no name/symbol under cursor!'
return 0
endif
let [start,symb,qual,unqual] = namsym
let imports = haskellmode#GatherImports()
let asm = has_key(imports[1],qual) ? imports[1][qual]['modules'] : []
let unqual = haskellmode#UrlEncode(unqual)
if a:engine=='hoogle'
let name = asm!=[] ? unqual.'+'.join(map(copy(asm),'"%2B".v:val'),'+')
\ : qual!='' ? unqual.'+'.haskellmode#UrlEncode('+').qual
\ : unqual
elseif a:engine=='hayoo!'
let name = asm!=[] ? unqual.'+module:('.join(copy(asm),' OR ').')'
\ : qual!='' ? unqual.'+module:'.qual
\ : unqual
else
let name = qual=="" ? unqual : qual.".".unqual
endif
if has_key(g:haskell_search_engines,a:engine)
call DocBrowser(printf(g:haskell_search_engines[a:engine],name))
else
echoerr "unknown search engine: ".a:engine
endif
endfunction
" used to pass on choices to CompleteAux
let s:choices=[]
" if there's no gui, use commandline completion instead of :popup
" completion function CompleteAux suggests completions for a:al, wrt to s:choices
function! CompleteAux(al,cl,cp)
"echomsg '|'.a:al.'|'.a:cl.'|'.a:cp.'|'
let res = []
let l = len(a:al)-1
for r in s:choices
if l==-1 || r[0 : l]==a:al
let res += [r]
endif
endfor
return res
endfunction
" CamelCase shorthand matching:
" favour upper-case letters and module qualifier separators (.) for disambiguation
function! CamelCase(shorthand,string)
let s1 = a:shorthand
let s2 = a:string
let notFirst = 0 " don't elide before first pattern letter
while ((s1!="")&&(s2!=""))
let head1 = s1[0]
let head2 = s2[0]
let elide = notFirst && ( ((head1=~'[A-Z]') && (head2!~'[A-Z.]'))
\ ||((head1=='.') && (head2!='.')) )
if elide
let s2=s2[1:]
elseif (head1==head2)
let s1=s1[1:]
let s2=s2[1:]
else
return 0
endif
let notFirst = (head1!='.')||(head2!='.') " treat separators as new beginnings
endwhile
return (s1=="")
endfunction
" use haddock name index for insert mode completion (CTRL-X CTRL-U)
function! CompleteHaddock(findstart, base)
if a:findstart
let namsym = haskellmode#GetNameSymbol(getline('.'),col('.'),-1) " insert-mode: we're 1 beyond the text
if namsym==[]
redraw
echo 'no name/symbol under cursor!'
return -1
endif
let [start,symb,qual,unqual] = namsym
return (start-1)
else " find keys matching with "a:base"
let res = []
let l = len(a:base)-1
let qual = a:base =~ '^[A-Z][a-zA-Z0-9_'']*\(\.[A-Z][a-zA-Z0-9_'']*\)*\(\.[a-zA-Z0-9_'']*\)\?$'
call HaveIndex()
for key in keys(g:haddock_index)
let keylist = map(deepcopy(keys(g:haddock_index[key])),'substitute(v:val,"\\[.\\]","","")')
if (key[0 : l]==a:base)
for m in keylist
let res += [{"word":key,"menu":m,"dup":1}]
endfor
elseif qual " this tends to be slower
for m in keylist
let word = m . '.' . key
if word[0 : l]==a:base
let res += [{"word":word,"menu":m,"dup":1}]
endif
endfor
endif
endfor
if res==[] " no prefix matches, try CamelCase shortcuts
for key in keys(g:haddock_index)
let keylist = map(deepcopy(keys(g:haddock_index[key])),'substitute(v:val,"\\[.\\]","","")')
if CamelCase(a:base,key)
for m in keylist
let res += [{"word":key,"menu":m,"dup":1}]
endfor
elseif qual " this tends to be slower
for m in keylist
let word = m . '.' . key
if CamelCase(a:base,word)
let res += [{"word":word,"menu":m,"dup":1}]
endif
endfor
endif
endfor
endif
return res
endif
endfunction
setlocal completefunc=CompleteHaddock
"
" Vim's default completeopt is menu,preview
" you probably want at least menu, or you won't see alternatives listed
" setlocal completeopt+=menu
" menuone is useful, but other haskellmode menus will try to follow your choice here in future
" setlocal completeopt+=menuone
" longest sounds useful, but doesn't seem to do what it says, and interferes with CTRL-E
" setlocal completeopt-=longest
" fully qualify an unqualified name
" TODO: - standardise commandline versions of menus
map <LocalLeader>. :call Qualify()<cr>
function! Qualify()
amenu ]Popup.- :echo '-'<cr>
aunmenu ]Popup
let namsym = haskellmode#GetNameSymbol(getline('.'),col('.'),0)
if namsym==[]
redraw
echo 'no name/symbol under cursor!'
return 0
endif
let [start,symb,qual,unqual] = namsym
if qual!='' " TODO: should we support re-qualification?
redraw
echo 'already qualified'
return 0
endif
let name = unqual
let line = line('.')
let prefix = (start<=1 ? '' : getline(line)[0:start-2] )
let dict = HaddockIndexLookup(name)
if dict=={} | return | endif
let keylist = map(deepcopy(keys(dict)),'substitute(v:val,"\\[.\\]","","")')
let imports = haskellmode#GatherImports()
let qualifiedImports = []
for qualifiedImport in keys(imports[1])
let c=0
for module in imports[1][qualifiedImport]['modules']
if haskellmode#ListElem(keylist,module) | let c+=1 | endif
endfor
if c>0 | let qualifiedImports=[qualifiedImport]+qualifiedImports | endif
endfor
"let asm = has_key(imports[1],qual) ? imports[1][qual]['modules'] : []
let keylist = filter(copy(keylist),'index(qualifiedImports,v:val)==-1')
if has("gui_running")
" amenu ]Popup.-imported- :
for key in qualifiedImports
let lhs=escape(prefix.name,'/.|\')
let rhs=escape(prefix.key.'.'.name,'/&|\')
exe 'amenu ]Popup.'.escape(key,'\.').' :'.line.'s/'.lhs.'/'.rhs.'/<cr>:noh<cr>'
endfor
amenu ]Popup.-not\ imported- :
for key in keylist
let lhs=escape(prefix.name,'/.|\')
let rhs=escape(prefix.key.'.'.name,'/&|\')
exe 'amenu ]Popup.'.escape(key,'\.').' :'.line.'s/'.lhs.'/'.rhs.'/<cr>:noh<cr>'
endfor
popup ]Popup
else
let s:choices = qualifiedImports+keylist
let key = input('qualify '.name.' with: ','','customlist,CompleteAux')
if key!=''
let lhs=escape(prefix.name,'/.\')
let rhs=escape(prefix.key.'.'.name,'/&\')
exe line.'s/'.lhs.'/'.rhs.'/'
noh
endif
endif
endfunction
" create (qualified) import for a (qualified) name
" TODO: refine search patterns, to avoid misinterpretation of
" oddities like import'Neither or not'module
map <LocalLeader>i :call Import(0,0)<cr>
map <LocalLeader>im :call Import(1,0)<cr>
map <LocalLeader>iq :call Import(0,1)<cr>
map <LocalLeader>iqm :call Import(1,1)<cr>
function! Import(module,qualified)
amenu ]Popup.- :echo '-'<cr>
aunmenu ]Popup
let namsym = haskellmode#GetNameSymbol(getline('.'),col('.'),0)
if namsym==[]
redraw
echo 'no name/symbol under cursor!'
return 0
endif
let [start,symb,qual,unqual] = namsym
let name = unqual
let pname = ( symb ? '('.name.')' : name )
let importlist = a:module ? '' : '('.pname.')'
let qualified = a:qualified ? 'qualified ' : ''
if qual!=''
exe 'call append(search(''\%1c\(\<import\>\|\<module\>\|{-# OPTIONS\|{-# LANGUAGE\)'',''nb''),''import '.qualified.qual.importlist.''')'
return
endif
let line = line('.')
let prefix = getline(line)[0:start-1]
let dict = HaddockIndexLookup(name)
if dict=={} | return | endif
let keylist = map(deepcopy(keys(dict)),'substitute(v:val,"\\[.\\]","","")')
if has("gui_running")
for key in keylist
" exe 'amenu ]Popup.'.escape(key,'\.').' :call append(search("\\%1c\\(import\\\\|module\\\\|{-# OPTIONS\\)","nb"),"import '.key.importlist.'")<cr>'
exe 'amenu ]Popup.'.escape(key,'\.').' :call append(search(''\%1c\(\<import\>\\|\<module\>\\|{-# OPTIONS\\|{-# LANGUAGE\)'',''nb''),''import '.qualified.key.escape(importlist,'|').''')<cr>'
endfor
popup ]Popup
else
let s:choices = keylist
let key = input('import '.name.' from: ','','customlist,CompleteAux')
if key!=''
exe 'call append(search(''\%1c\(\<import\>\|\<module\>\|{-# OPTIONS\|{-# LANGUAGE\)'',''nb''),''import '.qualified.key.importlist.''')'
endif
endif
endfunction
function! HaddockIndexLookup(name)
call HaveIndex()
if !has_key(g:haddock_index,a:name)
echoerr a:name 'not found in haddock index'
return {}
endif
return g:haddock_index[a:name]
endfunction
" rudimentary hpaste support for vim
" (using netrw for reading, wget for posting/annotating)
"
" claus reinke, last modified: 07/04/2009
"
" part of haskell plugins: http://projects.haskell.org/haskellmode-vim
" unless wget is in your PATH, you need to set g:wget
" before loading this script. windows users are out of
" luck, unless they have wget installed (such as the
" cygwin one looked for here), or adapt this script to
" whatever alternative they have at hand (perhaps using
" vim's perl/python bindings?)
if !exists("g:wget")
if executable("wget")
let g:wget = "!wget -q"
else
let g:wget = "!c:\\cygwin\\bin\\wget -q"
endif
endif
" read (recent) hpaste files
" show index in new buffer, where ,r will open current entry
" and ,p will annotate current entry with current buffer
command! HpasteIndex call HpasteIndex()
function! HpasteIndex()
new
read http://hpaste.org
%s/\_$\_.//g
%s/<tr[^>]*>//g
%s/<\/tr>/ /g
g/<\/table>/d
g/DOCTYPE/d
%s/<td>\([^<]*\)<\/td><td><a href="\/fastcgi\/hpaste\.fcgi\/view?id=\([0-9]*\)">\([^<]*\)<\/a><\/td><td>\([^<]*\)<\/td><td>\([^<]*\)<\/td><td>\([^<]*\)<\/td>/\2 [\1] "\3" \4 \5 \6/
map <buffer> ,r 0yE:noh<cr>:call HpasteEditEntry('"')<cr>
endfunction
" load an existing entry for editing
command! -nargs=1 HpasteEditEntry call HpasteEditEntry(<f-args>)
function! HpasteEditEntry(entry)
new
exe 'Nread http://hpaste.org/fastcgi/hpaste.fcgi/raw?id='.a:entry
"exe 'map <buffer> ,p :call HpasteAnnotate('''.a:entry.''')<cr>'
endfunction
" " posting temporarily disabled -- needs someone to look into new
" " hpaste.org structure
" " annotate existing entry (only to be called via ,p in HpasteIndex)
" function! HpasteAnnotate(entry)
" let nick = input("nick? ")
" let title = input("title? ")
" if nick=='' || title==''
" echo "nick or title missing. aborting annotation"
" return
" endif
" call HpastePost('annotate/'.a:entry,nick,title)
" endfunction
"
" " post new hpaste entry
" " using 'wget --post-data' and url-encoded content
" command! HpastePostNew call HpastePost('new',<args>)
" function! HpastePost(mode,nick,title,...)
" let lines = getbufline("%",1,"$")
" let pat = '\([^[:alnum:]]\)'
" let code = '\=printf("%%%02X",char2nr(submatch(1)))'
" let lines = map(lines,'substitute(v:val."\r\n",'''.pat.''','''.code.''',''g'')')
"
" let url = 'http://hpaste.org/' . a:mode
" let nick = substitute(a:nick,pat,code,'g')
" let title = substitute(a:title,pat,code,'g')
" if a:0==0
" let announce = 'false'
" else
" let announce = a:1
" endif
" let cmd = g:wget.' --post-data="content='.join(lines,'').'&nick='.nick.'&title='.title.'&announce='.announce.'" '.url
" exe escape(cmd,'%')
" endfunction
-- 7.6.3
AlternativeLayoutRule
AlternativeLayoutRuleTransitional
Arrows
BangPatterns
CApiFFI
CPP
ConstrainedClassMethods
ConstraintKinds
DataKinds
DatatypeContexts
DefaultSignatures
DeriveDataTypeable
DeriveFoldable
DeriveFunctor
DeriveGeneric
DeriveTraversable
DisambiguateRecordFields
DoAndIfThenElse
DoRec
EmptyDataDecls
ExistentialQuantification
ExplicitForAll
ExplicitNamespaces
ExtendedDefaultRules
FlexibleContexts
FlexibleInstances
ForeignFunctionInterface
FunctionalDependencies
GADTSyntax
GADTs
GHCForeignImportPrim
GeneralizedNewtypeDeriving
Haskell2010
Haskell98
ImplicitParams
ImplicitPrelude
ImpredicativeTypes
IncoherentInstances
InstanceSigs
InterruptibleFFI
KindSignatures
LambdaCase
LiberalTypeSynonyms
MagicHash
MonadComprehensions
MonoLocalBinds
MonoPatBinds
MonomorphismRestriction
MultiParamTypeClasses
MultiWayIf
NPlusKPatterns
NamedFieldPuns
NoAlternativeLayoutRule
NoAlternativeLayoutRuleTransitional
NoArrows
NoBangPatterns
NoCApiFFI
NoCPP
NoConstrainedClassMethods
NoConstraintKinds
NoDataKinds
NoDatatypeContexts
NoDefaultSignatures
NoDeriveDataTypeable
NoDeriveFoldable
NoDeriveFunctor
NoDeriveGeneric
NoDeriveTraversable
NoDisambiguateRecordFields
NoDoAndIfThenElse
NoDoRec
NoEmptyDataDecls
NoExistentialQuantification
NoExplicitForAll
NoExplicitNamespaces
NoExtendedDefaultRules
NoFlexibleContexts
NoFlexibleInstances
NoForeignFunctionInterface
NoFunctionalDependencies
NoGADTSyntax
NoGADTs
NoGHCForeignImportPrim
NoGeneralizedNewtypeDeriving
NoImplicitParams
NoImplicitPrelude
NoImpredicativeTypes
NoIncoherentInstances
NoInstanceSigs
NoInterruptibleFFI
NoKindSignatures
NoLambdaCase
NoLiberalTypeSynonyms
NoMagicHash
NoMonadComprehensions
NoMonoLocalBinds
NoMonoPatBinds
NoMonomorphismRestriction
NoMultiParamTypeClasses
NoMultiWayIf
NoNPlusKPatterns
NoNamedFieldPuns
NoNondecreasingIndentation
NoOverlappingInstances
NoOverloadedStrings
NoPackageImports
NoParallelArrays
NoParallelListComp
NoPatternGuards
NoPatternSignatures
NoPolyKinds
NoPolymorphicComponents
NoPostfixOperators
NoQuasiQuotes
NoRank2Types
NoRankNTypes
NoRebindableSyntax
NoRecordPuns
NoRecordWildCards
NoRecursiveDo
NoRelaxedLayout
NoRelaxedPolyRec
NoScopedTypeVariables
NoStandaloneDeriving
NoTemplateHaskell
NoTraditionalRecordSyntax
NoTransformListComp
NoTupleSections
NoTypeFamilies
NoTypeOperators
NoTypeSynonymInstances
NoUnboxedTuples
NoUndecidableInstances
NoUnicodeSyntax
NoUnliftedFFITypes
NoViewPatterns
NondecreasingIndentation
OverlappingInstances
OverloadedStrings
PackageImports
ParallelArrays
ParallelListComp
PatternGuards
PatternSignatures
PolyKinds
PolymorphicComponents
PostfixOperators
QuasiQuotes
Rank2Types
RankNTypes
RebindableSyntax
RecordPuns
RecordWildCards
RecursiveDo
RelaxedLayout
RelaxedPolyRec
Safe
ScopedTypeVariables
StandaloneDeriving
TemplateHaskell
TraditionalRecordSyntax
TransformListComp
Trustworthy
TupleSections
TypeFamilies
TypeOperators
TypeSynonymInstances
UnboxedTuples
UndecidableInstances
UnicodeSyntax
UnliftedFFITypes
Unsafe
ViewPatterns
--
-fimplicit-import-qualified
" cecutil.vim : save/restore window position
" save/restore mark position
" save/restore selected user maps
" Author: Charles E. Campbell, Jr.
" Version: 16
" Date: Feb 12, 2007
"
" Saving Restoring Destroying Marks: {{{1
" call SaveMark(markname) let savemark= SaveMark(markname)
" call RestoreMark(markname) call RestoreMark(savemark)
" call DestroyMark(markname)
" commands: SM RM DM
"
" Saving Restoring Destroying Window Position: {{{1
" call SaveWinPosn() let winposn= SaveWinPosn()
" call RestoreWinPosn() call RestoreWinPosn(winposn)
" \swp : save current window/buffer's position
" \rwp : restore current window/buffer's previous position
" commands: SWP RWP
"
" Saving And Restoring User Maps: {{{1
" call SaveUserMaps(mapmode,maplead,mapchx,suffix)
" call RestoreUserMaps(suffix)
"
" GetLatestVimScripts: 1066 1 :AutoInstall: cecutil.vim
"
" You believe that God is one. You do well. The demons also {{{1
" believe, and shudder. But do you want to know, vain man, that
" faith apart from works is dead? (James 2:19,20 WEB)
" Load Once: {{{1
if &cp || exists("g:loaded_cecutil")
finish
endif
let g:loaded_cecutil = "v16"
let s:keepcpo = &cpo
set cpo&vim
"DechoVarOn
" -----------------------
" Public Interface: {{{1
" -----------------------
" Map Interface: {{{2
if !hasmapto('<Plug>SaveWinPosn')
map <unique> <Leader>swp <Plug>SaveWinPosn
endif
if !hasmapto('<Plug>RestoreWinPosn')
map <unique> <Leader>rwp <Plug>RestoreWinPosn
endif
nmap <silent> <Plug>SaveWinPosn :call SaveWinPosn()<CR>
nmap <silent> <Plug>RestoreWinPosn :call RestoreWinPosn()<CR>
" Command Interface: {{{2
com! -bar -nargs=0 SWP call SaveWinPosn()
com! -bar -nargs=0 RWP call RestoreWinPosn()
com! -bar -nargs=1 SM call SaveMark(<q-args>)
com! -bar -nargs=1 RM call RestoreMark(<q-args>)
com! -bar -nargs=1 DM call DestroyMark(<q-args>)
if v:version < 630
let s:modifier= "sil "
else
let s:modifier= "sil keepj "
endif
" ---------------------------------------------------------------------
" SaveWinPosn: {{{1
" let winposn= SaveWinPosn() will save window position in winposn variable
" call SaveWinPosn() will save window position in b:cecutil_winposn{b:cecutil_iwinposn}
" let winposn= SaveWinPosn(0) will *only* save window position in winposn variable (no stacking done)
fun! SaveWinPosn(...)
" call Dfunc("SaveWinPosn() a:0=".a:0)
if line(".") == 1 && getline(1) == ""
" call Dfunc("SaveWinPosn : empty buffer")
return ""
endif
let so_keep = &so
let siso_keep = &siso
let ss_keep = &ss
set so=0 siso=0 ss=0
let swline = line(".")
let swcol = col(".")
let swwline = winline() - 1
let swwcol = virtcol(".") - wincol()
let savedposn = "call GoWinbufnr(".winbufnr(0).")|silent ".swline
let savedposn = savedposn."|".s:modifier."norm! 0z\<cr>"
if swwline > 0
let savedposn= savedposn.":".s:modifier."norm! ".swwline."\<c-y>\<cr>"
endif
if swwcol > 0
let savedposn= savedposn.":".s:modifier."norm! 0".swwcol."zl\<cr>"
endif
let savedposn = savedposn.":".s:modifier."call cursor(".swline.",".swcol.")\<cr>"
" save window position in
" b:cecutil_winposn_{iwinposn} (stack)
" only when SaveWinPosn() is used
if a:0 == 0
if !exists("b:cecutil_iwinposn")
let b:cecutil_iwinposn= 1
else
let b:cecutil_iwinposn= b:cecutil_iwinposn + 1
endif
" call Decho("saving posn to SWP stack")
let b:cecutil_winposn{b:cecutil_iwinposn}= savedposn
endif
let &so = so_keep
let &siso = siso_keep
let &ss = ss_keep
" if exists("b:cecutil_iwinposn") " Decho
" call Decho("b:cecutil_winpos{".b:cecutil_iwinposn."}[".b:cecutil_winposn{b:cecutil_iwinposn}."]")
" else " Decho
" call Decho("b:cecutil_iwinposn doesn't exist")
" endif " Decho
" call Dret("SaveWinPosn [".savedposn."]")
return savedposn
endfun
" ---------------------------------------------------------------------
" RestoreWinPosn: {{{1
fun! RestoreWinPosn(...)
" call Dfunc("RestoreWinPosn() a:0=".a:0)
" call Decho("getline(1)<".getline(1).">")
" call Decho("line(.)=".line("."))
if line(".") == 1 && getline(1) == ""
" call Dfunc("RestoreWinPosn : empty buffer")
return ""
endif
let so_keep = &so
let siso_keep = &siso
let ss_keep = &ss
set so=0 siso=0 ss=0
if a:0 == 0 || a:1 == ""
" use saved window position in b:cecutil_winposn{b:cecutil_iwinposn} if it exists
if exists("b:cecutil_iwinposn") && exists("b:cecutil_winposn{b:cecutil_iwinposn}")
" call Decho("using stack b:cecutil_winposn{".b:cecutil_iwinposn."}<".b:cecutil_winposn{b:cecutil_iwinposn}.">")
try
exe "silent! ".b:cecutil_winposn{b:cecutil_iwinposn}
catch /^Vim\%((\a\+)\)\=:E749/
" ignore empty buffer error messages
endtry
" normally drop top-of-stack by one
" but while new top-of-stack doesn't exist
" drop top-of-stack index by one again
if b:cecutil_iwinposn >= 1
unlet b:cecutil_winposn{b:cecutil_iwinposn}
let b:cecutil_iwinposn= b:cecutil_iwinposn - 1
while b:cecutil_iwinposn >= 1 && !exists("b:cecutil_winposn{b:cecutil_iwinposn}")
let b:cecutil_iwinposn= b:cecutil_iwinposn - 1
endwhile
if b:cecutil_iwinposn < 1
unlet b:cecutil_iwinposn
endif
endif
else
echohl WarningMsg
echomsg "***warning*** need to SaveWinPosn first!"
echohl None
endif
else " handle input argument
" call Decho("using input a:1<".a:1.">")
" use window position passed to this function
exe "silent ".a:1
" remove a:1 pattern from b:cecutil_winposn{b:cecutil_iwinposn} stack
if exists("b:cecutil_iwinposn")
let jwinposn= b:cecutil_iwinposn
while jwinposn >= 1 " search for a:1 in iwinposn..1
if exists("b:cecutil_winposn{jwinposn}") " if it exists
if a:1 == b:cecutil_winposn{jwinposn} " and the pattern matches
unlet b:cecutil_winposn{jwinposn} " unlet it
if jwinposn == b:cecutil_iwinposn " if at top-of-stack
let b:cecutil_iwinposn= b:cecutil_iwinposn - 1 " drop stacktop by one
endif
endif
endif
let jwinposn= jwinposn - 1
endwhile
endif
endif
" seems to be something odd: vertical motions after RWP
" cause jump to first column. Following fixes that
if wincol() > 1
silent norm! hl
elseif virtcol(".") < virtcol("$")
silent norm! lh
endif
let &so = so_keep
let &siso = siso_keep
let &ss = ss_keep
" call Dret("RestoreWinPosn")
endfun
" ---------------------------------------------------------------------
" GoWinbufnr: go to window holding given buffer (by number) {{{1
" Prefers current window; if its buffer number doesn't match,
" then will try from topleft to bottom right
fun! GoWinbufnr(bufnum)
" call Dfunc("GoWinbufnr(".a:bufnum.")")
if winbufnr(0) == a:bufnum
" call Dret("GoWinbufnr : winbufnr(0)==a:bufnum")
return
endif
winc t
let first=1
while winbufnr(0) != a:bufnum && (first || winnr() != 1)
winc w
let first= 0
endwhile
" call Dret("GoWinbufnr")
endfun
" ---------------------------------------------------------------------
" SaveMark: sets up a string saving a mark position. {{{1
" For example, SaveMark("a")
" Also sets up a global variable, g:savemark_{markname}
fun! SaveMark(markname)
" call Dfunc("SaveMark(markname<".a:markname.">)")
let markname= a:markname
if strpart(markname,0,1) !~ '\a'
let markname= strpart(markname,1,1)
endif
" call Decho("markname=".markname)
let lzkeep = &lz
set lz
if 1 <= line("'".markname) && line("'".markname) <= line("$")
let winposn = SaveWinPosn(0)
exe s:modifier."norm! `".markname
let savemark = SaveWinPosn(0)
let g:savemark_{markname} = savemark
let savemark = markname.savemark
call RestoreWinPosn(winposn)
else
let g:savemark_{markname} = ""
let savemark = ""
endif
let &lz= lzkeep
" call Dret("SaveMark : savemark<".savemark.">")
return savemark
endfun
" ---------------------------------------------------------------------
" RestoreMark: {{{1
" call RestoreMark("a") -or- call RestoreMark(savemark)
fun! RestoreMark(markname)
" call Dfunc("RestoreMark(markname<".a:markname.">)")
if strlen(a:markname) <= 0
" call Dret("RestoreMark : no such mark")
return
endif
let markname= strpart(a:markname,0,1)
if markname !~ '\a'
" handles 'a -> a styles
let markname= strpart(a:markname,1,1)
endif
" call Decho("markname=".markname." strlen(a:markname)=".strlen(a:markname))
let lzkeep = &lz
set lz
let winposn = SaveWinPosn(0)
if strlen(a:markname) <= 2
if exists("g:savemark_{markname}") && strlen(g:savemark_{markname}) != 0
" use global variable g:savemark_{markname}
" call Decho("use savemark list")
call RestoreWinPosn(g:savemark_{markname})
exe "norm! m".markname
endif
else
" markname is a savemark command (string)
" call Decho("use savemark command")
let markcmd= strpart(a:markname,1)
call RestoreWinPosn(markcmd)
exe "norm! m".markname
endif
call RestoreWinPosn(winposn)
let &lz = lzkeep
" call Dret("RestoreMark")
endfun
" ---------------------------------------------------------------------
" DestroyMark: {{{1
" call DestroyMark("a") -- destroys mark
fun! DestroyMark(markname)
" call Dfunc("DestroyMark(markname<".a:markname.">)")
" save options and set to standard values
let reportkeep= &report
let lzkeep = &lz
set lz report=10000
let markname= strpart(a:markname,0,1)
if markname !~ '\a'
" handles 'a -> a styles
let markname= strpart(a:markname,1,1)
endif
" call Decho("markname=".markname)
let curmod = &mod
let winposn = SaveWinPosn(0)
1
let lineone = getline(".")
exe "k".markname
d
put! =lineone
let &mod = curmod
call RestoreWinPosn(winposn)
" restore options to user settings
let &report = reportkeep
let &lz = lzkeep
" call Dret("DestroyMark")
endfun
" ---------------------------------------------------------------------
" ListWinPosn:
"fun! ListWinPosn() " Decho
" if !exists("b:cecutil_iwinposn") || b:cecutil_iwinposn == 0 " Decho
" call Decho("nothing on SWP stack") " Decho
" else " Decho
" let jwinposn= b:cecutil_iwinposn " Decho
" while jwinposn >= 1 " Decho
" if exists("b:cecutil_winposn{jwinposn}") " Decho
" call Decho("winposn{".jwinposn."}<".b:cecutil_winposn{jwinposn}.">") " Decho
" else " Decho
" call Decho("winposn{".jwinposn."} -- doesn't exist") " Decho
" endif " Decho
" let jwinposn= jwinposn - 1 " Decho
" endwhile " Decho
" endif " Decho
"endfun " Decho
"com! -nargs=0 LWP call ListWinPosn() " Decho
" ---------------------------------------------------------------------
" SaveUserMaps: this function sets up a script-variable (s:restoremap) {{{1
" which can be used to restore user maps later with
" call RestoreUserMaps()
"
" mapmode - see :help maparg for its list
" ex. "n" = Normal
" If the first letter is u, then unmapping will be done
" ex. "un" = Normal + unmapping
" maplead - see mapchx
" mapchx - "<something>" handled as a single map item.
" ex. "<left>"
" - "string" a string of single letters which are actually
" multiple two-letter maps (using the maplead:
" maplead . each_character_in_string)
" ex. maplead="\" and mapchx="abc" saves user mappings for
" \a, \b, and \c
" Of course, if maplead is "", then for mapchx="abc",
" mappings for a, b, and c are saved.
" - :something handled as a single map item, w/o the ":"
" ex. mapchx= ":abc" will save a mapping for "abc"
" suffix - a string unique to your plugin
" ex. suffix= "DrawIt"
fun! SaveUserMaps(mapmode,maplead,mapchx,suffix)
" call Dfunc("SaveUserMaps(mapmode<".a:mapmode."> maplead<".a:maplead."> mapchx<".a:mapchx."> suffix<".a:suffix.">)")
if !exists("s:restoremap_{a:suffix}")
" initialize restoremap_suffix to null string
let s:restoremap_{a:suffix}= ""
endif
" set up dounmap: if 1, then save and unmap (a:mapmode leads with a "u")
" if 0, save only
if a:mapmode =~ '^u'
let dounmap= 1
let mapmode= strpart(a:mapmode,1)
else
let dounmap= 0
let mapmode= a:mapmode
endif
" save single map :...something...
if strpart(a:mapchx,0,1) == ':'
let amap= strpart(a:mapchx,1)
if amap == "|" || amap == "\<c-v>"
let amap= "\<c-v>".amap
endif
let amap = a:maplead.amap
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|:silent! ".mapmode."unmap ".amap
if maparg(amap,mapmode) != ""
let maprhs = substitute(maparg(amap,mapmode),'|','<bar>','ge')
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|:".mapmode."map ".amap." ".maprhs
endif
if dounmap
exe "silent! ".mapmode."unmap ".amap
endif
" save single map <something>
elseif strpart(a:mapchx,0,1) == '<'
let amap = a:mapchx
if amap == "|" || amap == "\<c-v>"
let amap= "\<c-v>".amap
endif
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|silent! ".mapmode."unmap ".amap
if maparg(a:mapchx,mapmode) != ""
let maprhs = substitute(maparg(amap,mapmode),'|','<bar>','ge')
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|".mapmode."map ".amap." ".maprhs
endif
if dounmap
exe "silent! ".mapmode."unmap ".amap
endif
" save multiple maps
else
let i= 1
while i <= strlen(a:mapchx)
let amap= a:maplead.strpart(a:mapchx,i-1,1)
if amap == "|" || amap == "\<c-v>"
let amap= "\<c-v>".amap
endif
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|silent! ".mapmode."unmap ".amap
if maparg(amap,mapmode) != ""
let maprhs = substitute(maparg(amap,mapmode),'|','<bar>','ge')
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|".mapmode."map ".amap." ".maprhs
endif
if dounmap
exe "silent! ".mapmode."unmap ".amap
endif
let i= i + 1
endwhile
endif
" call Dret("SaveUserMaps : restoremap_".a:suffix.": ".s:restoremap_{a:suffix})
endfun
" ---------------------------------------------------------------------
" RestoreUserMaps: {{{1
" Used to restore user maps saved by SaveUserMaps()
fun! RestoreUserMaps(suffix)
" call Dfunc("RestoreUserMaps(suffix<".a:suffix.">)")
if exists("s:restoremap_{a:suffix}")
let s:restoremap_{a:suffix}= substitute(s:restoremap_{a:suffix},'|\s*$','','e')
if s:restoremap_{a:suffix} != ""
" call Decho("exe ".s:restoremap_{a:suffix})
exe "silent! ".s:restoremap_{a:suffix}
endif
unlet s:restoremap_{a:suffix}
endif
" call Dret("RestoreUserMaps")
endfun
" ---------------------------------------------------------------------
" Restore: {{{1
let &cpo= s:keepcpo
unlet s:keepcpo
" ---------------------------------------------------------------------
" Modelines: {{{1
" vim: ts=4 fdm=marker
"=============================================================================
" File: eregex.vim and eregex_e.vim
" Author: AKUTSU toshiyuki <locrian@mbd.ocn.ne.jp>
" Maintainer: Kao, Wei-Ko <othree@gmail.com>
" Requirements: Vim version 6.1 and later.
" Description: eregex.vim is a converter from extended regex to vim regex
" eregex_e.vim is an evaluater for command of eregex.vim
" The meaning of extended regex is pseudo ruby/perl-style regex.
" Previous $Id: eregex.vim,v 2.56 2010-10-18 11:59:41+08 ta Exp $
" $Id: eregex.vim,v 2.60 2013-02-22 14:38:41+08 ta Exp $
" Note: English isn't my mother tongue.
"=============================================================================
" Principle:
" eregex.vim adopts the way of extended regex about "alternation",
" "repetition" and "grouping".
" As for those things, the way of Vim regex is adopted.
" You can use '\_^', '\zs', '\<', '\%<23c', '\_u', etc in extended regex.
"=============================================================================
" Functions:
"
" E2v({extended_regex} [, {iISCDMm}])
" The result is a String, which is vim style regex.
"
" :let vimregex = E2v('(?<=abc),\d+,(?=xzy)','i')
" :echo vimregex
" \c\%(abc\)\@<=,\d\+,\%(xzy\)\@=
"
" E2v('','V')
" The result is a Number, which is eregex.vim version.
"
" :echo E2v('','V')
" 238
"
" E2v({replacement} ,{R1,R2,R3})
" The result is a String, which is used for the "to" part of :S/from/to/
"
" E2v('\r,\n,\&,&,\~,~', 'R1') => \n,\r,\&,&,\~,~
" E2v('\r,\n,\&,&,\~,~', 'R2') => \r,\n,&,\&,~,\~
" E2v('\r,\n,\&,&,\~,~', 'R3') => \n,\r,&,\&,~,\~
"
"=============================================================================
" Commands:
"
" :[range]E2v [iISCDMm]
" Extended regex To Vim regex.
" Replace each extended-regex in [range] with vim-style-regex.
"
" :M/eregex/[offset][iISCDMm]
" Match.
" :M/<span class="foo">.*?<\/span>/Im
" => /\C<span class="foo">\_.\{-}<\/span>
"
" :[range]S/eregex/replacement/[&cegpriISCDMm]
" Substitute.
" :'<,'>S/(\d{1,3})(?=(\d\d\d)+($|\D))/\1,/g
" => :'<,'>s/\(\d\{1,3}\)\%(\(\d\d\d\)\+\($\|\D\)\)\@=/\1,/g
"
" :[range]G/eregex/command
" Global.
" :G/<<-(["'])?EOD\1/,/^\s*EOD\>/:left 8
" => :g/<<-\(["']\)\=EOD\1/,/^\s*EOD\>/:left 8
"
" :[range]V/eregex/command
" Vglobal
"
"=============================================================================
" Tips And Configuration:
"
" Put the following commands in your ~/.vimrc to replace normal / with :M/
"
" nnoremap / :M/
" nnoremap ,/ /
"
" v238, v243
" If you put 'let eregex_replacement=3' in your ~/.vimrc,
"
" :S/pattern/\r,\n,\&,&,\~,~/ will be converted to :s/pattern/\n,\r,&,\&,~,\~/
"
" +--------------------+-----------------------------+
" | eregex_replacement | :S/pattern/\n,\r,&,\&,~,\~/ |
" +--------------------+-----------------------------+
" | 0 | :s/pattern/\n,\r,&,\&,~,\~/ |
" | 1 | :s/pattern/\r,\n,&,\&,~,\~/ |
" | 2 | :s/pattern/\n,\r,\&,&,\~,~/ |
" | 3 | :s/pattern/\r,\n,\&,&,\~,~/ |
" +--------------------+-----------------------------+
" See :h sub-replace-special
"
"=============================================================================
" Options:
" Note: "^L" is "\x0c".
"
" "i" ignorecase
" "I" noignorecase
" "S" convert "\s" to "[ \t\r\n^L]" and also convert "\S" to "[^ \t\r^L]"
" Mnemonic: extended spaces
" "C" convert "[^az]" to "\_[^az]" and also convert "\W" to "\_W".
" Mnemonic: extended complement
" Vim's "[^az]" matches anything but "a", "z", and a newline.
" "D" convert "." to "\_."
" Mnemonic: extended dot
" Normally, "." matches any character except a newline.
" "M" partial multiline; do both "S" and "C".
" In other words, It is not "multiline" in ruby way.
" "m" full multiline; do all the above conversions "S", "C" and "D".
" In other words, It is just "multiline" in ruby way.
"
"+-----+----------------------------------------------+--------------------+
"| Num | eregex.vim => vim regex | ruby regex |
"+-----+----------------------------------------------+--------------------+
"| (1) | :M/a\s[^az].z/ => /a\s[^az].z/ | /a[ \t][^az\n].z/ |
"+-----+----------------------------------------------+--------------------+
"| | :M/a\s[^az].z/S => /a[ \t\r\n^L][^az].z/ | /a\s[^az\n].z/ |
"| | :M/a\s[^az].z/C => /a\s\_[^az].z/ | /a[ \t][^az].z/ |
"| | :M/a\s[^az].z/D => /a\s[^az]\_.z/ | /a[ \t][^az\n].z/m |
"+-----+----------------------------------------------+--------------------+
"| (2) | :M/a\s[^az].z/M => /a[ \t\r\n^L]\_[^az].z/ | /a\s[^az].z/ |
"| (3) | :M/a\s[^az].z/m => /a[ \t\r\n^L]\_[^az]\_.z/ | /a\s[^az].z/m |
"+-----+----------------------------------------------+--------------------+
"
" Note:
" As for "\s", "[^az]" and ".", "M" and "m" options make
" eregex.vim-regexen compatible with ruby/perl-style-regexen.
" Note:
" Vim's "[^az]" doesn't match a newline.
" Contrary to the intention, "[^az\n]" matches a newline.
" The countermeasure is to convert "[^\s]" to "[^ \t\r^L]" with
" multiline.
"
"=============================================================================
" pseudo ruby/perl-style regexen.
"
" available extended regexen:
" alternation:
" "a|b"
" repetition:
" "a+", "a*", "a?", "a+?", "a*?", "a??,"
" "a{3,5}", "a{3,}", "a{,5}", "a{3,5}?", "a{3,}?", "a{,5}?"
" grouping:
" "(foo)", "(?:foo)", "(?=foo)", "(?!foo)", "(?<=foo)",
" "(?<!foo)", "(?>foo)"
" modifiers:
" "(?I)", "(?i)", "(?M)", "(?m)", "(?#comment)"
"
" Note:
" The use of "\M" or "\m" is preferable to the use of "(?M)" or "(?m)".
" "(?M)" and "(?m)" can't expand "\s" in brackets to " \t\r\n^L".
"
" not available extended regexen:
" "\A", "\b", "\B", "\G", "\Z", "\z",
" "(?i:a)", "(?-i)", "(?m:.)",
" There are no equivalents in vim-style regexen.
"
" special atoms:
" "\C" noignorecase
" "\c" ignorecase
" "\M" partial multiline
" "\m" full multiline
"
" For example:
" :M/a\s[^az].z/M => /a[ \t\r\n^L]\_[^az].z/
" :M/a\s[^az].z\M/ => /a[ \t\r\n^L]\_[^az].z/
" :M/a\s[^az].z/m => /a[ \t\r\n^L]\_[^az]\_.z/
" :M/a\s[^az].z\m/ => /a[ \t\r\n^L]\_[^az]\_.z/
" The order of priority:
" [A] /IiMm, [B] \C, \c, \M, \m, [C] (?I), (?i), (?M), (?m)
"
" many other vim-style regexen available:
" "\d", "\D", "\w", "\W", "\s", "\S", "\a", "\A",
" "\u", "\U", "\b"
" "\<", "\>"
" "\zs", "\ze"
" "\_[a-z]", "\%[abc]", "[[:alpha:]]"
" "\_.", "\_^", "\_$"
" "\%23l", "\%23c", "\%23v", "\%#"
" and so on. See :h /ordinary-atom
"
" misc:
" Convert "\xnn" to char except "\x00", "\x0a" and "\x08".
" "\x41\x42\x43" => "ABC"
" "\x2a\x5b\x5c" => "\*\[\\"
" Expand atoms in brackets.
" "[#$\w]" => "[#$0-9A-Za-z_]"
"
" "\f" in brackets is converted to "\x0c".
" but "\f" out of brackets is a class of filename characters.
"
" eregex.vim expansion of atoms and its meaning.
" +-------+----------------------+----------------------+
" | atom | out of brackets | in brackets |
" +-------+----------------------+----------------------+
" | \a | alphabetic char | alphabetic char |
" | \b | \x08 | \x08 |
" | \e | \x1b | \x1b |
" | \f | filename char | \x0c |
" | \n | \x0a | \x0a |
" | \r | \x0d | \x0d |
" | \s | [ \t] or [ \t\r\n\f] | " \t" or " \t\r\n\f" |
" | \t | \x09 | \x09 |
" | \v | \x0b | \x0b |
" | \xnn | hex nn | hex nn |
" +-------+----------------------+----------------------+
"
"=============================================================================
if version < 601 | finish | endif
if exists("loaded_eregex")
finish
endif
let loaded_eregex=1
"=============================================================================
"Commands And Mappings:
command! -nargs=? -range E2v :<line1>,<line2>call <SID>ExtendedRegex2VimRegexLineWise(<q-args>)
command! -nargs=? -count=1 M :let s:eregex_tmp_hlsearch = &hlsearch | let v:searchforward = <SID>Ematch(<count>, <q-args>) | if s:eregex_tmp_hlsearch == 1 | set hlsearch | endif
"command! -nargs=? -range S :<line1>,<line2>call <SID>Esubstitute(<q-args>)
command! -nargs=? -range S :<line1>,<line2>call <SID>Esubstitute(<q-args>) <Bar> :noh
command! -nargs=? -range=% -bang G :<line1>,<line2>call <SID>Eglobal(<q-bang>, <q-args>)
command! -nargs=? -range=% V :<line1>,<line2>call <SID>Evglobal(<q-args>)
"=============================================================================
"Script Variables:
let s:eglobal_working=0
"--------------------
let s:ch_with_backslash=0
let s:ch_posix_charclass=1
let s:ch_brackets=2
let s:ch_braces=3
let s:ch_parentheses_option=4
let s:ch_parentheses=5
let s:re_factor{0}='\\\%([^x_]\|x\x\{0,2}\|_[.$^]\=\)'
let s:re_factor{1}= '\[:\%(alnum\|alpha\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|' .
\ 'space\|upper\|xdigit\|return\|tab\|escape\|backspace\):\]'
let s:re_factor{2}='\[\%([^^][^]]*\|\^.[^]]*\)\]'
let s:re_factor{3}='{[0-9,]\+}?\='
"v141
"let s:re_factor{4}='(?[iISCDMm]\{1,7})'
let s:re_factor{4}='(?[iImM]\{1,2})'
let s:re_factor{5}='(\(?:\|?=\|?!\|?<=\|?<!\|?>\|?[-#ixm]\)\=[^()]*)'
let s:re_factor_size=6
"--------------------
let s:mark_left="\<Esc>" . strftime("%X") . ":" . strftime("%d") . "\<C-f>"
let s:mark_right="\<C-l>" . strftime("%X") . ":" . strftime("%d") . "\<Esc>"
let s:stack_size=0
let s:invert=0
let s:multiline=0
let s:ignorecase=0
"v220
let s:re_unescaped='\%(\\\)\@<!\%(\\\\\)*\zs'
let s:re_escaped='\%(\\\)\@<!\%(\\\\\)*\zs\\'
let s:bakregex=''
let s:mark_complements=s:mark_left . 'cOmPLemEnTs' . s:mark_right
"v141, 210
let s:extended_spaces=0
let s:extended_complements=0
let s:extended_dots=0
let s:str_modifiers='iISCDMm'
let s:meta_chars='$*.[\]^~'
"v217
"Why does "[^abc\n]" match a newline ???
let s:countermeasure=1
":M/(?:v21[5-9]|why)/i
"v238
let s:eregex_replacement=0
if exists('eregex_replacement')
let s:eregex_replacement=eregex_replacement
endif
"v240
let s:tmp=matchstr("$Revision: 2.60 $", '[0-9.]\+')
let s:maj=matchstr(s:tmp, '\d\+') * 100
let s:min=matchstr(s:tmp, '\.\zs\d\+') + 0
let s:version = s:maj + s:min
unlet s:tmp s:maj s:min
"v260
if !exists('g:eregex_forward_delim')
let g:eregex_forward_delim = '/'
endif
if !exists('g:eregex_backward_delim')
let g:eregex_backward_delim = '?'
endif
let s:enable = 0
function! eregex#toggle(...)
let silent = 0
if exists('a:1') && a:1
let silent = 1
endif
if s:enable == 0
exec 'nnoremap <expr> '.g:eregex_forward_delim.' ":<C-U>".v:count1."M/"'
exec 'nnoremap <expr> '.g:eregex_backward_delim.' ":<C-U>".v:count1."M?"'
if silent != 1
echo "eregx.vim key mapping enabled"
endif
else
exec 'nunmap '.g:eregex_forward_delim
exec 'nunmap '.g:eregex_backward_delim
if silent != 1
echo "eregx.vim key mapping disabled"
endif
endif
let s:enable = 1 - s:enable
endfun
if !(exists('g:eregex_default_enable') && g:eregex_default_enable == 0)
call eregex#toggle(1)
endif
"=============================================================================
"Functions:
function! s:Push(fct, kind)
let fct = a:fct
if (a:kind==s:ch_with_backslash) && (fct =~# '^\\x\x\{1,2}$')
" \x41
exec 'let code=0 + 0x' . matchstr(fct, '\x\{1,2}$')
if code!=0x0a && code!=0 && code!=0x08
let fct = nr2char(code)
"v141
if stridx(s:meta_chars, fct)!=-1
let fct = "\\" . fct
endif
endif
elseif a:kind == s:ch_with_backslash
" \. \_x
let chr = fct[1]
if chr =~# '[+?{}|()=]'
let fct = chr
elseif chr =~# '[Vv]'
if chr ==# 'v'
let fct=nr2char(0x0b)
else
let fct='V'
endif
"[IiMm]
endif
elseif a:kind == s:ch_posix_charclass
" [:alpha:] pass through
elseif a:kind == s:ch_brackets
"[ ]
let fct = s:ExpandAtomsInBrackets(fct)
elseif a:kind == s:ch_braces
"{ }
let fct = '\' . fct
" minimal match, not greedy
if fct =~# '?$'
if fct =~# '\d\+,\d\+'
let fct = substitute(fct, '{\(\d\+\),\(\d\+\)}?', '{-\1,\2}', '')
elseif fct =~# ',}'
let fct = substitute(fct, '{\(\d\+\),}?', '{-\1,}', '')
elseif fct =~# '{,'
let fct = substitute(fct, '{,\(\d\+\)}?', '{-,\1}', '')
else
let fct = strpart(fct, 1)
endif
endif
elseif a:kind==s:ch_parentheses_option
"( )
"v223
call s:SetModifiers(fct)
let fct = ''
elseif (a:kind==s:ch_parentheses) && (fct =~# '(?[-#ixm]')
"( )
if fct =~# '(?-\=[ixm]\{1,3})' || fct =~# '(?#'
let fct = ''
else
let fct = substitute(fct, '(?-\=[ixm]\{1,3}:\([^()]*\))', '\1', "")
let fct = s:ReplaceRemainFactorWithVimRegexFactor(fct)
endif
elseif a:kind==s:ch_parentheses
"( )
let kakko = matchstr(fct, '(\(?:\|?=\|?!\|?<=\|?<!\|?>\)\=')
let fct = substitute(fct, '(\(?:\|?=\|?!\|?<=\|?<!\|?>\)\=', "", "")
let fct = strpart(fct, 0, strlen(fct)-1)
let fct = s:ReplaceRemainFactorWithVimRegexFactor(fct)
if kakko ==# '('
let fct = '\(' . fct . '\)'
elseif kakko ==# '(?:'
let fct = '\%(' . fct . '\)'
elseif kakko ==# '(?='
let fct = '\%(' . fct . '\)\@='
elseif kakko ==# '(?!'
let fct = '\%(' . fct . '\)\@!'
elseif kakko ==# '(?<='
let fct = '\%(' . fct . '\)\@<='
elseif kakko ==# '(?<!'
let fct = '\%(' . fct . '\)\@<!'
elseif kakko ==# '(?>'
let fct = '\%(' . fct . '\)\@>'
else
let fct = ":BUG:"
endif
endif
let s:stack{s:stack_size} = fct
let s:stack_size = s:stack_size + 1
endfunction
"end s:Push()
"-----------------------------------------------------------------------------
function! s:ExpandAtomsInBrackets(bracket)
let bracket = a:bracket
let re_mark = s:mark_left . '\d\+' . s:mark_right
let re_snum = s:mark_left . '\(\d\+\)' . s:mark_right
"v120
let has_newline=0
"v216,v249
let complement=(bracket =~# '^\[^')
let searchstart = 0
let mtop = match(bracket, re_mark, searchstart)
while mtop >= 0
let mstr = matchstr(bracket, re_mark, searchstart)
let snum = substitute(mstr, re_snum, '\1', "") + 0
"v222
let fct = s:stack{snum}
"exclude, \e=0x1b, \b=0x08, \r=0x0d, \t=0x09
if fct =~# '^\\[adfhlosuwx]$'
let chr = fct[1]
if chr ==# 'a'
let fct='A-Za-z'
elseif chr ==# 'd'
let fct='0-9'
elseif chr ==# 'f'
"let fct=nr2char(0x0c)
let fct="\x0c"
elseif chr ==# 'h'
let fct='A-Za-z_'
elseif chr ==# 'l'
let fct='a-z'
elseif chr ==# 'o'
let fct='0-7'
elseif chr ==# 's'
"v141
if s:extended_spaces==1
"v217
if (s:countermeasure==1) && (complement==1)
let fct=" \\t\\r\x0c"
else
let fct=" \\t\\r\\n\x0c"
endif
let has_newline=1
else
let fct=' \t'
endif
elseif chr ==# 'u'
let fct='A-Z'
elseif chr ==# 'w'
let fct='0-9A-Za-z_'
elseif chr ==# 'x'
let fct='0-9A-Fa-f'
endif
let s:stack{snum}=fct
else
"v120
if fct ==# '\n'
"If there is only "\n" of inside of the brackets.
"It becomes the same as "\_.".
let has_newline=1
"v219
elseif fct ==# '-'
" '-' converted from \xnn
"If there is '-' in the beginning of the brackets and the end.
"Unnecessary '\' is stuck.
let s:stack{snum}='\-'
"v237
elseif fct ==# '\['
" '\[' converted from \xnn
let s:stack{snum}='['
endif
endif
let searchstart = mtop + strlen(mstr)
let mtop = match(bracket, re_mark, searchstart)
endwhile
"v120
if (complement==1) && (has_newline==0)
let bracket = s:mark_complements . bracket
endif
return bracket
endfunction
"end ExpandAtomsInBrackets()
"-----------------------------------------------------------------------------
function! s:Pop()
if s:stack_size <= 0 | return "" | endif
let s:stack_size = s:stack_size - 1
return s:stack{s:stack_size}
endfunction
"-----------------------------------------------------------------------------
" Debug:
function! s:UnletStack()
let i = 0
while exists("s:stack" . i)
exec "unlet s:stack" . i
let i = i + 1
endwhile
let s:stack_size = 0
endfunction
" Debug:
"function! EachStack()
" let lineno = line(".")
" let i = 0
" while exists("s:stack" . i)
" call append(lineno + i, i . " -> " . s:stack{i})
" let i = i + 1
" endwhile
"endfunction
"-----------------------------------------------------------------------------
function! s:ReplaceExtendedRegexFactorWithNumberFactor(extendedregex)
let halfway = a:extendedregex
let s:stack_size = 0
let i=0
let id_num=0
while i < s:re_factor_size
"CASESENSE:
let regex = '\C' . s:re_factor{i}
let mtop = match(halfway, regex)
while mtop >= 0
let factor = matchstr(halfway, regex)
let pre_match = strpart(halfway, 0, mtop)
let post_match= strpart(halfway, mtop + strlen(factor))
let halfway = pre_match . s:mark_left . id_num . s:mark_right . post_match
"END:
call s:Push( factor, i )
let id_num = id_num + 1
let mtop = match(halfway, regex)
endwhile
let i = i + 1
endwhile
return halfway
endfunction
"end s:ReplaceExtendedRegexFactorWithNumberFactor()
"-----------------------------------------------------------------------------
function! s:ReplaceRemainFactorWithVimRegexFactor(halfway)
let halfway = a:halfway
" minimal match, not greedy
let halfway = substitute(halfway, '+?', '\\{-1,}', 'g')
let halfway = substitute(halfway, '\*?', '\\{-}', 'g')
let halfway = substitute(halfway, '??', '\\{-,1}', 'g')
"--------------------
let halfway = substitute(halfway, '+', '\\+', 'g')
let halfway = substitute(halfway, '?', '\\=', 'g')
"--------------------
let halfway = substitute(halfway, '|', '\\|', 'g')
"--------------------
let halfway = substitute(halfway, '\~', '\\&', 'g')
"--------------------
"v141
if s:extended_dots==1
let halfway = substitute(halfway, '\.', '\\_.', 'g')
endif
return halfway
endfunction
"end s:ReplaceRemainFactorWithVimRegexFactor()
"-----------------------------------------------------------------------------
function! s:ReplaceNumberFactorWithVimRegexFactor(halfway)
let vimregex = a:halfway
let i = s:stack_size
while i > 0
let i = i - 1
let factor = s:Pop()
let str_mark = s:mark_left . i . s:mark_right
let vimregex = s:ReplaceAsStr(vimregex, str_mark, factor)
endwhile
"Debug:
call s:UnletStack()
"v221
"v120
if stridx(vimregex, s:mark_complements)!=-1
"v141
if s:extended_complements==1
"there isn't \_ before [^...].
" [^...] doesn't contain \n.
let re='\C\%(\%(\\\)\@<!\(\\\\\)*\\_\)\@<!\zs' . s:mark_complements
let vimregex = substitute(vimregex, re, '\\_', "g")
endif
let vimregex = substitute(vimregex, '\C' . s:mark_complements, '', "g")
endif
"v220
if s:extended_complements==1
let re='\C' . s:re_escaped . '\([ADHLOUWX]\)'
let vimregex = substitute(vimregex, re, '\\_\1', "g")
endif
"v141
if s:extended_spaces==1
" | atom | normal | extended spaces
" | \s | [ \t] | [ \t\r\n\f]
" | \S | [^ \t] | [^ \t\r\n\f]
" | \_s | \_[ \t] | [ \t\r\n\f]
" | \_S | \_[^ \t] | [^ \t\r\n\f] *
let ff=nr2char(0x0c)
let re='\C' . s:re_escaped . '_\=s'
let vimregex=substitute(vimregex, re, '[ \\t\\r\\n' . ff . ']', "g")
let re='\C' . s:re_escaped . '_\=S'
if s:countermeasure==1
"v216
let vimregex=substitute(vimregex, re, '[^ \\t\\r' . ff . ']', "g")
else
let vimregex=substitute(vimregex, re, '[^ \\t\\r\\n' . ff . ']', "g")
endif
endif
if s:ignorecase > 0
let tmp = (s:ignorecase==1) ? '\c' : '\C'
let vimregex = tmp . vimregex
endif
"if &magic==0
" let vimregex = '\m' . vimregex
"endif
return vimregex
endfunction
"end s:ReplaceNumberFactorWithVimRegexFactor()
"=============================================================================
"Main:
function! s:ExtendedRegex2VimRegex(extendedregex, ...)
"v141
let s:ignorecase=0
let s:multiline=0
let s:extended_spaces=0
let s:extended_complements=0
let s:extended_dots=0
if a:0==1
"v238,v243
if a:1 =~# 'R[0-3]'
return s:ExchangeReplaceSpecials(a:extendedregex, matchstr(a:1, 'R\zs[0-3]'))
"v240
elseif a:1 ==# 'V'
return s:version
endif
call s:SetModifiers(a:1)
endif
"v240 moved here
if strlen(a:extendedregex)==0
return ""
endif
"v141
let eregex=a:extendedregex
"v221
let mods = matchstr(eregex, '\C' . s:re_escaped . '[Mm]')
let mods = mods . matchstr(eregex, '\C' . s:re_escaped . '[Cc]')
if mods !=# ''
let mods = substitute(mods, '\CC', 'I',"g")
let mods = substitute(mods, '\Cc', 'i',"g")
call s:SetModifiers(mods)
let re='\C' . s:re_escaped . '[MmCc]'
let eregex=substitute(eregex, re, '', "g")
endif
"--------------------
let halfway = s:ReplaceExtendedRegexFactorWithNumberFactor(eregex)
let halfway = s:ReplaceRemainFactorWithVimRegexFactor(halfway)
let vimregex = s:ReplaceNumberFactorWithVimRegexFactor(halfway)
"v221
return vimregex
endfunction
"end s:ExtendedRegex2VimRegex()
"-----------------------------------------------------------------------------
function! s:ExtendedRegex2VimRegexLineWise(...) range
if a:1 ==# '--version'
echo "$Id: eregex.vim,v 2.56 2003-09-19 17:39:41+09 ta Exp $"
return
endif
let modifiers= a:1
let i = a:firstline
while i <= a:lastline
call setline(i, s:ExtendedRegex2VimRegex(getline(i), modifiers))
let i = i + 1
endwhile
endfunction
"end s:ExtendedRegex2VimRegexLineWise()
"-----------------------------------------------------------------------------
"Public:
function! E2v(extendedregex, ...)
if a:0==0
return s:ExtendedRegex2VimRegex(a:extendedregex)
endif
return s:ExtendedRegex2VimRegex(a:extendedregex, a:1)
endfunction
"end E2v()
"-----------------------------------------------------------------------------
function! s:Ematch(...)
if strlen(a:2) <= 1 | return | endif
let ccount = a:1
let string = a:2
let delim=string[0]
if delim !=# '/' && delim !=# '?'
let v:errmsg= "The delimiter `" . delim . "' isn't available, use `/' ."
echo v:errmsg
return
endif
let rxp ='^delim\([^delim\\]*\%(\\.[^delim\\]*\)*\)' .
\ '\(delim.*\)\=$'
let rxp=substitute(rxp, 'delim', delim, "g")
let regex = substitute(string, rxp, '\1',"")
let offset= substitute(string, rxp, '\2', "")
"--------------------
let modifiers=''
"v141
if offset =~# '[' . s:str_modifiers . ']'
let modifiers = substitute(offset, '\C[^' . s:str_modifiers . ']\+', "", "g")
let offset = substitute(offset, '\C[' . s:str_modifiers . ']\+', "", "g")
endif
if &ignorecase
let modifiers .= 'i'
endif
let regex = s:ExtendedRegex2VimRegex(regex, modifiers)
"v130
"set s:bakregex
let regex = s:EscapeAndUnescape(regex, delim)
"--------------------
if offset==# ''
let offset = delim
endif
let cmd = 'normal! ' . ccount . delim . regex . offset . "\<CR>"
let v:errmsg=''
set nohlsearch
silent! exec cmd
if (v:errmsg !~# '^E\d\+:') || (v:errmsg =~# '^E486:')
"v130
if s:bakregex !=# ''
let @/ = s:bakregex
endif
endif
if v:errmsg ==# ''
redraw!
else
echo 'M' . a:2
echo v:errmsg
endif
if delim == '?'
return 0
else
return 1
endif
endfunction
"end s:Ematch()
"-----------------------------------------------------------------------------
function! s:Esubstitute(...) range
if strlen(a:1) <= 1 | return | endif
let string = a:1
let delim = s:GetDelim(string[0])
if delim==# '' | return | endif
let rxp ='^delim\([^delim\\]*\%(\\.[^delim\\]*\)*\)delim\([^delim\\]*\%(\\.[^delim\\]*\)*\)' .
\ '\(delim.*\)\=$'
let rxp=substitute(rxp, 'delim', delim, "g")
if string !~# rxp
if s:eglobal_working==0
echo 'Invalid arguments S' . a:1
endif
return
endif
let regex = substitute(string, rxp, '\1',"")
let replacement = substitute(string, rxp, '\2', "")
let options = substitute(string, rxp, '\3',"")
"--------------------
"v141
let modifiers=''
if options =~# '[' . s:str_modifiers . ']'
let modifiers = substitute(options, '\C[^' . s:str_modifiers . ']\+', "", "g")
let options = substitute(options, '\C[SCDmM]', "", "g")
endif
if &ignorecase
let modifiers .= 'i'
endif
let regex = s:ExtendedRegex2VimRegex(regex, modifiers)
"v130
"set s:bakregex
let regex = s:EscapeAndUnescape(regex, delim)
"v238, v243
if (s:eregex_replacement > 0) && (strlen(replacement) > 1)
let replacement = s:ExchangeReplaceSpecials(replacement, s:eregex_replacement)
endif
"--------------------
if options ==# ''
let options = delim
endif
let cmd = a:firstline . ',' . a:lastline . 's' . delim . regex . delim . replacement . options
"Evaluater:
let g:eregex_evaluater_how_exe = s:eglobal_working
if g:eregex_evaluater_how_exe==0
let v:statusmsg=''
let v:errmsg=''
endif
let confirmoption = (options =~# 'c')
if confirmoption==1
"with confirm option.
let g:eregex_evaluater_how_exe=1
endif
let g:eregex_evaluater_cmd = cmd
runtime plugin/eregex_e.vim
if g:eregex_evaluater_how_exe==0 || confirmoption==1
unlet! g:eregex_evaluater_cmd
"v130
if s:bakregex !=# ''
let @/ = s:bakregex
endif
if confirmoption==0
if v:errmsg==# ''
if v:statusmsg !=# ''
echo v:statusmsg
endif
else
echo v:errmsg
endif
endif
endif
endfunction
"end s:Esubstitute()
"-----------------------------------------------------------------------------
function! s:Eglobal(bang, ...) range
if strlen(a:1)<=1 | return | endif
let string=a:1
let delim = s:GetDelim(string[0])
if delim==#'' | return | endif
"--------------------
let re_pattern = substitute('[^delim\\]*\%(\\.[^delim\\]*\)*', 'delim', delim,"g")
let re_offset = '\%([-+0-9]\d*\|\.[-+]\=\d*\)'
let re_sep = '[,;]'
let re_command = '[^,;].*'
let re_command_less = '\_$'
let re_end = '\%(' . re_sep . '\|' . re_command . '\|' . re_command_less . '\)'
"--------------------
let toprxp0 = '^' . delim . '\(' . re_pattern . '\)\(' . delim . re_offset . re_sep . '\)'
let toprxp1 = '^' . delim . '\(' . re_pattern . '\)\(' . delim . re_sep . '\)'
let toprxp2 = '^'
let endrxp0 = delim . '\(' . re_pattern . '\)\(' . delim . re_offset . re_end . '\)'
let endrxp1 = delim . '\(' . re_pattern . '\)\(' . delim . re_end . '\)'
let endrxp2 = delim . '\(' . re_pattern . '\)' . re_command_less
"--------------------
let mtop = -1
let j = 0
while j < 3
let i = 0
while i < 3
let regexp = toprxp{j} . endrxp{i}
let mtop = match(string, regexp)
if mtop>=0 | break | endif
let i = i + 1
endwhile
if mtop>=0 | break | endif
let j = j + 1
endwhile
if mtop<0 | return | endif
"--------------------
if a:bang==# '!'
let s:invert=1
endif
let cmd = (s:invert==0) ? 'g' : 'v'
let s:invert=0
let cmd = a:firstline . ',' . a:lastline . cmd
let globalcmd = ''
if j == 2
let pattern1 = substitute(string, regexp, '\1', "")
let strright = delim
if i < 2
let strright = substitute(string, regexp, '\2', "")
endif
let pattern1 = s:ExtendedRegex2VimRegex(pattern1)
"v130
let pattern1 = s:EscapeAndUnescape(pattern1, delim)
let globalcmd = cmd . delim . pattern1 . strright
else
let pattern1 = substitute(string, regexp, '\1', "")
let strmid = substitute(string, regexp, '\2',"")
let pattern2 = substitute(string, regexp, '\3', "")
let strright = delim
if i < 2
let strright = substitute(string, regexp, '\4', "")
endif
let pattern1 = s:ExtendedRegex2VimRegex(pattern1)
let pattern2 = s:ExtendedRegex2VimRegex(pattern2)
"v130
let pattern1 = s:EscapeAndUnescape(pattern1, delim)
let pattern2 = s:EscapeAndUnescape(pattern2, delim)
let globalcmd = cmd . delim . pattern1 . strmid . delim . pattern2 . strright
endif
"--------------------
"Evaluater:
let s:eglobal_working=1
let g:eregex_evaluater_how_exe=2
let g:eregex_evaluater_cmd = globalcmd
runtime plugin/eregex_e.vim
let s:eglobal_working=0
"let g:eregex_evaluater_how_exe=0
unlet! g:eregex_evaluater_cmd
endfunction
"end s:Eglobal()
"-----------------------------------------------------------------------------
function! s:Evglobal(...) range
let s:invert=1
let cmd = a:firstline . ',' . a:lastline . 'G' . a:1
exec cmd
endfunction
"end s:Evglobal()
"-----------------------------------------------------------------------------
function! s:GetDelim(str)
let valid = '[/@#]'
let delim = a:str[0]
if delim =~# valid
return delim
endif
let v:errmsg = "The delimiter `" . delim . "' isn't available, use " . valid
echo v:errmsg
return ''
endfunction
"end s:GetDelim()
"=============================================================================
"v130
"called from Ematch(), Esubstitute(), Eglobal()
"use s:re_unescaped, s:re_escaped, s:bakregex
function! s:EscapeAndUnescape(vimregex, delim)
let vimregex = a:vimregex
let s:bakregex= a:vimregex
if a:delim ==# '@'
return vimregex
endif
if s:bakregex =~# s:re_escaped . a:delim
" \/ or \# exists
let s:bakregex = substitute(vimregex, s:re_escaped . a:delim, a:delim, "g")
endif
if vimregex =~# s:re_unescaped . a:delim
" / or # exists
let vimregex = substitute(vimregex, s:re_unescaped . a:delim, '\\' . a:delim, "g")
endif
return vimregex
endfunction
"end s:EscapeAndUnescape()
"=============================================================================
"v141
"called from only s:ExtendedRegex2VimRegex()
function! s:SetModifiers(mods)
"v221
if s:ignorecase==0
if a:mods =~# 'i'
let s:ignorecase=1
elseif a:mods =~# 'I'
let s:ignorecase=2
endif
endif
"v221
if s:multiline==0
if a:mods =~? 'm'
let s:extended_spaces=1
let s:extended_complements=1
if a:mods =~# 'M'
"partial multiline
let s:multiline=1
else
"full multiline
let s:extended_dots=1
let s:multiline=2
endif
endif
endif
if a:mods =~# 'S'
let s:extended_spaces=1
endif
if a:mods =~# 'C'
let s:extended_complements=1
endif
if a:mods =~# 'D'
let s:extended_dots=1
endif
endfunction
"End: s:SetModifiers(mods)
"=============================================================================
"v238,
function! s:ExchangeReplaceSpecials(replacement, sort)
let rs=a:replacement
"v243,v246
if (rs !~# '[&~]\|\\[rnx]') || (rs =~# '^\\=')
return rs
endif
if (a:sort % 2)==1
let rs=substitute(rs, '\C' . s:re_escaped . 'r', '\\R', "g")
let rs=substitute(rs, '\C' . s:re_escaped . 'n', '\\r', "g")
let rs=substitute(rs, '\C' . s:re_escaped . 'R', '\\n', "g")
endif
if a:sort >= 2
let rs=substitute(rs, '\C' . s:re_escaped . '&', '\\R', "g")
let rs=substitute(rs, '\C' . s:re_escaped . '\~', '\\N', "g")
let rs=substitute(rs, '\C' . s:re_unescaped . '[&~]', '\\&', "g")
let rs=substitute(rs, '\C' . s:re_escaped . 'R', '\&', "g")
let rs=substitute(rs, '\C' . s:re_escaped . 'N', '\~', "g")
endif
return rs
endfunction
"End: s:ExchangeReplaceSpecials()
"=============================================================================
"=============================================================================
"Import: macros/locrian.vim
function! s:ReplaceAsStr(str, search, replacement, ...)
let gsub = a:0
if a:0 > 0
let gsub = (a:1=~? 'g') ? 1 : 0
endif
let oldstr = a:str
let newstr = ""
let len = strlen(a:search)
let i = stridx(oldstr, a:search)
while i >= 0
let newstr = newstr . strpart(oldstr, 0, i) . a:replacement
let oldstr = strpart(oldstr, i + len)
if gsub==0
break
endif
let i = stridx(oldstr, a:search)
endwhile
if strlen(oldstr)!=0
let newstr = newstr . oldstr
endif
return newstr
endfunction
"end s:ReplaceAsStr()
"=============================================================================
" $Id: eregex_e.vim,v 1.40 2003-06-03 18:25:59+09 ta Exp ta $
" An evaluater for eregex.vim
if exists('g:eregex_evaluater_cmd') && exists('g:eregex_evaluater_how_exe')
if g:eregex_evaluater_how_exe==0
" :s silently exec, handle errmsg
silent! exec g:eregex_evaluater_cmd
elseif g:eregex_evaluater_how_exe==1
" :s invoked by :g and
" :s with confirm option
exec g:eregex_evaluater_cmd
elseif g:eregex_evaluater_how_exe==2
":g
redraw
exec g:eregex_evaluater_cmd
endif
endif
{'version': 0.3, 'files': [{'file': '/home/bro3886/.vim/doc/eregex.jax', 'checksum': ''}, {'file': '/home/bro3886/.vim/doc/eregex.txt', 'checksum': ''}, {'file': '/home/bro3886/.vim/plugin/eregex.vim', 'checksum': ''}, {'file': '/home/bro3886/.vim/plugin/eregex_e.vim', 'checksum': ''}], 'install_type': 'makefile', 'script_version': '2.61', 'package': 'eregex.vim', 'generated_by': 'Vim-Makefile'}
...@@ -51,12 +51,10 @@ set pastetoggle=<F10> ...@@ -51,12 +51,10 @@ set pastetoggle=<F10>
set title set title
set laststatus=2 set laststatus=2
"set t_Co=256
nore ; : nore ; :
nore , ; nore , ;
map < :tabp<CR> noremap < :tabp<CR>
map > :tabn<CR> noremap > :tabn<CR>
command! C let @/="" command! C let @/=""
cmap w!! w !sudo tee >/dev/null % cmap w!! w !sudo tee >/dev/null %
vnoremap cy "*y vnoremap cy "*y
...@@ -64,19 +62,20 @@ vnoremap cp "*p ...@@ -64,19 +62,20 @@ vnoremap cp "*p
inoremap <Down> <C-o>gj inoremap <Down> <C-o>gj
inoremap <Up> <C-o>gk inoremap <Up> <C-o>gk
colorscheme koehler colorscheme murphy
execute pathogen#infect() execute pathogen#infect()
autocmd Bufenter,BufNew *.pro set syntax=prolog autocmd Bufenter,BufNew *.pro set syntax=prolog
autocmd Filetype gitcommit setlocal spell textwidth=72 autocmd Filetype gitcommit setlocal spell textwidth=72
autocmd Bufenter *.hs compiler ghc autocmd Bufenter *.hs compiler ghc
" From http://vi.stackexchange.com/questions/258/
autocmd BufWritePre *.sh if !filereadable(expand('%')) | let b:is_new = 1 | endif autocmd BufWritePre *.sh if !filereadable(expand('%')) | let b:is_new = 1 | endif
autocmd BufWritePost *.sh if get(b:, 'is_new', 0) | silent execute '!chmod +x %' | endif autocmd BufWritePost *.sh if get(b:, 'is_new', 0) | silent execute '!chmod +x %' | endif
let g:SuperTabDefaultCompletionType="context" let g:SuperTabDefaultCompletionType="context"
set omnifunc=syntaxcomplete#Complete set omnifunc=syntaxcomplete#Complete
set foldmethod=syntax set foldmethod=syntax
"let g:SuperTabDefaultCompletionType = \"<C-X><C-O>\"
let g:syntastic_cpp_compiler_options=' -std=c++11' let g:syntastic_cpp_compiler_options=' -std=c++11'
let g:syntastic_python_python_exec = '/usr/bin/python3' let g:syntastic_python_python_exec = '/usr/bin/python3'
let g:airline#extensions#tabline#enabled = 1 let g:airline#extensions#tabline#enabled = 1
...@@ -104,9 +103,53 @@ if has("gui_running") ...@@ -104,9 +103,53 @@ if has("gui_running")
endif endif
endif endif
" From http://vi.stackexchange.com/questions/239/
if @% == "" && getcwd() == "/tmp" if @% == "" && getcwd() == "/tmp"
:silent edit test.sh :silent edit test.sh
endif endif
let g:DiffColors=100 let g:DiffColors=100
set path+=~/devel/elearning_academy/**
" function LookupFiles ()
" python <<EOF
" from os.path import *
" from vim import *
" current_file = eval ('expand("%")')
" current_index = str (current.buffer.number)
" PATHS = ['~', '~/.vim', '/etc']
"
" if current_file != '' and not isfile (current_file):
" for p in map (expanduser, PATHS):
" f = join (p, current_file)
" if isfile (f):
" command ('bad ' + f)
" command ('bd ' + current_index)
" command ('bl')
" # command ('silent keepalt file ' + f)
" break
" EOF
" endfunction
"
" autocmd BufWinEnter * nested call LookupFiles()
" From http://vi.stackexchange.com/questions/2009/
function! FindInPath(name)
let path=&path
" Add any extra directories to the normal search path
set path+=~,~/.vim,/etc
" If :find finds a file, then wipeout the buffer that was created for the "new" file
setlocal bufhidden=wipe
exe 'silent! keepalt find '. fnameescape(a:name)
" Restore 'path' and 'bufhidden' to their normal values
let &path=path
set bufhidden<
endfunction
autocmd BufNewFile * nested call FindInPath(expand('<afile>'))
"au VimEnter * tab all | tabfirst
" From http://vi.stackexchange.com/questions/2358/
autocmd FileType * exec("setlocal dictionary+=".$HOME."/.vim/dictionary/".expand('<amatch>'))
set completeopt=menuone,longest,preview
set complete+=k
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment