SmiteshP / nvim-navic

Simple winbar/statusline plugin that shows your current code context

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Winbar escaping not working

aareman opened this issue · comments

Thank you for this plugin.

Winbar esaping doesn't work, but statusline does.

image

navic setup

local M = {}
local navic = require("nvim-navic")
local gps = require("nvim-gps")

gps.setup()
navic.setup({
    highlight = true,
    safe_output = true,
    icons = {
        File = '',
        Module = '',
        Namespace = '',
        Package = '',
        Class = '',
        Method = '',
        Property = '',
        Field = '',
        Constructor = '',
        Enum = '',
        Interface = '',
        Function = '',
        Variable = '',
        Constant = '',
        String = '',
        Number = '',
        Boolean = '',
        Array = '',
        Object = '',
        Key = '',
        Null = '',
        EnumMember = '',
        Struct = '',
        Event = '',
        Operator = '',
        TypeParameter = ''
    }
})

local function get_context()
    if navic.is_available() then
        return navic.get_location()
    elseif gps.is_available() then
        return gps.get_location()
    elseif require("nvim-treesitter").statusline(90) then
        return require("nvim-treesitter").statusline(90)
    else
        return ''
    end
end

M.get_context = get_context

I have a get_context function that tries navic, then gps, than treesitter vanilla, and then returns '' otherwise.

winbar setup

In my init.vim, I have

set winbar=%{v:lua.orgmode.statusline()}
" This DOESN'T work (that's the screenshot above)
set winbar+=%{v:lua.require'aareman.lualine'.get_context()}
" This works, but I don't know why. 
" set winbar+=%{%v:lua.require'nvim-navic'.get_location()%}
set winbar+=%= " right align
set winbar+=%m " Modified
set winbar+=\ %f " Filename

🤦‍♂️ See this

- set winbar+=%{v:lua.require'aareman.lualine'.get_context()}
+ set winbar+=%{%v:lua.require'aareman.lualine'.get_context()%}