mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 03:05:11 -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,
|
priority = -math.huge,
|
||||||
function(path, bufnr)
|
function(path, bufnr)
|
||||||
local content = vim.filetype.getlines(bufnr, 1)
|
local content = vim.api.nvim_buf_get_lines(bufnr, 0, 1, false)[1] or ''
|
||||||
if vim.filetype.matchregex(content, [[^#!.*\<mine\>]]) then
|
if vim.regex([[^#!.*\<mine\>]]):match_str(content) ~= nil then
|
||||||
return 'mine'
|
return 'mine'
|
||||||
elseif vim.filetype.matchregex(content, [[\<drawing\>]]) then
|
elseif vim.regex([[\<drawing\>]]):match_str(content) ~= nil then
|
||||||
return 'drawing'
|
return 'drawing'
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@ -428,10 +428,17 @@ vim.cmd = setmetatable({}, {
|
|||||||
end,
|
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.
|
-- These are the vim.env/v/g/o/bo/wo variable magic accessors.
|
||||||
do
|
do
|
||||||
local validate = vim.validate
|
local validate = vim.validate
|
||||||
|
|
||||||
|
--- @param scope string
|
||||||
|
--- @param handle? false|integer
|
||||||
|
--- @return vim.var_accessor
|
||||||
local function make_dict_accessor(scope, handle)
|
local function make_dict_accessor(scope, handle)
|
||||||
validate({
|
validate({
|
||||||
scope = { scope, 's' },
|
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' }
|
local TAGGED_TYPES = { 'TSNode', 'LanguageTree' }
|
||||||
|
|
||||||
-- Document these as 'table'
|
-- 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_outfile = nil --- @type string?
|
||||||
local debug_output = {}
|
local debug_output = {}
|
||||||
|
Loading…
Reference in New Issue
Block a user