mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	fix(filetype): add typing and dry (#24573)
This commit is contained in:
		| @@ -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 = {} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Lewis Russell
					Lewis Russell