Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight new import declaration, and dialect declaration #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions ftplugin/grace.vim
Expand Up @@ -7,6 +7,7 @@ setlocal expandtab
setlocal smartindent setlocal smartindent
setlocal foldmethod=syntax setlocal foldmethod=syntax
setlocal commentstring=//%s setlocal commentstring=//%s
setlocal iskeyword+='


let g:tagbar_type_grace = { let g:tagbar_type_grace = {
\ 'ctagstype' : 'grace', \ 'ctagstype' : 'grace',
Expand Down
27 changes: 19 additions & 8 deletions syntax/grace.vim
Expand Up @@ -11,31 +11,37 @@ syn case match
syn sync minlines=5000 syn sync minlines=5000


" foldable blocks " foldable blocks
syn region graceMethodDef start="\s*\<method\>" end="{"he=e-1 contains=graceStatementMethod,graceType,graceKeyword syn region graceMethodDef start="\s*\<method\>" end="{" contains=graceStatementMethod,graceType,graceKeyword
syn keyword graceStatementMethod method contained syn keyword graceStatementMethod method contained
syn region graceMethodFold start="^\z(\s*\)\<method\>.*[^}]$" end="^\z1}\s*\(//.*\)\=$" transparent fold keepend extend syn region graceMethodFold start="^\z(\s*\)\<method\>.*[^}]$" end="^\z1}\s*\(//.*\)\=$" transparent fold keepend extend
syn region graceTypeDef start="\s*\<type\>" end="{"he=e-1 contains=graceStatementType,graceKeyword syn region graceTypeDef start="\s*\<type\>" end="[{\n]"he=e-1 contains=graceStatementType,graceKeyword
syn keyword graceStatementType type contained syn keyword graceStatementType type contained
syn region graceTypeFold start="^\z(\s*\)\<type\>.*[^}]$" end="^\z1}\s*\(//.*\)\=$" transparent fold keepend extend syn region graceTypeFold start="^\z(\s*\)\<type\>.*=\s*{[^}]*$" end="^\z1}\s*\(//.*\)\=$" transparent fold keepend extend
syn region graceClassDef start="\s*\<class\>" end="{"he=e-1 contains=graceClass,graceClassName,graceClassSpecializer,graceClassParams,graceType syn region graceClassDef start="\s*\<class\>" end="{"he=e-1 contains=graceClass,graceClassName,graceClassSpecializer,graceClassParams,graceType
syn keyword graceClass class contained nextgroup=graceClassName syn keyword graceClass class contained nextgroup=graceClassName
syn match graceClassName "[^ =:;{}()\[]\+" contained nextgroup=graceClassSpecializer skipwhite syn match graceClassName "[^ =:;{}()\[]\+" contained nextgroup=graceClassSpecializer skipwhite
syn region graceClassSpecializer start="\[" end="\]" contained contains=graceClassSpecializer nextgroup=GraceClassParams syn region graceClassSpecializer start="\[" end="\]" contained contains=graceClassSpecializer nextgroup=GraceClassParams
syn region graceClassParams start="(" end=")" contained contains=graceType syn region graceClassParams start="(" end=")" contained contains=graceType
syn region graceClassFold start="^\z(\s*\)\<class\>.*[^}]$" end="^\z1}\s*\(//.*\)\=$" transparent fold keepend extend syn region graceClassFold start="^\z(\s*\)\<class\>.*[^}]$" end="^\z1}\s*\(//.*\)\=$" transparent fold keepend extend


syn region graceConstructorDef start="\s*\<constructor\>" end="{"he=e-1 contains=graceConstructor,graceConstructorName,graceConstructorSpecializer,graceConstructorParams,graceType
syn keyword graceConstructor constructor contained nextgroup=graceConstructorName
syn match graceConstructorName "[^ =:;{}()\[]\+" contained nextgroup=graceConstructorSpecializer skipwhite
syn region graceConstructorSpecializer start="<" end=">" contained contains=graceConstructorSpecializer nextgroup=GraceConstructorParams
syn region graceConstructorParams start="(" end=")" contained contains=graceType
syn region graceConstructorFold start="^\z(\s*\)\<constructor\>.*[^}]$" end="^\z1}\s*\(//.*\)\=$" transparent fold keepend extend

" most Grace keywords " most Grace keywords
syn keyword graceKeyword object return var def is syn keyword graceKeyword object return var def is inherits
syn match graceKeyword "->" syn match graceKeyword "->"
syn match graceKeyword ":=" syn match graceKeyword ":="


syn match graceOperator ":\{2,\}" "this is not a type syn match graceOperator ":\{2,\}" "this is not a type




" package and import statements " import and dialect statements
syn keyword gracePackage package nextgroup=graceFqn skipwhite syn keyword graceDialect dialect nextgroup=graceString skipwhite
syn keyword graceImport import nextgroup=graceFqn skipwhite syn region graceImport start="^import" end="as" contains=graceString
syn match graceFqn "\<[._$a-zA-Z0-9,]*" contained


" boolean literals " boolean literals
syn keyword graceBoolean true false syn keyword graceBoolean true false
Expand Down Expand Up @@ -100,6 +106,8 @@ hi def link graceError Error
hi def link graceWSError Error hi def link graceWSError Error
hi def link graceBuiltinMethod Identifier hi def link graceBuiltinMethod Identifier
hi def link graceKeyword Keyword hi def link graceKeyword Keyword
hi def link graceImport Keyword
hi def link graceDialect Keyword
hi def link graceStatementMethod graceKeyword hi def link graceStatementMethod graceKeyword
hi def link graceStatementType graceKeyword hi def link graceStatementType graceKeyword
hi def link gracePackage Include hi def link gracePackage Include
Expand Down Expand Up @@ -127,6 +135,9 @@ hi def link graceDefName Function
hi def link graceDefSpecializer Function hi def link graceDefSpecializer Function
hi def link graceClassName Special hi def link graceClassName Special
hi def link graceClassSpecializer Special hi def link graceClassSpecializer Special
hi def link graceConstructor Keyword
hi def link graceConstructorName Special
hi def link graceConstructorSpecializer Special
hi def link graceInterpolationDelimiter Delimiter hi def link graceInterpolationDelimiter Delimiter
hi def link gracePragma PreProc hi def link gracePragma PreProc


Expand Down