Removed status line in favor of winbar

This commit is contained in:
Jason Hilder 2026-02-12 09:26:59 +02:00
parent 425bdec4ef
commit aa637123b1
2 changed files with 120 additions and 28 deletions

View File

@ -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.splitbelow = true -- Set vertical splits to the bottom as default
vim.o.completeopt = 'menuone,noselect' -- Configures how the completion menu works vim.o.completeopt = 'menuone,noselect' -- Configures how the completion menu works
vim.o.winborder = 'rounded' -- LSP hover borders vim.o.winborder = 'rounded' -- LSP hover borders
vim.opt.showmode = true vim.opt.showmode = false
vim.opt.laststatus = 0
--------------------------------------------------------------------------------- ---------------------------------------------------------------------------------
-- [[ PLUGINS ]] -- [[ PLUGINS ]]
@ -39,7 +40,7 @@ vim.pack.add({
{ src = "https://github.com/akinsho/toggleterm.nvim" }, { src = "https://github.com/akinsho/toggleterm.nvim" },
{ src = "https://github.com/folke/trouble.nvim" }, { src = "https://github.com/folke/trouble.nvim" },
{ src = "https://github.com/tribela/transparent.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") vim.cmd.colorscheme("kanagawa")
@ -48,34 +49,9 @@ require("trouble").setup()
require("mini.pick").setup() require("mini.pick").setup()
require("mini.pairs").setup() require("mini.pairs").setup()
require("mini.surround").setup() require("mini.surround").setup()
require("mini.statusline").setup()
require("oil").setup({ view_options = { show_hidden = true, } }) require("oil").setup({ view_options = { show_hidden = true, } })
require("toggleterm").setup({ open_mapping = [[<c-\>]], direction = "float" }) require("toggleterm").setup({ open_mapping = [[<c-\>]], direction = "float" })
require('winbar').setup()
--------------------------------------------------------------------------------
-- [[ 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
--------------------------------------------------------------------------------- ---------------------------------------------------------------------------------
-- [[ KEYMAPS ]] -- [[ KEYMAPS ]]
@ -119,3 +95,27 @@ vim.api.nvim_create_autocmd('TextYankPost', {
pattern = '*', 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

View File

@ -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