comparison runtime/autoload/dist/script.vim @ 32576:5d32f2d42a6b v9.0.1620

patch 9.0.1620: Nix files are not recognized from the hashbang line Commit: https://github.com/vim/vim/commit/19548c6a742d954ecd0b50b0680c37cc6ced7473 Author: Bram Moolenaar <Bram@vim.org> 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)
author Bram Moolenaar <Bram@vim.org>
date Thu, 08 Jun 2023 22:30:04 +0200
parents 2a17771529af
children c777d71cf397
comparison
equal deleted inserted replaced
32575:c03fa34ca300 32576:5d32f2d42a6b
2 2
3 # Vim function for detecting a filetype from the file contents. 3 # Vim function for detecting a filetype from the file contents.
4 # Invoked from "scripts.vim" in 'runtimepath' 4 # Invoked from "scripts.vim" in 'runtimepath'
5 # 5 #
6 # Maintainer: Bram Moolenaar <Bram@vim.org> 6 # Maintainer: Bram Moolenaar <Bram@vim.org>
7 # Last Change: 2023 May 06 7 # Last Change: 2023 Jun 08
8 8
9 export def DetectFiletype() 9 export def DetectFiletype()
10 var line1 = getline(1) 10 var line1 = getline(1)
11 if line1[0] == '#' && line1[1] == '!' 11 if line1[0] == '#' && line1[1] == '!'
12 # File that starts with "#!". 12 # File that starts with "#!".
42 elseif line1 =~ '^#!.*\<env\>' 42 elseif line1 =~ '^#!.*\<env\>'
43 name = substitute(line1, '^#!.*\<env\>\s\+\(\i\+\).*', '\1', '') 43 name = substitute(line1, '^#!.*\<env\>\s\+\(\i\+\).*', '\1', '')
44 elseif line1 =~ '^#!\s*[^/\\ ]*\>\([^/\\]\|$\)' 44 elseif line1 =~ '^#!\s*[^/\\ ]*\>\([^/\\]\|$\)'
45 name = substitute(line1, '^#!\s*\([^/\\ ]*\>\).*', '\1', '') 45 name = substitute(line1, '^#!\s*\([^/\\ ]*\>\).*', '\1', '')
46 else 46 else
47 name = substitute(line1, '^#!\s*\S*[/\\]\(\i\+\).*', '\1', '') 47 name = substitute(line1, '^#!\s*\S*[/\\]\(\f\+\).*', '\1', '')
48 endif 48 endif
49 49
50 # tcl scripts may have #!/bin/sh in the first line and "exec wish" in the 50 # tcl scripts may have #!/bin/sh in the first line and "exec wish" in the
51 # third line. Suggested by Steven Atkinson. 51 # third line. Suggested by Steven Atkinson.
52 if getline(3) =~ '^exec wish' 52 if getline(3) =~ '^exec wish'
194 setl ft=icon 194 setl ft=icon
195 195
196 # Guile 196 # Guile
197 elseif name =~ 'guile' 197 elseif name =~ 'guile'
198 setl ft=scheme 198 setl ft=scheme
199
200 # Nix
201 elseif name =~ 'nix-shell'
202 setl ft=nix
199 203
200 endif 204 endif
201 enddef 205 enddef
202 206
203 207