]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0327: filetype: uv scripts are not detected v9.2.0327
authorChristian Brabandt <cb@256bit.org>
Thu, 9 Apr 2026 20:50:01 +0000 (20:50 +0000)
committerChristian Brabandt <cb@256bit.org>
Thu, 9 Apr 2026 20:50:01 +0000 (20:50 +0000)
Problem:  filetype: uv scripts are not detected
          (Asger Hautop Drewsen)
Solution: Detect uv scripts as python filetype if the shebang line
          contains "uv run"

Reference:
https://docs.astral.sh/uv/guides/scripts/#using-a-shebang-to-create-an-executable-file

fixes: #19941

Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/autoload/dist/script.vim
src/testdir/test_filetype.vim
src/version.c

index de168f0c09e6407032e5fb14aae07ad732f29c16..0106900f8f54e00e2f94dfdb6d85c9c5f4cff1ab 100644 (file)
@@ -4,7 +4,7 @@ vim9script
 # Invoked from "scripts.vim" in 'runtimepath'
 #
 # Maintainer:  The Vim Project <https://github.com/vim/vim>
-# Last Change: 2025 Dec 22
+# Last Change: 2026 Apr 09
 # Former Maintainer:   Bram Moolenaar <Bram@vim.org>
 
 export def DetectFiletype()
@@ -115,7 +115,7 @@ export def Exe2filetype(name: string, line1: string): string
     return 'php'
 
     # Python
-  elseif name =~ 'python'
+  elseif name =~ 'python' || (name == 'uv' && line1 =~ '\<uv run\>')
     return 'python'
 
     # Groovy
index 7a6615531c5244ced025acc7900321a678219c15..04036b0eb4b47680894418ba0923e9733a5f2b23 100644 (file)
@@ -1108,7 +1108,8 @@ def s:GetScriptChecks(): dict<list<list<string>>>
     php:    [['#!/path/php']],
     python: [['#!/path/python'],
             ['#!/path/python2'],
-            ['#!/path/python3']],
+            ['#!/path/python3'],
+            ['#!/usr/bin/env -S uv run --script']],
     groovy: [['#!/path/groovy']],
     ruby:   [['#!/path/ruby']],
     javascript: [['#!/path/node'],
index 70bca368922345bf367f9e3e73a5e1757f5b3728..483f55d9f619488d5f4d72e6cebf7d22ecfe938a 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    327,
 /**/
     326,
 /**/