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