Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indent lines #1136

Closed
drjosephliu opened this issue May 31, 2020 · 5 comments · Fixed by #1138
Closed

Indent lines #1136

drjosephliu opened this issue May 31, 2020 · 5 comments · Fixed by #1138

Comments

@drjosephliu
Copy link

Description

When you open the file explorer, it can sometimes be hard to determine the level of nesting for each of the files display. It would be great if there was indent lines displayed to help you determine that.

PhilRunninger added a commit that referenced this issue Jun 1, 2020
conceallevel=3 always hides the character, but conceallevel=2 allows an
alternate character to be displayed instead.
PhilRunninger added a commit that referenced this issue Jun 1, 2020
* Closes #1136. Allow concealed characters to show another character.

conceallevel=3 always hides the character, but conceallevel=2 allows an
alternate character to be displayed instead.

* Update version number in changelog.
@PhilRunninger
Copy link
Member

Lines showing the tree structure were removed from NERDTree nine years ago (commit eac3214), long before I took over support for it. I can only guess as to why, but Martin may have liked the cleaner look of the triangles and no lines. I have no plans to reintroduce the lines, because I think they clutter the display.

You can, however, simulate them to a certain extent with some clever syntax rules. Save the following text to your vim setup. Pay attention to the file's name and path:

~/.vim/after/syntax/nerdtree.vim

" This block displays every other leading space in the NERDTree buffer as
" a vertical bar. It works only if your vim has the +conceal feature
" turned on, and this file must be saved as ~/.vim/after/syntax/nerdtree.vim
" to work properly.

if has("conceal")
    syntax clear NERDTreeOpenable
    syntax clear NERDTreeClosable
    let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~]\-').escape(g:NERDTreeDirArrowExpandable, '~]\-')
    exec 'syntax match MarkIndents #\(  \)\{-}\zs \ze \(  \)*\(['.s:dirArrows.' ] \)\?'.g:NERDTreeNodeDelimiter.'# containedin=ALL conceal cchar=|'
endif

It will display every other leading space as a vertical bar, like so:
image

You will need to pull the latest version of NERDTree, and nerdtree-buffer-ops if you use it.

@PhilRunninger
Copy link
Member

PhilRunninger commented Jun 1, 2020

vim-devicons is another NERDTree plugin, and it sets conceallevel=3, which may cause the above snippet to not work, depending on the order in which the syntax statements are called. If you are using it, you can create an issue there and reference this one.

@drjosephliu
Copy link
Author

This is great, thank you!

@alexnix
Copy link

alexnix commented Jan 12, 2021

Could this be like a configurable setting? I would like to activate it too, and at the same time I wish this persists in my vimrc so I can easily replicate my environment on a different pc and such...

Thanks

PS: I could implement it and do PR but I need some hints how to do it

@PhilRunninger
Copy link
Member

@alexnix No, as stated above, I won't reintroduce the lines into NERDTree. As far as your vim configuration goes, don't try to put every setup statement into your vimrc file. Your config can, and should, contain multiple files in several folders. The files in the different folders are sourced at the appropriate time or for specific purposes, and using the folders makes your config simpler than trying to accomplish that in a single vimrc file. Take a look at my Neovim setup for an example of how to do it. With it being in Github, replicating my vim environment is as simple as cloning the repo on a new machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants