Enhances UI with bufferline, diagnostics, and theme

- Integrates plugins for improved buffer management (bufferline, bufdelete) and diagnostics display (trouble).
- Applies the Catppuccin theme for a refreshed visual experience.
- Updates Neovim settings to support new UI elements and enable Nerd Fonts.
This commit is contained in:
sharmaharshitnone 2025-05-30 11:53:51 +05:30
parent edc87670eb
commit b94576c7b4
6 changed files with 280 additions and 1 deletions

View file

@ -91,7 +91,7 @@ vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
-- Set to true if you have a Nerd Font installed and selected in the terminal
vim.g.have_nerd_font = false
vim.g.have_nerd_font = true
-- [[ Setting options ]]
-- See `:help vim.o`
@ -123,6 +123,12 @@ vim.o.mouse = 'a'
-- Don't show the mode, since it's already in the status line
vim.o.showmode = false
-- Hide the command line when not in use
vim.o.cmdheight = 1
-- Hide the default tab line since we're using bufferline
vim.o.showtabline = 0
-- Sync clipboard between OS and Neovim.
-- Schedule the setting after `UiEnter` because it can increase startup-time.
-- Remove this option if you want your OS clipboard to remain independent.
@ -362,6 +368,7 @@ require('lazy').setup({
{ '<leader>s', group = '[S]earch' },
{ '<leader>t', group = '[T]oggle' },
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
{ '<leader>b', group = '[B]uffer' },
},
},
},

View file

@ -0,0 +1,18 @@
-- filepath: /home/kali/.config/nvim/lua/custom/plugins/bufdelete.lua
-- Bufdelete for properly closing buffers
-- https://github.com/famiu/bufdelete.nvim
return {
'famiu/bufdelete.nvim',
event = "VeryLazy", -- lazy load
config = function()
-- Key mappings to delete buffers
vim.keymap.set('n', '<leader>bd', function()
require("bufdelete").bufdelete(0, false)
end, {noremap = true, desc = "Delete buffer"})
vim.keymap.set('n', '<leader>bD', function()
require("bufdelete").bufdelete(0, true)
end, {noremap = true, desc = "Delete buffer (force)"})
end
}

View file

@ -0,0 +1,87 @@
-- filepath: /home/kali/.config/nvim/lua/custom/plugins/bufferline.lua
-- Bufferline configuration
-- https://github.com/akinsho/bufferline.nvim
return {
'akinsho/bufferline.nvim',
version = "*", -- use the latest stable version
event = "VeryLazy", -- lazy load for better startup
dependencies = {
'nvim-tree/nvim-web-devicons', -- for file icons
},
opts = {
options = {
-- Themes and appearance
indicator = {
style = 'icon',
icon = '',
},
buffer_close_icon = '󰅖',
modified_icon = '',
close_icon = '',
left_trunc_marker = '',
right_trunc_marker = '',
max_name_length = 18,
max_prefix_length = 15,
truncate_names = true,
tab_size = 18,
diagnostics = "nvim_lsp", -- Use LSP diagnostics
diagnostics_update_in_insert = false,
diagnostics_indicator = function(count, level, diagnostics_dict, context)
local icon = level:match("error") and " " or " "
return " " .. icon .. count
end,
offsets = {
{
filetype = "neo-tree",
text = "File Explorer",
text_align = "center",
separator = true
}
},
color_icons = true,
show_buffer_icons = true,
show_buffer_close_icons = true,
show_close_icon = true,
show_tab_indicators = true,
separator_style = "thin",
enforce_regular_tabs = false,
always_show_bufferline = true,
hover = {
enabled = true,
delay = 200,
reveal = {'close'}
},
},
-- Colorscheme integration
highlights = {
-- These are automatically integrated with your colorscheme
},
},
config = function(_, opts)
require("bufferline").setup(opts)
-- Key mappings for navigating between buffers
vim.keymap.set('n', '<leader>bp', '<cmd>BufferLinePick<CR>', {noremap = true, desc = "Pick buffer"})
vim.keymap.set('n', '<leader>bc', '<cmd>BufferLinePickClose<CR>', {noremap = true, desc = "Pick buffer to close"})
vim.keymap.set('n', '<leader>bh', '<cmd>BufferLineCyclePrev<CR>', {noremap = true, desc = "Previous buffer"})
vim.keymap.set('n', '<leader>bl', '<cmd>BufferLineCycleNext<CR>', {noremap = true, desc = "Next buffer"})
vim.keymap.set('n', '<leader>bH', '<cmd>BufferLineMovePrev<CR>', {noremap = true, desc = "Move buffer left"})
vim.keymap.set('n', '<leader>bL', '<cmd>BufferLineMoveNext<CR>', {noremap = true, desc = "Move buffer right"})
vim.keymap.set('n', '<leader>b1', '<cmd>BufferLineGoToBuffer 1<CR>', {noremap = true, desc = "Go to buffer 1"})
vim.keymap.set('n', '<leader>b2', '<cmd>BufferLineGoToBuffer 2<CR>', {noremap = true, desc = "Go to buffer 2"})
vim.keymap.set('n', '<leader>b3', '<cmd>BufferLineGoToBuffer 3<CR>', {noremap = true, desc = "Go to buffer 3"})
vim.keymap.set('n', '<leader>b4', '<cmd>BufferLineGoToBuffer 4<CR>', {noremap = true, desc = "Go to buffer 4"})
vim.keymap.set('n', '<leader>b5', '<cmd>BufferLineGoToBuffer 5<CR>', {noremap = true, desc = "Go to buffer 5"})
vim.keymap.set('n', '<leader>b6', '<cmd>BufferLineGoToBuffer 6<CR>', {noremap = true, desc = "Go to buffer 6"})
vim.keymap.set('n', '<leader>b7', '<cmd>BufferLineGoToBuffer 7<CR>', {noremap = true, desc = "Go to buffer 7"})
vim.keymap.set('n', '<leader>b8', '<cmd>BufferLineGoToBuffer 8<CR>', {noremap = true, desc = "Go to buffer 8"})
vim.keymap.set('n', '<leader>b9', '<cmd>BufferLineGoToBuffer 9<CR>', {noremap = true, desc = "Go to buffer 9"})
-- Additional keymaps for Alt+number to switch buffers quickly
for i = 1, 9 do
vim.keymap.set('n', string.format('<A-%s>', i), string.format('<cmd>BufferLineGoToBuffer %s<CR>', i),
{noremap = true, desc = string.format("Go to buffer %s", i)})
end
end,
}

