Customizing source #290
Replies: 10 comments 1 reply
-
I think that would be a whole new source. A lot of it would be shared with the existing "filesystem" source, but you'd also need to bring in LSP information. I'm not sure how "References" is built, that may logically be another source too. That makes the visual studio project pane really a combo of multiple sources, which is a very interesting concept. Are there specific aspects of the Visual Studio project pane that you are looking for? |
Beta Was this translation helpful? Give feedback.
-
That sounds a lot more complex than I initially assumed haha. My idea was that I somehow provide the list of files/directories myself to neo-tree and whenever it wants to interact with the filesystem I would translate the proxy path to the real path. For example: neo-tree would display the following structure
Now when I want to open the file neo-tree will ask me to resolve the I hope I explained it good enough
Just the more organized way of viewing the project |
Beta Was this translation helpful? Give feedback.
-
So that is definitely a new source. If you wanted to take a crack at this, there is a minimal boilerplate to get started with adding new sources: https://github.com/nvim-neo-tree/neo-tree.nvim/tree/v2.x/lua/neo-tree/sources/example Hopefully that has been kept up to date... You can also look at the other sources to see how they are done. The buffers source is particularly good because it is both actively used and a pretty simple implementation. |
Beta Was this translation helpful? Give feedback.
-
Of course, maybe I am overthinking this. If all you want to do is to display the project name as the root folder instead of the path, you can just override the |
Beta Was this translation helpful? Give feedback.
-
I think this is more what I meant. Please give me an example and thank you! |
Beta Was this translation helpful? Give feedback.
-
Here is how you can customize how the root is displayed: require('neo-tree').setup({
event_handlers = {
{
event = "before_render",
handler = function(state)
local root_path = state.path
state.project_name = nil
-- Do something to figure out if this is a project root_name
-- if so, then set the root_name to the project name.
-- This is in the before render event to ensure it is only called once
-- per render instead of once per node
state.project_name = "Project Name (" .. root_path .. ")"
end
},
},
filesystem = {
components = {
name = function(config, node, state)
-- first call the default name component
local cc = require("neo-tree.sources.common.components")
local result = cc.name(config, node, state)
-- if it is root, use the project name
if node:get_depth() == 1 and state.project_name then
result.text = state.project_name
end
return result
end
}
},
}) |
Beta Was this translation helpful? Give feedback.
-
I tried out just using a customized root, but after playing with this a bit I think I have to implement a custom source. |
Beta Was this translation helpful? Give feedback.
-
How can I provide the custom source in my own config? I looked through the code, but it looks like this currently is internal only. |
Beta Was this translation helpful? Give feedback.
-
Sorry I wasn't clear. A custom source is not a config option, it would require adding files to the project. It would actually be that difficult to allow external sources to be added as extensions though. Someday I may add that functionality. |
Beta Was this translation helpful? Give feedback.
-
You mean wouldn't right? I mean I don't know the codebase as well as you, but at first glance it doesn't seem to be hard. |
Beta Was this translation helpful? Give feedback.
-
Title might be a bit vague, but I am trying to do the following:
I am parsing the solution file of a visual studio project and I want to customize neo-tree in way so that it looks the same as in visual studio.
Is this currently possible?
Beta Was this translation helpful? Give feedback.
All reactions