From aa637123b15cf2661f323baca70bf30b3b9fc432 Mon Sep 17 00:00:00 2001 From: Jason Hilder Date: Thu, 12 Feb 2026 09:26:59 +0200 Subject: [PATCH] Removed status line in favor of winbar --- config/nvim/init.lua | 56 +++++++++++------------ config/nvim/lua/winbar.lua | 92 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+), 28 deletions(-) create mode 100644 config/nvim/lua/winbar.lua diff --git a/config/nvim/init.lua b/config/nvim/init.lua index a719729..ba01ba7 100644 --- a/config/nvim/init.lua +++ b/config/nvim/init.lua @@ -26,7 +26,8 @@ vim.o.splitright = true -- Set horizontal splits to the right as vim.o.splitbelow = true -- Set vertical splits to the bottom as default vim.o.completeopt = 'menuone,noselect' -- Configures how the completion menu works vim.o.winborder = 'rounded' -- LSP hover borders -vim.opt.showmode = true +vim.opt.showmode = false +vim.opt.laststatus = 0 --------------------------------------------------------------------------------- -- [[ PLUGINS ]] @@ -39,7 +40,7 @@ vim.pack.add({ { src = "https://github.com/akinsho/toggleterm.nvim" }, { src = "https://github.com/folke/trouble.nvim" }, { src = "https://github.com/tribela/transparent.nvim" }, - { src = "https://github.com/nvim-treesitter/nvim-treesitter", version = "master" } + { src = "https://github.com/nvim-treesitter/nvim-treesitter", version = "master" }, }) vim.cmd.colorscheme("kanagawa") @@ -48,34 +49,9 @@ require("trouble").setup() require("mini.pick").setup() require("mini.pairs").setup() require("mini.surround").setup() -require("mini.statusline").setup() require("oil").setup({ view_options = { show_hidden = true, } }) require("toggleterm").setup({ open_mapping = [[]], direction = "float" }) - --------------------------------------------------------------------------------- --- [[ Godot ]] ---------------------------------------------------------------------------------- --- paths to check for project.godot file -local paths_to_check = {'/', '/../'} -local is_godot_project = false -local godot_project_path = '' -local cwd = vim.fn.getcwd() - --- iterate over paths and check -for key, value in pairs(paths_to_check) do - if vim.uv.fs_stat(cwd .. value .. 'project.godot') then - is_godot_project = true - godot_project_path = cwd .. value - break - end -end - --- check if server is already running in godot project path -local is_server_running = vim.uv.fs_stat(godot_project_path .. '/server.pipe') --- start server, if not already running -if is_godot_project and not is_server_running then - vim.fn.serverstart(godot_project_path .. '/server.pipe') -end +require('winbar').setup() --------------------------------------------------------------------------------- -- [[ KEYMAPS ]] @@ -119,3 +95,27 @@ vim.api.nvim_create_autocmd('TextYankPost', { pattern = '*', }) +-------------------------------------------------------------------------------- +-- [[ Godot ]] +--------------------------------------------------------------------------------- +-- paths to check for project.godot file +local paths_to_check = {'/', '/../'} +local is_godot_project = false +local godot_project_path = '' +local cwd = vim.fn.getcwd() + +-- iterate over paths and check +for key, value in pairs(paths_to_check) do + if vim.uv.fs_stat(cwd .. value .. 'project.godot') then + is_godot_project = true + godot_project_path = cwd .. value + break + end +end + +-- check if server is already running in godot project path +local is_server_running = vim.uv.fs_stat(godot_project_path .. '/server.pipe') +if is_godot_project and not is_server_running then + vim.fn.serverstart(godot_project_path .. '/server.pipe') +end + diff --git a/config/nvim/lua/winbar.lua b/config/nvim/lua/winbar.lua new file mode 100644 index 0000000..a2b6dec --- /dev/null +++ b/config/nvim/lua/winbar.lua @@ -0,0 +1,92 @@ +local M = {} + +-- Define highlight groups to match your statusline +local function setup_highlights() + vim.api.nvim_set_hl(0, 'WinBarNormal', { bg = '#569cd6', fg = '#000000', bold = true }) + vim.api.nvim_set_hl(0, 'WinBarInsert', { bg = '#6a9955', fg = '#000000', bold = true }) + vim.api.nvim_set_hl(0, 'WinBarVisual', { bg = '#c586c0', fg = '#000000', bold = true }) + vim.api.nvim_set_hl(0, 'WinBarCommand', { bg = '#dcdcaa', fg = '#000000', bold = true }) + vim.api.nvim_set_hl(0, 'WinBarTerminal', { bg = '#4ec9b0', fg = '#000000', bold = true }) + vim.api.nvim_set_hl(0, 'WinBarReplace', { bg = '#d16969', fg = '#000000', bold = true }) + vim.api.nvim_set_hl(0, 'WinBarFilepath', { bg = '', fg = '#cccccc' }) + vim.api.nvim_set_hl(0, 'WinBarInfo', { bg = '', fg = '#cccccc', bold = true }) +end + +-- Function to get file size +function _G.get_filesize() + local filepath = vim.fn.expand('%:p') + if filepath == '' then + return '' + end + + local stat = vim.loop.fs_stat(filepath) + if not stat then + return '' + end + + local size = stat.size + if size < 1024 then + return size .. 'B' + elseif size < 1024 * 1024 then + return string.format('%.2fKiB', size / 1024) + else + return string.format('%.2fMiB', size / (1024 * 1024)) + end +end + +-- Function to build the winbar +function _G.get_winbar() + local mode = vim.api.nvim_get_mode().mode + local mode_config = { + ['n'] = { label = 'NORMAL', hl = 'WinBarNormal' }, + ['i'] = { label = 'INSERT', hl = 'WinBarInsert' }, + ['v'] = { label = 'VISUAL', hl = 'WinBarVisual' }, + ['V'] = { label = 'V-LINE', hl = 'WinBarVisual' }, + ['\22'] = { label = 'V-BLOCK', hl = 'WinBarVisual' }, + ['c'] = { label = 'COMMAND', hl = 'WinBarCommand' }, + ['t'] = { label = 'TERMINAL', hl = 'WinBarTerminal' }, + ['R'] = { label = 'REPLACE', hl = 'WinBarReplace' }, + } + + local config = mode_config[mode] or { label = mode, hl = 'WinBarNormal' } + + local filepath = vim.fn.expand('%:p') + local modified = vim.bo.modified and ' [*]' or '' + local encoding = vim.bo.fileencoding ~= '' and vim.bo.fileencoding or vim.o.encoding + local filesize = _G.get_filesize() + + -- Get cursor position + local line = vim.fn.line('.') + local col = vim.fn.col('.') + local total_lines = vim.fn.line('$') + + -- Build the winbar string with encoding on right side first + return string.format( + '%%#%s# %s %%#WinBarFilepath# %s%%#WarningMsg#%s%%=%%#WinBarInfo# %s %s:%s [%s] %s', + config.hl, + config.label, + filepath, + modified, + encoding, + line, + col, + total_lines, + filesize + ) +end + +-- Setup function +function M.setup() + setup_highlights() + + -- Update winbar on various events + vim.api.nvim_create_autocmd({ 'ModeChanged', 'BufEnter', 'CursorMoved', 'CursorMovedI' }, { + callback = function() + vim.wo.winbar = _G.get_winbar() + end, + }) + + -- Set initial winbar + vim.wo.winbar = _G.get_winbar() +end +return M