View file

@ -0,0 +1,80 @@
-- In your plugins configuration file (e.g., lua/plugins/catppuccin.lua or similar)
return {
{
'catppuccin/nvim',
name = 'catppuccin', -- Optional, but can be useful for referring to the plugin
priority = 1000, -- Ensure it loads early to apply the colorscheme
lazy = false, -- Load on startup if you want it as your default theme
config = function()
-- Load the colorscheme here
-- vim.cmd.colorscheme "catppuccin" -- Default is "mocha" if no flavour is specified
-- Or, to specify a flavour and set up integrations:
require('catppuccin').setup {
flavour = 'mocha', -- latte, frappe, macchiato, mocha
background = { -- :h background
light = 'latte',
dark = 'mocha',
},
transparent_background = false, -- useful if you want the underlying terminal colors to show through
show_end_of_buffer = false, -- shows the '~' characters after the end of buffers
term_colors = true, -- Toggles Neovim terminal colors for the Catppuccin palette.
dim_inactive = {
enabled = false, -- dims inactive windows
shade = 'dark',
percentage = 0.15,
},
no_italic = false, -- Force no italic
no_bold = false, -- Force no bold
no_underline = false, -- Force no underline
styles = { -- Handles the styles of general hi groups (see `:h highlight-args`):
comments = { 'italic' },
conditionals = { 'italic' },
loops = {},
functions = {},
keywords = {},
strings = {},
variables = {},
numbers = {},
booleans = {},
properties = {},
types = {},
operators = {},
-- miscs = {}, -- Custom groups for miscellaneous items specific to firmware development
},
color_overrides = {},
custom_highlights = {},
integrations = {
cmp = true,
gitsigns = true,
nvimtree = true,
telescope = true,
notify = true,
mini = {
enabled = true,
indentscope_color = '',
},
-- For more plugins integrations please check integration table in the README project
native_lsp = {
enabled = true,
underlines = {
errors = { 'undercurl' },
hints = { 'undercurl' },
warnings = { 'undercurl' },
information = { 'undercurl' },
},
},
headlines = true,
indent_blankline = {
enabled = true,
scope_color = 'mauve', -- catppuccin color a available flavor
-- Also a vailable: latte, frappe, macchiato, mocha
},
},
}
-- After setting up, set the colorscheme
vim.cmd.colorscheme 'catppuccin'
end,
},
}

View file

