diff --git a/.SpaceVim.d/tasks.toml b/.SpaceVim.d/tasks.toml index 6946ebc2d..cb5575616 100644 --- a/.SpaceVim.d/tasks.toml +++ b/.SpaceVim.d/tasks.toml @@ -273,9 +273,9 @@ [test_regexp.problemMatcher] useStdout = true [test_regexp.problemMatcher.pattern] - regexp = '\(.*\):\(\d\+\):\(\d\+\)\s\(\S.*\)' - file = 1 - line = 2 - column = 3 - #severity = 4 - message = 4 + regexp = '\(.*\):\(\d\+\):\(\d\+\)\s\(\S.*\)' + file = 1 + line = 2 + column = 3 + #severity = 4 + message = 4 diff --git a/.editorconfig b/.editorconfig index e3fdcd2d3..38656ffcb 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,3 +7,8 @@ end_of_line = lf insert_final_newline = true charset = utf-8 +[*.toml] +indent_style = space +indent_size = 4 +charset = utf-8 + diff --git a/bundle/vim-toml/indent/toml.vim b/bundle/vim-toml/indent/toml.vim new file mode 100644 index 000000000..66f6bcb3c --- /dev/null +++ b/bundle/vim-toml/indent/toml.vim @@ -0,0 +1,69 @@ +"============================================================================= +" toml.vim --- Toml indent file +" Copyright (c) 2024 Wang Shidong & Contributors +" Author: Wang Shidong < wsdjeg@outlook.com > +" URL: https://spacevim.org +" License: GPLv3 +"============================================================================= + + +if exists('b:did_indent') + finish +endif + +let b:did_indent = 1 + +setlocal indentexpr=GetTOMLIndent(v:lnum) +setlocal indentkeys=!^F,o,O,0#,0},0],<:>,0- +setlocal nosmartindent + +let b:undo_indent = 'setlocal indentexpr< indentkeys< smartindent<' + +" Only define the function once. +if exists('*GetTOMLIndent') + finish +endif + +" do not indent string block +let s:is_string_block = 0 + +function! s:PrevArrayIndent(lnum) abort + let prevlnum = prevnonblank(a:lnum - 1) + while prevlnum && getline(prevlnum) !~# '^\s*[' + let prevlnum = prevnonblank(prevlnum - 1) + endwhile + return indent(prevlnum) +endfunction + +function! GetTOMLIndent(lnum) abort + if a:lnum == 1 || !prevnonblank(a:lnum - 1) + return 0 + endif + + let prevlnum = prevnonblank(a:lnum - 1) + let previndent = indent(prevlnum) + + let line = getline(a:lnum) + if s:is_string_block == 0 && line =~# "'''$" + let s:is_string_block = 1 + elseif s:is_string_block && line !~# '\s*' . "'''" . '$' + return -1 + elseif s:is_string_block && line =~# '\s*' . "'''" . '$' + let s:is_string_block = 0 + return 0 + endif + + + if line =~# '^\s*#' && getline(prevlnum) =~# '^\s*#' + return previndent + elseif line =~# "^\\s*'" && getline(prevlnum) =~# "^\\s*'" + return previndent + elseif line =~# "^\\s*'" + return previndent + &shiftwidth + elseif line =~# '^\s*[\]]' + return previndent + elseif line =~# '[a-zA-Z_]*\s*=' " key: foodyy = 'xxxxx' + return s:PrevArrayIndent(a:lnum) + &shiftwidth + endif + +endfunction diff --git a/docs/bundle-plugins.md b/docs/bundle-plugins.md index 0ddf9da0f..1be89db16 100644 --- a/docs/bundle-plugins.md +++ b/docs/bundle-plugins.md @@ -16,6 +16,7 @@ In `bundle/` directory, there are two kinds of plugins: forked plugins without c - [`chat` layer](#chat-layer) - [`cscope` layer](#cscope-layer) - [`lang#java` layer](#langjava-layer) + - [`lang#toml` layer](#langtoml-layer) - [No changed plugins](#no-changed-plugins) - [`autocomplete` layer](#autocomplete-layer) - [`core` layer](#core-layer-1) @@ -80,6 +81,10 @@ These plugins are changed based on a specific version of origin plugin. - `vim-javacomplete2`: based on [artur-shaik/vim-javacomplete2@a716e32](https://github.com/artur-shaik/vim-javacomplete2/tree/a716e32bbe36daaed6ebc9aae76525aad9536245) +#### `lang#toml` layer + +- `vim-toml`: based on [cespare/vim-toml@717bd87](https://github.com/cespare/vim-toml/tree/717bd87ef928293e0cc6cfc12ebf2e007cb25311) + ### No changed plugins