mirror of
https://mzte.de/git/LordMZTE/dotfiles.git
synced 2024-09-27 20:48:53 +02:00
make mzte-nv notifs use mini view
This commit is contained in:
parent
f709ea6ffa
commit
cc0ad9602d
3 changed files with 23 additions and 25 deletions
|
@ -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
|
||||
:vim.lsp.util.stylize_markdown
|
||||
: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}
|
||||
:lsp {:override (collect [_ o (ipairs overrides)] (values o true))}
|
||||
:routes [;; Redirect DAP messages to mini view
|
||||
{:filter {:event :notify
|
||||
:cond #(and $1.opts (= $.opts.title :DAP))}
|
||||
:view :mini}]
|
||||
{:filter {:event :notify :cond show-mini?} :view :mini}]
|
||||
:presets {:lsp_doc_border true}})
|
||||
|
||||
;; Shift-Enter to redirect cmdline
|
||||
|
|
|
@ -39,10 +39,12 @@ pub const std_options = struct {
|
|||
.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();
|
||||
|
||||
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{};
|
||||
_ = 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 {
|
||||
_ = l;
|
||||
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(
|
||||
"MZTE-NV v{s} Initialized on NVIM v{}.{}.{}{s}",
|
||||
.{ version, major, minor, patch, prerelease },
|
||||
"MZTE-NV v{s} Initialized on NVIM v{s}",
|
||||
.{ version, nvim.longVersion },
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -42,3 +42,12 @@ fn lFindInPath(l: *c.lua_State) !c_int {
|
|||
c.lua_pushnil(l);
|
||||
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