From bda58fea24ae4ee887d206f8f67e7bebe2986e47 Mon Sep 17 00:00:00 2001 From: lucy Date: Mon, 13 Apr 2026 10:45:05 +0200 Subject: [PATCH] replace bufferline with lualine --- init.lua | 367 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 184 insertions(+), 183 deletions(-) diff --git a/init.lua b/init.lua index 9499097..4894add 100644 --- a/init.lua +++ b/init.lua @@ -18,122 +18,111 @@ opt.winborder = "single" opt.shiftwidth = 8 vim.diagnostic.config({ - virtual_text = { - spacing = 4, - source = true, - }, + virtual_text = { + spacing = 4, + source = true, + }, }) -- add plugins vim.pack.add({ - "https://github.com/folke/snacks.nvim", - "https://github.com/nvim-lualine/lualine.nvim", - "https://github.com/tinted-theming/tinted-vim", - "https://github.com/akinsho/bufferline.nvim", - "https://github.com/nvimdev/lspsaga.nvim", - "https://github.com/neovim/nvim-lspconfig", - "https://github.com/nvim-treesitter/nvim-treesitter", - "https://github.com/vyfor/cord.nvim", - "https://github.com/mason-org/mason-lspconfig.nvim.git", - "https://github.com/mason-org/mason.nvim.git", - { src = "https://github.com/Saghen/blink.cmp", version = "v1" }, + "https://github.com/folke/snacks.nvim", + "https://github.com/nvim-lualine/lualine.nvim", + "https://github.com/tinted-theming/tinted-vim", + "https://github.com/nvimdev/lspsaga.nvim", + "https://github.com/neovim/nvim-lspconfig", + "https://github.com/nvim-treesitter/nvim-treesitter", + "https://github.com/vyfor/cord.nvim", + "https://github.com/mason-org/mason-lspconfig.nvim.git", + "https://github.com/mason-org/mason.nvim.git", + { src = "https://github.com/Saghen/blink.cmp", version = "v1" }, }) -- function to set colorsceme local default_theme = "base16-oceanicnext" local function get_tinty_theme() - local theme_name = vim.fn.system("cat /home/lucy/.local/share/tinted-theming/tinty/current_scheme") + local theme_name = vim.fn.system("cat /home/lucy/.local/share/tinted-theming/tinty/current_scheme") - if vim.v.shell_error ~= 0 then - return default_theme - else - return vim.trim(theme_name) - end + if vim.v.shell_error ~= 0 then + return default_theme + else + return vim.trim(theme_name) + end end vim.cmd("colorscheme " .. get_tinty_theme()) -- set up qmlls to point to the right binary vim.lsp.config("qmlls", { - cmd = { "qmlls6" }, + cmd = { "qmlls6" }, }) require("blink.cmp").setup({ - fuzzy = { implementation = "prefer_rust_with_warning" }, - completion = { - menu = { - auto_show = false, - }, - }, - sources = { - default = { "lsp", "path", "snippets", "buffer" }, - }, + fuzzy = { implementation = "prefer_rust_with_warning" }, + completion = { + menu = { + auto_show = false, + }, + }, + sources = { + default = { "lsp", "path", "snippets", "buffer" }, + }, }) require("mason").setup() require("mason-lspconfig").setup() -require("bufferline").setup({ - options = { - themable = true, - numbers = "ordinal", - indicator = { - icon = "", - style = "underline", - }, - }, -}) require("snacks").setup({ - notifier = { enabled = true }, - statuscolumn = { enabled = true }, - picker = {}, - dashboard = { - enabled = true, - width = 60, - row = nil, -- dashboard position. nil for center - col = nil, -- dashboard position. nil for center - pane_gap = 4, -- empty columns between vertical panes - autokeys = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", -- autokey sequence - -- These settings are used by some built-in sections - preset = { - -- Defaults to a picker that supports `fzf-lua`, `telescope.nvim` and `mini.pick` - ---@type fun(cmd:string, opts:table)|nil - pick = nil, - -- Used by the `keys` section to show keymaps. - -- Set your custom keymaps here. - -- When using a function, the `items` argument are the default keymaps. - ---@type snacks.dashboard.Item[] - keys = { - { - icon = " ", - key = "f", - desc = "Find File", - action = ":lua Snacks.dashboard.pick('files')", - }, - { icon = " ", key = "n", desc = "New File", action = ":ene | startinsert" }, - { - icon = " ", - key = "g", - desc = "Find Text", - action = ":lua Snacks.dashboard.pick('live_grep')", - }, - { - icon = " ", - key = "r", - desc = "Recent Files", - action = ":lua Snacks.dashboard.pick('oldfiles')", - }, - { - icon = " ", - key = "c", - desc = "Config", - action = ":lua Snacks.dashboard.pick('files', {cwd = vim.fn.stdpath('config')})", - }, - { icon = " ", key = "s", desc = "Restore Session", section = "session" }, - { - icon = "󰒲 ", - key = "L", - desc = "Lazy", - action = ":Lazy", - enabled = package.loaded.lazy ~= nil, - }, - { icon = " ", key = "q", desc = "Quit", action = ":qa" }, - }, - -- Used by the `header` section - header = [[ + notifier = { enabled = true }, + statuscolumn = { enabled = true }, + picker = {}, + dashboard = { + enabled = true, + width = 60, + row = nil, -- dashboard position. nil for center + col = nil, -- dashboard position. nil for center + pane_gap = 4, -- empty columns between vertical panes + autokeys = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", -- autokey sequence + -- These settings are used by some built-in sections + preset = { + -- Defaults to a picker that supports `fzf-lua`, `telescope.nvim` and `mini.pick` + ---@type fun(cmd:string, opts:table)|nil + pick = nil, + -- Used by the `keys` section to show keymaps. + -- Set your custom keymaps here. + -- When using a function, the `items` argument are the default keymaps. + ---@type snacks.dashboard.Item[] + keys = { + { + icon = " ", + key = "f", + desc = "Find File", + action = ":lua Snacks.dashboard.pick('files')", + }, + { icon = " ", key = "n", desc = "New File", action = ":ene | startinsert" }, + { + icon = " ", + key = "g", + desc = "Find Text", + action = ":lua Snacks.dashboard.pick('live_grep')", + }, + { + icon = " ", + key = "r", + desc = "Recent Files", + action = ":lua Snacks.dashboard.pick('oldfiles')", + }, + { + icon = " ", + key = "c", + desc = "Config", + action = ":lua Snacks.dashboard.pick('files', {cwd = vim.fn.stdpath('config')})", + }, + { icon = " ", key = "s", desc = "Restore Session", section = "session" }, + { + icon = "󰒲 ", + key = "L", + desc = "Lazy", + action = ":Lazy", + enabled = package.loaded.lazy ~= nil, + }, + { icon = " ", key = "q", desc = "Quit", action = ":qa" }, + }, + -- Used by the `header` section + header = [[ ⠀⠀⠀⠀⠀⠀⣠⡤⠶⠒⠛⠉⠙⠛⠒⠶⢤⣀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡴⠋⠁⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠈⠙⢦⡀⠀⠀⠀ ⠀⠀⠀⠀⣀⣠⠤⠤⡴⠻⢓⣶⠦⠤⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢦⡀⠀ @@ -145,79 +134,91 @@ require("snacks").setup({ ⠀⠀⢠⢿⣠⠟⠓⠛⠉⠛⡟⠛⠛⠛⠛⠒⠒⠚⠉⠉⠁⠀⠀⠀⠀⠀⢀⡴⠋⠀ ⠀⠀⠈⠛⢯⣀⣀⣀⡤⠤⠤⠤⢤⣤⣀⣀⣀⣀⣀⣀⣀⣤⠤⠴⠒⠋⠁⠀⠀⠀ ]], - }, - -- item field formatters - formats = { - icon = function(item) - if item.file and item.icon == "file" or item.icon == "directory" then - return Snacks.dashboard.icon(item.file, item.icon) - end - return { item.icon, width = 2, hl = "icon" } - end, - footer = { "%s", align = "center" }, - header = { "%s", align = "center" }, - file = function(item, ctx) - local fname = vim.fn.fnamemodify(item.file, ":~") - fname = ctx.width and #fname > ctx.width and vim.fn.pathshorten(fname) or fname - if #fname > ctx.width then - local dir = vim.fn.fnamemodify(fname, ":h") - local file = vim.fn.fnamemodify(fname, ":t") - if dir and file then - file = file:sub(-(ctx.width - #dir - 2)) - fname = dir .. "/…" .. file - end - end - local dir, file = fname:match("^(.*)/(.+)$") - return dir and { { dir .. "/", hl = "dir" }, { file, hl = "file" } } or { { fname, hl = "file" } } - end, - }, - sections = { - { section = "header" }, - { section = "keys", gap = 1, padding = 1 }, - }, - }, + }, + -- item field formatters + formats = { + icon = function(item) + if item.file and item.icon == "file" or item.icon == "directory" then + return Snacks.dashboard.icon(item.file, item.icon) + end + return { item.icon, width = 2, hl = "icon" } + end, + footer = { "%s", align = "center" }, + header = { "%s", align = "center" }, + file = function(item, ctx) + local fname = vim.fn.fnamemodify(item.file, ":~") + fname = ctx.width and #fname > ctx.width and vim.fn.pathshorten(fname) or fname + if #fname > ctx.width then + local dir = vim.fn.fnamemodify(fname, ":h") + local file = vim.fn.fnamemodify(fname, ":t") + if dir and file then + file = file:sub(-(ctx.width - #dir - 2)) + fname = dir .. "/…" .. file + end + end + local dir, file = fname:match("^(.*)/(.+)$") + return dir and { { dir .. "/", hl = "dir" }, { file, hl = "file" } } or + { { fname, hl = "file" } } + end, + }, + sections = { + { section = "header" }, + { section = "keys", gap = 1, padding = 1 }, + }, + }, }) require("lspsaga").setup({ - symbol_in_winbar = { enable = true }, - lightbulb = { - enable = true, - sign = false, - }, - hover = { - max_width = 0.6, - open_link = "gx", - open_browser = "!google-chrome", - }, + symbol_in_winbar = { enable = true }, + lightbulb = { + enable = true, + sign = false, + }, + hover = { + max_width = 0.6, + open_link = "gx", + open_browser = "!google-chrome", + }, }) require("cord").setup({ - display = { - theme = "atom", - }, - editor = { tooltip = "ur gay x3" }, + display = { + theme = "atom", + }, + editor = { tooltip = "ur gay x3" }, }) require("lualine").setup({ - options = { - section_separators = { left = "", right = "" }, - component_separators = { left = "|", right = "|" }, - }, - sections = { - lualine_a = { "mode" }, - lualine_b = { "diagnostics" }, - lualine_c = { "filename", "branch", "navic" }, - lualine_x = { "lsp_status", "filetype", "filesize" }, - lualine_y = { "" }, - lualine_z = { "location" }, - }, + options = { + section_separators = { left = "", right = "" }, + component_separators = { left = "|", right = "|" }, + globalstatus = true, + always_divide_middle = true, + }, + sections = { + lualine_a = { "mode" }, + lualine_b = { "diagnostics" }, + lualine_c = { "filename", "filesize", }, + lualine_x = { "lsp_status", "filetype" }, + lualine_y = { "" }, + lualine_z = { "location" }, + }, + tabline = { + lualine_a = { { 'buffers', mode = 2, show_modified_status = true, } }, + lualine_b = { 'branch' }, + lualine_c = {}, + lualine_x = {}, + lualine_y = {}, + lualine_z = { 'tabs' } + } }) + -- keymaps local map = vim.keymap.set map("n", "ff", function() - Snacks.picker.files() + Snacks.picker.files() end) map("n", "lg", function() - Snacks.picker.grep() + Snacks.picker.grep() end) map("n", "", "h") @@ -234,19 +235,19 @@ map("n", "go", " Lspsaga goto_definition") map("n", "gr", " Lspsaga finder") map("n", "qf", " Lspsaga code_action") map("n", "", function() - vim.lsp.buf.format() + vim.lsp.buf.format() end) --- bufferline keybinds -map("n", "", " BufferLineGoToBuffer 1 ") -map("n", "", " BufferLineGoToBuffer 2 ") -map("n", "", " BufferLineGoToBuffer 3 ") -map("n", "", " BufferLineGoToBuffer 4 ") -map("n", "", " BufferLineGoToBuffer 5 ") -map("n", "", " BufferLineGoToBuffer 6 ") -map("n", "", " BufferLineGoToBuffer 7 ") -map("n", "", " BufferLineGoToBuffer 8 ") -map("n", "", " BufferLineGoToBuffer 9 ") -map("n", "", " BufferLineGoToBuffer last ") +-- buffer keybinds +map("n", "", " LualineBuffersJump! 1 ") +map("n", "", " LualineBuffersJump! 2 ") +map("n", "", " LualineBuffersJump! 3 ") +map("n", "", " LualineBuffersJump! 4 ") +map("n", "", " LualineBuffersJump! 5 ") +map("n", "", " LualineBuffersJump! 6 ") +map("n", "", " LualineBuffersJump! 7 ") +map("n", "", " LualineBuffersJump! 8 ") +map("n", "", " LualineBuffersJump! 9 ") +map("n", "", " LualineBuffersJump! last ") map("n", "w", " bdelete! ") -- util keybinds @@ -258,26 +259,26 @@ map("i", "", vim.lsp.completion.get, { desc = "trigger autocompletion" -- tinty function local function handle_focus_gained() - local new_theme_name = get_tinty_theme() - local current_theme_name = vim.g.colors_name + local new_theme_name = get_tinty_theme() + local current_theme_name = vim.g.colors_name - if current_theme_name ~= new_theme_name then - vim.cmd("colorscheme " .. new_theme_name) - require("lualine").setup() - end - require("lualine").setup() + if current_theme_name ~= new_theme_name then + vim.cmd("colorscheme " .. new_theme_name) + require("lualine").setup() + end + require("lualine").setup() end local function main() - vim.o.termguicolors = true - vim.g.tinted_colorspace = 256 - local current_theme_name = get_tinty_theme() + vim.o.termguicolors = true + vim.g.tinted_colorspace = 256 + local current_theme_name = get_tinty_theme() - vim.cmd("colorscheme " .. current_theme_name) + vim.cmd("colorscheme " .. current_theme_name) - vim.api.nvim_create_autocmd("FocusGained", { - callback = handle_focus_gained, - }) + vim.api.nvim_create_autocmd("FocusGained", { + callback = handle_focus_gained, + }) end main()