]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1620: Nix files are not recognized from the hashbang line v9.0.1620
authorBram Moolenaar <Bram@vim.org>
Thu, 8 Jun 2023 20:27:13 +0000 (21:27 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 8 Jun 2023 20:27:13 +0000 (21:27 +0100)
Problem:    Nix files are not recognized from the hashbang line.
Solution:   Add a hashbang check. (issue #12507)

runtime/autoload/dist/script.vim
src/testdir/test_filetype.vim
src/version.c

index b55fab354f12d25950d6faee3b81ff289b8d8e94..0079f4b4e26faf3ba1d32b4a3fad834399740f4b 100644 (file)
@@ -4,7 +4,7 @@ vim9script
 # 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 @@ def DetectFromHashBang(firstline: string)
   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 @@ def DetectFromHashBang(firstline: string)
   elseif name =~ 'guile'
     setl ft=scheme
 
+    # Nix
+  elseif name =~ 'nix-shell'
+    setl ft=nix
+
   endif
 enddef
 
index d5e003848a11c5f566e849486b4efb20e234b559..ae76969a5aff94b0dc3ec7f663d183784702be28 100644 (file)
@@ -852,6 +852,7 @@ def s:GetScriptChecks(): dict<list<list<string>>>
     expect: [['#!/path/expect']],
     gnuplot: [['#!/path/gnuplot']],
     make:   [['#!/path/make']],
+    nix:    [['#!/path/nix-shell']],
     pike:   [['#!/path/pike'],
             ['#!/path/pike0'],
             ['#!/path/pike9']],
@@ -902,6 +903,7 @@ def s:GetScriptEnvChecks(): dict<list<list<string>>>
     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
 
index 90331ed8e2a437054288910c29affd6213b903f9..bad9e5428c7815c9e2cbadb69914d18daa1a4526 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1620,
 /**/
     1619,
 /**/