1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-04-15 08:09:11 +08:00

chore(plantuml_previewer): update plantuml_previewer

This commit is contained in:
wsdjeg 2023-03-25 15:33:59 +08:00
parent 9a33b7f001
commit d5a0d06272
11 changed files with 6890 additions and 6843 deletions

2
bundle/README.md vendored
View File

@ -97,4 +97,4 @@ This plugins are changed based on a specific version of origin plugin.
- [`scrooloose/vim-slumlord@5c34739`](https://github.com/scrooloose/vim-slumlord/tree/5c34739a6ca71ef3617ed71491b3387bb2fb5620) - [`scrooloose/vim-slumlord@5c34739`](https://github.com/scrooloose/vim-slumlord/tree/5c34739a6ca71ef3617ed71491b3387bb2fb5620)
- [`aklt/plantuml-syntax@845abb5`](https://github.com/aklt/plantuml-syntax/tree/845abb56dcd3f12afa6eb47684ef5ba3055802b8) - [`aklt/plantuml-syntax@845abb5`](https://github.com/aklt/plantuml-syntax/tree/845abb56dcd3f12afa6eb47684ef5ba3055802b8)
- [`weirongxu/plantuml-previewer.vim`](https://github.com/weirongxu/plantuml-previewer.vim) - [`weirongxu/plantuml-previewer.vim@1dd4d0f`](https://github.com/weirongxu/plantuml-previewer.vim/tree/1dd4d0f2b09cd80a217f76d82f93830dbbe689b3)

View File

@ -1,17 +1,20 @@
# Plantuml Previewer Vim # Plantuml Previewer Vim
Vim/NeoVim plugin for preview [PlantUML](http://plantuml.com/) Vim/NeoVim plugin for preview [PlantUML](http://plantuml.com/)
![image](https://user-images.githubusercontent.com/1709861/40650003-dcd75a76-6364-11e8-8cb1-40d710a0cc0a.png) ![image](https://user-images.githubusercontent.com/1709861/40650003-dcd75a76-6364-11e8-8cb1-40d710a0cc0a.png)
## Dependencies ## Dependencies
* Java
* Graphviz (https://www.graphviz.org/download/) - Java
* brew install graphviz - Graphviz (https://www.graphviz.org/download/)
* apt-get install graphviz - brew install graphviz
* [open-browser.vim](https://github.com/tyru/open-browser.vim) - apt-get install graphviz
* [aklt/plantuml-syntax](https://github.com/aklt/plantuml-syntax) (vim syntax file for plantuml) - [open-browser.vim](https://github.com/tyru/open-browser.vim)
- [aklt/plantuml-syntax](https://github.com/aklt/plantuml-syntax) (vim syntax file for plantuml)
## Usage ## Usage
1. Start editing plantuml file in Vim 1. Start editing plantuml file in Vim
2. Run `:PlantumlOpen` to open previewer webpage in browser 2. Run `:PlantumlOpen` to open previewer webpage in browser
3. Saving plantuml file in Vim, then previewer webpage will refresh 3. Saving plantuml file in Vim, then previewer webpage will refresh
@ -19,21 +22,27 @@ Vim/NeoVim plugin for preview [PlantUML](http://plantuml.com/)
### Commands ### Commands
#### PlantumlOpen #### PlantumlOpen
Open previewer webpage in browser, and watch current buffer Open previewer webpage in browser, and watch current buffer
#### PlantumlStart #### PlantumlStart
Like `PlantumlOpen`, but won't open in browser Like `PlantumlOpen`, but won't open in browser
#### PlantumlStop #### PlantumlStop
Stop watch buffer Stop watch buffer
#### PlantumlSave [filepath] [format] #### PlantumlSave [filepath] [format]
Export uml diagram to file path Export uml diagram to file path
Available formats Available formats
> png, svg, eps, pdf, vdx, xmi, > png, svg, eps, pdf, vdx, xmi,
> scxml, html, txt, utxt, latex > scxml, html, txt, utxt, latex
Example: Example:
``` ```
:e diagram.puml :e diagram.puml
@ -43,7 +52,9 @@ Example:
``` ```
### Variables ### Variables
#### `g:plantuml_previewer#plantuml_jar_path` #### `g:plantuml_previewer#plantuml_jar_path`
Custom plantuml.jar file path Custom plantuml.jar file path
If plant uml was installed by homebrew, you can add the following code to your `.vimrc` to use the version installed by homebrew: If plant uml was installed by homebrew, you can add the following code to your `.vimrc` to use the version installed by homebrew:
@ -57,15 +68,23 @@ au FileType plantuml let g:plantuml_previewer#plantuml_jar_path = get(
``` ```
#### `g:plantuml_previewer#save_format` #### `g:plantuml_previewer#save_format`
`:PlantumlSave` default format `:PlantumlSave` default format
Default: 'png' Default: 'png'
#### `g:plantuml_previewer#viewer_path` #### `g:plantuml_previewer#viewer_path`
Custom plantuml viewer path Custom plantuml viewer path
The plugin will copy viewer to here if the directory does not exist The plugin will copy viewer to here if the directory does not exist
And `tmp.puml` and `tmp.svg` will output to here And `tmp.puml` and `tmp.svg` will output to here
#### `g:plantuml_previewer#debug_mode`
Debug mode
The plugin will print debug message if this is set to `1`
Default: 0
## Related ## Related
* [vim-slumlord](https://github.com/scrooloose/vim-slumlord)
* [previm](https://github.com/kannokanno/previm) - [vim-slumlord](https://github.com/scrooloose/vim-slumlord)
- [previm](https://github.com/kannokanno/previm)

View File

@ -6,7 +6,11 @@ let s:base_path = fnameescape(expand("<sfile>:p:h")) . '/..'
let s:default_jar_path = s:base_path . '/lib/plantuml.jar' let s:default_jar_path = s:base_path . '/lib/plantuml.jar'
let s:tmp_path = s:base_path . '/tmp' let s:default_java_path = 'java'
let s:default_include_path = ''
let s:tmp_path = (s:is_win ? s:base_path . '/tmp' : '/tmp/plantuml-previewer')
let s:save_as_script_path = s:base_path . '/script/save-as' . (s:is_win ? '.cmd' : '.sh') let s:save_as_script_path = s:base_path . '/script/save-as' . (s:is_win ? '.cmd' : '.sh')
@ -16,10 +20,8 @@ let s:watched_bufnr = 0
let s:started = v:false let s:started = v:false
let s:java = get(g:, 'plantuml_java_command', 'java')
function! plantuml_previewer#start() "{{{ function! plantuml_previewer#start() "{{{
if !executable(s:java) if !executable(s:java_path())
echoerr 'require java command' echoerr 'require java command'
return v:false return v:false
endif endif
@ -83,6 +85,7 @@ function! plantuml_previewer#copy_viewer_directory() "{{{
call system('xcopy ' . default_viewer_path . ' ' . g:plantuml_previewer#viewer_path . ' /O /X /E /H /K') call system('xcopy ' . default_viewer_path . ' ' . g:plantuml_previewer#viewer_path . ' /O /X /E /H /K')
else else
call system('cp -r ' . default_viewer_path . ' ' . g:plantuml_previewer#viewer_path) call system('cp -r ' . default_viewer_path . ' ' . g:plantuml_previewer#viewer_path)
call system('chmod a=rwX ' . g:plantuml_previewer#viewer_path)
endif endif
echom 'copy ' . default_viewer_path . ' -> ' . viewer_path echom 'copy ' . default_viewer_path . ' -> ' . viewer_path
endif endif
@ -113,11 +116,25 @@ function! s:viewer_html_path() "{{{
return s:viewer_path() . '/index.html' return s:viewer_path() . '/index.html'
endfunction "}}} endfunction "}}}
function! s:is_debug_mode() "{{{
return get(g:, 'plantuml_previewer#debug_mode', 0)
endfunction "}}}
function! s:java_path() "{{{
let path = get(g:, 'plantuml_previewer#java_path', 0)
return s:is_zero(path) ? s:default_java_path : path
endfunction "}}}
function! s:jar_path() "{{{ function! s:jar_path() "{{{
let path = get(g:, 'plantuml_previewer#plantuml_jar_path', 0) let path = get(g:, 'plantuml_previewer#plantuml_jar_path', 0)
return s:is_zero(path) ? s:default_jar_path : path return s:is_zero(path) ? s:default_jar_path : path
endfunction "}}} 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() "{{{ function! s:save_format() "{{{
return get(g:, 'plantuml_previewer#save_format', 'png') return get(g:, 'plantuml_previewer#save_format', 'png')
endfunction "}}} endfunction "}}}
@ -130,17 +147,39 @@ function! s:fmt_to_ext(fmt) "{{{
return a:fmt == 'latex' ? 'tex' : a:fmt return a:fmt == 'latex' ? 'tex' : a:fmt
endfunction "}}} endfunction "}}}
function! s:print_stdout(lines) "{{{
let msg = trim(join(a:lines))
if !empty(msg)
echomsg msg
endif
endfunction "}}}
function! s:print_stderr(lines) "{{{
let msg = trim(join(a:lines))
if !empty(msg)
echoerr msg
endif
endfunction "}}}
function! s:run_in_background(cmd) "{{{ function! s:run_in_background(cmd) "{{{
if s:Job.is_available() if s:is_debug_mode()
call s:Job.start(a:cmd) if s:Job.is_available()
call s:Job.start(a:cmd, {'on_stdout': function('s:print_stdout'), 'on_stderr': function('s:print_stderr')})
else
call s:print_stdout(s:Process.execute(a:cmd))
endif
else else
try if s:Job.is_available()
call s:Process.execute(a:cmd, { call s:Job.start(a:cmd)
\ 'background': 1, else
\}) try
catch call s:Process.execute(a:cmd, {
call s:Process.execute(a:cmd) \ 'background': 1,
endtry \})
catch
call s:Process.execute(a:cmd)
endtry
endif
endif endif
endfunction "}}} endfunction "}}}
@ -158,7 +197,7 @@ function! plantuml_previewer#refresh(bufnr) "{{{
let finial_path = s:viewer_path() . '/tmp.' . image_ext let finial_path = s:viewer_path() . '/tmp.' . image_ext
let cmd = [ let cmd = [
\ s:update_viewer_script_path, \ s:update_viewer_script_path,
\ s:java, \ s:java_path(),
\ s:jar_path(), \ s:jar_path(),
\ puml_src_path, \ puml_src_path,
\ s:normalize_path(output_dir_path), \ s:normalize_path(output_dir_path),
@ -167,12 +206,13 @@ function! plantuml_previewer#refresh(bufnr) "{{{
\ image_type, \ image_type,
\ localtime(), \ localtime(),
\ s:normalize_path(s:viewer_tmp_js_path()), \ s:normalize_path(s:viewer_tmp_js_path()),
\ s:include_path(),
\ ] \ ]
call s:run_in_background(cmd) call s:run_in_background(cmd)
endfunction "}}} endfunction "}}}
function! plantuml_previewer#save_as(...) "{{{ function! plantuml_previewer#save_as(...) "{{{
if !executable('java') if !executable(s:java_path())
echoerr 'require java command' echoerr 'require java command'
return return
endif endif
@ -198,13 +238,14 @@ function! plantuml_previewer#save_as(...) "{{{
call mkdir(fnamemodify(save_path, ':p:h'), 'p') call mkdir(fnamemodify(save_path, ':p:h'), 'p')
let cmd = [ let cmd = [
\ s:save_as_script_path, \ s:save_as_script_path,
\ s:java, \ s:java_path(),
\ s:jar_path(), \ s:jar_path(),
\ puml_src_path, \ puml_src_path,
\ s:normalize_path(output_dir_path), \ s:normalize_path(output_dir_path),
\ s:normalize_path(output_path), \ s:normalize_path(output_path),
\ s:normalize_path(save_path), \ s:normalize_path(save_path),
\ image_type, \ image_type,
\ s:include_path(),
\ ] \ ]
call s:run_in_background(cmd) call s:run_in_background(cmd)
endfunction "}}} endfunction "}}}

View File

@ -87,6 +87,11 @@ COMMANDS *plantuml-previewer-interface-commands*
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
VARIABLES *plantuml-previewer-interface-variables* VARIABLES *plantuml-previewer-interface-variables*
*g:plantuml_previewer#java_path
g:plantuml_previewer#java_path
The location of the Java executable.
Default: "java"
*g:plantuml_previewer#plantuml_jar_path* *g:plantuml_previewer#plantuml_jar_path*
g:plantuml_previewer#plantuml_jar_path g:plantuml_previewer#plantuml_jar_path
plantuml.jar path plantuml.jar path
@ -102,6 +107,18 @@ g:plantuml_previewer#viewer_path
Custom plantuml viewer path Custom plantuml viewer path
The plugin will copy viewer to here if the directory does not exist The plugin will copy viewer to here if the directory does not exist
And `tmp.puml` and `tmp.svg` will output to here And `tmp.puml` and `tmp.svg` will output to here
Default: "~/.plantuml-previewer"
*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
============================================================================== ==============================================================================
vim:tw=78:ts=8:ft=help:norl: vim:tw=78:ts=8:ft=help:norl:

Binary file not shown.

View File

@ -1,11 +1,20 @@
set java_path=%1 set java=%1
set jar_path=%2 shift
set jar_path=%1
shift
set puml_src_path=%3 set puml_src_path=%1
set output_dir_path=%4 shift
set output_path=%5 set output_dir_path=%1
set save_path=%6 shift
set image_type=%7 set output_path=%1
shift
set save_path=%1
shift
set image_type=%1
shift
set include_path=%1
shift
"%java_path%" -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%" copy "%output_path%" "%save_path%"

View File

@ -1,12 +1,13 @@
#!/usr/bin/env bash #!/usr/bin/env bash
java_path=$1 java=${1}
jar_path=$2 jar_path=${2}
puml_src_path=$3 puml_src_path=${3}
output_dir_path=$4 output_dir_path=${4}
output_path=$5 output_path=${5}
save_path=$6 save_path=${6}
image_type=$7 image_type=${7}
include_path=${8}
"$java_path" -Dapple.awt.UIElement=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" cp "$output_path" "$save_path"

View File

@ -1,15 +1,26 @@
set java_path=%1 set java=%1
set jar_path=%2 shift
set jar_path=%1
shift
set puml_src_path=%3 set puml_src_path=%1
set output_dir_path=%4 shift
set output_path=%5 set output_dir_path=%1
set finial_path=%6 shift
set image_type=%7 set output_path=%1
shift
set finial_path=%1
shift
set image_type=%1
shift
set timestamp=%8 set timestamp=%1
set update_js_path=%9 shift
set update_js_path=%1
shift
set include_path=%1
shift
"%java_path%" -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 F | xcopy /S /Q /F /Y "%output_path%" "%finial_path%"
echo window.updateDiagramURL('%timestamp%') > "%update_js_path%" echo window.updateDiagramURL('%timestamp%') > "%update_js_path%"

View File

@ -1,17 +1,18 @@
#!/usr/bin/env bash #!/usr/bin/env bash
java_path=$1 java=${1}
jar_path=$2 jar_path=${2}
puml_src_path=$3 puml_src_path=${3}
output_dir_path=$4 output_dir_path=${4}
output_path=$5 output_path=${5}
finial_path=$6 finial_path=${6}
image_type=$7 image_type=${7}
timestamp=$8 timestamp=${8}
update_js_path=$9 update_js_path=${9}
include_path=${10}
"$java_path" -Dapple.awt.UIElement=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" cp "$output_path" "$finial_path"
echo "window.updateDiagramURL('$timestamp')" > "$update_js_path" echo "window.updateDiagramURL('$timestamp')" > "$update_js_path"

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,7 @@
"devDependencies": { "devDependencies": {
"file-loader": "^1.1.11", "file-loader": "^1.1.11",
"node-sass": "^4.13.1", "node-sass": "^4.13.1",
"poi": "^10.1.9", "poi": "^12.10.3",
"sass-loader": "^7.0.1" "sass-loader": "^7.0.1"
}, },
"scripts": { "scripts": {