Replies: 5 comments 2 replies
-
Yes, you can do that. The way it works now is that it reacts to nvim's DiagnosticChanged event. Is there a similar event for CoC? The general idea is to call: require("neo-tree.sources.manager").diagnostics_changed("filesystem", {
diagnostics_lookup = {
"path/to/file" = { severity_number = 1, severity_string = "Error" },
"path/to/file2" = { severity_number = 2, severity_string = "Warning" }
}
}} ... whenever the diagnostic counts change. Here is the built-in function that creates the lookup from LSP Disagnostics: neo-tree.nvim/lua/neo-tree/utils.lua Line 104 in caa64cf |
Beta Was this translation helpful? Give feedback.
-
Thanks for your response. Yes, Coc has ‘User CocDiagnosticChange’. So I should call ‘ require("neo-tree.sources.manager").diagnostics_changed’ with a table of diagnostics on that event, right? How about the git information? |
Beta Was this translation helpful? Give feedback.
-
Actually, there might be a cleaner way to replace the built-in diagnostics. You can replace the built in event handler AFTER you call the setup() function like this: require("neo-tree").setup({
enable_diagnostics = true
...
})
local events = require("neo-tree.events")
events.destroy_event(events.VIM_DIAGNOSTIC_CHANGED)
events.define_autocmd_event(events.VIM_DIAGNOSTIC_CHANGED, { "User CocDiagnosticChange" }, 500, function(args)
args.diagnostics_lookup = utils.get_diagnostic_counts() -- <-- your handler here
return args
end) Doing it that way, you won't need to call For the git status data, there is no git event so I just pull that data before every render using the neo-tree require("neo-tree").setup({
enable_git_status = false,
event_handlers = {
{
event = "before_render",
handler = function(state)
state.git_status_lookup = require("neo-tree.git").status() -- <-- replace with your handler
end
},
}
}) The built-in git status provider is at: https://github.com/nvim-neo-tree/neo-tree.nvim/blob/v1.x/lua/neo-tree/git/init.lua |
Beta Was this translation helpful? Give feedback.
-
Thank you so much for the help. Indeed this looks like a cleaner way to override those functionalities. Also, thanks for this plugin, I appreciate the extra efforts making it so customizable. Closing this issue. |
Beta Was this translation helpful? Give feedback.
-
You're very welcome! One other thing you may want to consider is that you don't have to use the built-in components to display this either. if you want to build the lookups differently or display different info, you can create a custum component. the wiki has some examples: and of course:
Let me know if you run into any issues I can help with. If you come up with a good solution, please consider posting it back here or the Wiki. I am converting this to a discussion for others to find. |
Beta Was this translation helpful? Give feedback.
-
Can the user provide functions to return the lsp and git information? i.e. I want to override utils.get_diagnostic_counts to use CoC. It would be super helpful if the setup function can take functions to obtain the git and Lsp info .. complying with whatever api currently used by builtin functions.
Beta Was this translation helpful? Give feedback.
All reactions