Skip to content

Commit

Permalink
Adds option to limit spell checking
Browse files Browse the repository at this point in the history
  • Loading branch information
nkakouros committed Apr 5, 2020
1 parent 8fc9136 commit 1a91fc0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
20 changes: 14 additions & 6 deletions after/syntax/yaml.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1a91fc0

Please sign in to comment.