diff --git a/autoload/nimrod.vim b/autoload/nimrod.vim index 52f1bb7..87d5950 100644 --- a/autoload/nimrod.vim +++ b/autoload/nimrod.vim @@ -1,11 +1,34 @@ let g:nimrod_log = [] let s:plugin_path = escape(expand(':p:h'), ' \') +if !exists("g:nimrod_caas_enabled") + let g:nimrod_caas_enabled = 1 +endif + exe 'pyfile ' . fnameescape(s:plugin_path) . '/nimrod_vim.py' +if !executable('nimrod') + echoerr "the nimrod compiler must be in your system's PATH" +endif + fun! nimrod#init() - let b:nimrod_project_root = "/foo" - let b:nimrod_caas_enabled = 0 + let cmd = printf("nimrod --dump.format:json --verbosity:0 dump %s", s:CurrentNimrodFile()) + let raw_dumpdata = system(cmd) + if !v:shell_error + " the silent bit is to ignore a warning about trailing characters + let dumpdata = eval(substitute(raw_dumpdata, "\n", "", "g")) + + let b:nimrod_project_root = dumpdata['project_path'] + let b:nimrod_caas_enabled = g:nimrod_caas_enabled + + for path in dumpdata['lib_paths'] + if finddir(path) == path + let &l:path = path . "," . &l:path + endif + endfor + else + let b:nimrod_caas_enabled = 0 + endif endf fun! s:UpdateNimLog() @@ -27,6 +50,8 @@ augroup NimLog au BufEnter log://nimrod call s:UpdateNimLog() augroup END +command! NimLog :e log://nimrod + fun! s:CurrentNimrodFile() let save_cur = getpos('.') call cursor(0, 0, 0) diff --git a/ftplugin/nimrod.vim b/ftplugin/nimrod.vim index d3b2b32..710b53e 100644 --- a/ftplugin/nimrod.vim +++ b/ftplugin/nimrod.vim @@ -15,17 +15,6 @@ setlocal commentstring=#\ %s setlocal omnifunc=NimComplete setlocal suffixesadd=.nim -if executable('nimrod') - let nimrod_paths = split(system('nimrod dump'),'\n') - let &l:path = &g:path - - for path in nimrod_paths - if finddir(path) == path - let &l:path = path . "," . &l:path - endif - endfor -endif - compiler nimrod let &cpo = s:cpo_save