mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
fix(filetype): add typing and dry (#24573)
This commit is contained in:
parent
61ed45486d
commit
c6c21db82b
@ -2654,10 +2654,10 @@ vim.filetype.add({filetypes}) *vim.filetype.add()*
|
||||
['.*'] = {
|
||||
priority = -math.huge,
|
||||
function(path, bufnr)
|
||||
local content = vim.filetype.getlines(bufnr, 1)
|
||||
if vim.filetype.matchregex(content, [[^#!.*\<mine\>]]) then
|
||||
local content = vim.api.nvim_buf_get_lines(bufnr, 0, 1, false)[1] or ''
|
||||
if vim.regex([[^#!.*\<mine\>]]):match_str(content) ~= nil then
|
||||
return 'mine'
|
||||
elseif vim.filetype.matchregex(content, [[\<drawing\>]]) then
|
||||
elseif vim.regex([[\<drawing\>]]):match_str(content) ~= nil then
|
||||
return 'drawing'
|
||||
end
|
||||
end,
|
||||
|
@ -428,10 +428,17 @@ vim.cmd = setmetatable({}, {
|
||||
end,
|
||||
})
|
||||
|
||||
--- @class vim.var_accessor
|
||||
--- @field [string] any
|
||||
--- @field [integer] vim.var_accessor
|
||||
|
||||
-- These are the vim.env/v/g/o/bo/wo variable magic accessors.
|
||||
do
|
||||
local validate = vim.validate
|
||||
|
||||
--- @param scope string
|
||||
--- @param handle? false|integer
|
||||
--- @return vim.var_accessor
|
||||
local function make_dict_accessor(scope, handle)
|
||||
validate({
|
||||
scope = { scope, 's' },
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -58,7 +58,11 @@ local TYPES = { 'integer', 'number', 'string', 'table', 'list', 'boolean', 'func
|
||||
local TAGGED_TYPES = { 'TSNode', 'LanguageTree' }
|
||||
|
||||
-- Document these as 'table'
|
||||
local ALIAS_TYPES = { 'Range', 'Range4', 'Range6', 'TSMetadata' }
|
||||
local ALIAS_TYPES = {
|
||||
'Range', 'Range4', 'Range6', 'TSMetadata',
|
||||
'vim.filetype.add.filetypes',
|
||||
'vim.filetype.match.args'
|
||||
}
|
||||
|
||||
local debug_outfile = nil --- @type string?
|
||||
local debug_output = {}
|
||||
|
Loading…
Reference in New Issue
Block a user