If this were an option in the ide, I’d have to go have a little lie down to recover my composure…
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 ♀ might make it happen.
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).
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.
Hang on, you’ve replaced the Anvil IDE editor with vim?
That’s even cooler than I first thought!
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.
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!
Holy smokes… This is amazing. Thanks for posting this. I just installed it and it is working great!
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:
- 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
- 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)
- 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.
- 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!
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.
My full dotfiles are on github
Auto-rendering - firenvim has a setting to disable that.
Thanks @owen.campbell . I appreciate it very much!
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
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).
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.
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.