Added optional HL of language elements (ex vars) based on recommended naming convention.

This commit is contained in:
Gustaf Johansson 2012-09-22 18:25:22 +02:00
parent 5361ac5211
commit d3071b81c3
5 changed files with 80 additions and 39 deletions

4
README
View File

@ -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

View File

@ -49,7 +49,6 @@ float
float2int
for
from
from
function
getcall
getreply

View File

@ -1,20 +1,28 @@
" Vim filetype plugin file
" Language: TTCN-3
" Maintainer: Stefan Karlsson <stefan.74@comhem.se>
" Last Change: 15 April 2004
" Maintainer: Gustaf Johansson <gustaf dot j at gmail dot com>
" 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("<sfile>: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

View File

@ -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:*/,://

View File

@ -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 "\<as\?_\w\+\>"
syn match ttcnConst "\<c\U\?_\w\+\>"
syn match ttcnEnum "\<e\U\?_\w\+\>"
syn match ttcnFunc "\<f\U\?_\w\+\>"
syn match ttcnParam "\<p\U\?_\w\+\>"
syn match ttcnTempl "\<m\U\?_\w\+\>"
syn match ttcnVar "\<v\U\?_\w\+\>"
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
@ -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
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
@ -208,6 +225,19 @@ if version >= 508 || !exists("g:did_ttcn_syn_inits")
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