SmiteshP / nvim-navic

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

Docs for `click` somewhat confusing #132

Closed sullyj3 closed 1 year ago

sullyj3 commented 1 year ago

Hi, I wasn't quite sure how to get click working. From reading the readme, it wasn't clear to me

I experimented with enabling click in setup, and using the native method:

use {
    'SmiteshP/nvim-navic',
    requires = "neovim/nvim-lspconfig",
    config = function()
        require 'nvim-navic'.setup {
        click = true,
        }
    end
}

-- ...

local on_attach = function(client, bufnr)
    if client.server_capabilities.documentSymbolProvider then
        require('nvim-navic').attach(client, bufnr)
        vim.o.winbar = "%{%v:lua.require'nvim-navic'.get_location()%}"
    end

-- ...

But clicking didn't seem to work.

If you could clear these questions up for me, I'd be happy to submit a docs PR.

SmiteshP commented 1 year ago

Make sure that the terminal emulator you are using supports click Or if there is a option to enable clicks in it

bigolu commented 1 year ago

I had the same issue and it looks like the value of click is only being used when it is passed to get_location(). So instead of passing click = true in the setup() function you can set your winbar like this and it should work: vim.o.winbar = "%{%v:lua.require'nvim-navic'.get_location({'click': v:true})%}".

To fix this, the code for applying the click option in the format_data() function, which gets called by the get_location() function, just needs to be added to the setup() function. Or better yet, have a central function that both setup() and get_location() can call to apply options so the two are always in sync

SmiteshP commented 1 year ago

Fixed in latest commit