s-ludwig / sdlang-org

https://sdlang.org website contents
15 stars 5 forks source link

Vim syntax files #10

Open araspik opened 6 years ago

araspik commented 6 years ago

SDLang is awesome, but I found no support for it in (Neo)Vi(m). As such, I took 2 hours to write it. Use it as you want, consider it public domain. Please publish this on the site as a useful add-on. Note that it is buggy and you want someone who's better at Vim syntax-ing to take a look at it, but it is a solid start. sdlang.zip

whitebyte commented 5 years ago

@araspik mind creating a separate GH repo?

s-ludwig commented 5 years ago

@araspik I'll add a link to the attachment for now, would indeed be great, though to have a repository link instead, where possible fixes would show up.

BTW, I've seen that you have a written D and Rust parsers - do you consider them stable enough to also be added to the list of implementations?

araspik commented 5 years ago

@s-ludwig Unfortunately (as you probably have seen) I haven't worked on either of the parsers in quite a while. I will, however, look back at the Rust parser (and if I can complete/improve the Rust parser, then maybe the D parser too). However, from what I remember, neither of the parsers are complete. I will look back at it.

al1-ce commented 1 year ago

Better SDLang vim syntax file, fixed bugs with boolean recognised as tags and strings being greedy ("this" is "still string" - all was recognised as string):

" quit when a syntax file was already loaded
if exists("b:current_syntax")
  finish
endif

syn case match

" boolean
syn keyword sdlangBool true false on off null
high def link sdlangBool Boolean

" tags
syn match sdlangTag /"\@![a-z][a-zA-Z._]\+"\@!/
high def link sdlangTag Identifier

" numbers
syn match sdlangNum /[+-]\?\d\+\(L\|BD\)\?/
high def link sdlangNum Number
syn match sdlangFloat /[+-]\?\d\+\.\d\+f\?/
high def link sdlangFloat Float

" date/time and duration
syn match sdlangDate /\d\{4}\/\d\{2}\/\d\{2}/ nextgroup=sdlangTime skipwhite
syn match sdlangTime /\d\{2}\:\d\{2}\:\d\{2}\.\d\{3}\(-UTC\)\?/
syn match sdlangDuration /\(\d\+d:\)\?\d\{2}\:\d\{2}\:\d\{2}\(\.\d\{3}\)\?/
high def link sdlangDate Constant
high def link sdlangTime Constant
high def link sdlangDuration Constant

" base64 data
syn match sdlangBase64 /\[[a-zA-Z0-9+/]*\]/
high def link sdlangBase64 Constant

" strings
syn region sdlangString start=+"+ end=+"[cwd]\=+ skip=+\\\\\|\\"+
syn region sdlangRawString start=+`+ end=+`[cwd]\=+
high def link sdlangString String
high def link sdlangRawString String

" generic value type - contains all of the above
syn cluster sdlangValue contains=sdlangNum,sdlangFloat,sdlangString,sdlangBool,sdlangDate,sdlangTime,sdlangDuration,sdlangBase64

" comments
syn match sdlangComment /\/\/.*$/
syn match sdlangComment /--.*$/
syn match sdlangComment /#.*$/
syn match sdlangComment /\/\*\_.\{-}\*\//
high def link sdlangComment Comment

" attributes
syn match sdlangAttribute /"\@![a-z][a-zA-Z._]\+"\@!=/ nextgroup=sdlangValue

let b:current_syntax = "sdlang"