diff --git a/mzte-nv/conf/lua/lsp.fnl b/mzte-nv/conf/lua/lsp.fnl index 611c378..3aedcb5 100644 --- a/mzte-nv/conf/lua/lsp.fnl +++ b/mzte-nv/conf/lua/lsp.fnl @@ -2,7 +2,9 @@ (fn on-lsp-attach [args] (local buf args.buf) (local client (vim.lsp.get_client_by_id args.data.client_id)) - (when client.server_capabilities.documentHighlightProvider + (when (and client.server_capabilities.documentHighlightProvider + (not vim.b.mzte_reg_hl_aucmd)) + (set vim.b.mzte_reg_hl_aucmd true) ;; Symbol highlighting (vim.api.nvim_create_autocmd :CursorHold {:buffer buf diff --git a/mzte-nv/conf/lua/pluginconf/p-catppuccin.fnl b/mzte-nv/conf/lua/pluginconf/p-catppuccin.fnl index d91f026..f067a17 100644 --- a/mzte-nv/conf/lua/pluginconf/p-catppuccin.fnl +++ b/mzte-nv/conf/lua/pluginconf/p-catppuccin.fnl @@ -1,6 +1,12 @@ -(local catppuccin (require :catppuccin)) +(print "catppuccin config") +(local (mztenv catppuccin palettes) + (values (require :mzte_nv) (require :catppuccin) + (require :catppuccin.palettes))) -(catppuccin.setup {;; Enable all relevant integrations +(local flavour :mocha) + +(catppuccin.setup {: flavour + ;; Enable all relevant integrations :integrations {:aerial true :harpoon true :gitsigns true @@ -17,3 +23,11 @@ :telescope true}}) (vim.cmd.colorscheme :catppuccin) + +;; Optimize this by saving the palette table +(let [get-palette palettes.get_palette] + (set mztenv.reg.catppuccin-palette (get-palette)) + (set palettes.get_palette + (fn [flav] + (if (or (not flav) (= flav flavour)) mztenv.reg.catppuccin-palette + (get-palette flav))))) diff --git a/mzte-nv/conf/lua/pluginconf/p-lightbulb.fnl b/mzte-nv/conf/lua/pluginconf/p-lightbulb.fnl new file mode 100644 index 0000000..0a47739 --- /dev/null +++ b/mzte-nv/conf/lua/pluginconf/p-lightbulb.fnl @@ -0,0 +1,23 @@ +(local lightbulb (require :nvim-lightbulb)) + +(local ignored-clients [:null-ls]) + +(lightbulb.setup {:ignore ignored-clients + ;; No gutter sign + :sign {:enabled false} + ;; Status bar text + :status_text {:enabled true :text "󱐌"}}) + +;; Create update autocmd on LSP attach +(fn on-lsp-attach [args] + (let [buf args.buf + client (vim.lsp.get_client_by_id args.data.client_id)] + (when (and client.server_capabilities.codeActionProvider + (not vim.b.mzte_reg_lighbulb_aucmd) + (not (vim.list_contains ignored-clients client.name))) + (set vim.b.mzte_reg_lighbulb_aucmd true) + (vim.api.nvim_create_autocmd :CursorHold + {:buffer buf + :callback lightbulb.update_lightbulb})))) + +(vim.api.nvim_create_autocmd :LspAttach {:callback on-lsp-attach}) diff --git a/mzte-nv/conf/lua/pluginconf/p-line.fnl b/mzte-nv/conf/lua/pluginconf/p-line.fnl index 46d6b80..2cf0134 100644 --- a/mzte-nv/conf/lua/pluginconf/p-line.fnl +++ b/mzte-nv/conf/lua/pluginconf/p-line.fnl @@ -1,4 +1,5 @@ -(local lline (require :lualine)) +(local (mztenv lline lightbulb) + (values (require :mzte_nv) (require :lualine) (require :nvim-lightbulb))) (lline.setup {:options {:theme :catppuccin} :sections {:lualine_b [:filename :diff] @@ -6,5 +7,7 @@ :tabline {:lualine_a [{1 :tabs ;; show file name :mode 1}] - :lualine_x [:searchcount] + :lualine_x [:searchcount + {1 #(lightbulb.get_status_text) + :color {:fg mztenv.reg.catppuccin-palette.teal}}] :lualine_y [:branch]}}) diff --git a/mzte-nv/conf/lua/plugins.fnl b/mzte-nv/conf/lua/plugins.fnl index 279da5c..1c319b6 100644 --- a/mzte-nv/conf/lua/plugins.fnl +++ b/mzte-nv/conf/lua/plugins.fnl @@ -38,7 +38,8 @@ (use {1 :lewis6991/gitsigns.nvim :config #((. (require :gitsigns) :setup) {})}) (use :dag/vim-fish) - (use/pconf use :nvim-lualine/lualine.nvim :line) + (use/pconf use :nvim-lualine/lualine.nvim :line + {:after :catppuccin :requires :lightbulb}) (use/pconf use :nvim-treesitter/nvim-treesitter :treesitter) (use/pconf use :nvim-tree/nvim-web-devicons :devicons) (use/pconf use :nvim-tree/nvim-tree.lua :nvimtree @@ -72,6 +73,7 @@ {:requires :jose-elias-alvarez/null-ls.nvim}) (use :nvim-treesitter/playground) (use {1 :Olical/conjure :setup (pconf :conjure)}) + (use/pconf use :kosayoda/nvim-lightbulb :lightbulb) (cmp-plugins use)) (packer.startup init) diff --git a/mzte-nv/src/main.zig b/mzte-nv/src/main.zig index 5c17cfb..51da461 100644 --- a/mzte-nv/src/main.zig +++ b/mzte-nv/src/main.zig @@ -60,10 +60,27 @@ pub const std_options = struct { pub const log_level = .debug; }; +const reg_key = "mzte-nv-reg"; + export fn luaopen_mzte_nv(l_: ?*c.lua_State) c_int { const l = l_.?; ser.luaPushAny(l, .{ + .reg = struct { + pub fn luaPush(lua: *c.lua_State) void { + c.lua_getfield(lua, c.LUA_REGISTRYINDEX, reg_key); + + // registry uninitialized + if (c.lua_isnil(lua, -1)) { + c.lua_pop(lua, 1); + c.lua_newtable(lua); + c.lua_pushvalue(lua, -1); + c.lua_setfield(lua, c.LUA_REGISTRYINDEX, reg_key); + } + } + }, + .onInit = ffi.luaFunc(lOnInit), + .cmp = modules.cmp, .compile = modules.compile, .cpbuf = modules.cpbuf, @@ -80,7 +97,7 @@ fn lOnInit(l: *c.lua_State) !c_int { try @import("options.zig").initOptions(); std.log.info( - "MZTE-NV v{s} Initialized on NVIM v{s}", + "MZTE-NV v{s} Initialized on {s}", .{ version, nvim.longVersion }, ); return 0;