mirror of
https://github.com/neovim/neovim.git
synced 2026-04-14 19:46:10 +00:00
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:
@@ -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.
|
||||
|
||||
@@ -1106,7 +1106,8 @@ func s:GetScriptChecks() abort
|
||||
\ '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'],
|
||||
|
||||
Reference in New Issue
Block a user