aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/lua/vim/filetype/detect.lua3
-rw-r--r--test/old/testdir/test_filetype.vim2
2 files changed, 4 insertions, 1 deletions
diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua
index b347215895..4e18ed190a 100644
--- a/runtime/lua/vim/filetype/detect.lua
+++ b/runtime/lua/vim/filetype/detect.lua
@@ -1459,6 +1459,7 @@ local patterns_hashbang = {
['gforth\\>'] = { 'forth', { vim_regex = true } },
['icon\\>'] = { 'icon', { vim_regex = true } },
guile = 'scheme',
+ ['nix%-shell'] = 'nix',
}
---@private
@@ -1491,7 +1492,7 @@ local function match_from_hashbang(contents, path, dispatch_extension)
elseif matchregex(first_line, [[^#!\s*[^/\\ ]*\>\([^/\\]\|$\)]]) then
name = vim.fn.substitute(first_line, [[^#!\s*\([^/\\ ]*\>\).*]], '\\1', '')
else
- name = vim.fn.substitute(first_line, [[^#!\s*\S*[/\\]\(\i\+\).*]], '\\1', '')
+ name = vim.fn.substitute(first_line, [[^#!\s*\S*[/\\]\(\f\+\).*]], '\\1', '')
end
-- tcl scripts may have #!/bin/sh in the first line and "exec wish" in the
diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim
index c0427c7b83..779de51785 100644
--- a/test/old/testdir/test_filetype.vim
+++ b/test/old/testdir/test_filetype.vim
@@ -773,6 +773,7 @@ let s:script_checks = {
\ 'expect': [['#!/path/expect']],
\ 'gnuplot': [['#!/path/gnuplot']],
\ 'make': [['#!/path/make']],
+ \ 'nix': [['#!/path/nix-shell']],
\ 'pike': [['#!/path/pike'],
\ ['#!/path/pike0'],
\ ['#!/path/pike9']],
@@ -819,6 +820,7 @@ let s:script_env_checks = {
\ 'scheme': [['#!/usr/bin/env VAR=val --ignore-environment scheme']],
\ 'python': [['#!/usr/bin/env VAR=val -S python -w -T']],
\ 'wml': [['#!/usr/bin/env VAR=val --split-string wml']],
+ \ 'nix': [['#!/usr/bin/env nix-shell']],
\ }
func Run_script_detection(test_dict)