nvim_runtime_lua

vim.filetype.detect

Methods105

function M.app(path, bufnr) -> any

Erlang Application Resource Files (*.app.src is matched by extension) See: https://erlang.org/doc/system/applications

function M.as(_, bufnr) -> any

This function checks for Kawasaki robots AS file or atlas file type.

function M.asm(path, bufnr) -> any

This function checks for the kind of assembly that is wanted by the user, or can be detected from the beginning of the file.

function M.mac(path, bufnr) -> any
function M.asm_syntax(_, bufnr) -> nil | string

Checks the first lines for a asmsyntax=foo override. Only whitespace characters can be present immediately before or after this statement.

function M.asp(_, bufnr) -> any

Active Server Pages (with Perl or Visual Basic Script)

function M.bas(_, bufnr) -> any

See frm() for Visual Basic form file detection

function M.bindzone(_, bufnr) -> "bindzone" | nil
function M.cfg(_, bufnr) -> string
function M.change(_, bufnr) -> "ch" | "change" | "chill"

This function checks if one of the first ten lines start with a '@'. In that case it is probably a change file. If the first line starts with # or ! it's probably a ch file. If a line has "main", "include", "//" or "/*" it's probably ch. Otherwise CHILL is assumed.

function M.changelog(_, bufnr) -> "debchangelog" | "changelog"
function M.cl(_, bufnr) -> "opencl" | "lisp"
function M.class(_, bufnr) -> "stata" | nil
function M.cls(_, bufnr) -> any

Determines whether a *.cls file is ObjectScript, TeX, Rexx, Visual Basic, or Smalltalk.

function M.cmd(_, bufnr) -> "lnk" | "rexx" | "dosbatch"

.cmd is close to a Batch file, but on OS/2 Rexx files and TI linker command files also use .cmd. lnk: /* comment */, // comment, and --linker-option=value rexx: /* comment */, -- comment

function M.conf(path, bufnr) -> "conf" | nil
function M.control(_, bufnr) -> "debcontrol" | "autopkgtest" | nil

Debian Control

function M.copyright(_, bufnr) -> "debcopyright" | nil

Debian Copyright

function M.cpp(_, _) -> "cynlib"
function M.csh(path, bufnr) -> nil | string
function M.dat(path, bufnr) -> any
function M.decl(_, bufnr) -> "sgmldecl" | nil
function M.dep3patch(path, bufnr) -> "dep3patch" | nil

This function is called for all files under /debian/patches/, make sure not to non-dep3patch files, such as README and other text files.

function M.dtrace(_, bufnr) -> "d" | nil | "dtrace"
function M.def(_, bufnr) -> ...any
function M.dsp(path, bufnr) -> any
function M.e(_, bufnr) -> any
function M.edn(_, bufnr) -> "edif" | "clojure"
function M.ent(_, bufnr) -> "cl" | "dtd"

This function checks for valid cl syntax in the first five lines. Look for either an opening comment, '#', or a block start, '{'. If not found, assume SGML.

function M.euphoria(_, _) -> any
function M.ex(_, bufnr) -> any
function M.f(_, bufnr) -> any

Distinguish between Forth and Fortran

function M.foam(_, bufnr) -> "foam" | nil

This function checks the first 15 lines for appearance of 'FoamFile' and then 'object' in a following line. In that case, it's probably an OpenFOAM file

function M.frm(_, bufnr) -> any
function M.fvwm_v1(_, _) -> ..."fvwm"
function M.fvwm_v2(_, _) -> ..."fvwm"
function M.fs(_, bufnr) -> any

Distinguish between Forth and F#

function M.git(_, bufnr) -> "git" | nil
function M.header(_, bufnr) -> "objc" | "objcpp" | "c" | "ch" | "cpp"
function M.haredoc(path, _) -> "haredoc" | nil
function M.html(_, bufnr) -> "htmlangular" | "xhtml" | "htmldjango" | "superhtml" | "html"
function M.hw(_, bufnr) -> "php" | "virata"

Virata Config Script File or Drupal module

function M.i(path, bufnr) -> any

This function checks for an assembly comment or a SWIG keyword or verbatim block in the first 50 lines. If not found, assume Progress.

function M.idl(_, bufnr) -> "msidl" | "idl"
function M.inc(path, bufnr) -> ...any
function M.inp(_, bufnr) -> "tex" | "abaqus" | "trasys" | nil
function M.install(path, bufnr) -> ...nil | string | "php"
function M.int(_, bufnr) -> any
function M.log(path, _) -> "upstreamlog" | "upstreaminstalllog" | "usserverlog" | "usw2kagtlog" | nil

Innovation Data Processing (refactor of filetype.vim since the patterns are case-insensitive)

function M.ll(_, bufnr) -> "llvm" | "lex" | "lifelines"
function M.lpc(_, bufnr) -> "lpc" | "c"
function M.lsl(_, bufnr) -> any
function M.m(_, bufnr) -> any
function M.m4(path, bufnr) -> "htmlm4" | "fvwm2m4" | "config" | "m4"

For files ending in *.m4, distinguish: – *.html.m4 files

  • fvwm2rc.m4 files
  • – files in the Autoconf M4 dialect – files in POSIX M4

