vim-patch:9.1.0442: hare runtime files outdated (#29011)

Problem:  hare runtime files outdated
Solution: runtime(hare): update hare.vim to match upstream
          (Amelia Clarke)

closes: vim/vim#14836

35dfe58a54

Co-authored-by: Amelia Clarke <selene@perilune.dev>
This commit is contained in:
zeertzjq
2024-05-26 07:11:50 +08:00
committed by GitHub
parent eaaf3d9048
commit 3d39ea3ea9
12 changed files with 416 additions and 118 deletions

View File

@@ -1637,7 +1637,7 @@ local filename = {
['.xsdbcmdhistory'] = 'tcl',
['texmf.cnf'] = 'texmf',
COPYING = 'text',
README = 'text',
README = detect_seq(detect.haredoc, 'text'),
LICENSE = 'text',
AUTHORS = 'text',
tfrc = 'tf',

View File

@@ -650,6 +650,30 @@ function M.header(_, bufnr)
end
end
--- Recursively search for Hare source files in a directory and any
--- subdirectories, up to a given depth.
--- @param dir string
--- @param depth number
--- @return boolean
local function is_hare_module(dir, depth)
depth = math.max(depth, 0)
for name, _ in vim.fs.dir(dir, { depth = depth + 1 }) do
if name:find('%.ha$') then
return true
end
end
return false
end
--- @type vim.filetype.mapfn
function M.haredoc(path, _)
if vim.g.filetype_haredoc then
if is_hare_module(vim.fs.dirname(path), vim.g.haredoc_search_depth or 1) then
return 'haredoc'
end
end
end
--- @type vim.filetype.mapfn
function M.html(_, bufnr)
for _, line in ipairs(getlines(bufnr, 1, 10)) do