feat: Add support for coc.nvim - #172
Open
samhed wants to merge 1 commit into
Open
Conversation
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
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,
},
})
endlualine: 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 = {},
...
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 manuallycoc = { 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