Line numbers in Neo-Tree #843
-
Greetings! I'd like to start off by saying that I'm really enjoying neotree and I am thankful to the developers for maintaining and improving it! My question is related to line numbers in neotree. Is there a way to always show neotree line numbers? So far what I was doing when in a larger file tree I would have to go to the neotree buffer and type Is there a way to make this persistent or to specify a config option to always keep it on? I've searched through the wiki and a bit through the readme today but couldn't find it being mentioned just yet. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
After a bit of digging, I figured out where buffer/window options are being set. win_options = {
colorcolumn = "",
signcolumn = "no",
}, These options are passed to Nui.nvim where they are applied to the buffer that is created by Nui via Neo-tree. As you see, there is no (current) way to influence the window options that are generated. The current Neo-tree state is provided to the function local default_position = utils.resolve_config_option(state, "window.position", "left")
local relative = utils.resolve_config_option(state, "window.relative", "editor") In theory this could just be another configuration option that we tie to I imagine this would look like local numberline = utils.resolve_config_option(state, 'window.numberline', false)
-- .. Skipping down to the win_options
win_options = {
-- Everything that is already in here
-- New variable pulled from config
number = numberline
} Of course, this is something that @cseickel would need to be ok with, and likely we would need to convert this to an issue if they decide they are ok with this. Also I could be completely wrong and there is some way to do this that I did not see |
Beta Was this translation helpful? Give feedback.
-
There is a solution for this already that doesn't require changing the source code, see the answer to this issue: #608 Essentially you add this to your config: require("neo-tree").setup({
event_handlers = {
{
event = "neo_tree_buffer_enter",
handler = function(arg)
vim.opt.relativenumber = true
end,
}
}, You can also add other options here, like |
Beta Was this translation helpful? Give feedback.
After a bit of digging, I figured out where buffer/window options are being set.
neo-tree.ui.renderer.lua:L831-L834
These options are passed to Nui.nvim where they are applied to the buffer that is created by Nui via Neo-tree.
As you see, there is no (current) way to influence the window options that are generated.
The current Neo-tree state is provided to the function
renderer.create_window
function however, and above in that same function we actually get some config options