feat: fennelize lsp_progress nvim
This commit is contained in:
parent
b76c23ac41
commit
80db042c04
2 changed files with 109 additions and 50 deletions
64
fnl/plugins/lsp-progress.fnl
Normal file
64
fnl/plugins/lsp-progress.fnl
Normal file
|
@ -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}
|
95
lua/plugins/lsp-progress.lua
generated
95
lua/plugins/lsp-progress.lua
generated
|
@ -1,52 +1,47 @@
|
||||||
return {
|
-- [nfnl] Compiled from ./fnl/plugins/lsp-progress.fnl by https://github.com/Olical/nfnl, do not edit.
|
||||||
"lsp-progress.nvim",
|
local function _1_()
|
||||||
event = "LspAttach",
|
local function _2_(client_name, spinner, series_messages)
|
||||||
after = function()
|
if (#series_messages == 0) then
|
||||||
require("lsp-progress").setup({
|
return nil
|
||||||
client_format = function(client_name, spinner, series_messages)
|
else
|
||||||
if #series_messages == 0 then
|
end
|
||||||
return nil
|
return {body = (spinner .. " " .. table.concat(series_messages, ", ")), name = client_name}
|
||||||
end
|
end
|
||||||
return {
|
local function _4_(client_messages)
|
||||||
name = client_name,
|
local function stringify(name, msg)
|
||||||
body = spinner .. " " .. table.concat(series_messages, ", "),
|
return ((msg and string.format("%s %s", name, msg)) or name)
|
||||||
}
|
end
|
||||||
end,
|
local sign = "\243\176\134\167"
|
||||||
format = function(client_messages)
|
local lsp_clients = vim.lsp.get_clients()
|
||||||
--- @param name string
|
local messages_map = {}
|
||||||
--- @param msg string?
|
for _, climsg in ipairs(client_messages) do
|
||||||
--- @return string
|
messages_map[climsg.name] = climsg.body
|
||||||
local function stringify(name, msg)
|
end
|
||||||
return msg and string.format("%s %s", name, msg) or name
|
if (#lsp_clients > 0) then
|
||||||
end
|
local function _5_(a, b)
|
||||||
|
return (a.name < b.name)
|
||||||
local sign = "" -- nf-fa-gear \uf013
|
end
|
||||||
local lsp_clients = vim.lsp.get_clients()
|
table.sort(lsp_clients, _5_)
|
||||||
local messages_map = {}
|
local builder = {}
|
||||||
for _, climsg in ipairs(client_messages) do
|
for _, cli in ipairs(lsp_clients) do
|
||||||
messages_map[climsg.name] = climsg.body
|
if (((type(cli) == "table") and (type(cli.name) == "string")) and (string.len(cli.name) > 0)) then
|
||||||
end
|
if messages_map[cli.name] then
|
||||||
|
table.insert(builder, stringify(cli.name, messages_map[cli.name]))
|
||||||
if #lsp_clients > 0 then
|
else
|
||||||
table.sort(lsp_clients, function(a, b)
|
table.insert(builder, stringify(cli.name))
|
||||||
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, ", ")
|
|
||||||
end
|
end
|
||||||
|
else
|
||||||
end
|
end
|
||||||
return ""
|
end
|
||||||
end,
|
if (#builder > 0) then
|
||||||
})
|
local ___antifnl_rtn_1___ = (sign .. " " .. table.concat(builder, ", "))
|
||||||
end,
|
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"}
|
||||||
|
|
Loading…
Reference in a new issue