aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim
diff options
context:
space:
mode:
authorGregory Anders <greg@gpanders.com>2023-08-24 12:56:24 -0500
committerGregory Anders <greg@gpanders.com>2023-08-24 13:04:04 -0500
commitaf38b46a2574f59358bc3bf54dd7c34b5c0f396d (patch)
tree10f4a754d81f2030032a1e4447975e5ed10181a2 /runtime/lua/vim
parent020d1f626a3fbda84b84b2f57e8a85662a792a1a (diff)
downloadrneovim-af38b46a2574f59358bc3bf54dd7c34b5c0f396d.tar.gz
rneovim-af38b46a2574f59358bc3bf54dd7c34b5c0f396d.tar.bz2
rneovim-af38b46a2574f59358bc3bf54dd7c34b5c0f396d.zip
fix(filetype): return on_detect function when matching by file contents
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r--runtime/lua/vim/filetype.lua15
1 files changed, 10 insertions, 5 deletions
diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua
index a05c1075eb..193c9b0199 100644
--- a/runtime/lua/vim/filetype.lua
+++ b/runtime/lua/vim/filetype.lua
@@ -2377,11 +2377,16 @@ function M.match(args)
-- If the function tries to use the filename that is nil then it will fail,
-- but this enables checks which do not need a filename to still work.
local ok
- ok, ft = pcall(require('vim.filetype.detect').match_contents, contents, name, function(ext)
- return dispatch(extension[ext], name, bufnr)
- end)
- if ok and ft then
- return ft
+ ok, ft, on_detect = pcall(
+ require('vim.filetype.detect').match_contents,
+ contents,
+ name,
+ function(ext)
+ return dispatch(extension[ext], name, bufnr)
+ end
+ )
+ if ok then
+ return ft, on_detect
end
end
end