Neovim in the browser

If this were an option in the ide, I’d have to go have a little lie down to recover my composure…

1 Like

Nice! Codemirror also has vim support (albeit not maintained) - and the anvil ide uses codemirror so… ive tried a couple of times (in vain) to make it work.

Wouldn’t it be great if there was a check box that said vim mode. I think if we ask enough the anvil fairies :fairy:‍♀ might make it happen.

1 Like

That’s slightly different (but would still be nce to have). Codemirror has vim key bindings but you’re still running codemirror and not vim itself.

Neovim can run in headless mode with any ui driving it, so this would be your own local installation of neovim being driven from within the browser. (vscode has this ability to drive neovim too).

I’ve gone for a little lie down…

3 Likes

All my local neovim plugins and settings work too - so I’ve got async linting and autocomplete, formatting with black, import sorting, code folding etc. etc.

I am a happy man.

2 Likes

Much to my surprise, even my tag browser works!

Hang on, you’ve replaced the Anvil IDE editor with vim?

That’s even cooler than I first thought!

1 Like

Yep. And it turned out to be a breeze to setup. I just followed the firenvim instructions (install the neovim plugin, install the browser extension) and it all just worked.

1 Like

I guess you lose things like dynamic code linking (ctl-click) for functions, etc.?

Yes, but I can toggle between neovim and codemirror very quickly and easily

I have firenvim set not to take over by default. I hit ctrl-e if I want neovim and :q to get back to codemirror.

So I tend to read in codemirror first and then switch to nvim for editing.

Even just having my key binding for Black formatting is a major win!

2 Likes

Holy smokes… This is amazing. Thanks for posting this. I just installed it and it is working great!

1 Like

Hello all. As a newcomer to anvil it has been painful to live without vim shortcuts and I was thrilled to come across this.

I have the extension working, but not optimally. I am using macOS as a desktop and Chrome for opening anvil.

Currently, the issues are:

  1. The font was far too small. I added “set guifont=Fira_Code:h16” to the end of ~/.config/nvim/init.vim, and that seems to have resolved it…but see #2
  2. When opened initially, the rendered neovim window overflows and doesn’t “fit”. If I click to open other files, the rendering gets even messier (see screenshot at the bottom)
  3. No autocomplete of anvil or python code. I suspect I can fix the python autocomplete issue by installing some neovim plugins, but not certain about the anvil side of things.
  4. The neovim rendering is triggered automatically…I have no option to start it or stop it.

I am guessing most of you faced the above issues but have gotten it working well for you. Would you please share what steps you had to take to get it working?

Thank you so much in advance. Having vim keystrokes + anvil would be a dream come true!

1 Like

Nice to know I’m not the only one!

  • Not sure about the overflow. I’ve never seen that - although I use Firefox on Ubuntu so my guess is it’s browser or OS specific.

  • I have a bunch of modern neovim plugins and other gizmos to do autocomplete etc. e.g. lspsaga, python lsp server, coq

    I also have github copilot and a demo of that in a previous topic.

    My full dotfiles are on github

  • Auto-rendering - firenvim has a setting to disable that.

3 Likes

Thanks @owen.campbell . I appreciate it very much!

1 Like

I know I am joining this topic late but how well does the autocomplete work for you guys? I am using the jedi-vim plugin. It doesn’t give me autocomplete suggestions for anvil components (sorta expected). But just wondering if you guys have managed to do that some way as well? I am completely new to vim so I don’t have much idea about things yet.

I have copilot with me which helps me in it though :grinning:

A little more detail to expand on my previous post…

My setup uses neovim’s built in support for Language Server Protocol.

I have a few different language servers installed locally and neovim handles starting the correct one for a given file. That’s done by the nvim-lspconfig plugin which also handles the setup and config for each of those servers.

For Python, I use Python LSP Server with several of its plugins (especially Black for formatting). pylsp uses jedi under the bonnet for the code completion actions.

For code completion itself, I use coq. That will use a language server as one of its completion sources. It will also use copilot and various other mechanisms if available - e.g. I use neovim’s TreeSitter support via the nvim-treesitter plugin and coq presents those completion suggestions too.

I use the lspsaga plugin for the other UI aspects of LSP support besides code completion (code actions, diagnostics etc.)

Finally, my setup is all available at GitHub - meatballs/dotfiles (the nvim folder within that repo has my entire neovim config).

Have fun!

2 Likes

Thanks! I will give those plugins a try!

I forgot to mention - for autocomplete of anvil stuff, pylsp needs to be using a python interpreter that has the anvil-uplink library installed. I tend to use a virtualenv for that.

As an alternative, I install pylsp using pipx. You could do that and use pipx inject python-lsp-server anvil-uplink instead.

1 Like

That seems nice. I will definitely be trying that out. This was what I needed! Although this problem no longers annoys me that much since copilot has adapted to Anvil much quicker than I thought.

1 Like

Hi @john.wells, @owen.campbell,
Have you managed to make it work in the the beta editor? I’m having the same overflow problem. I’m on Windows 11 and I’ve tried Firefox and Chrome
It only works in the classic editor for me.