mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 07:20:04 +08:00
feat(toml): add toml indent file
This commit is contained in:
parent
7f33b177fe
commit
714e3b41ca
@ -273,9 +273,9 @@
|
|||||||
[test_regexp.problemMatcher]
|
[test_regexp.problemMatcher]
|
||||||
useStdout = true
|
useStdout = true
|
||||||
[test_regexp.problemMatcher.pattern]
|
[test_regexp.problemMatcher.pattern]
|
||||||
regexp = '\(.*\):\(\d\+\):\(\d\+\)\s\(\S.*\)'
|
regexp = '\(.*\):\(\d\+\):\(\d\+\)\s\(\S.*\)'
|
||||||
file = 1
|
file = 1
|
||||||
line = 2
|
line = 2
|
||||||
column = 3
|
column = 3
|
||||||
#severity = 4
|
#severity = 4
|
||||||
message = 4
|
message = 4
|
||||||
|
@ -7,3 +7,8 @@ end_of_line = lf
|
|||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
charset = utf-8
|
charset = utf-8
|
||||||
|
|
||||||
|
[*.toml]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
charset = utf-8
|
||||||
|
|
||||||
|
69
bundle/vim-toml/indent/toml.vim
Normal file
69
bundle/vim-toml/indent/toml.vim
Normal file
@ -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
|
@ -16,6 +16,7 @@ In `bundle/` directory, there are two kinds of plugins: forked plugins without c
|
|||||||
- [`chat` layer](#chat-layer)
|
- [`chat` layer](#chat-layer)
|
||||||
- [`cscope` layer](#cscope-layer)
|
- [`cscope` layer](#cscope-layer)
|
||||||
- [`lang#java` layer](#langjava-layer)
|
- [`lang#java` layer](#langjava-layer)
|
||||||
|
- [`lang#toml` layer](#langtoml-layer)
|
||||||
- [No changed plugins](#no-changed-plugins)
|
- [No changed plugins](#no-changed-plugins)
|
||||||
- [`autocomplete` layer](#autocomplete-layer)
|
- [`autocomplete` layer](#autocomplete-layer)
|
||||||
- [`core` layer](#core-layer-1)
|
- [`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)
|
- `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
|
### No changed plugins
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user