asg017 / dataflow

An experimental self-hosted Observable notebook editor, with support for FileAttachments, Secrets, custom standard libraries, and more!
https://alexgarcia.xyz/dataflow/
MIT License
402 stars 24 forks source link

Editor-agnostic auto-completion #18

Open asg017 opened 3 years ago

asg017 commented 3 years ago

Say you have:

element = html`<div>
<table>
...`

update = {
  element;
}

When updating the update cell and accessing element, I want to be able to use autocompletion (ie, <Tab>) to see all th enumerable fields of the element cell's value. In this case, it's an HTML element, so I should see a dropdown list of querySelector, querySelectorAll, getAttribute, etc.

But I use VS Code, some people like vim, others emacs. Autocompletion in each editor would be different, but the same underlying list of enumerable fields should be the same for all potential editor clients.

wizzard0 commented 3 years ago

Hm, this sounds like a job for the custom Language Server (with an additional complication that it would have to fetch actual values from the browser window) -- but at least it should cover multiple editors simultaneously? the list of tools with LSP support is steadily growing

asg017 commented 3 years ago

@wizzard0 that sounds right! I haven't played much with vscode language servers, but from what I've used before it sounds do-able. There would need to be some sort of "connection" between a selected client and your code editor of choice, where the client shared data on what cells are active/what keys can be accessed on those objects. I dont know of any other VS Code language server that does this sort of dynamic auto-complete option (I'd imagine most just do static analysis of your code to figure it out).

"Editor-agnostic" would be key here, idk if any other editor that has a "language server" like vscode, mostly because Ive never looked into it. Im sure that vim has some crazy extensions that can do this, or Atom

wizzard0 commented 3 years ago

idk if any other editor that has a "language server" like vscode

The list of tools on LSP website looks quite decent! dunno about the quality of integrations in all of them though. But Rust, Go etc etc. already provide LSPs so it seems like it's on its way to becoming a de-facto standard.

https://microsoft.github.io/language-server-protocol/implementors/tools/