mirror of
https://mzte.de/git/LordMZTE/dotfiles.git
synced 2024-06-26 15:18:41 +02:00
make mzte-nv notifs use mini view
This commit is contained in:
parent
f709ea6ffa
commit
cc0ad9602d
|
@ -1,15 +1,19 @@
|
||||||
(local noice (require :noice))
|
(local (mztenv noice) (values (require :mzte_nv) (require :noice)))
|
||||||
|
|
||||||
(local overrides [:vim.lsp.util.convert_input_to_markdown_lines
|
(local overrides [:vim.lsp.util.convert_input_to_markdown_lines
|
||||||
:vim.lsp.util.stylize_markdown
|
:vim.lsp.util.stylize_markdown
|
||||||
:cmp.entry.get_documentation])
|
:cmp.entry.get_documentation])
|
||||||
|
|
||||||
|
(fn show-mini? [notif]
|
||||||
|
(and notif.opts (or ;; DAP notifs
|
||||||
|
(= notif.opts.title :DAP)
|
||||||
|
;; MZTE-NV notifications
|
||||||
|
notif.opts.mzte_nv_mini)))
|
||||||
|
|
||||||
(noice.setup {:messages {:view :mini}
|
(noice.setup {:messages {:view :mini}
|
||||||
:lsp {:override (collect [_ o (ipairs overrides)] (values o true))}
|
:lsp {:override (collect [_ o (ipairs overrides)] (values o true))}
|
||||||
:routes [;; Redirect DAP messages to mini view
|
:routes [;; Redirect DAP messages to mini view
|
||||||
{:filter {:event :notify
|
{:filter {:event :notify :cond show-mini?} :view :mini}]
|
||||||
:cond #(and $1.opts (= $.opts.title :DAP))}
|
|
||||||
:view :mini}]
|
|
||||||
:presets {:lsp_doc_border true}})
|
:presets {:lsp_doc_border true}})
|
||||||
|
|
||||||
;; Shift-Enter to redirect cmdline
|
;; Shift-Enter to redirect cmdline
|
||||||
|
|
|
@ -39,10 +39,12 @@ pub const std_options = struct {
|
||||||
.err => nvim.LOGLVL_ERR,
|
.err => nvim.LOGLVL_ERR,
|
||||||
};
|
};
|
||||||
|
|
||||||
var dict = znvim.Dictionary{.alloc = std.heap.c_allocator};
|
var dict = znvim.Dictionary{ .alloc = std.heap.c_allocator };
|
||||||
defer dict.deinit();
|
defer dict.deinit();
|
||||||
|
|
||||||
dict.push(@constCast("title"), znvim.nvimObject(@as([]u8, title))) catch return;
|
dict.push(@constCast("title"), znvim.nvimObject(@as([]u8, title))) catch return;
|
||||||
|
// noice notficitaions recognize this and show in the mini view instead of notifs
|
||||||
|
dict.push(@constCast("mzte_nv_mini"), comptime znvim.nvimObject(true)) catch return;
|
||||||
|
|
||||||
var e = znvim.Error{};
|
var e = znvim.Error{};
|
||||||
_ = nvim.nvim_notify(
|
_ = nvim.nvim_notify(
|
||||||
|
@ -70,29 +72,12 @@ export fn luaopen_mzte_nv(l_: ?*c.lua_State) c_int {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lOnInit(l: *c.lua_State) !c_int {
|
fn lOnInit(l: *c.lua_State) !c_int {
|
||||||
|
_ = l;
|
||||||
try @import("options.zig").initOptions();
|
try @import("options.zig").initOptions();
|
||||||
|
|
||||||
c.lua_getglobal(l, "vim"); // 1
|
|
||||||
c.lua_getfield(l, 1, "version");
|
|
||||||
c.lua_call(l, 0, 1); // 2
|
|
||||||
|
|
||||||
c.lua_getfield(l, 2, "major");
|
|
||||||
const major = c.lua_tointeger(l, -1);
|
|
||||||
|
|
||||||
c.lua_getfield(l, 2, "minor");
|
|
||||||
const minor = c.lua_tointeger(l, -1);
|
|
||||||
|
|
||||||
c.lua_getfield(l, 2, "patch");
|
|
||||||
const patch = c.lua_tointeger(l, -1);
|
|
||||||
|
|
||||||
c.lua_getfield(l, 2, "prerelease");
|
|
||||||
const prerelease = if (c.lua_toboolean(l, -1) != 0) " (prerelease)" else "";
|
|
||||||
|
|
||||||
c.lua_settop(l, 1);
|
|
||||||
|
|
||||||
std.log.info(
|
std.log.info(
|
||||||
"MZTE-NV v{s} Initialized on NVIM v{}.{}.{}{s}",
|
"MZTE-NV v{s} Initialized on NVIM v{s}",
|
||||||
.{ version, major, minor, patch, prerelease },
|
.{ version, nvim.longVersion },
|
||||||
);
|
);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,3 +42,12 @@ fn lFindInPath(l: *c.lua_State) !c_int {
|
||||||
c.lua_pushnil(l);
|
c.lua_pushnil(l);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Starts if arg 1 starts with arg 2
|
||||||
|
fn lStartsWith(l: *c.lua_State) !c_int {
|
||||||
|
const haystack = ffi.luaCheckstring(l, 1);
|
||||||
|
const needle = ffi.luaCheckstring(l, 1);
|
||||||
|
|
||||||
|
c.lua_pushbool(std.mem.startsWith(u8, haystack, needle));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue