From 80db042c042fb1d9249e83530bbbda88c61f903b Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Sat, 1 Feb 2025 14:30:14 -0800 Subject: [PATCH] feat: fennelize lsp_progress nvim --- fnl/plugins/lsp-progress.fnl | 64 ++++++++++++++++++++++++ lua/plugins/lsp-progress.lua | 95 +++++++++++++++++------------------- 2 files changed, 109 insertions(+), 50 deletions(-) create mode 100644 fnl/plugins/lsp-progress.fnl diff --git a/fnl/plugins/lsp-progress.fnl b/fnl/plugins/lsp-progress.fnl new file mode 100644 index 0000000..a0fd6fc --- /dev/null +++ b/fnl/plugins/lsp-progress.fnl @@ -0,0 +1,64 @@ +;; Adds LSP information to Lualine + +{1 :lsp-progress.nvim + :after (fn [] + ((. (require :lsp-progress) :setup) {:client_format (fn [client-name + spinner + series-messages] + (when (= (length series-messages) + 0) + (lua "return nil")) + {:body (.. spinner + " " + (table.concat series-messages + ", ")) + :name client-name}) + :format (fn [client-messages] + (fn stringify [name + msg] + (or (and msg + (string.format "%s %s" + name + msg)) + name)) + + (local sign "󰆧") + (local lsp-clients + (vim.lsp.get_clients)) + (local messages-map {}) + (each [_ climsg (ipairs client-messages)] + (tset messages-map + climsg.name + climsg.body)) + (when (> (length lsp-clients) + 0) + (table.sort lsp-clients + (fn [a + b] + (< a.name + b.name))) + (local builder {}) + (each [_ cli (ipairs lsp-clients)] + (when (and (and (= (type cli) + :table) + (= (type cli.name) + :string)) + (> (string.len cli.name) + 0)) + (if (. messages-map + cli.name) + (table.insert builder + (stringify cli.name + (. messages-map + cli.name))) + (table.insert builder + (stringify cli.name))))) + (when (> (length builder) + 0) + (let [___antifnl_rtn_1___ (.. sign + " " + (table.concat builder + ", "))] + (lua "return ___antifnl_rtn_1___")))) + "")})) + :event :LspAttach} diff --git a/lua/plugins/lsp-progress.lua b/lua/plugins/lsp-progress.lua index 5a0680d..8c1e640 100644 --- a/lua/plugins/lsp-progress.lua +++ b/lua/plugins/lsp-progress.lua @@ -1,52 +1,47 @@ -return { - "lsp-progress.nvim", - event = "LspAttach", - after = function() - require("lsp-progress").setup({ - client_format = function(client_name, spinner, series_messages) - if #series_messages == 0 then - return nil - end - return { - name = client_name, - body = spinner .. " " .. table.concat(series_messages, ", "), - } - end, - format = function(client_messages) - --- @param name string - --- @param msg string? - --- @return string - local function stringify(name, msg) - return msg and string.format("%s %s", name, msg) or name - end - - local sign = "󰆧" -- nf-fa-gear \uf013 - local lsp_clients = vim.lsp.get_clients() - local messages_map = {} - for _, climsg in ipairs(client_messages) do - messages_map[climsg.name] = climsg.body - end - - if #lsp_clients > 0 then - table.sort(lsp_clients, function(a, b) - return a.name < b.name - end) - local builder = {} - for _, cli in ipairs(lsp_clients) do - if type(cli) == "table" and type(cli.name) == "string" and string.len(cli.name) > 0 then - if messages_map[cli.name] then - table.insert(builder, stringify(cli.name, messages_map[cli.name])) - else - table.insert(builder, stringify(cli.name)) - end - end - end - if #builder > 0 then - return sign .. " " .. table.concat(builder, ", ") +-- [nfnl] Compiled from ./fnl/plugins/lsp-progress.fnl by https://github.com/Olical/nfnl, do not edit. +local function _1_() + local function _2_(client_name, spinner, series_messages) + if (#series_messages == 0) then + return nil + else + end + return {body = (spinner .. " " .. table.concat(series_messages, ", ")), name = client_name} + end + local function _4_(client_messages) + local function stringify(name, msg) + return ((msg and string.format("%s %s", name, msg)) or name) + end + local sign = "\243\176\134\167" + local lsp_clients = vim.lsp.get_clients() + local messages_map = {} + for _, climsg in ipairs(client_messages) do + messages_map[climsg.name] = climsg.body + end + if (#lsp_clients > 0) then + local function _5_(a, b) + return (a.name < b.name) + end + table.sort(lsp_clients, _5_) + local builder = {} + for _, cli in ipairs(lsp_clients) do + if (((type(cli) == "table") and (type(cli.name) == "string")) and (string.len(cli.name) > 0)) then + if messages_map[cli.name] then + table.insert(builder, stringify(cli.name, messages_map[cli.name])) + else + table.insert(builder, stringify(cli.name)) end + else end - return "" - end, - }) - end, -} + end + if (#builder > 0) then + local ___antifnl_rtn_1___ = (sign .. " " .. table.concat(builder, ", ")) + return ___antifnl_rtn_1___ + else + end + else + end + return "" + end + return require("lsp-progress").setup({client_format = _2_, format = _4_}) +end +return {"lsp-progress.nvim", after = _1_, event = "LspAttach"}