weirongxu / plantuml-previewer.vim

Vim / Neovim plugin for preview PlantUML

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

narrow region and scratch buffer

dfroger opened this issue · comments

I'm writing a document using rst2pdf, which supports plantuml code in a reStructuredText directive .. uml::. I'm using NrrwRgn to edit the plantuml code and format it as @startuml ... @enduml in a scratch buffer.

But the image preview do not work, I think it's because I'm running PlantumlOpen in a scratch buffer. (see :help special-buffers).

Any idea? Thanks!

So in this function (plantuml_previewer.vim), the puml_src_path file does not actually exist:

function! plantuml_previewer#refresh(bufnr) "{{{
  let puml_src_path = fnamemodify(bufname(a:bufnr), ':p')   
  let puml_filename = fnamemodify(puml_src_path, ':t:r')
  let image_type = 'svg'
  let image_ext = s:fmt_to_ext(image_type)
  let output_dir_path = s:tmp_path
  let output_path = output_dir_path . '/' . puml_filename . '.' . image_ext
  let finial_path = s:viewer_path() . '/tmp.' . image_ext
  let cmd = [
       \ s:update_viewer_script_path,    
       \ s:jar_path(),  
       \ puml_src_path,
       \ s:normalize_path(output_dir_path),
       \ s:normalize_path(output_path),
       \ s:normalize_path(finial_path), 
       \ image_type,
       \ localtime(),
       \ s:normalize_path(s:viewer_tmp_js_path()),
       \ ]
  call s:run_in_background(cmd)
endfunction "}}}

I've just run into this too, I think this plugin needs to pipe the buffer contents to a file rather than trying to read it directly. Or you can use -p and pipe the contents in directly instead.

Thanks, I must admit I don't remember about this issue... I think my solution was to include the uml as an external file. However, I no more use plantuml (nor rst2pdf), so feel free to close the issue if it's relevant!