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

Struggling to get non-default config #7

Closed
hlmtre opened this issue Oct 25, 2021 · 2 comments
Closed

Struggling to get non-default config #7

hlmtre opened this issue Oct 25, 2021 · 2 comments

Comments

@hlmtre
Copy link

hlmtre commented Oct 25, 2021

Hi! First off, thanks for this plugin; it's beautiful.

I'm struggling to get a non-default configuration of this plugin going. I've included the code chunk in the README at the beginning of my plugins.lua, and it does successfully load the lsp_progress component in lualine, but I actually had to modify lualine-lsp-progress's source to change the default-if-unset symbol from the block to the moon (which is, incidentally fabulous - I assume a reference to Lua meaning 'moon').

Anyway, relevant config below. This does not work - I still get the block spinners, instead of the moons.

plugins.lua
-- Color for highlights
local colors = {
  yellow = '#ECBE7B',
  cyan = '#008080',
  darkblue = '#081633',
  green = '#98be65',
  orange = '#FF8800',
  violet = '#a9a1e1',
  magenta = '#c678dd',
  blue = '#51afef',
  red = '#ec5f67'
}

local lualine_config = {
  options = {
    icons_enabled = true,
    theme = 'gruvbox',
    lower = true,
    component_separators = {'', ''},
    section_separators = {'', ''},
    disabled_filetypes = {}
  },
  sections = {
    lualine_a = {'mode'},
    lualine_b = {'filename', 'branch', {'diagnostics', sources = {'nvim_lsp'}}},
    lualine_c = {},
    lualine_x = {},
    lualine_y = {'encoding', 'fileformat', 'filetype'},
    lualine_z = {'progress','location'},
  },
  -- these aren't off; these are what are on when the window is unfocused
  inactive_sections = {
    lualine_a = {},
    lualine_b = {},
    lualine_c = {'filename'},
    lualine_x = {'location'},
    lualine_y = {},
    lualine_z = {}
  },
  tabline = {},
  extensions = {"nvim-tree", "quickfix"}
}

-- Inserts a component in lualine_c at left section
local function ins_left(component)
  table.insert(lualine_config.sections.lualine_c, component)
end

ins_left {
  'lsp_progress',
  colors = {
    percentage  = colors.cyan,
    title  = colors.cyan,
    message  = colors.cyan,
    spinner = colors.cyan,
    lsp_client_name = colors.magenta,
    use = true,
  },
  separators = {
    component = ' ',
    progress = ' | ',
    percentage = { pre = '', post = '%% ' },
    title = { pre = '', post = ': ' },
    lsp_client_name = { pre = '[', post = ']' },
    spinner = { pre = '', post = '' },
    message = { commenced = 'In Progress', completed = 'Completed' },
  },
  display_components = { 'lsp_client_name', 'spinner', { 'title', 'percentage', 'message' } },
  timer = { progress_enddelay = 500, spinner = 1000, lsp_client_name_enddelay = 1000 },
  spinner_symbols = { '🌑 ', '🌒 ', '🌓 ', '🌔 ', '🌕 ', '🌖 ', '🌗 ', '🌘 ' },
}
...
    use({
      "nvim-lualine/lualine.nvim",
      config = function()
        require('lualine').setup({
          extensions = lualine_config.extensions,
          options = lualine_config.options,
          sections = lualine_config.sections,
          inactive_sections = lualine_config.inactive_sections,
        })
      end,
    })

I assume I'm making a silly mistake, which will likely become obvious when you point it out. Thanks!

@arkav
Copy link
Owner

arkav commented Oct 29, 2021

Hello, it looks like your using packer lazy loading. Since lualine_config is defined as a local variable, when packer executes its compiled script it doesn't see anything outside the scope of your config function.

@hlmtre
Copy link
Author

hlmtre commented Oct 29, 2021 via email

@arkav arkav closed this as completed Oct 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants