]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(yaml): disable multiline_scalar detection by default
authorChristian Brabandt <cb@256bit.org>
Thu, 29 Feb 2024 16:23:51 +0000 (17:23 +0100)
committerChristian Brabandt <cb@256bit.org>
Thu, 29 Feb 2024 16:28:07 +0000 (17:28 +0100)
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 #13845

Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/doc/indent.txt
runtime/doc/tags
runtime/indent/yaml.vim

index 7865bb6893d67ba19aade26e6543600eb9510227..9fb6dd9f25de3c260bb211486e9f44d0586dc8d2 100644 (file)
@@ -1255,5 +1255,11 @@ Example of configuration: >
 This variable is equivalent to `g:vim_indent.line_continuation`.
 It's supported for backward compatibility.
 
+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:
index fb0b540535bb4a4fbf7e3ff884f5da33e266846f..8af0b573a5e6084ae6f18c0a703c7a53957b2f77 100644 (file)
@@ -7364,6 +7364,7 @@ ft-xhtml-omni     insert.txt      /*ft-xhtml-omni*
 ft-xml-omni    insert.txt      /*ft-xml-omni*
 ft-xml-syntax  syntax.txt      /*ft-xml-syntax*
 ft-xpm-syntax  syntax.txt      /*ft-xpm-syntax*
+ft-yaml-indent indent.txt      /*ft-yaml-indent*
 ft-yaml-syntax syntax.txt      /*ft-yaml-syntax*
 ft-zimbu-plugin        filetype.txt    /*ft-zimbu-plugin*
 ft-zsh-syntax  syntax.txt      /*ft-zsh-syntax*
index 93fd8ea6f6df3b22e0d2a93abc2a6d8d5d6b4cf2..e5daf9f2193810474fc92dc45321bfb57a55da6f 100644 (file)
@@ -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*%(\#.*)?$))*'