From 1a91fc024e00fae8580602b37cb5558767058c6d Mon Sep 17 00:00:00 2001 From: Nikolaos Kakouros Date: Sun, 5 Apr 2020 17:52:22 +0200 Subject: [PATCH] Adds option to limit spell checking --- README.md | 6 ++++++ after/syntax/yaml.vim | 20 ++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index fe4013a..a64a078 100644 --- a/README.md +++ b/README.md @@ -4,3 +4,9 @@ Vim Yaml Syntax file from [http://www.vim.org/scripts/script.php?script_id=739](http://www.vim.org/scripts/script.php?script_id=739) Yaml files in vim 7.4 are really slow, due to core yaml syntax. This syntax is simpler/faster. + +`g:yaml_limit_spell` +------------------- + +Set to `1` to limit spell checking (if spelling is enabled) to Yaml comments and +strings. diff --git a/after/syntax/yaml.vim b/after/syntax/yaml.vim index 85aea4a..d246b8f 100644 --- a/after/syntax/yaml.vim +++ b/after/syntax/yaml.vim @@ -19,17 +19,25 @@ if version < 600 endif syntax clear +if exists('g:yaml_limit_spell') && g:yaml_limit_spell + syn cluster yamlSpelling contains=@Spell +else + " dummy directive to just have yamlSpelling defined, without any group + syn cluster yamlSpelling remove=whatever +endif + + syn match yamlInline "[\[\]\{\}]" syn match yamlBlock "[>|]\d\?[+-]" -syn region yamlComment start="\#" end="$" +syn region yamlComment start="\#" end="$" contains=@yamlSpelling syn match yamlIndicator "#YAML:\S\+" -syn region yamlString start="\(^\|\s\|\[\|\,\|\-\)\@<='" end="'" skip="\\'" -syn region yamlString start='"' end='"' skip='\\"' contains=yamlEscape -syn region yamlString matchgroup=yamlBlock start=/[>|]\s*\n\+\z(\s\+\)\S/rs=s+1 skip=/^\%(\z1\S\|^$\)/ end=/^\z1\@!.*/me=s-1 -syn region yamlString matchgroup=yamlBlock start=/[>|]\(\d\|[+-]\)\s*\n\+\z(\s\+\)\S/rs=s+2 skip=/^\%(\z1\S\|^$\)/ end=/^\z1\@!.*/me=s-1 -syn region yamlString matchgroup=yamlBlock start=/[>|]\d\(\d\|[+-]\)\s*\n\+\z(\s\+\)\S/rs=s+3 skip=/^\%(\z1\S\|^$\)/ end=/^\z1\@!.*/me=s-1 +syn region yamlString start="\(^\|\s\|\[\|\,\|\-\)\@<='" end="'" skip="\\'" contains=@yamlSpelling +syn region yamlString start='"' end='"' skip='\\"' contains=yamlEscape contains=@yamlSpelling +syn region yamlString matchgroup=yamlBlock start=/[>|]\s*\n\+\z(\s\+\)\S/rs=s+1 skip=/^\%(\z1\S\|^$\)/ end=/^\z1\@!.*/me=s-1 contains=@yamlSpelling +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 +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 syn match yamlEscape +\\[abfnrtv'"\\]+ contained syn match yamlEscape "\\\o\o\=\o\=" contained syn match yamlEscape "\\x\x\+" contained