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

Hide square brackets around flag string? #815

Closed
eivindml opened this issue Mar 12, 2018 · 11 comments
Closed

Hide square brackets around flag string? #815

eivindml opened this issue Mar 12, 2018 · 11 comments

Comments

@eivindml
Copy link

Hi,

is there a way, or is it possible to add an option to hide the square brackets around the flag string (e.g. used by the nerdtree-git-plugin)? I think that would look much cleaner.

Screenshot

Relevant code here: https://github.com/scrooloose/nerdtree/blob/509122df20e200b50e887c32cb7d92b19171a4ab/lib/nerdtree/flag_set.vim#L55

@kutsan
Copy link
Contributor

kutsan commented Mar 13, 2018

You can achieve that by concealing those characters with conceal. They will be still there unfortunately but conceal will hide them for you. You just won't see them anymore.

augroup nerdtreeconcealbrackets
      autocmd!
      autocmd FileType nerdtree syntax match hideBracketsInNerdTree "\]" contained conceal containedin=ALL
      autocmd FileType nerdtree syntax match hideBracketsInNerdTree "\[" contained conceal containedin=ALL
      autocmd FileType nerdtree setlocal conceallevel=3
      autocmd FileType nerdtree setlocal concealcursor=nvic
augroup END

By the way, if by any chance happen to use vim-devicons plugin in future; that plugin handles those characters for you.

Also, see #806 and #807 for bonus tips.

@eivindml
Copy link
Author

Thank you for this. :)

It did work, but it was a bit buggy. The "+" symbol was a too close. And I would prefer to have a space between the symbol and the title. Maybe to have the icons at the end of the title would be best, so the indentation of files/folders are always the same. Now it can be a bit visually confusing as they get indented differently depending on if they have a icon or not.

Think I will stick with default settings for now. :) But I will check out the great bonus tips.

screen shot 2018-03-13 at 12 53 09

For others seeing this, remember that default vim shipped with macOS doesn't have the conceal thing, so you need to get a newer vim from homebrew for instance. (I didn't know this at first)

@PhilRunninger
Copy link
Member

Changing the conceallevel from 3 to 1 will introduce the space you're looking for. See :h conceallevel.

@eivindml
Copy link
Author

thanks. :) Then this happened?

screen shot 2018-03-13 at 13 14 24

@PhilRunninger
Copy link
Member

PhilRunninger commented Mar 13, 2018

Or even better than conceallevel=1,

augroup nerdtreeconcealbrackets
      autocmd!
      autocmd FileType nerdtree syntax match hideBracketsInNerdTree "\]" contained conceal containedin=ALL cchar= 
      autocmd FileType nerdtree syntax match hideBracketsInNerdTree "\[" contained conceal containedin=ALL
      autocmd FileType nerdtree setlocal conceallevel=2
      autocmd FileType nerdtree setlocal concealcursor=nvic
augroup END

The cchar= value is a space. conceallevel=2 uses that explicitly defined space to replace the ], and it completely hides the [ because no cchar is specified for that one.

The reason your concealed characters are visible is because your color scheme is not setting the Conceal highlight. You can set it yourself or find another color scheme that does. See pangloss/vim-javascript#151 for a discussion about this issue.

@kutsan
Copy link
Contributor

kutsan commented Mar 13, 2018

@eivindml

It did work, but it was a bit buggy. The "+" symbol was a too close. And I would prefer to have a space between the symbol and the title.

You can tweak that by adding a space character after each icon for that plugin. I know I know, it's still hacky solution but that's what we have.

let g:NERDTreeIndicatorMapCustom = {
    \ "Modified"  : "",
    \ "Staged"    : "",
    \ "Untracked" : "",
    \ "Renamed"   : "",
    \ "Unmerged"  : "",
    \ "Deleted"   : "",
    \ "Dirty"     : "",
    \ "Clean"     : "✔︎ ",
    \ 'Ignored'   : '',
    \ "Unknown"   : "? "
    \ }

Maybe to have the icons at the end of the title would be best, so the indentation of files/folders are always the same.

Yes, I feel you. That's probably why I don't use that plugin. I think it would be better to get rid off all icon stuff and just use highlighting instead of icons; if it's modified, then highlight its foreground color as yellow like other IDEs does.

NERDTree itself is poorly written, so its plugins use some hacks to achieve that kind of functionality.

@PhilRunninger
Copy link
Member

@eivindml If you are satisfied with these answers, please close the issue. Thanks!

@eivindml
Copy link
Author

Thanks for the help. I also think just highlighting the status with colour would be best.

I use Atom on and off, and how they do it works really well.

Hopefully someone takes up the challenge to create something like this. Will close this issue.

screen shot 2018-03-16 at 10 52 55

@kutsan
Copy link
Contributor

kutsan commented Mar 16, 2018

Back then, I did something with my local nerdtree-git-plugin fork but it was buggy, not usable; and due to vim highlight mechanics, it was slow; we were creating a highlight element every single file node, which is insane when it comes to performance. I don't have any motivation to continue now.

I've been using vim for years and I'd like to say it's not really great experience (at least for me) when you start to make some integration plugins like git.

image

@eivindml
Copy link
Author

Yeah. I can see that. That looks really good though. :)

@aanari
Copy link

aanari commented May 20, 2020

Since I am also using the syntax highlighting plugin, this did the trick for me:

augroup nerdtree
  autocmd!
  autocmd FileType nerdtree syntax clear NERDTreeFlags
  autocmd FileType nerdtree syntax match hideBracketsInNerdTree "\]" contained conceal containedin=ALL
  autocmd FileType nerdtree syntax match hideBracketsInNerdTree "\[" contained conceal containedin=ALL
  autocmd FileType nerdtree setlocal conceallevel=3
  autocmd FileType nerdtree setlocal concealcursor=nvic
augroup END

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

No branches or pull requests

4 participants