Skip to content

Commit 1a91fc0

Browse files
committed
Adds option to limit spell checking
1 parent 8fc9136 commit 1a91fc0

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,9 @@ Vim Yaml
44
Syntax file from [http://www.vim.org/scripts/script.php?script_id=739](http://www.vim.org/scripts/script.php?script_id=739)
55

66
Yaml files in vim 7.4 are really slow, due to core yaml syntax. This syntax is simpler/faster.
7+
8+
`g:yaml_limit_spell`
9+
-------------------
10+
11+
Set to `1` to limit spell checking (if spelling is enabled) to Yaml comments and
12+
strings.

after/syntax/yaml.vim

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,25 @@ if version < 600
1919
endif
2020
syntax clear
2121

22+
if exists('g:yaml_limit_spell') && g:yaml_limit_spell
23+
syn cluster yamlSpelling contains=@Spell
24+
else
25+
" dummy directive to just have yamlSpelling defined, without any group
26+
syn cluster yamlSpelling remove=whatever
27+
endif
28+
29+
2230
syn match yamlInline "[\[\]\{\}]"
2331
syn match yamlBlock "[>|]\d\?[+-]"
2432

25-
syn region yamlComment start="\#" end="$"
33+
syn region yamlComment start="\#" end="$" contains=@yamlSpelling
2634
syn match yamlIndicator "#YAML:\S\+"
2735

28-
syn region yamlString start="\(^\|\s\|\[\|\,\|\-\)\@<='" end="'" skip="\\'"
29-
syn region yamlString start='"' end='"' skip='\\"' contains=yamlEscape
30-
syn region yamlString matchgroup=yamlBlock start=/[>|]\s*\n\+\z(\s\+\)\S/rs=s+1 skip=/^\%(\z1\S\|^$\)/ end=/^\z1\@!.*/me=s-1
31-
syn region yamlString matchgroup=yamlBlock start=/[>|]\(\d\|[+-]\)\s*\n\+\z(\s\+\)\S/rs=s+2 skip=/^\%(\z1\S\|^$\)/ end=/^\z1\@!.*/me=s-1
32-
syn region yamlString matchgroup=yamlBlock start=/[>|]\d\(\d\|[+-]\)\s*\n\+\z(\s\+\)\S/rs=s+3 skip=/^\%(\z1\S\|^$\)/ end=/^\z1\@!.*/me=s-1
36+
syn region yamlString start="\(^\|\s\|\[\|\,\|\-\)\@<='" end="'" skip="\\'" contains=@yamlSpelling
37+
syn region yamlString start='"' end='"' skip='\\"' contains=yamlEscape contains=@yamlSpelling
38+
syn region yamlString matchgroup=yamlBlock start=/[>|]\s*\n\+\z(\s\+\)\S/rs=s+1 skip=/^\%(\z1\S\|^$\)/ end=/^\z1\@!.*/me=s-1 contains=@yamlSpelling
39+
syn region yamlString matchgroup=yamlBlock start=/[>|]\(\d\|[+-]\)\s*\n\+\z(\s\+\)\S/rs=s+2 skip=/^\%(\z1\S\|^$\)/ end=/^\z1\@!.*/me=s-1 contains=@yamlSpelling
40+
syn region yamlString matchgroup=yamlBlock start=/[>|]\d\(\d\|[+-]\)\s*\n\+\z(\s\+\)\S/rs=s+3 skip=/^\%(\z1\S\|^$\)/ end=/^\z1\@!.*/me=s-1 contains=@yamlSpelling
3341
syn match yamlEscape +\\[abfnrtv'"\\]+ contained
3442
syn match yamlEscape "\\\o\o\=\o\=" contained
3543
syn match yamlEscape "\\x\x\+" contained

0 commit comments

Comments
 (0)