Neovim/lua/plugins/cokeline.lua

202 lines
7.3 KiB
Lua

return {
{
"willothy/nvim-cokeline",
config = true,
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons"
},
opts = {
fill_hl = "NeoTreeTabInactive",
show_if_buffers_are_at_least = 1,
buffers = {
focus_on_delete = "next",
new_buffers_position = 'last',
delete_on_right_click = false
},
mappings = {
disable_mouse = false,
},
default_hl = {
bg = function(buffer)
if buffer.is_focused then
return "NeoTreeTabActive"
end
return "NeoTreeTabInactive"
end,
fg = function(buffer)
if buffer.is_focused then
return "NeoTreeTabActive"
end
return "NeoTreeTabInactive"
end,
},
components = {
{
text = function (buffer)
local text = ' '
if buffer.is_focused then
text = ''
end
return text
end,
fg = function(buffer) return buffer.devicon.color end
},
{
text = function(buffer) return ' ' .. buffer.devicon.icon end,
fg = function(buffer) return buffer.devicon.color end,
},
{
text = function(buffer) return buffer.filename .. ' ' end,
fg = function (buffer)
if buffer.is_focused then
if buffer.diagnostics.errors > 0 then
return "DiagnosticError"
elseif buffer.diagnostics.warnings > 0 then
return "DiagnosticWarn"
elseif buffer.diagnostics.infos > 0 then
return "DiagnosticInfo"
elseif buffer.diagnostics.hints > 0 then
return "DiagnosticHint"
end
else
return 'NeoTreeTabInactive'
end
end
},
-- show icon and number of diagnostics if there are more than one
{
text = function (buffer)
local errors = buffer.diagnostics.errors
if errors > 0 then
return require("options").lsp.icons.Error .. errors .. ' '
end
return ''
end,
fg = "DiagnosticError"
},
{
text = function (buffer)
local warns = buffer.diagnostics.warnings
if warns > 0 then
return require("options").lsp.icons.Warn .. warns .. ' '
end
return ''
end,
fg = function (buffer)
if not buffer.is_focused then
return 'NeoTreeTabInactive'
end
return "DiagnosticWarn"
end
},
{
text = function (buffer)
local infos = buffer.diagnostics.infos
if infos > 0 then
return require("options").lsp.icons.Info .. infos .. ' '
end
return ''
end,
fg = function (buffer)
if not buffer.is_focused then
return 'NeoTreeTabInactive'
end
return "DiagnosticInfo"
end
},
{
text = function (buffer)
local hints = buffer.diagnostics.hints
if hints > 0 then
return require("options").lsp.icons.Hint .. hints .. ' '
end
return ''
end,
fg = function (buffer)
if not buffer.is_focused then
return 'NeoTreeTabInactive'
end
return "DiagnosticHint"
end
},
{
text = ' ',
},
{
text = function(buffer)
local text = "󰅖"
if buffer.is_modified then
text = ''
elseif buffer.is_readonly then
text = ''
end
return text .. ' '
end,
on_click = function(_, _, _, _, buffer)
buffer:delete()
end
}
},
tabs = {
placement = "right",
components = {
{
text = function(tabpage)
return ' ' .. tabpage.number .. ' '
end,
bg = function(tabpage)
if tabpage.is_active then
return "NeoTreeTabActive"
end
return "NeoTreeTabInactive"
end,
fg = function(tabpage)
if tabpage.is_active then
return "NeoTreeTabActive"
end
return "NeoTreeTabInactive"
end
},
{
text = function(tabpage)
if tabpage.is_active then
return "󰅙 "
end
return ""
end,
on_click = function(_, _, _, _, tabpage)
tabpage:close()
end,
bg = function(_)
return "NeoTreeTabActive"
end,
fg = function(_)
return "NeoTreeTabActive"
end
}
},
},
rhs = {
{
text = "󰓩 2 tabs"
}
},
sidebar = {
filetype = {
'neo-tree'
},
components = {
{
text = '',
fg = "NeoTreeTabInactive",
bg = "NeoTreeTabInactive"
}
}
}
}
}
}