vim-patch:9.2.0327: filetype: uv scripts are not detected (#38920)

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: vim/vim#19941

6c16ccaf61

Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq
2026-04-10 07:28:24 +08:00
committed by GitHub
parent cfbbec6fda
commit 93b3ea26ac
2 changed files with 6 additions and 1 deletions

View File

@@ -2162,6 +2162,10 @@ local function match_from_hashbang(contents, path, dispatch_extension)
end
end
if name == 'uv' and matchregex(first_line, [[\<uv run\>]]) then
return 'python'
end
-- If nothing matched, check the extension table. For a hashbang like
-- '#!/bin/env foo', this will set the filetype to 'fooscript' assuming
-- the filetype for the 'foo' extension is 'fooscript' in the extension table.