Skip to content

feat: Add support for coc.nvim - #172

Open
samhed wants to merge 1 commit into
SmiteshP:masterfrom
samhed:coc-support
Open

feat: Add support for coc.nvim#172
samhed wants to merge 1 commit into
SmiteshP:masterfrom
samhed:coc-support

Conversation

@samhed

@samhed samhed commented Jul 10, 2026

Copy link
Copy Markdown

We could previously only get document symbols through Neovim's builtin LSP client. This adds a second request path that uses coc.nvim's "documentSymbols" action.

New API:

  • navic.attach_coc(bufnr) to attach manually
  • coc = { auto_attach = true } setup option, which attaches to buffers once Coc reports a documentSymbol provider for them.

Note that Coc has no LspAttach equivalent, and providers register asynchronously, so this polls hasProvider on BufEnter/CursorHold until one shows up.

The buffer is marked with navic_client_name = "coc", so is_available(), the lualine component, and the one-client-per-buffer conflict handling all work unchanged.

Closes #53

nvim-navic could previously only get document symbols through Neovim's
builtin LSP client. This adds a second request path that uses coc.nvim's
"documentSymbols" action.

New API:
- navic.attach_coc(bufnr) to attach manually
- coc = { auto_attach = true } setup option, which attaches to buffers
  once coc reports a documentSymbol provider for them.

Note that CoC has no LspAttach equivalent and providers register
asynchronously, so this polls hasProvider on BufEnter/CursorHold until
one shows up.

The buffer is marked with navic_client_name = "coc", so is_available(),
the lualine component and the one-client-per-buffer conflict handling
all work unchanged.

Closes SmiteshP#53
@samhed

samhed commented Jul 10, 2026

Copy link
Copy Markdown
Author

Tested in Neovim v0.12.4 together with Lazy, Lualine, and Coc-extensions for Lua, C++, Python, and JavaScript.

The relevant configs I used:

lazy.nvim:

{
    dir = "~/devel/nvim-navic",
    dependencies = "neoclide/coc.nvim",
    config = require("setup.navic"),
    event = "VeryLazy",
}

setup.navic:

return function()
    require('nvim-navic').setup({
        coc = {
            auto_attach = true,
        },
    })
end

lualine:

return function()
    require("nvim-navic")
    require("lualine").setup({
      ...
      winbar = {
          lualine_a = {},
          lualine_b = {},
          lualine_c = {},
          lualine_x = {
              { 'filetype', icon_only = true, separator = '' },
              { 'filename', symbols = { unnamed = '' } },
          },
          lualine_y = {
              { "navic", color_correction = nil, navic_opts = nil },
          },
          lualine_z = {},
       ...
    },

@samhed samhed changed the title Add support for coc.nvim feat: Add support for coc.nvim Jul 10, 2026
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

Successfully merging this pull request may close these issues.

integration with coc.nvim

1 participant