SmiteshP / nvim-navic

Simple winbar/statusline plugin that shows your current code context
Apache License 2.0
1.43k stars 50 forks source link

Lualine example error #121

Closed karma-riuk closed 1 year ago

karma-riuk commented 1 year ago

I've spotted a slight mistake in the README.md, namely in the example for lualine.

If I insert the code from the README.md (c.f. code below)

winbar = {
        lualine_c = {
            "navic",
            color_correction = "static",
            navic_opts = { highlight = true }
        }
    }
}

I get a notification that tells me there was an error with lualine and to run :LualineNotices. The output of the latter is the following (shortened, because it was duplicated for both color_correction and navic_opts):

Unrecognized component

Only functions, strings and tables can be used as component. You seem to have a table as component indexed as navic_opts. Something like:

    navic_opts = {
  highlight = true
},

This commonly occurs when you forget to pass table with option for component. When a component has option that component needs to be a table which holds the component as first element and the options as key value pairs. For example:

lualine_c = {
    {'diagnostics',
        sources = {'nvim'},
    }
}

Notice the inner extra {} surrounding the component and it's options. Make sure your config follows this.

If we follow the message, by simply applying the braces around the component, then it works! So the correct version of the example would be the following:

winbar = {
    lualine_c = {
        {
            "navic",
            color_correction = "static",
            navic_opts = { highlight = true },
        },
    },
}

I will create a PR to fix this minor issue.