Replacing codemirror with vscode?

From reading various posts in the forum, I’ve learned that the editor Anvil uses is CodeMirror.

I find the autocomplete functionality to be very frustrating. I’ve set up neovim + firenvim and this is working, but I still use the built-in editor at times and every time I press enter it seems to do the opposite of what I want.

I know VSCode is a very capable editor, and it can be made to work in the browser. Has the Anvil team thought about making that an option?

Thanks in advance!

1 Like

Following up on this. Home Assistant (https://www.home-assistant.io/) in a python-based open source project which provides a nicely-integrated VSCode experience in the browser. Below is a view of it running on one of my home servers. What a wonderful thing this would be to have as a part of Anvil :wink:

1 Like

Thanks for the feedback.

There are a few big players for online code editors: Ace, CodeMirror and Monaco.
For every VSCode using Monaco, there’s a Mozilla using CodeMirror.

There’s no intention for us to switch over to Monaco, or to replace the Beta IDE with VSCode.
We will of course be continuing to improve our code editor as we improve the Beta IDE.

As an aside, the team behind CodeMirror are currently in the process of a full rewrite, which looks like a promising step forward for online editors.

Also, worth noting that any Anvil app can be pulled locally to your editor of choice using Anvil’s git integration. So if you prefer to make edits in VSCode or Vim, then that workflow is available.

If there are specific issues with editor features, use of enter, or otherwise, it’s always worth creating separate Q+A posts, prefixed with [Beta], so that we can add it to our list.

2 Likes

Fair enough Stu and thanks for the response. I already have firenvim working in the browser, so that does work well enough to get my vim keystrokes working.

What I miss is the autocomplete of the anvil API, and I do find this very helpful. I’m wondering if there’s a way to stub out the API into a neovim plugin, but that’s something I’ll explore at a later date as I’m rather new to the deep functionality of neovim (though I’ve been using h,j,k,l and various keystrokes for decades).

Has any thought be given to providing autocomplete outside of the browser for things like VSCode or neovim as an extension?

Here’s one user-contributed effort towards that: Anvil SDK for PyCharm - #4 by ben.lawrence

I kind of doubt it would make business sense for Anvil staff to devote time to creating a VSCode extension, but there’s no reason we can’t get an open source effort started.

1 Like

That’s already doable. Both VSCode and Neovim use the Language Server Protocol. As long as you have a local instance of a server running with access to the anvil-uplink library, you can use autocompletion in either tool.

Here’s an example of my local neovim in action:

Peek 2022-02-08 17-11

4 Likes

What I miss is the autocomplete of the anvil API, and I do find this very helpful. I’m wondering if there’s a way to stub out the API

In case you want to look at doing a neovim plugin yourself, I have all the stubs for the anvil API here:
anvil API stubs
(in python of course)

2 Likes

Thanks very much for the response Owen and Ben. It’s on my (rather long) list of things to explore :wink: I will post my results here when I have them.

A suggestion to improve the autocomplete range:

1 Like