aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/nvim/.config
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2022-11-16 18:48:21 -0600
committerToby Vincent <tobyv13@gmail.com>2022-11-16 18:48:21 -0600
commit7e1efd604e47be566e9702fe6214ab970b2bcd5f (patch)
treed6ea95ed72104e58ffe59f638984c4f5aba6c18f /nvim/.config
parent947bbff8c7c0b5b81cae77e20f812fd58b0a2ad1 (diff)
feat(nvim): add plenary.log to vim.notify
Diffstat (limited to 'nvim/.config')
-rw-r--r--nvim/.config/nvim/lua/tobyvin.lua17
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/notify.lua10
2 files changed, 23 insertions, 4 deletions
diff --git a/nvim/.config/nvim/lua/tobyvin.lua b/nvim/.config/nvim/lua/tobyvin.lua
index 904abdd..4b97462 100644
--- a/nvim/.config/nvim/lua/tobyvin.lua
+++ b/nvim/.config/nvim/lua/tobyvin.lua
@@ -1,3 +1,20 @@
+local log = require("plenary.log").new({ plugin = "notify" })
+for k, v in pairs(vim.log.levels) do
+ log[v + 1] = log[k:lower()]
+end
+
+setmetatable(log, {
+ __call = function(t, msg, level, opts)
+ pcall(t[level], msg, level, opts)
+ vim.api.nvim_exec_autocmds("User", {
+ pattern = "Notify",
+ data = { msg, level, opts },
+ })
+ end,
+})
+
+vim.notify = log
+
local M = {
options = require("tobyvin.options"),
autocmds = require("tobyvin.autocmds"),
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/notify.lua b/nvim/.config/nvim/lua/tobyvin/plugins/notify.lua
index dc4155a..2292f45 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/notify.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/notify.lua
@@ -1,4 +1,3 @@
-local utils = require("tobyvin.utils")
local M = {}
M.setup = function()
@@ -12,13 +11,16 @@ M.setup = function()
background_colour = "#" .. vim.api.nvim_get_hl_by_name("Pmenu", true).background,
})
- vim.notify = notify
+ vim.api.nvim_create_autocmd("User", {
+ pattern = "Notify",
+ callback = function(args)
+ notify.notify(unpack(args.data))
+ end,
+ })
local telescope_ok, telescope = pcall(require, "telescope")
if telescope_ok then
telescope.load_extension("notify")
-
- utils.keymap.group("n", "<leader>f", { desc = "find" })
vim.keymap.set("n", "<leader>fn", telescope.extensions.notify.notify, { desc = "notifications" })
end
end