fixed the "cannot reload GotoDefinition while executing" error
errors are redirected to a log buffer now instead of echoerr
This commit is contained in:
parent
95533181c2
commit
ecc3d1f633
2 changed files with 133 additions and 110 deletions
|
|
@ -7,116 +7,7 @@ let b:nimrod_loaded = 1
|
|||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
if executable('nimrod')
|
||||
let nimrod_paths = split(system('nimrod dump'),'\n')
|
||||
let &l:tags = &g:tags
|
||||
|
||||
for path in nimrod_paths
|
||||
if finddir(path) == path
|
||||
let &l:tags = path . "/tags," . &l:tags
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
fun! CurrentNimrodFile()
|
||||
let save_cur = getpos('.')
|
||||
call cursor(0, 0, 0)
|
||||
|
||||
let PATTERN = "\\v^\\#\\s*included from \\zs.*\\ze"
|
||||
let l = search(PATTERN, "n")
|
||||
|
||||
if l != 0
|
||||
let f = matchstr(getline(l), PATTERN)
|
||||
let l:to_check = expand('%:h') . "/" . f
|
||||
else
|
||||
let l:to_check = expand("%")
|
||||
endif
|
||||
|
||||
call setpos('.', save_cur)
|
||||
return l:to_check
|
||||
endf
|
||||
|
||||
let g:nimrod_symbol_types = {
|
||||
\ 'skParam': 'v',
|
||||
\ 'skVar': 'v',
|
||||
\ 'skLet': 'v',
|
||||
\ 'skTemp': 'v',
|
||||
\ 'skForVar': 'v',
|
||||
\ 'skConst': 'v',
|
||||
\ 'skResult': 'v',
|
||||
\ 'skGenericParam': 't',
|
||||
\ 'skType': 't',
|
||||
\ 'skField': 'm',
|
||||
\ 'skProc': 'f',
|
||||
\ 'skMethod': 'f',
|
||||
\ 'skIterator': 'f',
|
||||
\ 'skConverter': 'f',
|
||||
\ 'skMacro': 'f',
|
||||
\ 'skTemplate': 'f',
|
||||
\ 'skEnumField': 'v',
|
||||
\ }
|
||||
|
||||
fun! NimComplete(findstart, base)
|
||||
if a:findstart
|
||||
if synIDattr(synIDtrans(synID(line("."),col("."),1)), "name") == 'Comment'
|
||||
return -1
|
||||
endif
|
||||
return col('.')
|
||||
else
|
||||
let result = []
|
||||
let cmd = printf("nimrod idetools --suggest --track:\"%s,%d,%d\" \"%s\"",
|
||||
\ expand('%:p'), line('.'), col('.'), CurrentNimrodFile())
|
||||
|
||||
let sugOut = system(cmd)
|
||||
for line in split(sugOut, '\n')
|
||||
let lineData = split(line, '\t')
|
||||
if lineData[0] == "sug"
|
||||
let kind = get(g:nimrod_symbol_types, lineData[1], '')
|
||||
let c = { 'word': lineData[2], 'kind': kind, 'menu': lineData[3], 'dup': 1 }
|
||||
call add(result, c)
|
||||
endif
|
||||
endfor
|
||||
return result
|
||||
endif
|
||||
endf
|
||||
|
||||
if !exists("g:neocomplcache_omni_patterns")
|
||||
let g:neocomplcache_omni_patterns = {}
|
||||
endif
|
||||
|
||||
let g:neocomplcache_omni_patterns['nimrod'] = '[^. *\t]\.\w*'
|
||||
|
||||
fun! GotoDefinition_nimrod()
|
||||
let cmd = printf("nimrod idetools --def --track:\"%s,%d,%d\" \"%s\"",
|
||||
\ expand('%:p'), line('.'), col('.'), CurrentNimrodFile())
|
||||
|
||||
let defOut = system(cmd)
|
||||
if v:shell_error
|
||||
echoerr "error executing nimrod. exit code: " . v:shell_error
|
||||
echoerr defOut
|
||||
return 0
|
||||
endif
|
||||
|
||||
let rawDef = matchstr(defOut, 'def\t\([^\n]*\)')
|
||||
if rawDef == ""
|
||||
echo "nimrod was unable to locate the definition"
|
||||
return 0
|
||||
endif
|
||||
|
||||
let defBits = split(rawDef, '\t')
|
||||
let file = defBits[4]
|
||||
let line = defBits[5]
|
||||
exe printf("e +%d %s", line, file)
|
||||
return 1
|
||||
endf
|
||||
|
||||
" Syntastic syntax checking
|
||||
fun! SyntaxCheckers_nimrod_GetLocList()
|
||||
let makeprg = 'nimrod check ' . CurrentNimrodFile()
|
||||
let errorformat = &errorformat
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endf
|
||||
call nimrod#init()
|
||||
|
||||
setlocal formatoptions-=t formatoptions+=croql
|
||||
setlocal comments=:#
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue