diff --git a/README b/README index cc9bdff..ecd10fe 100644 --- a/README +++ b/README @@ -1,8 +1,12 @@ Based on: ttcn-syntax: http://www.vim.org/scripts/script.php?script_id=753 + Folds: If the variable "g:ttcn_fold" is defined (e.g. by ":let g:ttcn_fold = 1" in your .vimrc file), folds will automatically be defined for each {...} block. + Highlight: If the variable "g:ttcn_hl_naming_convention" (e.g. by ":let g:ttcn_hl_naming_convention = 1" in your .vimrc file), Language elements following generic naming conventions will be highlighted. + This is not standardized but noted on http://www.ttcn-3.org/NamingConventions.htm. + ttcn-indent: http://www.vim.org/scripts/script.php?script_id=754 diff --git a/dicts/ttcn.dict b/dicts/ttcn.dict index ad5e572..06cc505 100644 --- a/dicts/ttcn.dict +++ b/dicts/ttcn.dict @@ -49,7 +49,6 @@ float float2int for from -from function getcall getreply diff --git a/ftplugin/ttcn.vim b/ftplugin/ttcn.vim index 183771c..be617d4 100644 --- a/ftplugin/ttcn.vim +++ b/ftplugin/ttcn.vim @@ -1,20 +1,28 @@ " Vim filetype plugin file " Language: TTCN-3 " Maintainer: Stefan Karlsson -" Last Change: 15 April 2004 +" Maintainer: Gustaf Johansson +" Last Change: 15 September 2012 if exists("b:did_ftplugin") finish endif let b:did_ftplugin = 1 +if exists("b:undo_ftplugin") + let b:undo_ftplugin = b:undo_ftplugin . " | setlocal foldmethod< foldlevel< include< suffixesadd< formatoptions<" +else + let b:undo_ftplugin = "setlocal foldmethod< foldlevel< include< suffixesadd< formatoptions<" +endif + if exists("g:ttcn_fold") setlocal foldmethod=syntax setlocal foldlevel=99 endif " Path to the dictionary (this path might need adjustment) -setlocal dict=~\vimfiles\dicts\ttcn.dict +" Set manually with: setlocal dict=~\path\to\ttcn.dict +let &dict=expand(":p:h") . "\..\dicts\ttcn.dict" " Enables gf, [I, [i, etc commands for ttcn files setlocal include=^\\s*import\\s\\+from @@ -25,6 +33,5 @@ setlocal formatoptions-=t " Enable auto breaking of comments and enable formatting of comments with " the gq command -setlocal formatoptions+=croq +setlocal formatoptions+=croq1n2 -setlocal cinoptions=(1s diff --git a/indent/ttcn.vim b/indent/ttcn.vim index 3813d34..9d04b28 100644 --- a/indent/ttcn.vim +++ b/indent/ttcn.vim @@ -19,6 +19,7 @@ setlocal indentexpr=Get_ttcn_indent(v:lnum) setlocal indentkeys=0{,0},0),!^F,o,O,e setlocal cinwords= +setlocal cinoptions=(1s setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:// diff --git a/syntax/ttcn.vim b/syntax/ttcn.vim index 7b32177..8a95577 100644 --- a/syntax/ttcn.vim +++ b/syntax/ttcn.vim @@ -24,11 +24,29 @@ else syn sync fromstart endif -" Automatically define folds. You enable this feature with :let ttcn_fold=1. +" Automatically define folds. You enable this feature with :let g:ttcn_fold=1. if exists("g:ttcn_fold") && g:ttcn_fold == 1 syn region ttcnFold start="{" end="}" transparent fold endif +" Highlight declared language elements following generic naming conventions, +" not standardized but noted on http://www.ttcn-3.org/NamingConventions.htm. +" Enable this feature with :let g:ttcn_hl_naming_convention=1. +if exists("g:ttcn_hl_naming_convention") && g:ttcn_hl_naming_convention == 1 + syn match ttcnAltStp "\" + syn match ttcnConst "\" + syn match ttcnEnum "\" + syn match ttcnFunc "\" + syn match ttcnParam "\" + syn match ttcnTempl "\" + syn match ttcnVar "\" + syn match ttcnTimer "\<[tT]\U\?_\w\+\>" +endif + +" ETSI ES 201 873-10 V3.4.1 +" Part 10: TTCN-3 Documentation Comment Specification +syn match ttcnDocComment "@\<\(author\|config\|desc\|exception\|member\|param\|purpose\|remark\|return\|see\|since\|status\|url\|verdict\|version\)\>" contained + " Built-in types syn keyword ttcnType address anytype boolean char default float integer syn keyword ttcnType objid verdicttype timer set record union @@ -38,7 +56,7 @@ syn match ttcnError "\" syn match ttcnType "\" " Type definitions -syn keyword ttcnTypDef type message procedure mixed +syn keyword ttcnTypDef type message procedure mixed " Storage classes syn keyword ttcnStore var const external @@ -130,7 +148,7 @@ syn keyword ttcnFunc oct2int oct2bit oct2hex oct2str oct2char syn keyword ttcnFunc str2int str2oct str2float enum2int syn keyword ttcnFunc lengthof sizeof ispresent ischosen syn keyword ttcnFunc isvalue regexp substr replace encvalue -syn keyword ttcnFunc decvalue rnd +syn keyword ttcnFunc decvalue rnd isbound log2str " Various keywords syn keyword ttcnKeyw in out inout any all sender to value modifies @@ -150,19 +168,18 @@ syn match ttcnNumber "-infinity\>" syn keyword ttcnBool true false syn keyword ttcnConst omit null pass fail inconc none error syn region ttcnString start=/"/ end=/"/ skip=/\\"/ oneline -syn match ttcnString /'[01]\+'B/ -syn match ttcnString /'\x\+'H/ -syn match ttcnString /'\(\x\x\)\+'O/ -syn match ttcnError /'\x\(\x\x\)\*'O/ -syn match ttcnError /''[BHO]/ +syn match ttcnString /'[01]*'B/ +syn match ttcnString /'\x*'H/ +syn match ttcnString /'\(\x\x\)*'O/ +syn match ttcnError /'\x\(\x\x\)*'O/ -" Comments -if version < 700 - syn match ttcnCmnt "//.*" contains=ttcnTodo - syn region ttcnCmnt start="/\*" end="\*/" contains=ttcnTodo +" Comments +if version < 700 + syn match ttcnCmnt "//.*" contains=ttcnTodo,ttcnDocComment + syn region ttcnCmnt start="/\*" end="\*/" contains=ttcnTodo,ttcnDocComment else - syn match ttcnCmnt "//.*" contains=ttcnTodo,@Spell - syn region ttcnCmnt start="/\*" end="\*/" contains=ttcnTodo,@Spell + syn match ttcnCmnt "//.*" contains=ttcnTodo,ttcnDocComment,@Spell + syn region ttcnCmnt start="/\*" end="\*/" contains=ttcnTodo,ttcnDocComment,@Spell endif syn case ignore @@ -180,34 +197,47 @@ if version >= 508 || !exists("g:did_ttcn_syn_inits") command -nargs=+ HiLink hi def link endif - HiLink ttcnAttrib PreProc - HiLink ttcnBool Boolean - HiLink ttcnConst Constant - HiLink ttcnCmnt Comment - HiLink ttcnCond Conditional + HiLink ttcnAttrib PreProc + HiLink ttcnBool Boolean + HiLink ttcnConst Constant + HiLink ttcnCmnt Comment + HiLink ttcnCond Conditional HiLink ttcnSpecial Special HiLink ttcnScope StorageClass - HiLink ttcnDecl Statement - HiLink ttcnError Error - HiLink ttcnExcept Exception - HiLink ttcnFunc Function - HiLink ttcnKeyw Keyword - HiLink ttcnLabel Label + HiLink ttcnDecl Statement + HiLink ttcnError Error + HiLink ttcnExcept Exception + HiLink ttcnFunc Function + HiLink ttcnKeyw Keyword + HiLink ttcnLabel Label HiLink ttcnModule Include HiLink ttcnPreProc PreProc HiLink ttcnInclude Include HiLink ttcnDefine Define HiLink ttcnPreCond PreCondit - HiLink ttcnNumber Number - HiLink ttcnOper Operator - HiLink ttcnRepeat Repeat - HiLink ttcnStat Statement - HiLink ttcnStore StorageClass - HiLink ttcnString String - HiLink ttcnTodo Todo - HiLink ttcnType Type - HiLink ttcnTypDef TypeDef + HiLink ttcnNumber Number + HiLink ttcnOper Operator + HiLink ttcnRepeat Repeat + HiLink ttcnStat Statement + HiLink ttcnStore StorageClass + HiLink ttcnString String + HiLink ttcnTodo Todo + HiLink ttcnType Type + HiLink ttcnTypDef TypeDef HiLink ttcnMacro Macro + HiLink ttcnDocComment SpecialComment + + if exists("g:ttcn_hl_naming_convention") && g:ttcn_hl_naming_convention == 1 + HiLink ttcnAltStp Function + HiLink ttcnConst Constant + HiLink ttcnEnum Structure + HiLink ttcnFunc Function + HiLink ttcnParam Identifier + HiLink ttcnTempl Function + HiLink ttcnVar Identifier + HiLink ttcnTimer Special + endif + delcommand HiLink endif