Improve hiding/showing statusline via config

navigator
Akianonymus 3 years ago committed by siduck76
parent dbf0b56059
commit 1f6dbed26b

@ -17,12 +17,16 @@ M.ui = {
-- For Ex : if you have onedark set in nvchad , set onedark's bg color on your terminal
transparency = false,
hidden_statusline = {
-- statusline related options
statusline = {
-- these are filetypes, not pattern matched
"NvimTree",
"terminal",
-- if a filetype is present in shown, it will always show the statusline, irrespective of filetypes in hidden
hidden = {},
shown = {
-- "terminal"
},
style = "default", -- default, round , slant , block , arrow
},
statusline_style = "default", -- default, round , slant , block , arrow
}
M.options = {

@ -17,12 +17,17 @@ M.ui = {
-- For Ex : if you have onedark set in nvchad , set onedark's bg color on your terminal
transparency = false,
hidden_statusline = {
-- statusline related options
statusline = {
-- these are filetypes, not pattern matched
"NvimTree",
-- "terminal",
-- if a filetype is present in shown, it will always show the statusline, irrespective of filetypes in hidden
hidden = {
"NvimTree",
"terminal",
},
shown = {},
style = "default", -- default, round , slant , block , arrow
},
statusline_style = "default", -- default, round , slant , block , arrow
}
M.options = {

@ -78,9 +78,10 @@ end
-- Don't show any numbers inside terminals
vim.cmd [[ au TermOpen term://* setlocal nonumber norelativenumber ]]
-- Don't show status line on certain windows
vim.cmd [[ au TermOpen term://* setfiletype terminal ]]
vim.cmd [[ let hidden_statusline = luaeval('require("utils").load_config().ui.hidden_statusline') | autocmd BufEnter,BufWinEnter,WinEnter,CmdwinEnter,TermEnter * nested if index(hidden_statusline, &ft) >= 0 | set laststatus=0 | else | set laststatus=2 | endif ]]
-- Don't show status line on certain windows
vim.cmd [[ autocmd BufEnter,BufWinEnter,WinEnter,CmdwinEnter,TermEnter * lua require("utils").hide_statusline() ]]
-- Open a file from its last left off position
-- vim.cmd [[ au BufReadPost * if expand('%:p') !~# '\m/\.git/' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif ]]

@ -181,6 +181,28 @@ M.file = function(mode, filepath, content)
return data
end
-- hide statusline
-- tables fetched from load_config function
M.hide_statusline = function(values)
local hidden = require("utils").load_config().ui.statusline.hidden
local shown = require("utils").load_config().ui.statusline.shown
local api = vim.api
local buftype = api.nvim_buf_get_option("%", "ft")
-- shown table from config has the highest priority
if vim.tbl_contains(shown, buftype) then
api.nvim_set_option("laststatus", 2)
return
end
if vim.tbl_contains(hidden, buftype) then
api.nvim_set_option("laststatus", 0)
return
else
api.nvim_set_option("laststatus", 2)
end
end
-- return a table of available themes
M.list_themes = function(return_type)
local themes = {}

Loading…
Cancel
Save