Missing dir arrows #522

Closed
dawikur opened this Issue Dec 3, 2015 · 13 comments

Comments

Projects
None yet
7 participants

dawikur commented Dec 3, 2015

I'm using Windows machine, ssh to Linux with putty and there running Vim.

echo nerdtree#runningWindows() returns 0
but because I am rendering on Windows I don't have those fancy arrows.
arrows

This was probably introduced with 677a83b.

Can we add option to force usage of +/~ ?

Workaround is simple:

let g:NERDTreeDirArrowExpandable="+"
let g:NERDTreeDirArrowCollapsible="~"

but this is always a workaround

Obviously this is a bug. Let's check plugin/NERD_tree.vim

if !nerdtree#runningWindows()
    call s:initVariable("g:NERDTreeDirArrowExpandable", "▸")
    call s:initVariable("g:NERDTreeDirArrowCollapsible", "▾")
else
    call s:initVariable("g:NERDTreeDirArrowExpandable", "+")
    call s:initVariable("g:NERDTreeDirArrowCollapsible", "~")
endif

This section means

When RunningWindows, arrows are +/~
Not RunningWindows, arrows are ▸/▾

The logic is reversed.

To make the logic right, we must remove ! from the above code.

if nerdtree#runningWindows()
    call s:initVariable("g:NERDTreeDirArrowExpandable", "▸")
    call s:initVariable("g:NERDTreeDirArrowCollapsible", "▾")
else
    call s:initVariable("g:NERDTreeDirArrowExpandable", "+")
    call s:initVariable("g:NERDTreeDirArrowCollapsible", "~")
endif

The change works for me.
image

dawikur commented Dec 10, 2015

@ChaoyuChen, Check your change when running vim directly on Windows - you will see [] instead of arrows.

The issue isn't that logic is reversed - it's correct. as You said:

When RunningWindows, arrows are +/~
Not RunningWindows, arrows are ▸/▾

On Windows most font's (if not all of them ) don't display arrows correctly, thus we use +/~ on it.
On Linux it's fine.

The issue is that, we I am running vim in Linux (nerdtree#runningWindows() returns 0),
but rendering it on Windows.

Because of that I am proposing adding option to force-use +/~ - you can check in vimrc file for environment variable $SSH_CLIENT and set flag or not.

I wouldn't do this in nerdtree itself, as you can ssh from linux (then rendering would could fine) or windows (rendering will be broken). Based on $SSH_CONNECTION you can check with nmap for OS, but it may fail and I think requires root privileges.

Hello dawikur,

Thanks for your sharing. I never executed vim on MS-Windows. Most of time I used putty with SSH session to my Linux.

Based on your description, I realized the reason is that putty cannot render the special characters ▸and ▾. Therefore we should solve this issue at the putty side.

At last, I found the cause is the font. I got the new font " Consolas for Powerline" from Github and change the font set at putty (Window -> Appearance -> font settings. Remember check "Allow selection of variable patch fonts") .

image

Then my putty showed these 2 character correctly.
image

By the way, I am wondering why these 2 characters are used.....

dawikur commented Dec 11, 2015

@ChaoyuChen , thanks for response.

You are right, this is fonts issue. I verified that Consolas for Powerline works fine with arrows, but unfortunately I am using Droid Sans (which you can see on screen from me).

I think this may be still considered as a problem.

It's probably not safe to assume all non windows terminal environments with all font configurations will have the arrow characters enabled by default. I'm running into similar missing character issues with both vim & neovim running on xfce terminal on Ubuntu 14.04 in a crouton environment - i prefer the Source Code Pro font. In my case I fixed it by just commenting out the if/endif block and just using straight pluses and minuses.

It maybe worth going back to +/- and having arrows as an option rather than the other way around

jeremyn commented Jun 26, 2016

This problem also happens using NERDTree/vim with Git (Bash) for Windows 2.9.0 and the mintty terminal. echo nerdtree#runningWindows() returns 0. The default font is Lucida Console and both arrow types display as boxes like in the first comment. The workaround in the first comment of setting the arrow values manually to +/~ works. Another option is changing the font to Consolas (click on the upper left icon > Options... > Text > Select...), which displays the arrows correctly.

Collaborator

PhilRunninger commented Jan 5, 2017

I disagree with adding another option. The "workaround" @dawikur suggested

let g:NERDTreeDirArrowExpandable="+"
let g:NERDTreeDirArrowCollapsible="~"

is sufficient to handle this scenario. It would come down to letting one new variable vs. these two existing variables. Just wrap those lines of vimrc with an appropriate if statement, identifying when ssh is being used.

it3xl commented Jan 9, 2017

All these endless workarounds with vimrc makes pain.
At least if !nerdtree#runningWindows() do not covers under the hood all those "Unix shell on Windows".
Some nix terminals have no arrow chatters.
Too much for a plugin. All punished to pay a fee and to be accustomed and prepared.
One more worthless knowledge.

Collaborator

PhilRunninger commented Jan 9, 2017

Vim running on the Linux box doesn't know that it is being rendered in a Windows putty window. Why would you expect anything other than 0 to be returned from nerdtree#runningWindows()? A Git Bash or cygwin window running natively in Windows is different situation, which may have gotten confused with the original issue.

@ChaoyuChen presents a perfectly valid solution - changing the font putty uses. Consolas works well, as should any of the Powerline fonts. These fonts will render the arrow triangles correctly. If you prefer + and ~ instead, then setting them in your vimrc is a better way to go than adding a redundant option to NERDTree.

I hesitate to use the word "workaround". There is a certain amount of setup (a better word, IMO) that is required for any plugin to work, whether in Vim, the plugin, or the terminal/emulator. Each person's way of working is different, so expecting a plugin to work out of the box for everyone is unrealistic.

alphaCTzo7G commented Nov 11, 2017

@ChaoyuChen, @dawikur Thanks for the solution. This worked for me, after I had worked through all the solutions posted here: https://serverfault.com/questions/475925/how-to-fix-putty-showing-garbled-characters!

Putty had a "Consolas" font installed by default.

Is there a difference between "Consolas" and "Consolas for Powerline"? The reason I am asking is because, I dont want to make too many manual configuration changes, as it becomes hard to keep track of.

Collaborator

PhilRunninger commented Nov 13, 2017

The Powerline fonts contain special glyphs that are used in Powerline, Airline, and perhaps other custom statusline plugins. The characters are defined in the Private Use Area section of the font. Here are some of the characters that these plugins use. Their codes are, from left to right: E0A0, E0A1, E0A2, E0B0, E0B1, E0B2, E0B3.

image

Thanks for pointing this out. Do you think then we can propose this to Putty? Powerline is pretty popular, and if Consolas for Powerline is a superset of Consolas, perhaps Putty should include "Consolas for Powerline" instead of "Consolas".

Would it be helpful if I add this as a point in Faq? I can do a PR

Collaborator

PhilRunninger commented Nov 14, 2017

I can't answer for the Putty folks. If you can find a way to contact them, good luck. Here, we are moving the FAQ into the Wiki. You can edit that yourself without a PR.

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