neo-tree.nvim
neo-tree.nvim copied to clipboard
Use sign column for diagnostics
but is it better to explicitly set it to off by default, or do nothing and assume the user's global default is what they expect?
I think if the signcolumn is not being used, it should be hidden by default. It shouldn't just be used for padding. There is already an option for padding in indent
component.
On related note, an option to display diagnostic in signcolumn would be nice!
Originally posted by @MunifTanjim in https://github.com/nvim-neo-tree/neo-tree.nvim/issues/408#issuecomment-1180207512
This is an interesting idea. I put it here to gauge interest from others. By using the sign column, you are essentially just left aligning the diag sign instead of the default right align.
Hi @cseickel, congratulations for your amazing work.
I think that using the gutter columns maybe helps to solving an issue that's coming from use numbers and relative numbers.
If you use those options, the signs at right side are displaced out of the neo-tree window. I should to try padding options yet. I've read the docs just a couples of times since migration from nvim-tree.
Cheers!
@barreiroleo One workaround is to use right_padding
on the container
component, but setting that globally only works in the main
branch right now:
require("neo-tree").setup({
default_component_configs = {
container = {
padding_right = 4,
},
}
})
You can also set custom renderers
that do not right align the symbols at all.
require("neo-tree").setup({
filesystem = {
renderers = {
directory = {
{ "indent" },
{ "icon" },
{ "current_filter" },
{ "name" },
{ "clipboard" },
{ "diagnostics", errors_only = true },
},
file = {
{ "indent" },
{ "icon" },
{
"name",
use_git_status_colors = true,
zindex = 10
},
{ "clipboard" },
{ "bufnr" },
{ "modified" },
{ "diagnostics" },
{ "git_status" },
}
},
},
})
(there may be typos in the above...)
Yeah, this works. I took the templates from defaults.lua. Do not pay attention to structure as a module, it's part of my config. Anyway, It would be nice to have diagnostics in the proper column.
M.directory = {
{ "indent" },
{ "icon" },
{ "current_filter" },
{ "container",
width = "100%",
right_padding = 4,
--max_width = 60,
content = {
{ "name", zindex = 10 },
{ "symlink_target",
zindex = 10,
highlight = "NeoTreeSymbolicLinkTarget",
},
{ "clipboard", zindex = 10 },
{ "diagnostics", errors_only = false, zindex = 20, align = "right" },
{ "git_status", zindex = 20, align = "right" },
},
}
}
M.file = {
{ "indent" },
{ "icon" },
{ "container",
width = "100%",
right_padding = 4,
--max_width = 60,
content = {
{ "name", zindex = 10 },
{ "symlink_target",
zindex = 10,
highlight = "NeoTreeSymbolicLinkTarget",
},
{ "clipboard", zindex = 10 },
{ "bufnr", zindex = 10 },
{ "modified", zindex = 20, align = "right" },
{ "diagnostics", zindex = 20, align = "right" },
{ "git_status", zindex = 20, align = "right" },
},
}
}
Thanks for all @cseickel, best regards!
Thanks for all @cseickel, best regards!
You're welcome!
BTW - I'd also consider it a bug that the sign and number columns are not accounted for when right aligning. I'd like to fix that one day as well...
Yeah, I was investigating to propose it as PR, but the methods available in the api only report the size of the window. Maybe you can check the status of "vim.g.number/relativenumber" but I think it's a bit hacky.
Set in the buffer a character on the -1 column, get the line and search for his position is another obscure way. I don't know, just I'm thinking aloud...
All the solutions I've seen are hacky. I've previously investigated this because I want to autosize splits when I focus them to match the longest line, but I didn't do it because I didn't like what I had to do to find the usable size of a window.
The best thing to do is to add this functionality to neovim itself, I might do that someday.
The next best thing would be to add the hacky function to plenary where lots of users can find and fix edge cases.
@barreiroleo FYI: https://github.com/nvim-neo-tree/neo-tree.nvim/commit/58d88d5636e85496465cb20ed3e636ac63936804
Good news @cseickel, I didn't notice textoff
. My fault, sorry
My fault, sorry
Nothing to be sorry about, I just found out about it too! It seems to be a rather new feature.
now that statuscolumn is implemented in neovim v0.9 this feature would be interesting :)