From adb2953f8ce75b50884e7ddc8cdf31e6aa8b57d0 Mon Sep 17 00:00:00 2001 From: Snoweuph Date: Sat, 1 Jun 2024 21:57:04 +0200 Subject: [PATCH] Fix Status bar --- .config/nvim/lua/plugins/status_bar.lua | 15 ++++- .../lua/plugins/temp/status_bar_plugin.lua | 58 +++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 .config/nvim/lua/plugins/temp/status_bar_plugin.lua diff --git a/.config/nvim/lua/plugins/status_bar.lua b/.config/nvim/lua/plugins/status_bar.lua index 7635892..dd7cdf6 100644 --- a/.config/nvim/lua/plugins/status_bar.lua +++ b/.config/nvim/lua/plugins/status_bar.lua @@ -5,9 +5,11 @@ return { "nvim-tree/nvim-web-devicons", "nvimdev/lspsaga.nvim", }, + after = "rcarriga/nvim-dap-ui", config = function() -- Setup -- local lspsaga_breadcrumbs = require("lspsaga.symbol.winbar").get_bar + require("lualine").setup({ options = { component_separators = { left = "", right = "" }, @@ -16,6 +18,15 @@ return { "neo-tree", "fugitive", "help", + statusline = { + "dap-repl", + "dapui_console", + "dapui_console", + "dapui_watches", + "dapui_stacks", + "dapui_breakpoints", + "dapui_scopes", + }, }, ignore_focus = {}, always_divide_middle = true, @@ -49,7 +60,9 @@ return { inactive_winbar = { lualine_a = { "filename" }, }, - extensions = {}, + extensions = { + require("plugins.temp.status_bar_plugin"), + }, }) end, }, diff --git a/.config/nvim/lua/plugins/temp/status_bar_plugin.lua b/.config/nvim/lua/plugins/temp/status_bar_plugin.lua new file mode 100644 index 0000000..120f25f --- /dev/null +++ b/.config/nvim/lua/plugins/temp/status_bar_plugin.lua @@ -0,0 +1,58 @@ +local M = {} + +M.filetypes = { + "dap-repl", + "dapui_console", + "dapui_console", + "dapui_watches", + "dapui_stacks", + "dapui_breakpoints", + "dapui_scopes", +} + +local function merge_colors(foreground, background) + local new_name = foreground .. background + + local hl_fg = vim.api.nvim_get_hl(0, { name = foreground }) + local hl_bg = vim.api.nvim_get_hl(0, { name = background }) + + local fg = string.format("#%06x", hl_fg.fg and hl_fg.fg or 0) + local bg = string.format("#%06x", hl_bg.bg and hl_bg.bg or 0) + + vim.api.nvim_set_hl(0, new_name, { fg = fg, bg = bg }) + return new_name +end + +local function get_dap_repl_winbar(active) + local get_mode = require("lualine.highlight").get_mode_suffix + + return function() + local filetype = vim.bo.filetype + local disabled_filetypes = { "dap-repl" } + + if not vim.tbl_contains(disabled_filetypes, filetype) then + return "" + end + + local background_color = string.format("lualine_b" .. "%s", active and get_mode() or "_inactive") + + local controls_string = "%#" .. background_color .. "#" + for element in require("dapui.controls").controls():gmatch("%S+") do + local color, action = string.match(element, "%%#(.*)#(%%.*)%%#0#") + controls_string = controls_string .. " %#" .. merge_colors(color, background_color) .. "#" .. action + end + return controls_string + end +end + +M.winbar = { + lualine_a = { { "filename", file_status = false } }, + lualine_b = { get_dap_repl_winbar(true) }, +} + +M.inactive_winbar = { + lualine_a = { { "filename", file_status = false } }, + lualine_b = { get_dap_repl_winbar(false) }, +} + +return M