pojokcodeid.nvim-lazy/lua/plugins/lspprogress.lua

78 lines
1.8 KiB
Lua
Raw Normal View History

local function ambilKataDariKiri(kalimat, jumlahKata)
2024-06-03 09:03:01 +07:00
local hasil = ""
local posisiAwal = 1
local kataKe = 0
2024-06-03 09:03:01 +07:00
while kataKe < jumlahKata do
local posisiSpasi = string.find(kalimat, " ", posisiAwal)
if posisiSpasi then
hasil = hasil .. string.sub(kalimat, posisiAwal, posisiSpasi - 1) .. " "
posisiAwal = posisiSpasi + 1
else
hasil = hasil .. string.sub(kalimat, posisiAwal)
break
end
kataKe = kataKe + 1
end
2024-06-03 09:03:01 +07:00
return hasil
end
2023-03-03 19:15:17 +07:00
local fidget = true
local lualine = false
2024-05-21 15:17:31 +07:00
if vim.g.pcode_progress == 1 then
2024-06-03 09:03:01 +07:00
fidget = false
lualine = true
2024-05-21 15:17:31 +07:00
elseif vim.g.pcode_progress == 2 then
2024-06-03 09:03:01 +07:00
fidget = true
lualine = false
2024-05-21 15:17:31 +07:00
elseif vim.g.pcode_progress == 0 then
2024-06-03 09:03:01 +07:00
fidget = false
lualine = false
2023-03-03 19:15:17 +07:00
else
2024-06-03 09:03:01 +07:00
fidget = true
lualine = false
end
if fidget then
return {
"j-hui/fidget.nvim",
lazy = true,
enabled = fidget,
tag = "legacy",
event = "BufRead",
config = function()
require("fidget").setup {
window = {
blend = 0,
relative = "editor",
},
}
end,
}
elseif lualine then
return {
"linrongbin16/lsp-progress.nvim",
enabled = lualine,
lazy = true,
branch = "main",
event = { "BufRead" },
config = function()
require("lsp-progress").setup {
client_format = function(client_name, spinner, series_messages)
return #series_messages > 0
and (spinner .. " " .. ambilKataDariKiri(table.concat(series_messages, ", "), 4) .. "...")
or nil
end,
format = function(client_messages)
local sign = ""
return #client_messages > 0
and (sign .. " " .. ambilKataDariKiri(table.concat(client_messages, " "), 4) .. "...")
or sign
end,
}
end,
}
else
return {}
2023-03-03 19:15:17 +07:00
end