diff options
author | Christian Clason <c.clason@uni-graz.at> | 2024-02-29 18:28:31 +0100 |
---|---|---|
committer | Christian Clason <c.clason@uni-graz.at> | 2024-02-29 22:54:57 +0100 |
commit | c8299d15db16fb8305c95a2cb5af53668a007ef2 (patch) | |
tree | 7169d85d608ebbe4cb9fe839e8728ffbf8902de4 | |
parent | bfcf5666cc83f1d87fe62ef371ff02e2bbd04bd4 (diff) | |
download | rneovim-c8299d15db16fb8305c95a2cb5af53668a007ef2.tar.gz rneovim-c8299d15db16fb8305c95a2cb5af53668a007ef2.tar.bz2 rneovim-c8299d15db16fb8305c95a2cb5af53668a007ef2.zip |
vim-patch:b4eb3f1e4489
runtime(yaml): disable multiline_scalar detection by default
There have been many complaints about Yaml indenting too much, because
it considers values to be multi-line by default, which leads to
unintended indenting for (apparently most) users.
So let's hide this feature behind the new feature flag, keep it
simple and prefer single line value key pairs by default.
If you want the old behaviour, set the following value: >
:let g:yaml_indent_multiline_scalar = 1
If not set, it will indent the same as the previous line.
closes vim/vim#13845
https://github.com/vim/vim/commit/b4eb3f1e44896b12fdfa3885a78c6eaa181eaeff
Co-authored-by: Christian Brabandt <cb@256bit.org>
-rw-r--r-- | runtime/doc/indent.txt | 6 | ||||
-rw-r--r-- | runtime/indent/yaml.vim | 7 |
2 files changed, 11 insertions, 2 deletions
diff --git a/runtime/doc/indent.txt b/runtime/doc/indent.txt index a79ce41ac1..ba1033ee0a 100644 --- a/runtime/doc/indent.txt +++ b/runtime/doc/indent.txt @@ -1226,5 +1226,11 @@ indent for a continuation line, a line that starts with a backslash: > Three times shiftwidth is the default value. +YAML *ft-yaml-indent* + +By default, the yaml indent script does not try to detect multiline scalars. +If you want to enable this, set the following variable: > + + let g:yaml_indent_multiline_scalar = 1 vim:tw=78:ts=8:noet:ft=help:norl: diff --git a/runtime/indent/yaml.vim b/runtime/indent/yaml.vim index 93fd8ea6f6..e5daf9f219 100644 --- a/runtime/indent/yaml.vim +++ b/runtime/indent/yaml.vim @@ -3,6 +3,7 @@ " Maintainer: Nikolai Pavlov <zyx.vim@gmail.com> " Last Updates: Lukas Reineke, "lacygoill" " Last Change: 2022 Jun 17 +" 2024 Feb 29 disable mulitline indent by default (The Vim project) " Only load this indent file when no other was loaded. if exists('b:did_indent') @@ -138,11 +139,13 @@ function GetYAMLIndent(lnum) else return indent(prevmapline) endif - elseif prevline =~# '^\s*- ' + elseif get(g:, 'yaml_indent_multiline_scalar', 0) && + \ prevline =~# '^\s*- ' " - List with " multiline scalar return previndent+2 - elseif prevline =~# s:mapkeyregex .. '\v\s*%(%(' .. s:c_ns_tag_property .. + elseif get(g:, 'yaml_indent_multiline_scalar', 0) && + \ prevline =~# s:mapkeyregex .. '\v\s*%(%(' .. s:c_ns_tag_property .. \ '\v|' .. s:c_ns_anchor_property .. \ '\v|' .. s:block_scalar_header .. \ '\v)%(\s+|\s*%(\#.*)?$))*' |