updated bufferline

This commit is contained in:
Tawfeeq 2025-04-06 14:09:10 +02:00
parent 9f9d663f0b
commit ffdb9eb0e5
5 changed files with 129 additions and 72 deletions

View File

@ -346,6 +346,7 @@ vim.opt.rtp:prepend(lazypath)
-- To update plugins you can run
-- :Lazy update
--
vim.o.mouse = 'a'
-- NOTE: Here is where you install your plugins.
require('lazy').setup({
-- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link).

View File

@ -1,5 +1,3 @@
-- ~/.config/nvim/lua/custom/config/lualine_config.lua
local lualine = require 'lualine'
-- Color table for highlights
@ -35,68 +33,49 @@ local conditions = {
-- Config
local config = {
options = {
-- Disable sections and component separators
component_separators = '',
section_separators = '',
-- theme = {
-- -- We are going to use lualine_c and lualine_x as left and
-- -- right sections. Both are highlighted by the c theme.
-- -- So we are just setting default looks of statusline
-- normal = { c = { fg = colors.fg, bg = colors.bg } },
-- inactive = { c = { fg = colors.fg, bg = colors.bg } },
-- },
theme = {
normal = { c = { fg = colors.fg, bg = colors.bg } },
inactive = { c = { fg = colors.fg, bg = colors.bg } },
},
},
sections = {
-- these are to remove the defaults
lualine_a = {
-- {
-- 'buffers',
-- show_filename_only = false,
-- },
},
lualine_b = {},
lualine_y = {},
lualine_z = {},
-- These will be filled later
lualine_c = {},
lualine_x = {},
},
inactive_sections = {
-- these are to remove the defaults
lualine_a = {},
lualine_b = {},
lualine_y = {},
lualine_z = {},
lualine_c = {},
lualine_x = {},
lualine_y = {},
lualine_z = {},
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {},
lualine_x = {},
lualine_y = {},
lualine_z = {},
},
}
-- Inserts a component in lualine_c at the left section
local function ins_left(component)
table.insert(config.sections.lualine_c, component)
end
-- Inserts a component in lualine_x at the right section
local function ins_right(component)
table.insert(config.sections.lualine_x, component)
end
-- Left components
ins_left {
function()
return ''
end,
color = { fg = colors.blue }, -- Sets highlighting of component
padding = { left = 0, right = 1 }, -- No space before this
function() return '' end,
color = { fg = colors.blue },
padding = { left = 0, right = 1 },
}
ins_left {
-- mode component
function()
return ''
end,
function() return '' end,
color = function()
-- Auto change color according to Neovim's mode
local mode_color = {
n = colors.red,
i = colors.green,
@ -124,21 +103,25 @@ ins_left {
padding = { right = 1 },
}
ins_left {
-- filesize component
'filesize',
cond = conditions.buffer_not_empty,
}
-- THIS IS THE MODIFIED COMPONENT (shows path)
ins_left {
'filename',
cond = conditions.buffer_not_empty,
color = { fg = colors.magenta, gui = 'bold' },
path = 1, -- Show relative path (2-3 parent directories)
}
ins_left { 'location', show_filename_only = false }
ins_left {
function()
local buf_count = #vim.fn.getbufinfo({buflisted = 1})
return 'Buffers: ' .. buf_count
end,
color = { fg = colors.cyan },
}
ins_left { 'location' }
ins_left { 'progress', color = { fg = colors.fg, gui = 'bold' } }
ins_left { 'buffers', show_filename_only = false }
ins_left {
'diagnostics',
sources = { 'nvim_diagnostic' },
@ -150,23 +133,14 @@ ins_left {
},
}
-- Insert mid section. You can make any number of sections in Neovim :)
-- for lualine it's any number greater than 2
ins_left {
function()
return '%='
end,
}
ins_left { function() return '%=' end }
ins_left {
-- Lsp server name
function()
local msg = 'No Active Lsp'
local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype')
local clients = vim.lsp.get_active_clients()
if next(clients) == nil then
return msg
end
if next(clients) == nil then return msg end
for _, client in ipairs(clients) do
local filetypes = client.config.filetypes
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
@ -179,10 +153,10 @@ ins_left {
color = { fg = '#ffffff', gui = 'bold' },
}
-- Add components to right sections
-- Right components
ins_right {
'o:encoding', -- option component same as &encoding in viml
fmt = string.upper, -- Convert to uppercase
'o:encoding',
fmt = string.upper,
cond = conditions.hide_in_width,
color = { fg = colors.green, gui = 'bold' },
}
@ -190,19 +164,18 @@ ins_right {
ins_right {
'fileformat',
fmt = string.upper,
icons_enabled = false, -- Disable icons
icons_enabled = false,
color = { fg = colors.green, gui = 'bold' },
}
ins_right {
'branch',
icon = '',
color = { fg = colors.red, gui = 'bold' },
color = { fg = colors.violet, gui = 'bold' },
}
ins_right {
'diff',
-- Symbols for diff
symbols = { added = '', modified = '󰝤 ', removed = '' },
diff_color = {
added = { fg = colors.green },
@ -213,12 +186,9 @@ ins_right {
}
ins_right {
function()
return ''
end,
function() return '' end,
color = { fg = colors.blue },
padding = { left = 1 },
}
-- Initialize lualine with the configuration
lualine.setup(config)

View File

@ -1,10 +1,14 @@
return {
'goolord/alpha-nvim',
priority = 1000,
dependencies = {
'nvim-tree/nvim-web-devicons',
'echasnovski/mini.icons',
'nvim-lua/plenary.nvim',
},
config = function()
require('alpha').setup(require('alpha.themes.theta').config)
local alpha = require 'alpha'
local dashboard = require 'alpha.themes.startify'
@ -25,7 +29,34 @@ return {
[[ ]],
[[ ]],
}
-- dashboard.section.header.val = {
-- [[ ]],
-- [[ ]],
-- [[ ]],
-- [[ ]],
-- [[ .-') _ ('-. (`-. _ .-') ]],
-- [[ ( OO ) )_( OO) _(OO )_ ( '.( OO )_ ]],
-- [[,--./ ,--,'(,------. .-'),-----. ,--(_/ ,. \ ,-.-') ,--. ,--.)]],
-- [[| \ | |\ | .---'( OO' .-. '\ \ /(__/ | |OO)| `.' | ]],
-- [[| \| | )| | / | | | | \ \ / / | | \| | ]],
-- [[| . |/(| '--. \_) | |\| | \ ' /, | |(_/| |'.'| | ]],
-- [[| |\ | | .--' \ | | | | \ /__),| |_.'| | | | ]],
-- [[| | \ | | `---. `' '-' ' \ / (_| | | | | | ]],
-- [[`--' `--' `------' `-----' `-' `--' `--' `--' ]],
-- [[ ]],
-- [[ ]],
-- [[ ]],
-- }
-- dashboard.section.header.val = {
--
-- [[ _ _ _ ]],
-- [[ | \| | ___ ___ __ __ (_) _ __ ]],
-- [[ | .` | / -_) / _ \ \ V / | | | ' \ ]],
-- [[ |_|\_| \___| \___/ _\_/_ _|_|_ |_|_|_| ]],
-- [[ _|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""| ]],
-- [[ "`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-' ]],
-- }
alpha.setup(dashboard.opts)
end,
}

View File

@ -1,8 +1,46 @@
return {
'akinsho/bufferline.nvim',
version = "*",
version = '*',
dependencies = 'nvim-tree/nvim-web-devicons',
config = function()
require("bufferline").setup{}
end
require('bufferline').setup {
options = {
diagnostics = 'nvim_lsp',
diagnostics_indicator = function(count, level)
local icon = level:match 'error' and '' or ''
return ' ' .. icon .. count
end,
hover = {
enabled = true,
delay = 200,
reveal = { 'close' },
},
offsets = {
{
filetype = 'NvimTree',
text = function()
return vim.fn.getcwd()
end,
highlight = 'Directory',
text_align = 'left',
},
},
},
}
vim.keymap.set('n', 'bk', ':BufferLinePick<CR>', { silent = true })
vim.keymap.set('n', 'bkk', ':BufferLinePickClose<CR>', { silent = true })
vim.keymap.set('n', 'bl', ':BufferLineCloseLeft<CR>', { silent = true })
vim.keymap.set('n', 'br', ':BufferLineCloseRight<CR>', { silent = true })
-- Remaps
vim.keymap.set('n', '<leader>1', ':BufferLineGoToBuffer 1<CR>', { silent = true })
vim.keymap.set('n', '<leader>2', ':BufferLineGoToBuffer 2<CR>', { silent = true })
vim.keymap.set('n', '<leader>3', ':BufferLineGoToBuffer 3<CR>', { silent = true })
vim.keymap.set('n', '<leader>4', ':BufferLineGoToBuffer 4<CR>', { silent = true })
vim.keymap.set('n', '<leader>5', ':BufferLineGoToBuffer 5<CR>', { silent = true })
vim.keymap.set('n', '<leader>6', ':BufferLineGoToBuffer 6<CR>', { silent = true })
vim.keymap.set('n', '<leader>7', ':BufferLineGoToBuffer 7<CR>', { silent = true })
vim.keymap.set('n', '<leader>8', ':BufferLineGoToBuffer 8<CR>', { silent = true })
vim.keymap.set('n', '<leader>9', ':BufferLineGoToBuffer 9<CR>', { silent = true })
vim.keymap.set('n', '<leader>$', ':BufferLineGoToBuffer -1<CR>', { silent = true })
end,
}

View File

@ -0,0 +1,17 @@
return {
'nvim-telescope/telescope-file-browser.nvim',
dependencies = { 'nvim-telescope/telescope.nvim', 'nvim-lua/plenary.nvim' },
vim.keymap.set("n", "<space>fb", ":Telescope file_browser<CR>"),
-- open file_browser with the path of the current buffer
vim.keymap.set("n", "<space>fb", ":Telescope file_browser path=%:p:h select_buffer=true<CR>"),
-- Alternatively, using lua API
vim.keymap.set("n", "<space>fb", function()
require("telescope").extensions.file_browser.file_browser()
end)
}