patch 9.0.1620: Nix files are not recognized from the hashbang line
Problem: Nix files are not recognized from the hashbang line.
Solution: Add a hashbang check. (issue #12507)
diff --git a/runtime/autoload/dist/script.vim b/runtime/autoload/dist/script.vim
index b55fab3..0079f4b 100644
--- a/runtime/autoload/dist/script.vim
+++ b/runtime/autoload/dist/script.vim
@@ -4,7 +4,7 @@
# Invoked from "scripts.vim" in 'runtimepath'
#
# Maintainer: Bram Moolenaar <Bram@vim.org>
-# Last Change: 2023 May 06
+# Last Change: 2023 Jun 08
export def DetectFiletype()
var line1 = getline(1)
@@ -44,7 +44,7 @@
elseif line1 =~ '^#!\s*[^/\\ ]*\>\([^/\\]\|$\)'
name = substitute(line1, '^#!\s*\([^/\\ ]*\>\).*', '\1', '')
else
- name = substitute(line1, '^#!\s*\S*[/\\]\(\i\+\).*', '\1', '')
+ name = substitute(line1, '^#!\s*\S*[/\\]\(\f\+\).*', '\1', '')
endif
# tcl scripts may have #!/bin/sh in the first line and "exec wish" in the
@@ -197,6 +197,10 @@
elseif name =~ 'guile'
setl ft=scheme
+ # Nix
+ elseif name =~ 'nix-shell'
+ setl ft=nix
+
endif
enddef
diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim
index d5e0038..ae76969 100644
--- a/src/testdir/test_filetype.vim
+++ b/src/testdir/test_filetype.vim
@@ -852,6 +852,7 @@
expect: [['#!/path/expect']],
gnuplot: [['#!/path/gnuplot']],
make: [['#!/path/make']],
+ nix: [['#!/path/nix-shell']],
pike: [['#!/path/pike'],
['#!/path/pike0'],
['#!/path/pike9']],
@@ -902,6 +903,7 @@
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']],
}
enddef
diff --git a/src/version.c b/src/version.c
index 90331ed..bad9e54 100644
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1620,
+/**/
1619,
/**/
1618,