mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
docs(filetype): add note about prefering explicit lists over pattern
This commit is contained in:
parent
95e0289cb2
commit
37910f2703
@ -310,11 +310,16 @@ FILETYPE DETECTION *dev-vimpatch-filetype*
|
|||||||
Nvim's filetype detection behavior matches Vim, but is implemented as part of
|
Nvim's filetype detection behavior matches Vim, but is implemented as part of
|
||||||
|vim.filetype| (see $VIMRUNTIME/lua/vim/filetype.lua).
|
|vim.filetype| (see $VIMRUNTIME/lua/vim/filetype.lua).
|
||||||
|
|
||||||
|
Prefer explicit filenames/extensions over patterns, especially for case
|
||||||
|
insensitive matches (see https://github.com/neovim/neovim/pull/29800): >
|
||||||
|
"*[mM]akefile" regex -> "makefile", "Makefile" filenames
|
||||||
|
"*.js\c" regex -> "js", "jS", "Js", "jS" extensions
|
||||||
|
|
||||||
Pattern matching has several differences:
|
Pattern matching has several differences:
|
||||||
- It is done using explicit Lua patterns (without implicit anchoring) instead
|
- It is done using explicit Lua patterns (without implicit anchoring) instead
|
||||||
of Vim regexes: >
|
of Vim regexes: >
|
||||||
"*/debian/changelog" -> "/debian/changelog$"
|
"*/debian/changelog" -> "/debian/changelog$"
|
||||||
"*/bind/db.*" -> "/bind/db%."
|
"*/bind/db.*" -> "/bind/db%."
|
||||||
<
|
<
|
||||||
- Filetype patterns are grouped by their parent pattern to improve matching
|
- Filetype patterns are grouped by their parent pattern to improve matching
|
||||||
performance. For this to work properly, parent pattern should:
|
performance. For this to work properly, parent pattern should:
|
||||||
|
@ -1896,6 +1896,8 @@ local detect_xkb = starsetf('xkb', { parent = '/usr/' })
|
|||||||
--- Vim regexes are converted into explicit Lua patterns (without implicit anchoring):
|
--- Vim regexes are converted into explicit Lua patterns (without implicit anchoring):
|
||||||
--- '*/debian/changelog' -> '/debian/changelog$'
|
--- '*/debian/changelog' -> '/debian/changelog$'
|
||||||
--- '*/bind/db.*' -> '/bind/db%.'
|
--- '*/bind/db.*' -> '/bind/db%.'
|
||||||
|
---
|
||||||
|
--- See more info in `:h dev-vimpatch-filetype`.
|
||||||
--- @type table<string,vim.filetype.mapping>
|
--- @type table<string,vim.filetype.mapping>
|
||||||
local pattern = {
|
local pattern = {
|
||||||
-- BEGIN PATTERN
|
-- BEGIN PATTERN
|
||||||
|
Loading…
Reference in New Issue
Block a user