function M.make(path, bufnr) -> "make"

Check if it is a Microsoft Makefile

function M.markdown(_, _) -> any
function M.mc(_, bufnr) -> "m4" | "msmessages"

Rely on the file to start with a comment. MS message text files use ';', Sendmail files use '#' or 'dnl'

function M.me(path: string) -> nil | string
function M.mm(_, bufnr) -> any
function M.mms(_, bufnr) -> "mmix" | "make"
function M.mod(path, bufnr) -> ...any

Determine if *.mod is ABB RAPID, LambdaProlog, Modula-2, Modsim III or go.mod

function M.mp(_, _) -> ..."mp"

Determine if *.mod is ABB RAPID, LambdaProlog, Modula-2, Modsim III or go.mod

function M.news(_, bufnr) -> "debchangelog" | nil
function M.nroff(_, bufnr) -> "nroff" | nil

This function checks if one of the first five lines start with a typical nroff pattern in man files. In that case it is probably an nroff file.

function M.patch(_, bufnr) -> "gitsendemail" | "diff"
function M.perl(path, bufnr) -> "perl" | nil

If the file has an extension of 't' and is in a directory 't' or 'xt' then it is almost certainly a Perl test file. If the first line starts with '#' and contains 'perl' it's probably a Perl file. (Slow test) If a file contains a 'use' statement then it is almost certainly a Perl file.

function M.pl(_, bufnr) -> any
function M.pm(_, bufnr) -> "xpm2" | "xpm" | "perl"
function M.pp(_, bufnr) -> any
function M.prg(_, bufnr) -> any
function M.printcap(ptcap_type) -> ..."ptcap" | nil
function M.progress_cweb(_, bufnr) -> any
function M.progress_pascal(_, bufnr) -> any

This function checks for valid Pascal syntax in the first 10 lines. Look for either an opening comment or a program start. If not found, assume Progress.

function M.proto(_, bufnr) -> "c" | "cpp" | "prolog" | nil

Distinguish between "default", Prolog and Cproto prototype file.

function M.psf(_, bufnr) -> "psf" | nil

Software Distributor Product Specification File (POSIX 1387.2-1995)

function M.r(_, bufnr) -> any
function M.redif(_, bufnr) -> "redif" | nil
function M.reg(_, bufnr) -> "registry" | nil
function M.rul(_, bufnr) -> "ishd" | "diva"

Diva (with Skill) or InstallShield

function M.rules(path) -> "udevrules" | "conf" | "javascript" | "hog"
function M.sig(_, bufnr) -> any

LambdaProlog and Standard ML signature files

function M.sa(_, bufnr) -> "tiasm" | "sather"
function M.sc(_, bufnr) -> "supercollider" | "scala"

This function checks the first 25 lines of file extension "sc" to resolve detection between scala and SuperCollider

function M.scd(_, bufnr) -> "scdoc" | "supercollider"

This function checks the first line of file extension "scd" to resolve detection between scdoc and SuperCollider

function M.sgml(_, bufnr) -> ..."sgmllnx" | "docbk" | "sgml"
function M.shell(path: string, contents: string[], name: nil | string) -> nil | string

For shell-like file types, check for an "exec" command hidden in a comment, as used for Tcl.

function M.sil(_, bufnr) -> "sile" | "sil"

Swift Intermediate Language or SILE

function M.smi(_, bufnr) -> "smil" | "mib"

SMIL or SNMP MIB file

function M.sql(_, _) -> any
function M.src(_, bufnr) -> any

Determine if a *.src file is Kuka Robot Language

function M.sys(_, bufnr) -> any
function M.tex(path, bufnr) -> "context" | "tex" | "plaintex"

Choose context, plaintex, or tex (LaTeX) based on these rules:

  1. Check the first line of the file for "%&<format>".
  2. Check the first 1000 non-comment lines for LaTeX or ConTeXt keywords.
  3. Default to "plain" or to g:tex_flavor, can be set in user's vimrc.
function M.tf(_, bufnr) -> any

Determine if a *.tf file is TF (TinyFugue) mud client or terraform

function M.ttl(_, bufnr) -> "turtle" | "teraterm"
function M.txt(_, bufnr) -> "text" | nil
function M.typ(_, bufnr) -> any
function M.uci(_, bufnr) -> "uci" | nil
function M.v(_, bufnr) -> any

Determine if a .v file is Verilog, V, or Coq

function M.vba(_, bufnr) -> "vim" | "vb"
function M.web(_, bufnr) -> "web" | "winbatch"

WEB (*.web is also used for Winbatch: Guess, based on expecting "%" comment lines in a WEB file).

function M.xfree86_v3(_, _) -> ..."xf86conf"

XFree86 config

function M.xfree86_v4(_, _) -> ..."xf86conf"

XFree86 config

function M.xml(_, bufnr) -> ..."docbk" | "xbl" | "xml"
function M.y(_, bufnr) -> "yacc" | "racc"
function M.match_contents(contents: string[], path: string, dispatch_extension: fun(name: string) -> ...nil | string) -> (nil | string, fun(b: integer) -> nil | nil)

Fields4