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 {
|
||||
"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"}
|
||||
|
|
Loading…
Reference in a new issue