# HG changeset patch # User Bram Moolenaar # Date 1686256204 -7200 # Node ID 5d32f2d42a6b7f5278c7fbf24cdb800f752adb87 # Parent c03fa34ca300d36d7e895ed5e08f9b2fbdb914f2 patch 9.0.1620: Nix files are not recognized from the hashbang line Commit: https://github.com/vim/vim/commit/19548c6a742d954ecd0b50b0680c37cc6ced7473 Author: Bram Moolenaar Date: Thu Jun 8 21:27:13 2023 +0100 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 https://github.com/vim/vim/issues/12507) diff --git a/runtime/autoload/dist/script.vim b/runtime/autoload/dist/script.vim --- a/runtime/autoload/dist/script.vim +++ b/runtime/autoload/dist/script.vim @@ -4,7 +4,7 @@ vim9script # Invoked from "scripts.vim" in 'runtimepath' # # Maintainer: Bram Moolenaar -# 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 diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim --- a/src/testdir/test_filetype.vim +++ b/src/testdir/test_filetype.vim @@ -852,6 +852,7 @@ def s:GetScriptChecks(): dict