refactor(nvim): improve file interception func passing logic

This commit is contained in:
Price Hiller 2024-02-04 13:24:06 -06:00
parent 86ee347e45
commit e86b68b7a6
Signed by: Price
SSH Key Fingerprint: SHA256:Y4S9ZzYphRn1W1kbJerJFO6GGsfu9O70VaBSxJO7dF8

View File

@ -72,11 +72,11 @@ M.setup = function()
vim.notify("Intercept file open set to " .. intercept_state, vim.log.levels.INFO, {
title = "Intercept File Open",
})
end, { desc = "Toggles intercepting BufNew to open files in custom programs" })
end, { desc = "Toggles intercepting BufEnter to open files in custom programs" })
-- NOTE: Add "BufReadPre" to the autocmd events to also intercept files given on the command line, e.g.
-- `nvim myfile.txt`
vim.api.nvim_create_autocmd({ "BufNew" }, {
vim.api.nvim_create_autocmd({ "BufEnter" }, {
group = augroup,
callback = function(args)
---@type string
@ -102,17 +102,11 @@ M.setup = function()
end
local extension_callbacks = {
["pdf"] = function(buf, fpath, fname)
open_mime(buf, fpath, fname)
end,
["pdf"] = open_mime,
["djvu"] = "pdf",
["png"] = function(buf, fpath, fname)
open_mime(buf, fpath, fname)
end,
["png"] = open_mime,
["jpg"] = "png",
["mp4"] = function(buf, fpath, fname)
open_mime(buf, fpath, fname)
end,
["mp4"] = open_mime,
["gif"] = "mp4",
}