From 7a29850ae926e8fabf18058061187582e04dedde Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Mon, 2 May 2016 10:50:59 +0200 Subject: Add plantuml syntax, closes #116 --- README.md | 1 + build | 1 + ftdetect/polyglot.vim | 8 +++ ftplugin/plantuml.vim | 22 +++++++ syntax/plantuml.vim | 173 ++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 205 insertions(+) create mode 100644 ftplugin/plantuml.vim create mode 100644 syntax/plantuml.vim diff --git a/README.md b/README.md index a56e728c..373187a4 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,7 @@ Optionally download one of the [releases](https://github.com/sheerun/vim-polyglo - [opencl](https://github.com/petRUShka/vim-opencl) (syntax, indent, ftplugin, ftdetect) - [perl](https://github.com/vim-perl/vim-perl) (syntax, indent, ftplugin, ftdetect) - [php](https://github.com/StanAngeloff/php.vim) (syntax) +- [plantuml](https://github.com/aklt/plantuml-syntax) (syntax, ftplugin, ftdetect) - [powershell](https://github.com/Persistent13/vim-ps1) (syntax, indent, ftplugin, ftdetect) - [protobuf](https://github.com/uarun/vim-protobuf) (syntax, ftdetect) - [puppet](https://github.com/voxpupuli/vim-puppet) (syntax, indent, ftplugin, ftdetect) diff --git a/build b/build index 4a7a813c..1fb572ed 100755 --- a/build +++ b/build @@ -148,6 +148,7 @@ PACKS=" opencl:petRUShka/vim-opencl perl:vim-perl/vim-perl php:StanAngeloff/php.vim + plantuml:aklt/plantuml-syntax powershell:Persistent13/vim-ps1 protobuf:uarun/vim-protobuf puppet:voxpupuli/vim-puppet diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index edb46195..8b93964a 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -347,6 +347,14 @@ endfunction autocmd BufReadPost *.pl,*.pm,*.t call s:DetectPerl6() autocmd BufNew,BufNewFile,BufRead *.nqp setf perl6 endif +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'plantuml') == -1 + +if did_filetype() + finish +endif +autocmd BufRead,BufNewFile * :if getline(1) =~ '^.*startuml.*$'| setfiletype plantuml | endif +autocmd BufRead,BufNewFile *.pu,*.uml,*.plantuml set filetype=plantuml +endif if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'protobuf') == -1 autocmd BufNewFile,BufRead *.proto setfiletype proto diff --git a/ftplugin/plantuml.vim b/ftplugin/plantuml.vim new file mode 100644 index 00000000..c4deb886 --- /dev/null +++ b/ftplugin/plantuml.vim @@ -0,0 +1,22 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'plantuml') == -1 + +" Vim plugin file +" Language: PlantUML +" Maintainer: Aaron C. Meadows < language name at shadowguarddev dot com> +" Last Change: 19-Jun-2012 +" Version: 0.1 + +if exists("g:loaded_plantuml_plugin") + finish +endif +let g:loaded_plantuml_plugin = 1 + +if !exists("g:plantuml_executable_script") + let g:plantuml_executable_script="plantuml" +endif + +autocmd Filetype plantuml let &l:makeprg=g:plantuml_executable_script . " " . fnameescape(expand("%")) + +setlocal comments=s1:/',mb:',ex:'/,:' commentstring=/'%s'/ formatoptions-=t formatoptions+=croql + +endif diff --git a/syntax/plantuml.vim b/syntax/plantuml.vim new file mode 100644 index 00000000..9ecd90eb --- /dev/null +++ b/syntax/plantuml.vim @@ -0,0 +1,173 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'plantuml') == -1 + +" Vim syntax file +" Language: PlantUML +" Maintainer: Anders Thøgersen +" Last Change: 03-Apr-2011 +" Version: 0.2 +" TODO: There are some bugs, add << >> +" +if exists("b:current_syntax") + finish +endif + +if version < 600 + syntax clear +endif + +let s:cpo_orig=&cpo +set cpo&vim + +let b:current_syntax = "plantuml" + +syntax sync minlines=100 + +syntax match plantumlPreProc /\%(^@startuml\|^@enduml\)\|!\%(include\|ifdef\|define\|endif\)\s*.*/ contains=plantumlDir +syntax region plantumlDir start=/\s\+/ms=s+1 end=/$/ contained + +syntax keyword plantumlTypeKeyword namespace component package interface class interface enum object participant activity skinparam abstract +syntax keyword plantumlKeyword actor boundary control entity database partition title activate as deactivate note left right top bottom of end destroy +syntax keyword plantumlKeyword if then else endif + +syntax keyword plantumlCommentTODO XXX TODO FIXME NOTE contained +syntax match plantumlColor /#[0-9A-Fa-f]\{6\}\>/ + +" Arrows - Differentiate between horizontal and vertical arrows +syntax match plantumlHorizontalArrow /\%([-\.]\%(|>\|>\|\*\|o\>\|\\\\\|\\\|\/\/\|\/\|\.\|-\)\|\%(<|\|<\|\*\|\\|>>\|>\|\*\|o\>\|\\\\\|\\\|\/\/\|\/\|\.\|-\)\%(\[[^\]]*\]\)\?/ contains=plantumlLabel +syntax match plantumlDirectedOrVerticalArrowRL /\%(<|\|<<\|<\|\*\|\