mirror of
https://github.com/neovim/neovim.git
synced 2026-05-04 21:15:09 +00:00
vim-patch:9.1.0354: runtime(uci): No support for uci file types (#28409)
Problem: runtime(uci): No support for uci file types
(Wu, Zhenyu)
Solution: include basic uci ftplugin and syntax plugins
(Colin Caine)
closes: vim/vim#14575
4b3fab14db
Co-authored-by: Colin Caine <complaints@cmcaine.co.uk>
Co-authored-by: Wu, Zhenyu <wuzhenyu@ustc.edu>
This commit is contained in:
@@ -14,7 +14,8 @@ local M = {}
|
||||
local function starsetf(ft, opts)
|
||||
return {
|
||||
function(path, bufnr)
|
||||
local f = type(ft) == 'function' and ft(path, bufnr) or ft
|
||||
-- Note: when `ft` is a function its return value may be nil.
|
||||
local f = type(ft) ~= 'function' and ft or ft(path, bufnr)
|
||||
if not vim.g.ft_ignore_pat then
|
||||
return f
|
||||
end
|
||||
@@ -2138,6 +2139,7 @@ local pattern = {
|
||||
['.*/%.init/.*%.conf'] = 'upstart',
|
||||
['.*/usr/share/upstart/.*%.override'] = 'upstart',
|
||||
['.*%.[Ll][Oo][Gg]'] = detect.log,
|
||||
['.*/etc/config/.*'] = starsetf(detect.uci),
|
||||
['.*%.vhdl_[0-9].*'] = starsetf('vhdl'),
|
||||
['.*%.ws[fc]'] = 'wsh',
|
||||
['.*/Xresources/.*'] = starsetf('xdefaults'),
|
||||
|
||||
@@ -1584,6 +1584,26 @@ function M.typ(_, bufnr)
|
||||
return 'typst'
|
||||
end
|
||||
|
||||
--- @type vim.filetype.mapfn
|
||||
function M.uci(_, bufnr)
|
||||
-- Return "uci" iff the file has a config or package statement near the
|
||||
-- top of the file and all preceding lines were comments or blank.
|
||||
for _, line in ipairs(getlines(bufnr, 1, 3)) do
|
||||
-- Match a config or package statement at the start of the line.
|
||||
if
|
||||
line:find('^%s*[cp]%s+%S')
|
||||
or line:find('^%s*config%s+%S')
|
||||
or line:find('^%s*package%s+%S')
|
||||
then
|
||||
return 'uci'
|
||||
end
|
||||
-- Match a line that is either all blank or blank followed by a comment
|
||||
if not (line:find('^%s*$') or line:find('^%s*#')) then
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Determine if a .v file is Verilog, V, or Coq
|
||||
--- @type vim.filetype.mapfn
|
||||
function M.v(_, bufnr)
|
||||
|
||||
Reference in New Issue
Block a user