fix: extensions not loading properly (#232)
* refactor: removed inactive sections from extensions * fix: extensions not loading properly
This commit is contained in:
parent
31de50919a
commit
f644841206
|
@ -6,8 +6,6 @@ local M = {}
|
|||
|
||||
M.sections = vim.deepcopy(nerdtree.sections)
|
||||
|
||||
M.inactive_sections = vim.deepcopy(nerdtree.inactive_sections)
|
||||
|
||||
M.filetypes = {'CHADTree'}
|
||||
|
||||
return M
|
||||
|
|
|
@ -9,8 +9,6 @@ end
|
|||
|
||||
M.sections = {lualine_a = {fugitive_branch}, lualine_z = {'location'}}
|
||||
|
||||
M.inactive_sections = vim.deepcopy(M.sections)
|
||||
|
||||
M.filetypes = {'fugitive'}
|
||||
|
||||
return M
|
||||
|
|
|
@ -6,8 +6,6 @@ local M = {}
|
|||
|
||||
M.sections = {lualine_a = {fzf_statusline}}
|
||||
|
||||
M.inactive_sections = vim.deepcopy(M.sections)
|
||||
|
||||
M.filetypes = {'fzf'}
|
||||
|
||||
return M
|
||||
|
|
|
@ -6,8 +6,6 @@ local M = {}
|
|||
|
||||
M.sections = {lualine_a = {get_short_cwd}}
|
||||
|
||||
M.inactive_sections = vim.deepcopy(M.sections)
|
||||
|
||||
M.filetypes = {'nerdtree'}
|
||||
|
||||
return M
|
||||
|
|
|
@ -4,9 +4,7 @@ local nerdtree = require('lualine.extensions.nerdtree')
|
|||
|
||||
local M = {}
|
||||
|
||||
M.sections = vim.deepcopy(nerdtree.inactive_sections)
|
||||
|
||||
M.inactive_sections = vim.deepcopy(nerdtree.inactive_sections)
|
||||
M.sections = vim.deepcopy(nerdtree.sections)
|
||||
|
||||
M.filetypes = {'NvimTree'}
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@ M.sections = {
|
|||
lualine_z = {'location'}
|
||||
}
|
||||
|
||||
M.inactive_sections = vim.deepcopy(M.sections)
|
||||
|
||||
M.filetypes = {'qf'}
|
||||
|
||||
return M
|
||||
|
|
|
@ -91,17 +91,14 @@ end
|
|||
|
||||
-- check if any extension matches the filetype and return proper sections
|
||||
local function get_extension_sections()
|
||||
local sections, inactive_sections = nil, nil
|
||||
for _, extension in ipairs(config.extensions) do
|
||||
for _, filetype in ipairs(extension.filetypes) do
|
||||
if vim.bo.filetype == filetype then
|
||||
sections = extension.sections
|
||||
inactive_sections = extension.inactive_sections
|
||||
break
|
||||
end
|
||||
local current_ft = vim.api.nvim_buf_get_option(
|
||||
vim.fn.winbufnr(vim.g.statusline_winid), 'filetype')
|
||||
if current_ft == filetype then return extension.sections end
|
||||
end
|
||||
end
|
||||
return {sections = sections, inactive_sections = inactive_sections}
|
||||
return nil
|
||||
end
|
||||
|
||||
local function status_dispatch()
|
||||
|
@ -116,15 +113,15 @@ local function status_dispatch()
|
|||
end
|
||||
local extension_sections = get_extension_sections()
|
||||
if vim.g.statusline_winid == vim.fn.win_getid() then
|
||||
local sections = extension_sections.sections
|
||||
if sections == nil then sections = config.sections end
|
||||
return statusline(sections, true)
|
||||
else
|
||||
local inactive_sections = extension_sections.inactive_sections
|
||||
if inactive_sections == nil then
|
||||
inactive_sections = config.inactive_sections
|
||||
if extension_sections ~= nil then
|
||||
return statusline(extension_sections, true)
|
||||
end
|
||||
return statusline(inactive_sections, false)
|
||||
return statusline(config.sections, true)
|
||||
else
|
||||
if extension_sections ~= nil then
|
||||
return statusline(extension_sections, false)
|
||||
end
|
||||
return statusline(config.inactive_sections, false)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -173,7 +170,7 @@ local function set_statusline()
|
|||
augroup lualine
|
||||
autocmd!
|
||||
autocmd WinLeave,BufLeave * lua vim.wo.statusline=require'lualine'.statusline()
|
||||
autocmd WinEnter,BufEnter * set statusline<
|
||||
autocmd BufWinEnter,WinEnter,BufEnter * set statusline<
|
||||
autocmd VimResized * redrawstatus
|
||||
augroup END
|
||||
]], false)
|
||||
|
|
|
@ -54,7 +54,6 @@ local function load_extensions(config)
|
|||
for index, extension in pairs(config.extensions) do
|
||||
local local_extension = require('lualine.extensions.' .. extension)
|
||||
load_sections(local_extension.sections, config.options)
|
||||
load_sections(local_extension.inactive_sections, config.options)
|
||||
config.extensions[index] = local_extension
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue