fix(filetype): add typing and dry (#24573)

This commit is contained in:
Lewis Russell 2023-08-08 16:36:06 +01:00 committed by GitHub
parent 61ed45486d
commit c6c21db82b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 822 additions and 946 deletions

View File

@ -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,

View File

@ -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

View File

@ -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 = {}