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

New shortline options #218

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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ The type of all of these section variables:
- `require('galaxyline').short_line_list` some special filetypes that show a
short statusline like `LuaTree defx coc-explorer vista` etc.

- `require('galaxyline').short_line_buftypes` list of buftypes that act like `short_line_list`

- `require('galaxyline').section.left` the statusline left section.

- `require('galaxyline').section.mid` the statusline mid section.
Expand All @@ -50,6 +52,8 @@ The type of all of these section variables:
- `require('galaxyline').section.short_line_right` statusline right section when
filetype is in `short_line_list` and for inactive window

- `require('galaxyline').inactive_window_shortline` whether inactive windows should use short statusline (default: `true`)


### Component keyword

Expand Down
10 changes: 9 additions & 1 deletion lua/galaxyline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ M.section.mid = {}
M.section.short_line_left = {}
M.section.short_line_right = {}
M.short_line_list = {}
M.short_line_buftypes = {}
M.inactive_window_shortline = true

_G.galaxyline_providers = {}

Expand Down Expand Up @@ -206,6 +208,8 @@ async_combin = uv.new_async(vim.schedule_wrap(function()

if vim.fn.index(M.short_line_list,vim.bo.filetype) ~= -1 then
line = short_line
elseif vim.fn.index(M.short_line_buftypes,vim.bo.buftype) ~= -1 then
line = short_line
end

vim.wo.statusline = line
Expand All @@ -217,7 +221,11 @@ function M.load_galaxyline()
end

function M.inactive_galaxyline()
if next(M.short_line_list) == nil then
if not M.inactive_window_shortline then
return
end

if next(M.short_line_list) == nil and next(M.short_line_buftypes) == nil then
vim.wo.statusline = normal_line
else
vim.wo.statusline = short_line
Expand Down
6 changes: 6 additions & 0 deletions lua/galaxyline/provider_fileinfo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ function M.filename_in_special_buffer()
return ''
end
end
local short_list_buftypes = require('galaxyline').short_list_buftypes
for _,v in ipairs(short_list_buftypes) do
if v == vim.bo.buftype then
return ''
end
end
return fname
end

Expand Down