]> git.r.bdr.sh - rbdr/api-notation.vim/commitdiff
Adds the syntax def
authorBen Beltran <redacted>
Tue, 23 Jun 2015 14:59:54 +0000 (09:59 -0500)
committerBen Beltran <redacted>
Tue, 23 Jun 2015 14:59:54 +0000 (09:59 -0500)
example-syntax.api [new file with mode: 0644]
ftdetect/api-notation.vim [new file with mode: 0644]
syntax/api-notation.vim [new file with mode: 0644]

diff --git a/example-syntax.api b/example-syntax.api
new file mode 100644 (file)
index 0000000..670be57
--- /dev/null
@@ -0,0 +1,17 @@
+HypotheticalModule
+  +staticProperty <String>
+  +anotherStaticProperty <Boolean>
+  ::toggleAnotherStaticProperty()
+  ::setStaticProperty(newValue <String>)
+  -instanceProperty <Number>
+  -anotherInstanceProperty <String>
+  #instanceMethodSync([optionalParameter]<Boolean>) => resultOfCall <String>
+  #instanceMethodAsync(someValue <Number>, [callback] <Function>) ->(error <String|null>, result <Number|null>)
+
+EventHypotheticalClass
+  +>AnotherClass<+staticEventToListen(eventData <PredefinedObject>)
+  <+staticEventDispatched(someData <SomeData>)
+  ~>listenedSocketEvent(eventData <SomeObject>)
+  <~dispatchedSocketEvent(eventData <BlaBla>)
+  ->AnotherClass<-instanceEventToListen(eventData <Object>)
+  <-instanceEventDispatched(specificDataType <DefinedObject>)
diff --git a/ftdetect/api-notation.vim b/ftdetect/api-notation.vim
new file mode 100644 (file)
index 0000000..f1d3ffb
--- /dev/null
@@ -0,0 +1 @@
+autocmd BufNewFile,BufRead *.api setlocal filetype=api-notation shiftwidth=2 expandtab
diff --git a/syntax/api-notation.vim b/syntax/api-notation.vim
new file mode 100644 (file)
index 0000000..405fcd5
--- /dev/null
@@ -0,0 +1,44 @@
+" Vim syntax file
+" Language: API Notation
+" Maintainer: Rubén Beltrán del Río
+" Latest Revision: 22 June 2015
+
+if exists("b:current_syntax")
+  finish
+endif
+
+syn match moduleName '^\w\+'
+
+syn match classMembers '^\s\+\(\(<+\)\|\(<\~\)\|\(<-\)\|\(+>\)\|\(\~>\)\|\(->\)\|-\|+\|\(::\)\|#\)' nextgroup=memberName skipwhite
+syn match internalOperators '\(\(<+\)\|\(<\~\)\|\(<-\)\|\(+>\)\|\(\~>\)\|\(->\)\|-\|+\|\(::\)\|#\)' contained nextgroup=memberName skipwhite
+syn match returnIdentifiers '\(=>\)' nextgroup=returnValue
+syn match returnIdentifiers '\(->\)'
+
+syn match memberName '\w\+' contained nextgroup=internalOperators,spacedDataType
+
+syn region parameterList start="(" end=")" transparent contains=parameters,separators,optionalParameter,dataType
+syn region optionalParameter start="\[" end="]" contains=optionalParameters contained
+syn region dataType start="<" end=">" contains=dataTypes,separators contained
+syn region spacedDataType start='\s\+<' end=">" contains=dataTypes,separators contained
+
+syn match optionalParameters '\w\+' contained
+syn match parameters '\w\+' contained
+syn match dataTypes '\w\+' contained
+syn match separators '|\|,' contained
+
+syn match returnValue '.*' contained contains=dataType,parameters
+
+
+hi def link moduleName Identifier
+
+hi def link classMembers Operator
+hi def link returnIdentifiers Operator
+hi def link internalOperators Operator
+
+hi def link memberName Special
+
+hi def link parameters PreProc
+hi def link optionalParameters Underlined
+hi def link dataTypes Constant
+
+hi def link separators Comment