From daab7a91c0aafd317d4a5dc19a07efdb9bb99195 Mon Sep 17 00:00:00 2001 From: Avimitin Date: Thu, 1 Feb 2024 18:49:48 +0800 Subject: [PATCH] Add support for global statusline Signed-off-by: Avimitin --- lua/galaxyline.lua | 21 ++++++++++++++++++--- plugin/galaxyline.vim | 4 ++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lua/galaxyline.lua b/lua/galaxyline.lua index 765dcec..6b6a704 100644 --- a/lua/galaxyline.lua +++ b/lua/galaxyline.lua @@ -2,6 +2,7 @@ local vim = vim local uv = vim.loop local M = {} +M.global_status_line = false M.section = {} M.section.left = {} M.section.right = {} @@ -208,7 +209,12 @@ async_combin = uv.new_async(vim.schedule_wrap(function() line = short_line end - vim.wo.statusline = line + if M.global_status_line then + vim.go.statusline = line + else + vim.wo.statusline = line + end + M.init_colorscheme() end)) @@ -230,7 +236,12 @@ function M.init_colorscheme() end function M.disable_galaxyline() - vim.wo.statusline = '' + if M.global_status_line then + vim.go.statusline = '' + else + vim.wo.statusline = '' + end + vim.api.nvim_command('augroup galaxyline') vim.api.nvim_command('autocmd!') vim.api.nvim_command('augroup END!') @@ -243,7 +254,11 @@ function M.galaxyline_augroup() local command = string.format('autocmd %s * lua require("galaxyline").load_galaxyline()',def) vim.api.nvim_command(command) end - vim.api.nvim_command('autocmd WinLeave * lua require("galaxyline").inactive_galaxyline()') + + if not M.global_status_line then + vim.api.nvim_command('autocmd WinLeave * lua require("galaxyline").inactive_galaxyline()') + end + vim.api.nvim_command('augroup END') end diff --git a/plugin/galaxyline.vim b/plugin/galaxyline.vim index 8ae0d0b..73b8669 100644 --- a/plugin/galaxyline.vim +++ b/plugin/galaxyline.vim @@ -12,6 +12,10 @@ endif let g:loaded_galaxyline = 1 +if &laststatus == 3 + lua require('galaxyline').global_status_line = true +endif + lua require('galaxyline').galaxyline_augroup() let &cpo = s:save_cpo