NokiMo
Octodemy
Octodemy

patreon


Setting up Nvim on an old Windows broke me

I decided last week to try and setup a nvim IDE to see if it could work as well as the good old vscode.

I used vim before, and I quite like it. But I just can't live without some of the more modern features that are usually present in IDE's.

And after seeing some people using nvim and turning them into beautifully customized editor's, it made me have an urge to try it.

So here are some of the problems and solutions I've come up with while doing this.

Not sure if the .gif images will work here, so I've added them on the attachments as well.

This here is a part rant, part an excuse why I didn't do anything useful this week as this task have consumed me.

The journey starts

I have an old windows machine. It's a windows 10 1803, last updated in 2018. And I use git bash to have that good old linux feeling back.

So when I first tried to run nvim. It didn't work.

Turns out nvim 0.10+ (which released about a year ago) no longer supports older windows. It needs a new terminal feature that is not present on my windows build.

So instead I had to use nvim 0.9.5. The latest version that supports older systems. But it's okay, I'm sure its gonna be fine.

Nvim 0.9.5 works now. Or at least it executes. Git bash is giving me some strange results.

The rendering is all wrong, writing over itself, and I can't even execute any command.

It turns out, for a complicated reason, git bash can't run nvim. So I had to run winpty to execute nvim. So running :'winpty nvim' makes it work now.

I also encountered a few other strange problems. For example, nvim would not open folders that were named "[something] folder name", that had [] or () within their name.

Well, that was fixed in 0.11, but I can't use that. This is what worked for me: https://github.com/vim/vim/issues/12629#issuecomment-1937596309

I had to manually replace all the calls for 'fnameescape' inside nvim files to escape those characters. But it worked.

Another problem I had was that I could not execute any bash commands by calling "!command" within nvim. The path locations were all wrong on calls there.

The solution for that one was adding: vim.opt.shell = 'cmd.exe' to the init.lua file

Great, its time to add some plugins. I installed lazy.nvim to manage the plugins. Added telescope.nvim to search files, and added a simple theme.

But something is very wrong with the colors.

That's the worst thing that could have happened. One of the biggest reasons I decided to give nvim a try was because of its cool appearance.

So I started to spiral trying to find a solution for this. I thought for a time that git bash only supported 16 colors and was lost for a long time.

Turns out, the problem was winpty. It doesn't support 256 colors... and never will.

Windows 1809 now have a ConPTY API that doesn't have this problem, winpty is now obsolete and haven't received updates since 2017. Another headache for using an older windows.

So I started to try other terminals just to see if they could work.

WezTerm didn't even ran. It requires ConPTY support to work. And I also installed ConEmu which I quite like right now.

But amidst this, I found I could run nvim without winpty by executing git bash directly from the windows "cmd.exe".

The way ConEmu works is also very similar to that. ConEmu instances other terminals inside itself, so the gitbash task it comes with almost worked out of the box. But it had a problem randomly escaping characters wrong.

So I created a ConEmu task to run gitbash make it work without winpty.

set "PATH=E:\Programas\Git\usr\bin;%PATH%" & E:\Programas\Git\git-cmd.exe --no-cd --command=E:\Programas\Git\bin\bash.exe -l -i -new_console:p

And added that to the context menu.

I also added a very hacky way to open a file directly with nvim by right-clicking the file. The hacky part was to be able to have ConEmu open it.

A created a {test} task with un-escaped parentheses

set "PATH=E:\Programas\Git\usr\bin;%PATH%" & E:\Programas\Git\bin\bash.exe -c ". ~/.bashrc;

And appended the end of it within the windows context menu command with

"F:\Programas\NeoVim\ConEmu\ConEmu64.exe" -run {test}cd \"$(dirname \"%1\")\";nvim \"$(basename \"%1\")\"" -cur_console:n

Now I got everything working, and life is good.

Then, on the next day, I decided to start customizing nvim.

I added 'treesitter.nvim' for syntax parsing, 'which-key' to show keys hints and was about to add 'neotree' for a better file explorer.

But then I noticed something strange. There are quite a bit of strange empty spaces around nvim's interface, as well as some empty squares.

The console is using a 'nerd font' and 'nvim-web-devicons' is installed so I should be seeing icons. But I was not. Icons are not working.

The icons are working on the terminal.

They just don't work on nvim.
And that's where nvim broke me. I tried everything I could think of.

The saddest thing is that the icons display's correctly on normal vim, they only don't work on nvim.

 One of the possible reasons for that is that I have my windows set to use japanese for unicode programs.

And turning that back to english, SOME of the icons now show up, but they are now too big and kinda clipping.

But I don't want to change out of my japanese locale. And again, it is working on vim without changing this so there should be a solution.

The problem is, again, my outdated windows. Maybe this is fixed on the newer version of nvim, or maybe a newer windows have better control of how unicode locales work. I don't think I'll be able to find a workaround for this.

...

But that's it, that's as far as I go with nvim for now.

I've already spend too much time messing around with this.

I could still use nvim. It's just the icons that don't work. But it will always feel like something is missing if I tried to use nvim now. So I guess I'll stick with vscode for now.

Maybe in a few years if I buy a new computer I can try out really switching to using nvim.

Sorry about all this. Just trying to get this out of my system so I can go back to doing more productive stuff.

-----

PS: I would update my windows if I could. But besides not having enough HDD space to even try to update it now. I fear that if I updated windows, it would just start auto-updating every day all over again. And I like not having to deal with all that. I got used to it. And I know what works and what don't.

----

Final update

Git bash is a lost cause, but I've manage to make SOME of the icons work on ConEmu.

For some reason, ConEmu was using the wrong unicode. So setting the utf unicode with 'chcp utf8' made it work better and now nvim can display some icons. Gitbash was already using the correct utf8 and it didn't make any difference in displaying the icons.

So now on ConEmu, only icons that uses double UTF codepoint are not displayed.

Like 'ESC' icon, 󱊷, which is \udb84\udeb7 doens't work.
But all single utf icons like 'UP', , \uf062 works.

Strangely enough, after setting the utf unicode in ConEmu, now vim don't work anymore, it can only displays single utf icons.

But setting the codepage 932 (same as the region settings japanese locale), makes the vim properly display the icons.

So, with chcp utf8 on ConEmu, vim displays wrong.

But if I set 932 like the regional settings

 

It now have working icons

 

This doesn't affect nvim, using 932 in nvim just makes ALL icons break instead.

So I'm kinda stuck, I think this is a nvim bug.

I might try to compile nvim from source and try to manually apply unicode fixes from 0.11 to see if anything works when I have some free time.

Anyways, this is the final result for now. Single codepoint icons works, double codepoint icons don't. Like the .txt files.

Most file icons seems to work, but extra icons for key-hints don't.

Setting up Nvim on an old Windows broke me Setting up Nvim on an old Windows broke me Setting up Nvim on an old Windows broke me Setting up Nvim on an old Windows broke me Setting up Nvim on an old Windows broke me Setting up Nvim on an old Windows broke me

Related Creators