If both pine.tmLanguage
and pine.sublime-syntax
exist, pine.sublime-syntax
is always prefered.
Is there a better way to turn off spell check for Japanese characters?
@jfcherng Understood! Than in this case, the spell check ignore part needs to be added to pine.sublime-syntax?
What should I change to make it happen?
This only gives CJK chars in comments and strings a special scope.
@@ -9,9 +9,16 @@
identifier_regex: '[a-zA-Z_][a-zA-Z0-9_]*'
contexts:
+ comments:
+ - match: //
+ push:
+ - meta_scope: comment.pine
+ - include: cjk-char
+ - match: $
+ pop: true
+
main:
- - match: //.*
- scope: comment.pine
+ - include: comments
#constants
@@ -117,6 +124,7 @@
single-quoted-string:
- meta_scope: string.quoted.single.pine
+ - include: cjk-char
- match: \\.
scope: constant.character.escape.pine
- match: ''''
@@ -124,7 +132,13 @@
double-quoted-string:
- meta_scope: string.quoted.double.pine
+ - include: cjk-char
- match: \\.
scope: constant.character.escape.pine
- match: '"'
pop: true
+
+ cjk-char:
+ - match: '[\x{3040}-\x{312f}\x{31f0}-\x{31ff}\x{4e00}-\x{9fff}\x{6300}-\x{77ff}\x{7800}-\x{8cff}\x{8d00}-\x{9fcc}\x{3400}-\x{4db5}\x{ff66}-\x{ff9f}\x{20000}-\x{215ff}\x{21600}-\x{230ff}\x{23100}-\x{245ff}\x{24600}-\x{260ff}\x{26100}-\x{275ff}\x{27600}-\x{290ff}\x{29100}-\x{2a6df}\x{2a700}-\x{2b734}\x{2b740}-\x{2b81d}]+'
+ scope: meta.text.cjk
And then you add - meta.text.cjk
into spelling_selector
in the global ST settings (preferences).
@jfcherng Thank you so much!
I have added the changes, does it look alright?
%YAML 1.2
---
name: pine
file_extensions:
- pine
scope: source.pine
variables:
identifier_regex: '[a-zA-Z_][a-zA-Z0-9_]*'
contexts:
comments:
- match: //
push:
- meta_scope: comment.pine
- include: cjk-char
- match: $
pop: true
main:
- include: comments
#constants
- match: \b(true|false)\b
scope: constant.language.pine
- match: \b(bool|float|integer|string)\b
scope: constant.language.pine
- match: \b(time|timenow|year|month|weekofyear|dayofmonth|dayofweek|hour|minute|second|interval|isdaily|isdwm|isintraday|ismonthly|isweekly)\b
scope: constant.language.pine
- match: \b(open|high|low|close|volume|na|period|tikerid|source|symbol)\b
scope: constant.language.pine
- match: \b(accdist|area|areabr|hl(2|c3)|ohlc4)\b
scope: constant.language.pine
- match: \badjustment\.(dividends|none|splits)\b
scope: constant.language.pine
- match: \b(monday|tuesday|wednesday|thursday|friday|saturday|sunday|dayofweek)\b
scope: constant.language.pine
- match: \b(line|stepline|histogram|cross[^\(]|area|columns|circles)\b
scope: constant.language.pine
- match: \b(solid|dotted|dashed)\b
scope: constant.language.pine
- match: \b(session|session.(extended|regular))\b
scope: constant.language.pine
- match: \bscale.(left|none|right)\b
scope: constant.language.pine
- match: \bbarmerge\.(gaps_(off|on)|lookahead_(off|on))\b
scope: constant.language.pine
- match: \bbarstate\.is(confirmed|first|history|last|new|realtime)\b
scope: constant.language.pine
- match: \bcurrency\.(AUD|CAD|CHF|EUR|GBP|HKD|JPY|NOK|NONE|NZD|RUB|SEK|SGD|TRY|USD|ZAR)\b
scope: constant.language.pine
- match: \blocation\.(abovebar|belowbar|top|bottom|absolute)\b
scope: constant.language.pine
- match: \bshape\.(x(cross)?|(triangle|arrow|label)(up|down)|flag|circle|square|diamond)\b
scope: constant.language.pine
- match: \bsize\.(auto|huge|large|normal|small|tiny)\b
scope: constant.language.pine
- match: \bstrategy\.(cash|closedtrades|commission\.(cash_per_contract|cash_per_order|percent)|direction\.(all|long|short)|equity|eventrades|fixed|grossloss|grossprofit|initial_capital|long|losstrades|max_contracts_held_all|max_contracts_held_long|max_contracts_held_short|max_drawdown|netprofit|oca\.(cancel|none|reduce)|openprofit|opentrades|percent_of_equity|position_avg_price|position_entry_name|position_size|short|wintrades)\b
scope: constant.language.pine
- match: \bsyminfo\.(mintick|pointvalue|prefix|root|session|timezone)\b
scope: constant.language.pine
- match: \b(aqua|black|silver|gray|white|maroon|red|purple|fuchsia|green|lime|olive|yellow|navy|blue|teal|orange)\b
scope: constant.language.pine
- match: '#[a-fA-F0-9]{6}'
scope: support.constant.pine
- match: '\b([0-9]+)\b'
scope: constant.numeric.pine
# strings
- match: ''''
push: single-quoted-string
- match: '"'
push: double-quoted-string
# operators
- match: (\-|\+|\*|/|%)
scope: keyword.operator.arithmetic.pine
- match: (==|!=|<=|>=|<|>|\:=)
scope: keyword.operator.comparison.pine
- match: (\?|\:)
scope: keyword.operator.ternary.pine
- match: \b(and|or|not)\b
scope: keyword.operator.logical.pine
- match: "="
scope: keyword.operator.assignment.pine
# functions
- match: '\b(alertcondition|a(bs|cos|lma|sin|tan|tr|vg)|bar(color|since)|bgcolor|cci|ceil|change|cog|color|correlation|cos|cross(over|under)?|cum|dayof(month|week)|dev|(e|s)ma|exp|falling|fill|fixnan|floor|heikinashi|highest(bars)?|hline|iff|input|kagi|linebreak|linreg|log(10)?|lowest(bars)?|macd|m(ax|in)|minute|mom|month|n(a|z)|offset|percentile_linear_(interpolation|nearest_rank)|percentrank|pivot(high|low)|plot(arrow|bar|candle|char|shape|figure)?|pow|renko|rising|r(ma|oc|si)|round|sar|second|security|sign|sin|sqrt|stdev|stoch|strategy|strategy\.(cancel|cancel_all|close|close_all|entry|exit|order)|study|sum|swma|tan|tickerid|time(stamp)?|tostring|tr|tsi|valuewhen|variance|v(wap|wma)|weekofyear|wma|year|{{identifier_regex}})(?=\()'
captures:
1: support.function.pine
- match: '{{identifier_regex}}\s*(?=:?\=)'
scope: variable.parameter.pine
- match: ('({{identifier_regex}})\(.*\)\s(=>)\s'|if|else)
captures:
1: entity.name.function
2: keyword.operator.assignment.pine
single-quoted-string:
- meta_scope: string.quoted.single.pine
- include: cjk-char
- match: \\.
scope: constant.character.escape.pine
- match: ''''
pop: true
double-quoted-string:
- meta_scope: string.quoted.double.pine
- include: cjk-char
- match: \\.
scope: constant.character.escape.pine
- match: '"'
pop: true
cjk-char:
- match: '[\x{3040}-\x{312f}\x{31f0}-\x{31ff}\x{4e00}-\x{9fff}\x{6300}-\x{77ff}\x{7800}-\x{8cff}\x{8d00}-\x{9fcc}\x{3400}-\x{4db5}\x{ff66}-\x{ff9f}\x{20000}-\x{215ff}\x{21600}-\x{230ff}\x{23100}-\x{245ff}\x{24600}-\x{260ff}\x{26100}-\x{275ff}\x{27600}-\x{290ff}\x{29100}-\x{2a6df}\x{2a700}-\x{2b734}\x{2b740}-\x{2b81d}]+'
scope: meta.text.cjk
I actually have another file in use (sorry I should put this out at first place coz I thought its not relevant). I use this file so that I can quick comment out a sentence in code with “command + /” on macOS:
File: pine_comments.tmPreferences
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>name</key>
<string>Comments</string>
<key>scope</key>
<string>source.pine</string>
<key>settings</key>
<dict>
<key>shellVariables</key>
<array>
<dict>
<key>name</key>
<string>TM_COMMENT_START</string>
<key>value</key>
<string>// </string>
</dict>
</array>
</dict>
</dict>
</plist>
Will this additional file make (or screw up) the changes made above? (sorry once again ><)
Looks good to me. You then need to , for example, use the following setting in your ST settings
"spelling_selector": "markup.raw, source string.quoted - punctuation - meta.preprocessor.include, source comment - source comment.block.preprocessor, -(source, constant, keyword, storage, support, variable, markup.underline.link, meta.tag, meta.text.cjk)",
to make ST exclude meta.text.cjk
from spelling check.
@jfcherng Awesome!
So just to clarify, I can still keep the pine_comments.tmPreferences file (with nothing changed), and with the modified pine.sublime-syntax and updated preference, it should work?
Hmm… still doesn’t work after those changes…
If I have additional comment sections like below, how can I add the cjk-chart ignore?
Because they don’t have “single-quoted-string:” this kind of title on top, so I am not sure how to accurately add them in the structure…
# ==========================================================
# [Comment]
# Comment Line: --
- match: '(^[ \t]+)?(--)'
captures:
1: punctuation.whitespace.comment.leading.pine
2: punctuation.definition.comment.pine
push:
- meta_scope: comment.line.double-dash.pine.one
- match: \n
pop: true
# Comment Line: //
- match: '(^[ \t]+)?(//)'
captures:
1: punctuation.whitespace.comment.leading.pine
2: punctuation.definition.comment.pine
push:
- meta_scope: comment.line.double-slash.pine.two
- match: \n
pop: true
# Comment Block: (*, *)
- match: \(\*
captures:
0: punctuation.definition.comment.pine
push:
- meta_scope: comment.block.pine.one
- match: \*\)
captures:
0: punctuation.definition.comment.pine
pop: true
# Comment Block: {, }
- match: '\{'
captures:
0: punctuation.definition.comment.pine
push:
- meta_scope: comment.block.pine.two
- match: '\}'
captures:
0: punctuation.definition.comment.pine
pop: true
I would like to know whether CJK chars in strings are ignored from spelling check first.
Please put the cursor at 作
and press ctrl+shift+alt+p or cmd+shift+alt+p (I am not sure since I don’t use Mac). There should be a popup which indicate the scope at the cursor position. I would like to check whether it contains meta.text.cjk
.
@jfcherng Finally, It is ⌘-⌥-P on mac
File: pine.sublime-syntax
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: vine
file_extensions:
- vine
first_line_match: // Language:vine
scope: source.vine
contexts:
comments:
- match: //
push:
- meta_scope: comment.vine
- include: cjk-char
- match: $
pop: true
cjk-char:
- match: '[\x{3040}-\x{312f}\x{31f0}-\x{31ff}\x{4e00}-\x{9fff}\x{6300}-\x{77ff}\x{7800}-\x{8cff}\x{8d00}-\x{9fcc}\x{3400}-\x{4db5}\x{ff66}-\x{ff9f}\x{20000}-\x{215ff}\x{21600}-\x{230ff}\x{23100}-\x{245ff}\x{24600}-\x{260ff}\x{26100}-\x{275ff}\x{27600}-\x{290ff}\x{29100}-\x{2a6df}\x{2a700}-\x{2b734}\x{2b740}-\x{2b81d}]+'
scope: meta.text.cjk
main:
- include: comments
#constants
- match: \b(true|false)\b
scope: constant.language.pine
- match: \b(bool|float|integer|string)\b
scope: constant.language.pine
- match: \b(time|timenow|year|month|weekofyear|dayofmonth|dayofweek|hour|minute|second|interval|isdaily|isdwm|isintraday|ismonthly|isweekly)\b
scope: constant.language.pine
- match: \b(open|high|low|close|volume|na|period|tikerid|source|symbol)\b
scope: constant.language.pine
- match: \b(accdist|area|areabr|hl(2|c3)|ohlc4)\b
scope: constant.language.pine
- match: \badjustment\.(dividends|none|splits)\b
scope: constant.language.pine
- match: \b(monday|tuesday|wednesday|thursday|friday|saturday|sunday|dayofweek)\b
scope: constant.language.pine
- match: \b(line|stepline|histogram|cross[^\(]|area|columns|circles)\b
scope: constant.language.pine
- match: \b(solid|dotted|dashed)\b
scope: constant.language.pine
- match: \b(session|session.(extended|regular))\b
scope: constant.language.pine
- match: \bscale.(left|none|right)\b
scope: constant.language.pine
- match: \bbarmerge\.(gaps_(off|on)|lookahead_(off|on))\b
scope: constant.language.pine
- match: \bbarstate\.is(confirmed|first|history|last|new|realtime)\b
scope: constant.language.pine
- match: \bcurrency\.(AUD|CAD|CHF|EUR|GBP|HKD|JPY|NOK|NONE|NZD|RUB|SEK|SGD|TRY|USD|ZAR)\b
scope: constant.language.pine
- match: \blocation\.(abovebar|belowbar|top|bottom|absolute)\b
scope: constant.language.pine
- match: \bshape\.(x(cross)?|(triangle|arrow|label)(up|down)|flag|circle|square|diamond)\b
scope: constant.language.pine
- match: \bsize\.(auto|huge|large|normal|small|tiny)\b
scope: constant.language.pine
- match: \bstrategy\.(cash|closedtrades|commission\.(cash_per_contract|cash_per_order|percent)|direction\.(all|long|short)|equity|eventrades|fixed|grossloss|grossprofit|initial_capital|long|losstrades|max_contracts_held_all|max_contracts_held_long|max_contracts_held_short|max_drawdown|netprofit|oca\.(cancel|none|reduce)|openprofit|opentrades|percent_of_equity|position_avg_price|position_entry_name|position_size|short|wintrades)\b
scope: constant.language.pine
- match: \bsyminfo\.(mintick|pointvalue|prefix|root|session|timezone)\b
scope: constant.language.pine
- match: \b(aqua|black|silver|gray|white|maroon|red|purple|fuchsia|green|lime|olive|yellow|navy|blue|teal|orange)\b
scope: constant.language.pine
- match: '#[a-fA-F0-9]{6}'
scope: support.constant.pine
- match: '\b([0-9]+)\b'
scope: constant.numeric.pine
# ==========================================================
# [Comment]
# Comment Line: --
- match: '(^[ \t]+)?(--)'
captures:
1: punctuation.whitespace.comment.leading.vine
2: punctuation.definition.comment.vine
push:
- meta_scope: comment.line.double-dash.vine.one
- match: \n
pop: true
# Comment Line: //
- match: '(^[ \t]+)?(//)'
captures:
1: punctuation.whitespace.comment.leading.vine
2: punctuation.definition.comment.vine
push:
- meta_scope: comment.line.double-slash.vine.two
- match: \n
pop: true
# Comment Block: (*, *)
- match: \(\*
captures:
0: punctuation.definition.comment.vine
push:
- meta_scope: comment.block.vine.one
- match: \*\)
captures:
0: punctuation.definition.comment.vine
pop: true
# Comment Block: {, }
- match: '\{'
captures:
0: punctuation.definition.comment.vine
push:
- meta_scope: comment.block.vine.two
- match: '\}'
captures:
0: punctuation.definition.comment.vine
pop: true
# ==========================================================
# [Text]
# Text String: ""
- match: '"'
comment: Double quoted strings are an extension and (generally) support C-style escape sequences.
captures:
0: punctuation.definition.string.begin.vine
push:
- meta_scope: string.quoted.double.vine
- match: '"'
captures:
0: punctuation.definition.string.end.vine
pop: true
# -------------------------------------------------------------------------
# This part is disabled to allow "\" with color syntax to function correctly in vine.
# - match: \\.
# scope: constant.character.escape.vine
# Text String: ''
- match: "'"
captures:
0: punctuation.definition.string.begin.vine
push:
- meta_scope: string.quoted.single.vine
- match: "''"
scope: constant.character.escape.apostrophe.vine
- match: "'"
captures:
0: punctuation.definition.string.end.vine
pop: true
# ==========================================================
# [Numbers]
# Comment Line: Numbers
- match: '\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\b'
scope: constant.numeric.vine
# ==========================================================
Then I assume Is there a better way to turn off spell check for Japanese characters? should just work unless you have syntax-specific settings which overrides the global one.
@jfcherng I actually removed all other files, just keep the “pine.sublime-syntax” now, as well as the syntax-preference file.
Also restarted sublime too… still no joy…
And chance can @jfcherng quickly do a final scan through my pine.sublime-syntax, see if its correct again?
Thank you so much @jfcherng
if you are able to see meta.text.cjk
as in
the only thing rest is Is there a better way to turn off spell check for Japanese characters?
what’s the output of view.settings().get('spelling_selector')
from ST console with the problematic view?
this is the output from console:
>>> view.settings().get('spelling_selector')
'markup.raw, source string.quoted - punctuation - meta.preprocessor.include, source comment - source comment.block.preprocessor, -(source, constant, keyword, storage, support, variable, markup.underline.link, meta.tag, meta.text.cjk)'
@jfcherng omg it works!
After adding:
“spell_check”: true,
“spelling_selector”: “- meta.text.cjk”,
Thank you so much again @jfcherng! You are amazing
This would be wrong for non-plain-text content. For exmpale, function name will be spelling checked.
@jfcherng So I should use this instead?
"spell_check": true,
"spelling_selector": "markup.raw, source string.quoted - punctuation - meta.preprocessor.include, source comment - source comment.block.preprocessor, -(source, constant, keyword, storage, support, variable, markup.underline.link, meta.tag, meta.text.cjk)",