From 65a2dbe9aa96c26a798977940eab2a2589025337 Mon Sep 17 00:00:00 2001 From: Aditya Date: Mon, 4 Mar 2024 15:47:25 +0530 Subject: [PATCH] add notifications --- config/default.nix | 1 + config/keymaps.nix | 6 ++--- config/ui/nvim-notify.nix | 46 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 config/ui/nvim-notify.nix diff --git a/config/default.nix b/config/default.nix index f2c4773..afad99b 100644 --- a/config/default.nix +++ b/config/default.nix @@ -3,5 +3,6 @@ ./sets.nix ./dap/dap.nix ./keymaps.nix + ./ui/nvim-notify.nix ]; } diff --git a/config/keymaps.nix b/config/keymaps.nix index 4beb4cb..1b33ed4 100644 --- a/config/keymaps.nix +++ b/config/keymaps.nix @@ -245,7 +245,7 @@ key = "J"; action = "mzJ`z"; options = { - search = true; + silent = true; desc = "Allow cursor to stay in the same place after appending to current line"; }; } @@ -279,8 +279,8 @@ { mode = "n"; key = "k"; - action._raw = " - [[(v.vount > 1 ? 'm`' . v:count : 'g') . 'k']] + action.__raw = " + [[(v:count > 1 ? 'm`' . v:count : 'g') . 'k']] "; options = { expr = true; diff --git a/config/ui/nvim-notify.nix b/config/ui/nvim-notify.nix new file mode 100644 index 0000000..7b6770e --- /dev/null +++ b/config/ui/nvim-notify.nix @@ -0,0 +1,46 @@ +{ + plugins.notify = { + enable = true; + backgroundColour = "#000000"; + fps = 60; + render = "default"; + timeout = 500; + topDown = true; + }; + + keymaps = [ + { + mode = "n"; + key = "un"; + action = '' + lua require("notify").dismiss({ silent = true, pending = true}) + ''; + options = { + desc = "Dsimiss all notifications"; + }; + } + ]; + + extraConfigLua = '' + local notify = require("notify") + local filtered_message = { "No information available" } + + -- Override notify function to filter out messages + ---@diagnostic disable-next-line: duplicate-set-field + vim.notify = function(message, level, opts) + local merged_opts = vim/tbl_extend("force", { + on_open = function(win) + local buf = vim.api.nvim_win_get_buf(win) + vim.api.nvim_buf_set_option(buf, "filetype", "markdown") + end, + }, opts or {}) + + for _, msg in ipairs(filtered_message) do + if message == msg then + return + end + end + return notify(message, level, merged_opts) + end + ''; +}