Neovim/lua/plugins/cokeline.lua

202 lines
7.3 KiB
Lua
Raw Normal View History

2023-11-27 22:37:34 +00:00
return {
2024-03-01 17:57:06 +00:00
{
2023-11-27 22:37:34 +00:00
"willothy/nvim-cokeline",
config = true,
2024-03-01 17:57:06 +00:00
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons"
},
2023-11-27 22:37:34 +00:00
opts = {
2024-02-25 17:12:48 +00:00
fill_hl = "NeoTreeTabInactive",
2023-11-27 22:37:34 +00:00
show_if_buffers_are_at_least = 1,
buffers = {
focus_on_delete = "next",
new_buffers_position = 'last',
2024-03-01 17:57:06 +00:00
delete_on_right_click = false
2023-11-27 22:37:34 +00:00
},
mappings = {
disable_mouse = false,
},
default_hl = {
bg = function(buffer)
if buffer.is_focused then
2024-02-25 17:12:48 +00:00
return "NeoTreeTabActive"
2023-11-27 22:37:34 +00:00
end
2024-02-25 17:12:48 +00:00
return "NeoTreeTabInactive"
2023-11-27 22:37:34 +00:00
end,
fg = function(buffer)
if buffer.is_focused then
2024-02-25 17:12:48 +00:00
return "NeoTreeTabActive"
2023-11-27 22:37:34 +00:00
end
2024-02-25 17:12:48 +00:00
return "NeoTreeTabInactive"
2023-12-01 17:33:05 +00:00
end,
2023-11-27 22:37:34 +00:00
},
components = {
{
2024-02-25 17:12:48 +00:00
text = function (buffer)
local text = ' '
if buffer.is_focused then
text = ''
end
return text
2023-12-01 17:33:05 +00:00
end,
2024-02-25 17:12:48 +00:00
fg = function(buffer) return buffer.devicon.color end
2023-12-01 17:33:05 +00:00
},
{
2024-03-01 17:57:06 +00:00
text = function(buffer) return ' ' .. buffer.devicon.icon end,
2023-11-27 22:37:34 +00:00
fg = function(buffer) return buffer.devicon.color end,
},
{
2024-02-25 17:12:48 +00:00
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
2023-11-27 22:37:34 +00:00
},
2024-02-23 18:23:02 +00:00
{
text = ' ',
},
2023-11-27 22:37:34 +00:00
{
text = function(buffer)
2024-02-25 17:12:48 +00:00
local text = "󰅖"
2023-11-27 22:37:34 +00:00
if buffer.is_modified then
2024-02-25 17:12:48 +00:00
text = ''
2023-11-27 22:37:34 +00:00
elseif buffer.is_readonly then
2024-02-25 17:12:48 +00:00
text = ''
2023-11-27 22:37:34 +00:00
end
2024-02-25 17:12:48 +00:00
return text .. ' '
2024-02-23 18:23:02 +00:00
end,
2023-11-27 22:37:34 +00:00
on_click = function(_, _, _, _, buffer)
buffer:delete()
end
}
},
tabs = {
placement = "right",
components = {
{
text = function(tabpage)
2023-12-01 17:33:05 +00:00
return ' ' .. tabpage.number .. ' '
end,
bg = function(tabpage)
if tabpage.is_active then
2024-02-25 17:12:48 +00:00
return "NeoTreeTabActive"
2023-12-01 17:33:05 +00:00
end
2024-02-25 17:12:48 +00:00
return "NeoTreeTabInactive"
2023-12-01 17:33:05 +00:00
end,
fg = function(tabpage)
if tabpage.is_active then
2024-02-25 17:12:48 +00:00
return "NeoTreeTabActive"
2023-12-01 17:33:05 +00:00
end
2024-02-25 17:12:48 +00:00
return "NeoTreeTabInactive"
2024-02-23 18:23:02 +00:00
end
2023-12-01 17:33:05 +00:00
},
{
text = function(tabpage)
if tabpage.is_active then
2024-02-23 18:23:02 +00:00
return "󰅙 "
2023-12-01 17:33:05 +00:00
end
return ""
end,
on_click = function(_, _, _, _, tabpage)
tabpage:close()
end,
2024-02-23 18:23:02 +00:00
bg = function(_)
2024-02-25 17:12:48 +00:00
return "NeoTreeTabActive"
2023-12-01 17:33:05 +00:00
end,
2024-02-23 18:23:02 +00:00
fg = function(_)
2024-02-25 17:12:48 +00:00
return "NeoTreeTabActive"
2024-02-23 18:23:02 +00:00
end
}
},
2023-11-27 22:37:34 +00:00
},
2024-03-01 17:57:06 +00:00
rhs = {
{
text = "󰓩 2 tabs"
}
},
2023-11-27 22:37:34 +00:00
sidebar = {
2024-03-01 17:57:06 +00:00
filetype = {
'neo-tree'
},
2023-11-27 22:37:34 +00:00
components = {
{
2024-03-01 17:57:06 +00:00
text = '',
fg = "NeoTreeTabInactive",
bg = "NeoTreeTabInactive"
2023-11-27 22:37:34 +00:00
}
2024-03-01 17:57:06 +00:00
}
}
2023-11-27 22:37:34 +00:00
}
}
}
2024-02-23 18:23:02 +00:00