komsit37 / sublime-q

Sublime Text Plugin for q/kdb
MIT License
24 stars 9 forks source link

Comment not highlighted unless double slashing (`//`) #4

Closed danielkrizian closed 8 years ago

danielkrizian commented 8 years ago

This is somewhat related to https://github.com/kimtang/sublime-q/issues/1 issue. Comment is not highlighted when single slash / used. Double slashing (//) works.

image

komsit37 commented 8 years ago

Hi Daniel,

Thanks for reporting. Yes, I'm aware of the issue, but sorry, I can't fix it for now.

/ is used in many places in q, not only for comment. So I don't have a good solution for this. If anyone would like to try fixing it, it's in this file https://github.com/komsit37/sublime-q/blob/master/syntax/q.tmLanguage

Komsit

danielkrizian commented 8 years ago

Hi Komsit, this regex should hopefully work: \s/.*|^/.* Other places should be safe, as use of / in adverbs and others requires preceding non-whitespace character (see tests below) Not sure how to test it in Sublime, never worked with Sublime add-on system, perhaps replacing this line? https://github.com/komsit37/sublime-q/blob/master/syntax/q.tmLanguage#L29

Tests: https://regex101.com/r/zI8zU5/2

image

Test q code:

/ this is comment
var: 1 / inline comment
// double slash comment

/ adverbs using (/) are safe:
addi:{0N!(x;y) x+y}
0 addi/ 1 2 3

0 +/ 1 2 3 / over (/) is safe
"</" ,/: ("abc"; "de"; enlist "f")  / each-right (/:) is safe 
1 2 3,/:\:10 20 / cross product is safe

/ converge (fun/) is safe
newtcycle:{[xn] xn-((xn*xn*xn+(-2*xn)+2)%-2+3*xn*xn}
newtcycle/[0.0]

`:/data/t set ([] c1:`a`b`c) / splayed tables are safe
komsit37 commented 8 years ago

Nice, I'll try it and let you know

komsit37 commented 8 years ago

Thanks, your solution works perfectly. I've pushed the change and published the new binaries v 0.2.6 release.

You should be able to update a new plugin version in package control in a few hours.