neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 7a8b0cd0f85ad2b488e943ecbcd085f1fbccf020
parent f72c13341afb3e2459202d3f6e57cd00614c2ab5
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Sun,  1 Jun 2025 08:31:00 +0800

Merge pull request #34239 from e-kwsm/vim-9.1.1342

vim-patch:9.1.{1342,1420}
Diffstat:
Mruntime/lua/vim/filetype/detect.lua | 9++++-----
Mtest/old/testdir/test_filetype.vim | 9+++++++--
2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua @@ -1959,11 +1959,10 @@ local function match_from_hashbang(contents, path, dispatch_extension) -- "#!/usr/bin/bash" to make matching easier. -- Recognize only a few {options} that are commonly used. if matchregex(first_line, [[^#!\s*\S*\<env\s]]) then - first_line = first_line:gsub('%S+=%S+', '') - first_line = first_line - :gsub('%-%-ignore%-environment', '', 1) - :gsub('%-%-split%-string', '', 1) - :gsub('%-[iS]', '', 1) + first_line = fn.substitute(first_line, [[\s\zs--split-string\(\s\|=\)]], '', '') + first_line = fn.substitute(first_line, [[\s\zs[A-Za-z0-9_]\+=\S*\ze\s]], '', 'g') + first_line = + fn.substitute(first_line, [[\s\zs\%(-[iS]\+\|--ignore-environment\)\ze\s]], '', 'g') first_line = fn.substitute(first_line, [[\<env\s\+]], '', '') end diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim @@ -1068,10 +1068,15 @@ func s:GetScriptEnvChecks() abort return { \ 'perl': [['#!/usr/bin/env VAR=val perl']], \ 'scala': [['#!/usr/bin/env VAR=val VVAR=vval scala']], - \ 'awk': [['#!/usr/bin/env VAR=val -i awk']], + \ 'awk': [['#!/usr/bin/env --split-string=VAR= awk -vFS="," -f']], + \ 'ruby': [['#!/usr/bin/env --split-string=ruby --debug']], + \ 'sed': [['#!/usr/bin/env -iS sed -f']], + \ 'zsh': [['#!/usr/bin/env -iS VAR=val zsh -l']], \ 'execline': [['#!/usr/bin/env execlineb']], \ 'scheme': [['#!/usr/bin/env VAR=val --ignore-environment scheme']], - \ 'python': [['#!/usr/bin/env VAR=val -S python -w -T']], + \ 'sh': [['#!/usr/bin/env -S --ignore-environment VAR= sh -u']], + \ 'python': [['#!/usr/bin/env -S -i VAR=val python -B -u']], + \ 'csh': [['#!/usr/bin/env -S VAR= csh -f']], \ 'wml': [['#!/usr/bin/env VAR=val --split-string wml']], \ 'nix': [['#!/usr/bin/env nix-shell']], \ }