mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:0acd3ab: runtime(sh): better function support for bash/zsh in indent script
closes: vim/vim#16052
0acd3abfad
Co-authored-by: Lukas Zapletal <lzap+git@redhat.com>
This commit is contained in:
parent
c9045f5ba3
commit
a785be9cc7
@ -7,6 +7,8 @@
|
|||||||
" License: Vim (see :h license)
|
" License: Vim (see :h license)
|
||||||
" Repository: https://github.com/chrisbra/vim-sh-indent
|
" Repository: https://github.com/chrisbra/vim-sh-indent
|
||||||
" Changelog:
|
" Changelog:
|
||||||
|
" 20241411 - Detect dash character in function keyword for
|
||||||
|
" bash mode (issue #16049)
|
||||||
" 20190726 - Correctly skip if keywords in syntax comments
|
" 20190726 - Correctly skip if keywords in syntax comments
|
||||||
" (issue #17)
|
" (issue #17)
|
||||||
" 20190603 - Do not indent in zsh filetypes with an `if` in comments
|
" 20190603 - Do not indent in zsh filetypes with an `if` in comments
|
||||||
@ -195,7 +197,9 @@ endfunction
|
|||||||
function! s:is_function_definition(line)
|
function! s:is_function_definition(line)
|
||||||
return a:line =~ '^\s*\<\k\+\>\s*()\s*{' ||
|
return a:line =~ '^\s*\<\k\+\>\s*()\s*{' ||
|
||||||
\ a:line =~ '^\s*{' ||
|
\ a:line =~ '^\s*{' ||
|
||||||
\ a:line =~ '^\s*function\s*\k\+\s*\%(()\)\?\s*{'
|
\ a:line =~ '^\s*function\s*\k\+\s*\%(()\)\?\s*{' ||
|
||||||
|
\ ((&ft is# 'zsh' || s:is_bash()) &&
|
||||||
|
\ a:line =~ '^\s*function\s*\S\+\s*\%(()\)\?\s*{' )
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:is_array(line)
|
function! s:is_array(line)
|
||||||
|
22
runtime/indent/testdir/bash.in
Normal file
22
runtime/indent/testdir/bash.in
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# vim: set ft=bash sw=2 noet:
|
||||||
|
|
||||||
|
# START_INDENT
|
||||||
|
a = 10
|
||||||
|
b = 20
|
||||||
|
|
||||||
|
function add() {
|
||||||
|
c = $((a + b))
|
||||||
|
}
|
||||||
|
|
||||||
|
function print {
|
||||||
|
# do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ $c -ge 15 ]];
|
||||||
|
then
|
||||||
|
print("ok")
|
||||||
|
else
|
||||||
|
print("not ok")
|
||||||
|
fi
|
||||||
|
# END_INDENT
|
22
runtime/indent/testdir/bash.ok
Normal file
22
runtime/indent/testdir/bash.ok
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# vim: set ft=bash sw=2 noet:
|
||||||
|
|
||||||
|
# START_INDENT
|
||||||
|
a = 10
|
||||||
|
b = 20
|
||||||
|
|
||||||
|
function add() {
|
||||||
|
c = $((a + b))
|
||||||
|
}
|
||||||
|
|
||||||
|
function print {
|
||||||
|
# do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ $c -ge 15 ]];
|
||||||
|
then
|
||||||
|
print("ok")
|
||||||
|
else
|
||||||
|
print("not ok")
|
||||||
|
fi
|
||||||
|
# END_INDENT
|
Loading…
Reference in New Issue
Block a user