scicloj / wolframite

An interface between Clojure and Wolfram Language (the language of Mathematica)
Mozilla Public License 2.0
47 stars 2 forks source link

Find out if we can get autocomplete support with loaded Wolf symbols in Calva/Cursive/Emacs #33

Closed holyjak closed 3 months ago

holyjak commented 8 months ago

load-all-symbols creates vars with docs in a namespace. But none of Cursive/kondo/Calva seems to "see" these and use them for autocompletion. Can we do anything to help them? Autocompl. would be helpful for UX.

holyjak commented 8 months ago

Update: Works in Calva

The following in VS Code + Calva (| denotes the position of the cursor):

(intern *ns* 'interned-var (fn [] "It's alive!"))
(interne|)

gives me autocompletion proposal for interned-var. However, clj-kondo wanrs about Unresolved symbol.

Cursive: nothing

The same thing does not work in Cursive, i.e. interned-var is not among completions. Not surprising, since Curisve uses a static code analysis.

chat

Emacs

See https://github.com/scicloj/wolframite/issues/36

Aside: clj-kondo

The clj-kondo linter cannot know these dynamic vars b/c it only does static code analysis.

holyjak commented 7 months ago

Suggestion

Perhaps we should have a fn that can generate a Clojure ns into a .clj file, based on the loaded symbols (or loading them as well, if not loaded already). Thus users could dump the symbols into a file on their dev-only classpath (something like dev/w.clj, where dev/ in on the classpath only in dev mode), and get auto-completion in all IDEs, and make clj-kondo stop complaining. We could make a variant of load-all-syms, which loads them if not loaded, checks the dumped file for existence, and writes it or overrides it if symbols have changed since last...

Having such a file on the classpath may be necessary to be able to (require ...) or load-file files that use these symbols and do not have the load-all-symbols at the top level or already executed elsewhere - f.ex. our tests had to do eval + quote trickery to deal with this problem. Having the Wolfram symbol vars ns on the classpath would have prevented it.