diff --git a/README.md b/README.md index 31cf344..e0689df 100644 --- a/README.md +++ b/README.md @@ -398,6 +398,17 @@ extensions = {'quickfix'} +
+Custom extensions + +You can define your own extensions. If you think an extension might be useful for others then please submit a pr. +```lua +local my_extension = {sections = {lualine_a = 'mode'}, filetypes = {'lua'}} +require'lualine'.setup {extensions = {my_extension}} +``` + +
+ --- ### Disabling lualine You can disable lualine for specific filetypes diff --git a/doc/lualine.txt b/doc/lualine.txt index a904339..c1a3a31 100644 --- a/doc/lualine.txt +++ b/doc/lualine.txt @@ -313,13 +313,22 @@ You can load extensions with: > extensions = {'quickfix'} < -Available extensions +Available extensions~ * |chadtree| * |fugitive| * |fzf| * |nerdtree| * |nvim-tree| * |quickfix| + * + +Custom extensions~ + +You can define your own extensions. +If you think an extension might be useful for others then please submit a pr. +> + local my_extension = {sections = {lualine_a = 'mode'}, filetypes = {'lua'}} + require'lualine'.setup {extensions = {my_extension}} ------------------------------------------------------------------------------ DISABLING LUALINE *lualine-disable* diff --git a/lua/lualine/utils/loader.lua b/lua/lualine/utils/loader.lua index 066a652..50b80f6 100644 --- a/lua/lualine/utils/loader.lua +++ b/lua/lualine/utils/loader.lua @@ -52,9 +52,14 @@ end 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) - config.extensions[index] = local_extension + if type(extension) == 'string' then + local local_extension = require('lualine.extensions.' .. extension) + load_sections(local_extension.sections, config.options) + config.extensions[index] = local_extension + elseif type(extension) == 'table' then + load_sections(extension.sections, config.options) + config.extensions[index] = extension + end end end