mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 18:58:12 +00:00
perf(win): set options with eventignore and handle ft manually
This commit is contained in:
parent
8c43597f10
commit
80d9a894f9
1 changed files with 9 additions and 0 deletions
|
@ -262,6 +262,12 @@ function M:show()
|
|||
self.opts.on_win(self)
|
||||
end
|
||||
|
||||
local ft = vim.bo[self.buf].filetype
|
||||
local lang = ft and vim.treesitter.language.get_lang(ft)
|
||||
if lang and not vim.b[self.buf].ts_highlight and not pcall(vim.treesitter.start, self.buf, lang) and ft then
|
||||
vim.bo[self.buf].syntax = ft
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("VimResized", {
|
||||
group = self.augroup,
|
||||
callback = function()
|
||||
|
@ -370,6 +376,8 @@ end
|
|||
---@private
|
||||
---@param type "win" | "buf"
|
||||
function M:set_options(type)
|
||||
local ei = vim.o.eventignore
|
||||
vim.o.eventignore = "all"
|
||||
local opts = type == "win" and self.opts.wo or self.opts.bo
|
||||
---@diagnostic disable-next-line: no-unknown
|
||||
for k, v in pairs(opts or {}) do
|
||||
|
@ -382,6 +390,7 @@ function M:set_options(type)
|
|||
Snacks.notify.error("Error setting option `" .. k .. "=" .. v .. "`\n\n" .. err, { title = "Snacks Float" })
|
||||
end
|
||||
end
|
||||
vim.o.eventignore = ei
|
||||
end
|
||||
|
||||
function M:buf_valid()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue