Compare commits

...

2 commits

Author SHA1 Message Date
LordMZTE e1316abe75
mzte-nv: enable inlay hints 2024-01-18 18:23:20 +01:00
LordMZTE 8b991b6728
zls: enable build on save 2024-01-18 18:04:00 +01:00
5 changed files with 50 additions and 4 deletions

View file

@ -1,4 +0,0 @@
{
"enable_snippets": true,
"warn_style": true
}

3
.config/zls.json.cgt Normal file
View file

@ -0,0 +1,3 @@
;<! tmpl:setPostProcessor(opt.fennelToJSON) !>
;; vim: ft=fennel
{:warn_style true :enable_build_on_save true :enable_autofix true}

View file

@ -1,3 +1,4 @@
(local mztenv (require :mzte_nv))
(local lspc (require :lspconfig))
(local lsp-configs (require :lspconfig.configs))
@ -5,6 +6,10 @@
(var args args)
(when (not args)
(set args {}))
(tset args :on_attach (if args.on_attach
`(fn [client# bufnr#] (mztenv.lsp.onAttach client# bufnr#)
(,args.on_attach client# bufnr#))
`mztenv.lsp.onAttach))
(tset args :capabilities `caps)
`((. lspc ,conf :setup) ,args))

View file

@ -13,6 +13,7 @@ const modules = struct {
const cpbuf = @import("modules/cpbuf.zig");
const fennel = @import("modules/fennel.zig");
const jdtls = @import("modules/jdtls.zig");
const lsp = @import("modules/lsp.zig");
const telescope = @import("modules/telescope.zig");
const tsn_actions = @import("modules/tsn_actions.zig");
const utils = @import("modules/utils.zig");
@ -87,6 +88,7 @@ export fn luaopen_mzte_nv(l_: ?*c.lua_State) c_int {
.cpbuf = modules.cpbuf,
.fennel = modules.fennel,
.jdtls = modules.jdtls,
.lsp = modules.lsp,
.telescope = modules.telescope,
.tsn_actions = modules.tsn_actions,
.utils = modules.utils,

View file

@ -0,0 +1,40 @@
//! Module for nvim-lsp related utilities
const std = @import("std");
const ser = @import("../ser.zig");
const ffi = @import("../ffi.zig");
const c = ffi.c;
pub fn luaPush(l: *c.lua_State) void {
ser.luaPushAny(l, .{
.onAttach = ffi.luaFunc(lOnAttach),
});
}
fn lOnAttach(l: *c.lua_State) !c_int {
c.luaL_checkany(l, 1);
const bufnr = c.luaL_checknumber(l, 2);
const has_inlay_hints = hints: {
c.lua_getfield(l, 1, "server_capabilities");
defer c.lua_pop(l, 1);
if (c.lua_isnil(l, -1)) break :hints false;
c.lua_getfield(l, -1, "inlayHintProvider");
defer c.lua_pop(l, 1);
break :hints c.lua_toboolean(l, -1) != 0;
};
if (has_inlay_hints) {
c.lua_getglobal(l, "vim");
defer c.lua_pop(l, 1);
c.lua_getfield(l, -1, "lsp");
defer c.lua_pop(l, 1);
c.lua_getfield(l, -1, "inlay_hint");
defer c.lua_pop(l, 1);
c.lua_getfield(l, -1, "enable");
c.lua_pushnumber(l, bufnr);
c.lua_pushboolean(l, 1);
c.lua_call(l, 2, 0);
}
return 0;
}