Skip to content

Commit

Permalink
feat: Add variable to extend the include path (#65)
Browse files Browse the repository at this point in the history
Co-authored-by: Jonas Siewert <[email protected]>
  • Loading branch information
jodojodo and Jonas Siewert committed Apr 22, 2022
1 parent f51d50b commit 887d55f
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 5 deletions.
9 changes: 9 additions & 0 deletions autoload/plantuml_previewer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ let s:base_path = fnameescape(expand("<sfile>:p:h")) . '/..'

let s:default_jar_path = s:base_path . '/lib/plantuml.jar'

let s:default_include_path = ''

let s:tmp_path = s:base_path . '/tmp'

let s:save_as_script_path = s:base_path . '/script/save-as' . (s:is_win ? '.cmd' : '.sh')
Expand Down Expand Up @@ -120,6 +122,11 @@ function! s:jar_path() "{{{
return s:is_zero(path) ? s:default_jar_path : path
endfunction "}}}

function! s:include_path() "{{{
let path = get(g:, 'plantuml_previewer#include_path', 0)
return s:is_zero(path) ? s:default_include_path : path
endfunction "}}}

function! s:save_format() "{{{
return get(g:, 'plantuml_previewer#save_format', 'png')
endfunction "}}}
Expand Down Expand Up @@ -190,6 +197,7 @@ function! plantuml_previewer#refresh(bufnr) "{{{
\ image_type,
\ localtime(),
\ s:normalize_path(s:viewer_tmp_js_path()),
\ s:include_path(),
\ ]
call s:run_in_background(cmd)
endfunction "}}}
Expand Down Expand Up @@ -227,6 +235,7 @@ function! plantuml_previewer#save_as(...) "{{{
\ s:normalize_path(output_path),
\ s:normalize_path(save_path),
\ image_type,
\ s:include_path(),
\ ]
call s:run_in_background(cmd)
endfunction "}}}
8 changes: 7 additions & 1 deletion doc/plantuml-previewer.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,13 @@ g:plantuml_previewer#viewer_path
And `tmp.puml` and `tmp.svg` will output to here
Default: "~/.plantuml-previewer"

*g:plantuml_previewer#debug_mode*
*g:plantuml_previewer#include_path*
g:plantuml_previewer#include_path
Extend the include path that plantuml uses to find files included
via "!include".
Default: ""

*g:plantuml_previewer#debug_mode*
g:plantuml_previewer#debug_mode
Debug mode
Default: 0
Expand Down
3 changes: 2 additions & 1 deletion script/save-as.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set output_dir_path=%3
set output_path=%4
set save_path=%5
set image_type=%6
set include_path=%7

java -Dapple.awt.UIElement=true -jar "%jar_path%" "%puml_src_path%" -t%image_type% -o "%output_dir_path%"
java -Dapple.awt.UIElement=true -Dplantuml.include.path="%include_path%" -jar "%jar_path%" "%puml_src_path%" -t%image_type% -o "%output_dir_path%"
copy "%output_path%" "%save_path%"
3 changes: 2 additions & 1 deletion script/save-as.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ output_dir_path=$3
output_path=$4
save_path=$5
image_type=$6
include_path=$7

java -Dapple.awt.UIElement=true -Djava.awt.headless=true -jar "$jar_path" "$puml_src_path" -t$image_type -o "$output_dir_path"
java -Dapple.awt.UIElement=true -Djava.awt.headless=true -Dplantuml.include.path="$include_path" -jar "$jar_path" "$puml_src_path" -t$image_type -o "$output_dir_path"
cp "$output_path" "$save_path"
3 changes: 2 additions & 1 deletion script/update-viewer.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ set image_type=%6

set timestamp=%7
set update_js_path=%8
set include_path=%9

java -Dapple.awt.UIElement=true -jar "%jar_path%" "%puml_src_path%" -t%image_type% -o "%output_dir_path%"
java -Dapple.awt.UIElement=true -Dplantuml.include.path="%include_path%" -jar "%jar_path%" "%puml_src_path%" -t%image_type% -o "%output_dir_path%"
echo F | xcopy /S /Q /F /Y "%output_path%" "%finial_path%"
echo window.updateDiagramURL('%timestamp%') > "%update_js_path%"
3 changes: 2 additions & 1 deletion script/update-viewer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ image_type=$6

timestamp=$7
update_js_path=$8
include_path=$9

java -Dapple.awt.UIElement=true -Djava.awt.headless=true -jar "$jar_path" "$puml_src_path" -t$image_type -o "$output_dir_path"
java -Dapple.awt.UIElement=true -Djava.awt.headless=true -Dplantuml.include.path="$include_path" -jar "$jar_path" "$puml_src_path" -t$image_type -o "$output_dir_path"
cp "$output_path" "$finial_path"
echo "window.updateDiagramURL('$timestamp')" > "$update_js_path"

0 comments on commit 887d55f

Please sign in to comment.