aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/filetype.lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2023-11-29 21:52:58 +0000
committerJosh Rahm <joshuarahm@gmail.com>2023-11-29 21:52:58 +0000
commit931bffbda3668ddc609fc1da8f9eb576b170aa52 (patch)
treed8c1843a95da5ea0bb4acc09f7e37843d9995c86 /runtime/lua/vim/filetype.lua
parent142d9041391780ac15b89886a54015fdc5c73995 (diff)
parent4a8bf24ac690004aedf5540fa440e788459e5e34 (diff)
downloadrneovim-931bffbda3668ddc609fc1da8f9eb576b170aa52.tar.gz
rneovim-931bffbda3668ddc609fc1da8f9eb576b170aa52.tar.bz2
rneovim-931bffbda3668ddc609fc1da8f9eb576b170aa52.zip
Merge remote-tracking branch 'upstream/master' into userreguserreg
Diffstat (limited to 'runtime/lua/vim/filetype.lua')
-rw-r--r--runtime/lua/vim/filetype.lua1565
1 files changed, 704 insertions, 861 deletions
diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua
index 9293c828b8..c6200f16bb 100644
--- a/runtime/lua/vim/filetype.lua
+++ b/runtime/lua/vim/filetype.lua
@@ -1,8 +1,16 @@
local api = vim.api
+local fn = vim.fn
local M = {}
----@private
+--- @alias vim.filetype.mapfn fun(path:string,bufnr:integer, ...):string?, fun(b:integer)?
+--- @alias vim.filetype.maptbl {[1]:string|vim.filetype.mapfn, [2]:{priority:integer}}
+--- @alias vim.filetype.mapping.value string|vim.filetype.mapfn|vim.filetype.maptbl
+--- @alias vim.filetype.mapping table<string,vim.filetype.mapping.value>
+
+--- @param ft string|vim.filetype.mapfn
+--- @param opts? {priority:integer}
+--- @return vim.filetype.maptbl
local function starsetf(ft, opts)
return {
function(path, bufnr)
@@ -24,36 +32,38 @@ local function starsetf(ft, opts)
end
---@private
---- Get a single line or line range from the buffer.
---- If only start_lnum is specified, return a single line as a string.
---- If both start_lnum and end_lnum are omitted, return all lines from the buffer.
----
----@param bufnr number|nil The buffer to get the lines from
----@param start_lnum number|nil The line number of the first line (inclusive, 1-based)
----@param end_lnum number|nil The line number of the last line (inclusive, 1-based)
----@return table<string>|string Array of lines, or string when end_lnum is omitted
-function M.getlines(bufnr, start_lnum, end_lnum)
- if end_lnum then
- -- Return a line range
- return api.nvim_buf_get_lines(bufnr, start_lnum - 1, end_lnum, false)
- end
+--- Get a line range from the buffer.
+---@param bufnr integer The buffer to get the lines from
+---@param start_lnum integer|nil The line number of the first line (inclusive, 1-based)
+---@param end_lnum integer|nil The line number of the last line (inclusive, 1-based)
+---@return string[] # Array of lines
+function M._getlines(bufnr, start_lnum, end_lnum)
if start_lnum then
- -- Return a single line
- return api.nvim_buf_get_lines(bufnr, start_lnum - 1, start_lnum, false)[1] or ''
- else
- -- Return all lines
- return api.nvim_buf_get_lines(bufnr, 0, -1, false)
+ return api.nvim_buf_get_lines(bufnr, start_lnum - 1, end_lnum or start_lnum, false)
end
+
+ -- Return all lines
+ return api.nvim_buf_get_lines(bufnr, 0, -1, false)
+end
+
+---@private
+--- Get a single line from the buffer.
+---@param bufnr integer The buffer to get the lines from
+---@param start_lnum integer The line number of the first line (inclusive, 1-based)
+---@return string
+function M._getline(bufnr, start_lnum)
+ -- Return a single line
+ return api.nvim_buf_get_lines(bufnr, start_lnum - 1, start_lnum, false)[1] or ''
end
---@private
--- Check whether a string matches any of the given Lua patterns.
---
----@param s string The string to check
----@param patterns table<string> A list of Lua patterns
+---@param s string? The string to check
+---@param patterns string[] A list of Lua patterns
---@return boolean `true` if s matched a pattern, else `false`
-function M.findany(s, patterns)
- if s == nil then
+function M._findany(s, patterns)
+ if not s then
return false
end
for _, v in ipairs(patterns) do
@@ -67,11 +77,11 @@ end
---@private
--- Get the next non-whitespace line in the buffer.
---
----@param bufnr number The buffer to get the line from
----@param start_lnum number The line number of the first line to start from (inclusive, 1-based)
+---@param bufnr integer The buffer to get the line from
+---@param start_lnum integer The line number of the first line to start from (inclusive, 1-based)
---@return string|nil The first non-blank line if found or `nil` otherwise
-function M.nextnonblank(bufnr, start_lnum)
- for _, line in ipairs(M.getlines(bufnr, start_lnum, -1)) do
+function M._nextnonblank(bufnr, start_lnum)
+ for _, line in ipairs(M._getlines(bufnr, start_lnum, -1)) do
if not line:find('^%s*$') then
return line
end
@@ -79,30 +89,93 @@ function M.nextnonblank(bufnr, start_lnum)
return nil
end
----@private
---- Check whether the given string matches the Vim regex pattern.
-M.matchregex = (function()
- local cache = {}
- return function(s, pattern)
- if s == nil then
- return nil
+do
+ --- @type table<string,vim.regex>
+ local regex_cache = {}
+
+ ---@private
+ --- Check whether the given string matches the Vim regex pattern.
+ --- @param s string?
+ --- @param pattern string
+ --- @return boolean
+ function M._matchregex(s, pattern)
+ if not s then
+ return false
end
- if not cache[pattern] then
- cache[pattern] = vim.regex(pattern)
+ if not regex_cache[pattern] then
+ regex_cache[pattern] = vim.regex(pattern)
end
- return cache[pattern]:match_str(s)
+ return regex_cache[pattern]:match_str(s) ~= nil
end
-end)()
+end
+
+--- @module 'vim.filetype.detect'
+local detect = setmetatable({}, {
+ --- @param k string
+ --- @param t table<string,function>
+ --- @return function
+ __index = function(t, k)
+ t[k] = function(...)
+ return require('vim.filetype.detect')[k](...)
+ end
+ return t[k]
+ end,
+})
+
+--- @param ... string|vim.filetype.mapfn
+--- @return vim.filetype.mapfn
+local function detect_seq(...)
+ local candidates = { ... }
+ return function(...)
+ for _, c in ipairs(candidates) do
+ if type(c) == 'string' then
+ return c
+ end
+ if type(c) == 'function' then
+ local r = c(...)
+ if r then
+ return r
+ end
+ end
+ end
+ end
+end
+
+local function detect_noext(path, bufnr)
+ local root = fn.fnamemodify(path, ':r')
+ return M.match({ buf = bufnr, filename = root })
+end
+
+--- @param pat string
+--- @param a string?
+--- @param b string?
+--- @return vim.filetype.mapfn
+local function detect_line1(pat, a, b)
+ return function(_path, bufnr)
+ if M._getline(bufnr, 1):find(pat) then
+ return a
+ end
+ return b
+ end
+end
+
+--- @type vim.filetype.mapfn
+local detect_rc = function(path, _bufnr)
+ if not path:find('/etc/Muttrc%.d/') then
+ return 'rc'
+ end
+end
-- luacheck: push no unused args
-- luacheck: push ignore 122
-- Filetypes based on file extension
---@diagnostic disable: unused-local
+--- @type vim.filetype.mapping
local extension = {
-- BEGIN EXTENSION
['8th'] = '8th',
- ['a65'] = 'a65',
+ a65 = 'a65',
aap = 'aap',
abap = 'abap',
abc = 'abc',
@@ -128,51 +201,36 @@ local extension = {
end
return 'aspvbs'
end,
- asm = function(path, bufnr)
- return require('vim.filetype.detect').asm(bufnr)
- end,
- lst = function(path, bufnr)
- return require('vim.filetype.detect').asm(bufnr)
- end,
- mac = function(path, bufnr)
- return require('vim.filetype.detect').asm(bufnr)
- end,
- ['asn1'] = 'asn',
+ asm = detect.asm,
+ lst = detect.asm,
+ mac = detect.asm,
+ asn1 = 'asn',
asn = 'asn',
- asp = function(path, bufnr)
- return require('vim.filetype.detect').asp(bufnr)
- end,
+ asp = detect.asp,
astro = 'astro',
atl = 'atlas',
as = 'atlas',
+ zed = 'authzed',
ahk = 'autohotkey',
- ['au3'] = 'autoit',
+ au3 = 'autoit',
ave = 'ave',
gawk = 'awk',
awk = 'awk',
ref = 'b',
imp = 'b',
mch = 'b',
- bas = function(path, bufnr)
- return require('vim.filetype.detect').bas(bufnr)
- end,
- bi = function(path, bufnr)
- return require('vim.filetype.detect').bas(bufnr)
- end,
- bm = function(path, bufnr)
- return require('vim.filetype.detect').bas(bufnr)
- end,
+ bas = detect.bas,
+ bass = 'bass',
+ bi = detect.bas,
+ bm = detect.bas,
bc = 'bc',
bdf = 'bdf',
beancount = 'beancount',
bib = 'bib',
- com = function(path, bufnr)
- return require('vim.filetype.detect').bindzone(bufnr, 'dcl')
- end,
- db = function(path, bufnr)
- return require('vim.filetype.detect').bindzone(bufnr)
- end,
+ com = detect_seq(detect.bindzone, 'dcl'),
+ db = detect.bindzone,
bicep = 'bicep',
+ bicepparam = 'bicep',
bb = 'bitbake',
bbappend = 'bitbake',
bbclass = 'bitbake',
@@ -190,7 +248,9 @@ local extension = {
BUILD = 'bzl',
qc = 'c',
cabal = 'cabal',
+ cairo = 'cairo',
capnp = 'capnp',
+ cdc = 'cdc',
cdl = 'cdl',
toc = 'cdrtoc',
cfc = 'cf',
@@ -199,9 +259,7 @@ local extension = {
hgrc = 'cfg',
chf = 'ch',
chai = 'chaiscript',
- ch = function(path, bufnr)
- return require('vim.filetype.detect').change(bufnr)
- end,
+ ch = detect.change,
chs = 'chaskell',
chatito = 'chatito',
chopro = 'chordpro',
@@ -224,22 +282,19 @@ local extension = {
atg = 'coco',
recipe = 'conaryrecipe',
hook = function(path, bufnr)
- return M.getlines(bufnr, 1) == '[Trigger]' and 'conf'
+ return M._getline(bufnr, 1) == '[Trigger]' and 'confini' or nil
end,
+ nmconnection = 'confini',
mklx = 'context',
mkiv = 'context',
mkii = 'context',
mkxl = 'context',
mkvi = 'context',
- control = function(path, bufnr)
- return require('vim.filetype.detect').control(bufnr)
- end,
- copyright = function(path, bufnr)
- return require('vim.filetype.detect').copyright(bufnr)
- end,
- csh = function(path, bufnr)
- return require('vim.filetype.detect').csh(path, bufnr)
- end,
+ control = detect.control,
+ copyright = detect.copyright,
+ corn = 'corn',
+ csh = detect.csh,
+ cpon = 'cpon',
moc = 'cpp',
hh = 'cpp',
tlh = 'cpp',
@@ -252,14 +307,15 @@ local extension = {
tcc = 'cpp',
hxx = 'cpp',
hpp = 'cpp',
- cpp = function(path, bufnr)
- return vim.g.cynlib_syntax_for_cpp and 'cynlib' or 'cpp'
- end,
- cc = function(path, bufnr)
- return vim.g.cynlib_syntax_for_cc and 'cynlib' or 'cpp'
- end,
+ ccm = 'cpp',
+ cppm = 'cpp',
+ cxxm = 'cpp',
+ ['c++m'] = 'cpp',
+ cpp = detect.cpp,
+ cc = detect.cpp,
cql = 'cqlang',
crm = 'crm',
+ cr = 'crystal',
csx = 'cs',
cs = 'cs',
csc = 'csc',
@@ -273,26 +329,23 @@ local extension = {
feature = 'cucumber',
cuh = 'cuda',
cu = 'cuda',
+ cue = 'cue',
pld = 'cupl',
si = 'cuplsim',
cyn = 'cynpp',
+ cypher = 'cypher',
dart = 'dart',
drt = 'dart',
ds = 'datascript',
dcd = 'dcd',
- decl = function(path, bufnr)
- return require('vim.filetype.detect').decl(bufnr)
- end,
- dec = function(path, bufnr)
- return require('vim.filetype.detect').decl(bufnr)
- end,
- dcl = function(path, bufnr)
- return require('vim.filetype.detect').decl(bufnr) or 'clean'
- end,
+ decl = detect.decl,
+ dec = detect.decl,
+ dcl = detect_seq(detect.decl, 'clean'),
def = 'def',
desc = 'desc',
directory = 'desktop',
desktop = 'desktop',
+ dhall = 'dhall',
diff = 'diff',
rej = 'diff',
Dockerfile = 'dockerfile',
@@ -300,125 +353,98 @@ local extension = {
bat = 'dosbatch',
wrap = 'dosini',
ini = 'dosini',
+ INI = 'dosini',
+ vbp = 'dosini',
dot = 'dot',
gv = 'dot',
drac = 'dracula',
drc = 'dracula',
dtd = 'dtd',
- d = function(path, bufnr)
- return require('vim.filetype.detect').dtrace(bufnr)
- end,
+ d = detect.dtrace,
dts = 'dts',
dtsi = 'dts',
dylan = 'dylan',
intr = 'dylanintr',
lid = 'dylanlid',
- e = function(path, bufnr)
- return require('vim.filetype.detect').e(bufnr)
- end,
- E = function(path, bufnr)
- return require('vim.filetype.detect').e(bufnr)
- end,
+ e = detect.e,
+ E = detect.e,
ecd = 'ecd',
edf = 'edif',
edif = 'edif',
edo = 'edif',
- edn = function(path, bufnr)
- return require('vim.filetype.detect').edn(bufnr)
- end,
+ edn = detect.edn,
eex = 'eelixir',
leex = 'eelixir',
am = 'elf',
exs = 'elixir',
elm = 'elm',
+ lc = 'elsa',
elv = 'elvish',
- ent = function(path, bufnr)
- return require('vim.filetype.detect').ent(bufnr)
- end,
+ ent = detect.ent,
epp = 'epuppet',
erl = 'erlang',
hrl = 'erlang',
yaws = 'erlang',
erb = 'eruby',
rhtml = 'eruby',
+ esdl = 'esdl',
ec = 'esqlc',
EC = 'esqlc',
strl = 'esterel',
- eu = function(path, bufnr)
- return vim.g.filetype_euphoria or 'euphoria3'
- end,
- EU = function(path, bufnr)
- return vim.g.filetype_euphoria or 'euphoria3'
- end,
- ew = function(path, bufnr)
- return vim.g.filetype_euphoria or 'euphoria3'
- end,
- EW = function(path, bufnr)
- return vim.g.filetype_euphoria or 'euphoria3'
- end,
- EX = function(path, bufnr)
- return vim.g.filetype_euphoria or 'euphoria3'
- end,
- exu = function(path, bufnr)
- return vim.g.filetype_euphoria or 'euphoria3'
- end,
- EXU = function(path, bufnr)
- return vim.g.filetype_euphoria or 'euphoria3'
- end,
- exw = function(path, bufnr)
- return vim.g.filetype_euphoria or 'euphoria3'
- end,
- EXW = function(path, bufnr)
- return vim.g.filetype_euphoria or 'euphoria3'
- end,
- ex = function(path, bufnr)
- return require('vim.filetype.detect').ex(bufnr)
- end,
+ eu = detect.euphoria,
+ EU = detect.euphoria,
+ ew = detect.euphoria,
+ EW = detect.euphoria,
+ EX = detect.euphoria,
+ exu = detect.euphoria,
+ EXU = detect.euphoria,
+ exw = detect.euphoria,
+ EXW = detect.euphoria,
+ ex = detect.ex,
exp = 'expect',
+ f = detect.f,
factor = 'factor',
fal = 'falcon',
fan = 'fan',
fwt = 'fan',
fnl = 'fennel',
- ['m4gl'] = 'fgl',
+ m4gl = 'fgl',
['4gl'] = 'fgl',
['4gh'] = 'fgl',
+ fir = 'firrtl',
fish = 'fish',
focexec = 'focexec',
fex = 'focexec',
- fth = 'forth',
ft = 'forth',
+ fth = 'forth',
+ ['4th'] = 'forth',
FOR = 'fortran',
- ['f77'] = 'fortran',
- ['f03'] = 'fortran',
+ f77 = 'fortran',
+ f03 = 'fortran',
fortran = 'fortran',
- ['F95'] = 'fortran',
- ['f90'] = 'fortran',
- ['F03'] = 'fortran',
+ F95 = 'fortran',
+ f90 = 'fortran',
+ F03 = 'fortran',
fpp = 'fortran',
FTN = 'fortran',
ftn = 'fortran',
['for'] = 'fortran',
- ['F90'] = 'fortran',
- ['F77'] = 'fortran',
- ['f95'] = 'fortran',
+ F90 = 'fortran',
+ F77 = 'fortran',
+ f95 = 'fortran',
FPP = 'fortran',
- f = 'fortran',
F = 'fortran',
- ['F08'] = 'fortran',
- ['f08'] = 'fortran',
+ F08 = 'fortran',
+ f08 = 'fortran',
fpc = 'fpcmake',
fsl = 'framescript',
- frm = function(path, bufnr)
- return require('vim.filetype.detect').frm(bufnr)
- end,
+ frm = detect.frm,
fb = 'freebasic',
- fs = function(path, bufnr)
- return require('vim.filetype.detect').fs(bufnr)
- end,
+ fs = detect.fs,
fsh = 'fsh',
fsi = 'fsharp',
fsx = 'fsharp',
+ fc = 'func',
fusion = 'fusion',
gdb = 'gdb',
gdmo = 'gdmo',
@@ -434,6 +460,8 @@ local extension = {
gift = 'gift',
gleam = 'gleam',
glsl = 'glsl',
+ gn = 'gn',
+ gni = 'gn',
gpi = 'gnuplot',
go = 'go',
gp = 'gp',
@@ -459,17 +487,16 @@ local extension = {
hsig = 'haskell',
hsc = 'haskell',
hs = 'haskell',
+ persistentmodels = 'haskellpersistent',
ht = 'haste',
htpp = 'hastepreproc',
+ hcl = 'hcl',
hb = 'hb',
- h = function(path, bufnr)
- return require('vim.filetype.detect').header(bufnr)
- end,
+ h = detect.header,
sum = 'hercules',
errsum = 'hercules',
ev = 'hercules',
vc = 'hercules',
- hcl = 'hcl',
heex = 'heex',
hex = 'hex',
['h32'] = 'hex',
@@ -479,56 +506,29 @@ local extension = {
hog = 'hog',
hws = 'hollywood',
hoon = 'hoon',
- cpt = function(path, bufnr)
- return require('vim.filetype.detect').html(bufnr)
- end,
- dtml = function(path, bufnr)
- return require('vim.filetype.detect').html(bufnr)
- end,
- htm = function(path, bufnr)
- return require('vim.filetype.detect').html(bufnr)
- end,
- html = function(path, bufnr)
- return require('vim.filetype.detect').html(bufnr)
- end,
- pt = function(path, bufnr)
- return require('vim.filetype.detect').html(bufnr)
- end,
- shtml = function(path, bufnr)
- return require('vim.filetype.detect').html(bufnr)
- end,
- stm = function(path, bufnr)
- return require('vim.filetype.detect').html(bufnr)
- end,
+ cpt = detect.html,
+ dtml = detect.html,
+ htm = detect.html,
+ html = detect.html,
+ pt = detect.html,
+ shtml = detect.html,
+ stm = detect.html,
htt = 'httest',
htb = 'httest',
- hw = function(path, bufnr)
- return require('vim.filetype.detect').hw(bufnr)
- end,
- module = function(path, bufnr)
- return require('vim.filetype.detect').hw(bufnr)
- end,
- pkg = function(path, bufnr)
- return require('vim.filetype.detect').hw(bufnr)
- end,
+ hurl = 'hurl',
+ hw = detect.hw,
+ module = detect.hw,
+ pkg = detect.hw,
iba = 'ibasic',
ibi = 'ibasic',
icn = 'icon',
- idl = function(path, bufnr)
- return require('vim.filetype.detect').idl(bufnr)
- end,
- inc = function(path, bufnr)
- return require('vim.filetype.detect').inc(bufnr)
- end,
+ idl = detect.idl,
+ inc = detect.inc,
inf = 'inform',
INF = 'inform',
ii = 'initng',
- inp = function(path, bufnr)
- return require('vim.filetype.detect').inp(bufnr)
- end,
- ms = function(path, bufnr)
- return require('vim.filetype.detect').nroff(bufnr) or 'xmath'
- end,
+ inp = detect.inp,
+ ms = detect_seq(detect.nroff, 'xmath'),
iss = 'iss',
mst = 'ist',
ist = 'ist',
@@ -537,6 +537,7 @@ local extension = {
jal = 'jal',
jpr = 'jam',
jpl = 'jam',
+ janet = 'janet',
jav = 'java',
java = 'java',
jj = 'javacc',
@@ -550,7 +551,7 @@ local extension = {
jsx = 'javascriptreact',
clp = 'jess',
jgr = 'jgraph',
- ['j73'] = 'jovial',
+ j73 = 'jovial',
jov = 'jovial',
jovial = 'jovial',
properties = 'jproperties',
@@ -558,15 +559,19 @@ local extension = {
slnf = 'json',
json = 'json',
jsonp = 'json',
+ geojson = 'json',
webmanifest = 'json',
ipynb = 'json',
['json-patch'] = 'json',
json5 = 'json5',
jsonc = 'jsonc',
+ jsonl = 'jsonl',
jsonnet = 'jsonnet',
libsonnet = 'jsonnet',
jsp = 'jsp',
jl = 'julia',
+ just = 'just',
+ kdl = 'kdl',
kv = 'kivy',
kix = 'kix',
kts = 'kotlin',
@@ -580,6 +585,7 @@ local extension = {
lte = 'latte',
ld = 'ld',
ldif = 'ldif',
+ lean = 'lean',
journal = 'ledger',
ldg = 'ledger',
ledger = 'ledger',
@@ -593,6 +599,7 @@ local extension = {
ly = 'lilypond',
ily = 'lilypond',
liquid = 'liquid',
+ liq = 'liquidsoap',
cl = 'lisp',
L = 'lisp',
lisp = 'lisp',
@@ -601,6 +608,7 @@ local extension = {
asd = 'lisp',
lt = 'lite',
lite = 'lite',
+ livemd = 'livebook',
lgt = 'logtalk',
lotos = 'lotos',
lot = 'lotos',
@@ -608,28 +616,21 @@ local extension = {
lou = 'lout',
ulpc = 'lpc',
lpc = 'lpc',
- c = function(path, bufnr)
- return require('vim.filetype.detect').lpc(bufnr)
- end,
- lsl = function(path, bufnr)
- return require('vim.filetype.detect').lsl(bufnr)
- end,
+ c = detect.lpc,
+ lsl = detect.lsl,
lss = 'lss',
nse = 'lua',
rockspec = 'lua',
lua = 'lua',
+ luau = 'luau',
lrc = 'lyrics',
- m = function(path, bufnr)
- return require('vim.filetype.detect').m(bufnr)
- end,
+ m = detect.m,
at = 'm4',
- mc = function(path, bufnr)
- return require('vim.filetype.detect').mc(bufnr)
- end,
+ mc = detect.mc,
quake = 'm3quake',
- ['m4'] = function(path, bufnr)
+ m4 = function(path, bufnr)
path = path:lower()
- return not (path:find('html%.m4$') or path:find('fvwm2rc')) and 'm4'
+ return not (path:find('html%.m4$') or path:find('fvwm2rc')) and 'm4' or nil
end,
eml = 'mail',
mk = 'make',
@@ -668,47 +669,34 @@ local extension = {
mib = 'mib',
mix = 'mix',
mixal = 'mix',
- mm = function(path, bufnr)
- return require('vim.filetype.detect').mm(bufnr)
- end,
+ mm = detect.mm,
nb = 'mma',
mmp = 'mmp',
- mms = function(path, bufnr)
- return require('vim.filetype.detect').mms(bufnr)
- end,
+ mms = detect.mms,
DEF = 'modula2',
- ['m2'] = 'modula2',
+ m2 = 'modula2',
mi = 'modula2',
lm3 = 'modula3',
+ mojo = 'mojo',
+ ['🔥'] = 'mojo', -- 🙄
ssc = 'monk',
monk = 'monk',
tsc = 'monk',
isc = 'monk',
moo = 'moo',
moon = 'moonscript',
+ move = 'move',
mp = 'mp',
- mpiv = function(path, bufnr)
- return 'mp', function(b)
- vim.b[b].mp_metafun = 1
- end
- end,
- mpvi = function(path, bufnr)
- return 'mp', function(b)
- vim.b[b].mp_metafun = 1
- end
- end,
- mpxl = function(path, bufnr)
- return 'mp', function(b)
- vim.b[b].mp_metafun = 1
- end
- end,
+ mpiv = detect.mp,
+ mpvi = detect.mp,
+ mpxl = detect.mp,
mof = 'msidl',
odl = 'msidl',
msql = 'msql',
mu = 'mupad',
mush = 'mush',
mysql = 'mysql',
- ['n1ql'] = 'n1ql',
+ n1ql = 'n1ql',
nql = 'n1ql',
nanorc = 'nanorc',
ncf = 'ncf',
@@ -718,6 +706,7 @@ local extension = {
nimble = 'nim',
ninja = 'ninja',
nix = 'nix',
+ norg = 'norg',
nqc = 'nqc',
roff = 'nroff',
tmac = 'nroff',
@@ -727,7 +716,10 @@ local extension = {
tr = 'nroff',
nsi = 'nsis',
nsh = 'nsis',
+ nu = 'nu',
obj = 'obj',
+ objdump = 'objdump',
+ cppobjdump = 'objdump',
obl = 'obse',
obse = 'obse',
oblivion = 'obse',
@@ -740,6 +732,7 @@ local extension = {
mli = 'ocaml',
ml = 'ocaml',
occ = 'occam',
+ odin = 'odin',
xom = 'omnimark',
xin = 'omnimark',
opam = 'opam',
@@ -759,6 +752,10 @@ local extension = {
g = 'pccts',
pcmk = 'pcmk',
pdf = 'pdf',
+ pem = 'pem',
+ cer = 'pem',
+ crt = 'pem',
+ csr = 'pem',
plx = 'perl',
prisma = 'prisma',
psgi = 'perl',
@@ -771,12 +768,10 @@ local extension = {
pike = 'pike',
pmod = 'pike',
rcp = 'pilrc',
- PL = function(path, bufnr)
- return require('vim.filetype.detect').pl(bufnr)
- end,
+ PL = detect.pl,
pli = 'pli',
- ['pl1'] = 'pli',
- ['p36'] = 'plm',
+ pl1 = 'pli',
+ p36 = 'plm',
plm = 'plm',
pac = 'plm',
plp = 'plp',
@@ -787,6 +782,7 @@ local extension = {
pod = 'pod',
filter = 'poefilter',
pk = 'poke',
+ pony = 'pony',
ps = 'postscr',
epsi = 'postscr',
afm = 'postscr',
@@ -803,11 +799,12 @@ local extension = {
pdb = 'prolog',
pml = 'promela',
proto = 'proto',
- ['psd1'] = 'ps1',
- ['psm1'] = 'ps1',
- ['ps1'] = 'ps1',
+ prql = 'prql',
+ psd1 = 'ps1',
+ psm1 = 'ps1',
+ ps1 = 'ps1',
pssc = 'ps1',
- ['ps1xml'] = 'ps1xml',
+ ps1xml = 'ps1xml',
psf = 'psf',
psl = 'psl',
pug = 'pug',
@@ -820,25 +817,29 @@ local extension = {
ptl = 'python',
ql = 'ql',
qll = 'ql',
+ qml = 'qml',
+ qbs = 'qml',
qmd = 'quarto',
- R = function(path, bufnr)
- return require('vim.filetype.detect').r(bufnr)
- end,
+ R = detect.r,
+ rkt = 'racket',
+ rktd = 'racket',
+ rktl = 'racket',
rad = 'radiance',
mat = 'radiance',
- ['pod6'] = 'raku',
+ pod6 = 'raku',
rakudoc = 'raku',
rakutest = 'raku',
rakumod = 'raku',
- ['pm6'] = 'raku',
+ pm6 = 'raku',
raku = 'raku',
- ['t6'] = 'raku',
- ['p6'] = 'raku',
+ t6 = 'raku',
+ p6 = 'raku',
raml = 'raml',
rbs = 'rbs',
rego = 'rego',
rem = 'remind',
remind = 'remind',
+ pip = 'requirements',
res = 'rescript',
resi = 'rescript',
frt = 'reva',
@@ -866,8 +867,11 @@ local extension = {
Snw = 'rnoweb',
robot = 'robot',
resource = 'robot',
+ ron = 'ron',
rsc = 'routeros',
x = 'rpcgen',
+ rpgle = 'rpgle',
+ rpgleinc = 'rpgle',
rpl = 'rpl',
Srst = 'rrst',
srst = 'rrst',
@@ -885,6 +889,7 @@ local extension = {
builder = 'ruby',
rake = 'ruby',
rs = 'rust',
+ sage = 'sage',
sas = 'sas',
sass = 'sass',
sa = 'sather',
@@ -893,9 +898,6 @@ local extension = {
ss = 'scheme',
scm = 'scheme',
sld = 'scheme',
- rkt = 'scheme',
- rktd = 'scheme',
- rktl = 'scheme',
sce = 'scilab',
sci = 'scilab',
scss = 'scss',
@@ -905,34 +907,18 @@ local extension = {
sdl = 'sdl',
sed = 'sed',
sexp = 'sexplib',
- bash = function(path, bufnr)
- return require('vim.filetype.detect').sh(path, M.getlines(bufnr), 'bash')
- end,
- ebuild = function(path, bufnr)
- return require('vim.filetype.detect').sh(path, M.getlines(bufnr), 'bash')
- end,
- eclass = function(path, bufnr)
- return require('vim.filetype.detect').sh(path, M.getlines(bufnr), 'bash')
- end,
- env = function(path, bufnr)
- return require('vim.filetype.detect').sh(path, M.getlines(bufnr))
- end,
- ksh = function(path, bufnr)
- return require('vim.filetype.detect').sh(path, M.getlines(bufnr), 'ksh')
- end,
- sh = function(path, bufnr)
- return require('vim.filetype.detect').sh(path, M.getlines(bufnr))
- end,
+ bash = detect.bash,
+ ebuild = detect.bash,
+ eclass = detect.bash,
+ env = detect.sh,
+ ksh = detect.ksh,
+ sh = detect.sh,
sieve = 'sieve',
siv = 'sieve',
- sig = function(path, bufnr)
- return require('vim.filetype.detect').sig(bufnr)
- end,
- sil = function(path, bufnr)
- return require('vim.filetype.detect').sil(bufnr)
- end,
+ sig = detect.sig,
+ sil = detect.sil,
sim = 'simula',
- ['s85'] = 'sinda',
+ s85 = 'sinda',
sin = 'sinda',
ssm = 'sisu',
sst = 'sisu',
@@ -969,7 +955,7 @@ local extension = {
spi = 'spyce',
spy = 'spyce',
tyc = 'sql',
- typ = 'sql',
+ typ = detect.typ,
pkb = 'sql',
tyb = 'sql',
pks = 'sql',
@@ -977,15 +963,18 @@ local extension = {
sqi = 'sqr',
sqr = 'sqr',
nut = 'squirrel',
- ['s28'] = 'srec',
- ['s37'] = 'srec',
+ s28 = 'srec',
+ s37 = 'srec',
srec = 'srec',
mot = 'srec',
- ['s19'] = 'srec',
+ s19 = 'srec',
srt = 'srt',
ssa = 'ssa',
ass = 'ssa',
st = 'st',
+ ipd = 'starlark',
+ star = 'starlark',
+ starlark = 'starlark',
imata = 'stata',
['do'] = 'stata',
mata = 'stata',
@@ -996,9 +985,15 @@ local extension = {
svelte = 'svelte',
svg = 'svg',
swift = 'swift',
+ swig = 'swig',
+ swg = 'swig',
svh = 'systemverilog',
sv = 'systemverilog',
+ cmm = 'trace32',
+ t32 = 'trace32',
+ td = 'tablegen',
tak = 'tak',
+ tal = 'tal',
task = 'taskedit',
tm = 'tcl',
tcl = 'tcl',
@@ -1014,9 +1009,7 @@ local extension = {
bbl = 'tex',
latex = 'tex',
sty = 'tex',
- cls = function(path, bufnr)
- return require('vim.filetype.detect').cls(bufnr)
- end,
+ cls = detect.cls,
texi = 'texinfo',
txi = 'texinfo',
texinfo = 'texinfo',
@@ -1035,20 +1028,31 @@ local extension = {
tsv = 'tsv',
tutor = 'tutor',
twig = 'twig',
- ts = function(path, bufnr)
- return M.getlines(bufnr, 1):find('<%?xml') and 'xml' or 'typescript'
- end,
+ ts = detect_line1('<%?xml', 'xml', 'typescript'),
mts = 'typescript',
cts = 'typescript',
tsx = 'typescriptreact',
uc = 'uc',
uit = 'uil',
uil = 'uil',
+ ungram = 'ungrammar',
+ u = 'unison',
+ uu = 'unison',
+ url = 'urlshortcut',
+ usd = 'usd',
+ usda = 'usd',
+ v = detect.v,
+ vsh = 'v',
+ vv = 'v',
+ ctl = 'vb',
+ dob = 'vb',
+ dsm = 'vb',
+ dsr = 'vb',
+ pag = 'vb',
sba = 'vb',
vb = 'vb',
- dsm = 'vb',
- ctl = 'vb',
vbs = 'vb',
+ vba = detect.vba,
vdf = 'vdf',
vdmpp = 'vdmpp',
vpp = 'vdmpp',
@@ -1058,7 +1062,6 @@ local extension = {
vr = 'vera',
vri = 'vera',
vrh = 'vera',
- v = 'verilog',
va = 'verilogams',
vams = 'verilogams',
vhdl = 'vhdl',
@@ -1069,17 +1072,18 @@ local extension = {
vbe = 'vhdl',
tape = 'vhs',
vim = 'vim',
- vba = 'vim',
mar = 'vmasm',
cm = 'voscm',
wrl = 'vrml',
vroom = 'vroom',
vue = 'vue',
- wat = 'wast',
- wast = 'wast',
+ wast = 'wat',
+ wat = 'wat',
wdl = 'wdl',
wm = 'webmacro',
+ wgsl = 'wgsl',
wbt = 'winbatch',
+ wit = 'wit',
wml = 'wml',
wsml = 'wsml',
ad = 'xdefaults',
@@ -1087,7 +1091,7 @@ local extension = {
xht = 'xhtml',
msc = 'xmath',
msf = 'xmath',
- ['psc1'] = 'xml',
+ psc1 = 'xml',
tpm = 'xml',
xliff = 'xml',
atom = 'xml',
@@ -1103,10 +1107,8 @@ local extension = {
csproj = 'xml',
wpl = 'xml',
xmi = 'xml',
- xpm = function(path, bufnr)
- return M.getlines(bufnr, 1):find('XPM2') and 'xpm2' or 'xpm'
- end,
- ['xpm2'] = 'xpm2',
+ xpm = detect_line1('XPM2', 'xpm2', 'xpm'),
+ xpm2 = 'xpm2',
xqy = 'xquery',
xqm = 'xquery',
xquery = 'xquery',
@@ -1121,191 +1123,80 @@ local extension = {
yxx = 'yacc',
yml = 'yaml',
yaml = 'yaml',
+ eyaml = 'yaml',
yang = 'yang',
- ['z8a'] = 'z8a',
+ yuck = 'yuck',
+ z8a = 'z8a',
zig = 'zig',
- zir = 'zir',
+ zon = 'zig',
zu = 'zimbu',
zut = 'zimbutempl',
+ zs = 'zserio',
zsh = 'zsh',
vala = 'vala',
- web = function(path, bufnr)
- return require('vim.filetype.detect').web(bufnr)
- end,
- pl = function(path, bufnr)
- return require('vim.filetype.detect').pl(bufnr)
- end,
- pp = function(path, bufnr)
- return require('vim.filetype.detect').pp(bufnr)
- end,
- i = function(path, bufnr)
- return require('vim.filetype.detect').progress_asm(bufnr)
- end,
- w = function(path, bufnr)
- return require('vim.filetype.detect').progress_cweb(bufnr)
- end,
- p = function(path, bufnr)
- return require('vim.filetype.detect').progress_pascal(bufnr)
- end,
- pro = function(path, bufnr)
- return require('vim.filetype.detect').proto(bufnr, 'idlang')
- end,
- patch = function(path, bufnr)
- return require('vim.filetype.detect').patch(bufnr)
- end,
- r = function(path, bufnr)
- return require('vim.filetype.detect').r(bufnr)
- end,
- rdf = function(path, bufnr)
- return require('vim.filetype.detect').redif(bufnr)
- end,
- rules = function(path, bufnr)
- return require('vim.filetype.detect').rules(path)
- end,
- sc = function(path, bufnr)
- return require('vim.filetype.detect').sc(bufnr)
- end,
- scd = function(path, bufnr)
- return require('vim.filetype.detect').scd(bufnr)
- end,
+ web = detect.web,
+ pl = detect.pl,
+ pp = detect.pp,
+ i = detect.i,
+ w = detect.progress_cweb,
+ p = detect.progress_pascal,
+ pro = detect_seq(detect.proto, 'idlang'),
+ patch = detect.patch,
+ r = detect.r,
+ rdf = detect.redif,
+ rules = detect.rules,
+ sc = detect.sc,
+ scd = detect.scd,
tcsh = function(path, bufnr)
- return require('vim.filetype.detect').shell(path, M.getlines(bufnr), 'tcsh')