@ -0,0 +1,87 @@
-- Trouble - A pretty diagnostics, references, telescope results, quickfix and location list
-- https://github.com/folke/trouble.nvim
return {
"folke/trouble.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
event = { "BufReadPost", "BufNewFile" },
cmd = { "TroubleToggle", "Trouble" },
opts = {
position = "bottom", -- position of the list can be: bottom, top, left, right
height = 12, -- height of the trouble list when position is top or bottom
width = 50, -- width of the list when position is left or right
icons = true, -- use devicons for filenames
mode = "workspace_diagnostics", -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist"
severity = nil, -- nil (ALL) or vim.diagnostic.severity.ERROR | WARN | INFO | HINT
fold_open = "", -- icon used for open folds
fold_closed = "", -- icon used for closed folds
group = true, -- group results by file
padding = true, -- add an extra new line on top of the list
action_keys = { -- key mappings for actions in the trouble list
close = "q", -- close the list
cancel = "<esc>", -- cancel the preview and get back to your last window / buffer / cursor
refresh = "r", -- manually refresh
jump = { "<cr>", "<tab>", "<2-leftmouse>" }, -- jump to the diagnostic or open / close folds
open_split = { "<c-x>" }, -- open buffer in new split
open_vsplit = { "<c-v>" }, -- open buffer in new vsplit
open_tab = { "<c-t>" }, -- open buffer in new tab
jump_close = {"o"}, -- jump to the diagnostic and close the list
toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode
switch_severity = "s", -- switch "diagnostics" severity filter
toggle_preview = "P", -- toggle auto_preview
hover = "K", -- opens a small popup with the full multiline message
preview = "p", -- preview the diagnostic location
open_code_href = "c", -- if present, open a URI with more information about the diagnostic error
close_folds = {"zM", "zm"}, -- close all folds
open_folds = {"zR", "zr"}, -- open all folds
toggle_fold = {"zA", "za"}, -- toggle fold of current file
previous = "k", -- previous item
next = "j", -- next item
help = "?" -- help menu
},
multiline = true, -- render multi-line messages
indent_lines = true, -- add an indent guide below the fold icons
win_config = { border = "rounded" }, -- window configuration for floating windows
auto_open = false, -- automatically open the list when you have diagnostics
auto_close = false, -- automatically close the list when you have no diagnostics
auto_preview = true, -- automatically preview the location of the diagnostic. <esc> to close preview and go back to last window
auto_fold = false, -- automatically fold a file trouble list at creation
auto_jump = {"lsp_definitions"}, -- for the given modes, automatically jump if there is only a single result
signs = {
-- icons / text used for a diagnostic
error = "",
warning = "",
hint = "",
information = "",
other = "",
},
use_diagnostic_signs = false -- enabling this will use the signs defined in your lsp client
},
keys = {
{ "<leader>xx", "<cmd>TroubleToggle document_diagnostics<cr>", desc = "Document Diagnostics (Trouble)" },
{ "<leader>xX", "<cmd>TroubleToggle workspace_diagnostics<cr>", desc = "Workspace Diagnostics (Trouble)" },
{ "<leader>xL", "<cmd>TroubleToggle loclist<cr>", desc = "Location List (Trouble)" },
{ "<leader>xQ", "<cmd>TroubleToggle quickfix<cr>", desc = "Quickfix List (Trouble)" },
{ "gR", "<cmd>TroubleToggle lsp_references<cr>", desc = "LSP References (Trouble)" },
{ "gD", "<cmd>TroubleToggle lsp_definitions<cr>", desc = "LSP Definitions (Trouble)" },
{ "<leader>xT", "<cmd>TodoTrouble<cr>", desc = "TODOs (Trouble)", cond = function() return require("lazy.core.config").spec.plugins["todo-comments"] ~= nil end },
},
config = function(_, opts)
require("trouble").setup(opts)
-- Add which-key group
local ok, which_key = pcall(require, "which-key")
if ok then
which_key.register({
["<leader>x"] = {
name = "Trouble/Diagnostics",
x = { "<cmd>TroubleToggle document_diagnostics<cr>", "Document Diagnostics" },
X = { "<cmd>TroubleToggle workspace_diagnostics<cr>", "Workspace Diagnostics" },
L = { "<cmd>TroubleToggle loclist<cr>", "Location List" },
Q = { "<cmd>TroubleToggle quickfix<cr>", "Quickfix List" },
T = { "<cmd>TodoTrouble<cr>", "TODOs" },
},
})
end
end,
}