diff options
| author | yilisharcs <yilisharcs@gmail.com> | 2025-10-27 14:19:16 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-27 10:19:16 -0700 |
| commit | b9451dfd4c06cac6c3e85eb069af51d3a8ace490 (patch) | |
| tree | 55ff6d9773167a8722ae99200fa04ae5495e5b7b /runtime/lua/vim/_extui | |
| parent | a943ea82f5ad4e92f74d50afea0e14b6d18c8f10 (diff) | |
fix(ui2): emit FileType event after setting default pager options #36315
Problem: Setting a filetype before configuring default options for ui2
buffers (pager, cmd, ...) prevents users from setting their own options.
Solution: Call nvim_set_option_value after defaults are set.
Closes #36314
Co-authored-by: Luuk van Baal <luukvbaal@gmail.com>
Diffstat (limited to 'runtime/lua/vim/_extui')
| -rw-r--r-- | runtime/lua/vim/_extui/shared.lua | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/runtime/lua/vim/_extui/shared.lua b/runtime/lua/vim/_extui/shared.lua index 208eb079ed..ed0932de69 100644 --- a/runtime/lua/vim/_extui/shared.lua +++ b/runtime/lua/vim/_extui/shared.lua @@ -65,13 +65,9 @@ function M.check_targets() end if setopt then - local name = { cmd = 'Cmd', dialog = 'Dialog', msg = 'Msg', pager = 'Pager' } - -- Fire a FileType autocommand with window context to let the user reconfigure local options. - -- First set 'eventignorewin' to avoid firing OptionSet and BufFilePost. - api.nvim_win_call(M.wins[type], function() - local ft = name[type]:sub(1, 1):lower() .. name[type]:sub(2) - api.nvim_set_option_value('filetype', ft, { scope = 'local' }) - local ignore = 'all' .. (type == 'pager' and ',-TextYankPost' or '') + -- Set options without firing OptionSet and BufFilePost. + vim._with({ win = M.wins[type], noautocmd = true }, function() + local ignore = 'all,-FileType' .. (type == 'pager' and ',-TextYankPost' or '') api.nvim_set_option_value('eventignorewin', ignore, { scope = 'local' }) api.nvim_set_option_value('wrap', true, { scope = 'local' }) api.nvim_set_option_value('linebreak', false, { scope = 'local' }) @@ -87,7 +83,11 @@ function M.check_targets() api.nvim_set_option_value('winhighlight', hl, { scope = 'local' }) end end) - api.nvim_buf_set_name(M.bufs[type], ('[%s]'):format(name[type])) + api.nvim_buf_set_name(M.bufs[type], ('[%s]'):format(type:sub(1, 1):upper() .. type:sub(2))) + -- Fire FileType with window context to let the user reconfigure local options. + vim._with({ win = M.wins[type] }, function() + api.nvim_set_option_value('filetype', type, { scope = 'local' }) + end) if type == 'pager' then -- Close pager with `q`, same as `checkhealth` |
