Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for global statusline #240

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions lua/galaxyline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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))

Expand All @@ -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!')
Expand All @@ -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

Expand Down
4 changes: 4 additions & 0 deletions plugin/galaxyline.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down