refactor(nvim): improve heirline usage
This commit is contained in:
parent
ef9c807b26
commit
e65eeea36a
@ -15,9 +15,6 @@ return {
|
|||||||
|
|
||||||
local utils = require("heirline.utils")
|
local utils = require("heirline.utils")
|
||||||
local conditions = require("heirline.conditions")
|
local conditions = require("heirline.conditions")
|
||||||
local lsp_attached = function()
|
|
||||||
return next(vim.lsp.get_clients({ bufnr = vim.api.nvim_get_current_buf() })) ~= nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local pad = function(num)
|
local pad = function(num)
|
||||||
return string.rep(" ", num)
|
return string.rep(" ", num)
|
||||||
@ -555,7 +552,7 @@ return {
|
|||||||
{
|
{
|
||||||
{
|
{
|
||||||
condition = function()
|
condition = function()
|
||||||
return lsp_attached() or conditions.has_diagnostics()
|
return conditions.lsp_attached() or conditions.has_diagnostics()
|
||||||
end,
|
end,
|
||||||
{
|
{
|
||||||
provider = seps.full.left,
|
provider = seps.full.left,
|
||||||
@ -578,7 +575,7 @@ return {
|
|||||||
provider = seps.full.right,
|
provider = seps.full.right,
|
||||||
hl = function()
|
hl = function()
|
||||||
local bg = colors.oniViolet2
|
local bg = colors.oniViolet2
|
||||||
if conditions.has_diagnostics() and not lsp_attached() then
|
if conditions.has_diagnostics() and not conditions.lsp_attached() then
|
||||||
bg = colors.sumiInk2
|
bg = colors.sumiInk2
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -587,13 +584,13 @@ return {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
condition = lsp_attached,
|
condition = utils.lsp_attached,
|
||||||
{
|
{
|
||||||
update = { "LspAttach", "LspDetach" },
|
|
||||||
|
|
||||||
provider = function()
|
provider = function()
|
||||||
local names = {}
|
local names = {}
|
||||||
for _, server in ipairs(vim.lsp.get_clients({ bufnr = 0 })) do
|
for _, server in
|
||||||
|
ipairs(vim.lsp.get_clients({ bufnr = vim.api.nvim_get_current_buf() }))
|
||||||
|
do
|
||||||
table.insert(names, server.name)
|
table.insert(names, server.name)
|
||||||
end
|
end
|
||||||
return " " .. table.concat(names, ", ")
|
return " " .. table.concat(names, ", ")
|
||||||
|
Loading…
Reference in New Issue
Block a user