added barbar bufferline

This commit is contained in:
Sven Vogel 2024-04-11 15:30:25 +02:00
parent 44f3b93498
commit 4258701c98
6 changed files with 37 additions and 213 deletions

View File

@ -24,10 +24,10 @@ return {
{ 'n', 'i' }, '<S-ScrollWheelDown>', '<ScrollWheelRight>', { desc = "Scroll sideways" } { 'n', 'i' }, '<S-ScrollWheelDown>', '<ScrollWheelRight>', { desc = "Scroll sideways" }
}, },
{ {
{ 'n' }, "<S-Tab>", "<Plug>(cokeline-focus-prev)", { desc = "Next Tab", silent = false } { 'n' }, "<S-Tab>", "<cmd>BufferPrevious<CR>", { desc = "Next Tab", silent = false }
}, },
{ {
{ 'n' }, "<Tab>", "<Plug>(cokeline-focus-next)", { desc = "Previous Tab", silent = false } { 'n' }, "<Tab>", "<cmd>BufferNext<CR>", { desc = "Previous Tab", silent = false }
}, },
{ {
{ 'n' }, '<C-w>', '', { desc = "Disable STRG+w" } { 'n' }, '<C-w>', '', { desc = "Disable STRG+w" }
@ -39,7 +39,7 @@ return {
{ 'n' }, '<C-w>h', '<cmd>split<CR>', { desc = "Split Horizontal", noremap = true } { 'n' }, '<C-w>h', '<cmd>split<CR>', { desc = "Split Horizontal", noremap = true }
}, },
{ {
{ 'n' }, '<C-w>q', '<cmd>q<CR>', { desc = "Quit Window" } { 'n' }, '<C-w>q', '<cmd>BufferClose<CR>', { desc = "Quit Window" }
}, },
{ {
{ 'n' }, '<C-w><Left>', '<cmd>wincmd h<CR>', { desc = "Window Left" } { 'n' }, '<C-w><Left>', '<cmd>wincmd h<CR>', { desc = "Window Left" }

32
lua/plugins/barbar.lua Normal file
View File

@ -0,0 +1,32 @@
return {
{
'romgrk/barbar.nvim',
init = function() vim.g.barbar_auto_setup = false end,
opts = function ()
local options = require('options')
return {
animation = true,
tabpages = true,
insert_at_end = true,
maximum_padding = 4,
sidebar_filetypes = {
NvimTree = true,
},
clickable = true,
pinned = {
button = '',
filename = true
},
icons = {
separator = {left = '', right = ''},
diagnostics = {
[vim.diagnostic.severity.ERROR] = {enabled = true, icon = options.lsp.icons.Error},
[vim.diagnostic.severity.WARN] = {enabled = false, icon = options.lsp.icons.Warn},
[vim.diagnostic.severity.INFO] = {enabled = false, icon = options.lsp.icons.Info},
[vim.diagnostic.severity.HINT] = {enabled = true}, icon = options.lsp.icons.Hint},
}
}
end
}
}

View File

@ -1,208 +0,0 @@
return {
{
"willothy/nvim-cokeline",
config = true,
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons"
},
opts = {
fill_hl = "NvimTreeNormal",
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 "BufferCurrent"
end
return "NvimTreeNormal"
end,
fg = function(buffer)
if buffer.is_focused then
return "BufferCurrent"
end
return "NvimTreeNormal"
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 'NvimTreeNormal'
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 'NvimTreeNormal'
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 'NvimTreeNormal'
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 'NvimTreeNormal'
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 "lualine_a_command"
end
return "NvimTreeNormal"
end,
fg = function(tabpage)
if tabpage.is_active then
return "lualine_a_command"
end
return "NvimTreeNormal"
end
},
{
text = function(tabpage)
if tabpage.is_active then
return "󰅙 "
end
return ""
end,
on_click = function(_, _, _, _, tabpage)
tabpage:close()
end,
bg = function(_)
return "lualine_a_command"
end,
fg = function(_)
return "lualine_a_command"
end
}
},
},
rhs = {
{
text = " TAB ",
on_click = function(_, _, _, _, _)
vim.defer_fn(function()
vim.cmd("tabnew")
end, 100)
end,
fg = "BufferCurrent",
bg = "BufferCurrent"
}
},
sidebar = {
filetype = {
'NvimTree'
},
components = {
{
text = '',
fg = "NvimTreeNormal",
bg = "NvimTreeNormal"
}
}
}
}
}
}

View File

@ -7,7 +7,6 @@ return {
"MunifTanjim/nui.nvim", -- gui component library "MunifTanjim/nui.nvim", -- gui component library
}, },
opts = function(_,_) opts = function(_,_)
local options = require("options")
return { return {
cmdline = { cmdline = {
enabled = true, enabled = true,

View File

@ -9,6 +9,7 @@ return {
"toggleterm", "toggleterm",
"dashboard", "dashboard",
"aerial", "aerial",
"NvimTree"
}, },
segments = { segments = {
-- diagnostic signs -- diagnostic signs

View File

@ -5,7 +5,7 @@ return {
opts = { opts = {
style = "dark", style = "dark",
transparent = true, transparent = true,
italic_comments = false italic_comments = false,
} }
} }
} }