mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
fix(filetype): run filetype.match on StdinReadPost (#20070)
Problem: filetype detection does not run on piped input Solution: add `StdinReadPost` to main filetype.lua autocommand Rationale: legacy filetype detection checked contents by sourcing `scripts.vim` in separate autocommands, including on `StdinReadPost`. For Lua filetype detection, this was moved into the main autocommand, with bundled `scripts.vim` gated behind `g:do_legacy_filetype` (i.e., only user `scripts.vim` are sourced for compatibility by default). Adding `StdinReadPost` to the main autocommand again runs content checks on piped input without requiring code duplication and low-payoff refactoring.
This commit is contained in:
@ -6,7 +6,7 @@ vim.g.did_load_filetypes = 1
|
||||
|
||||
vim.api.nvim_create_augroup('filetypedetect', { clear = false })
|
||||
|
||||
vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, {
|
||||
vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile', 'StdinReadPost' }, {
|
||||
group = 'filetypedetect',
|
||||
callback = function(args)
|
||||
local ft, on_detect = vim.filetype.match({ filename = args.match, buf = args.buf })
|
||||
|
Reference in New Issue
Block a user