tamton-aquib / staline.nvim

A modern lightweight statusline and bufferline plugin for neovim in lua.
MIT License
373 stars 16 forks source link

can we add custom statusline module. #4

Closed ghost closed 3 years ago

ghost commented 3 years ago

I wanted to add nvim_lsp diagnostics and treesitter nearest function to my staline.

tamton-aquib commented 3 years ago

Hey @blackCauldron7 , sorry for the inconvenience and late reply.😅

As it states in README, staline doesn't have git or lsp related stuff by default but, defaults.filename_section and defaults.cool_symbol can take custom modules.

The easiest way would be to create a function which returns a string and pass it to filename_section or cool_symbol. For example,

function Get_lsp_stuff()
    local errors = vim.lsp.diagnostic.get_count(0, 'Error')
    return " "..errors
end

and pass that function into filename_section,

require'staline'.setup{
    defaults = {
        filename_section = '%{luaeval("Get_lsp_stuff()")}'
    }
}

Which would look something like,

image

ghost commented 3 years ago

thanks that works.

Thanks for the Amazing Plugin.