-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto-completion for packages #44
Comments
We could simply add symbols for all packages to the default list. |
It would be misleading if a word gets highlighted or autocompleted by M2, but it's just a symbol in M2 because the corresponding package hasn't been loaded yet, or maybe the package is something irrelevant to the user. Moreover, your suggestion is still incongruent with the behavior of M2 in a terminal. |
I haven't tested it yet, but this Emacs package might be helpful for this: https://github.com/monsanto/readline-complete.el |
I've been thinking about a possible solution for this problem, so that TAB in Emacs would give all the same symbols as in the terminal using readline.
The Python major mode does something similar. The big difference in Macaulay2, though, is that we have output line numbers and variables like |
This sounds promising, but before putting in much work I'd rather make sure this is the right direction for getting auto completion working on vscode and other modern editors as well. @etdavila10 pointed me to LSP in this direction. |
I have a very early draft of an M2 LSP server, so I'm definitely interested in moving in that direction at some point! |
Btw, Do you know if using LSP would require an instance of M2 (or perhaps a dedicated thread communicating via a side channel)? |
Yes, I think it might!
That's currently how my draft is implemented, yes. Emacs or VS Code or whatever would be communicating with a second M2 instance running the server. |
To be clear, I think perhaps |
This is very exciting! I would be more than happy to contribute to an M2 LSP as I think it would be extremely beneficial to future M2 development. |
@etdavila10 -- Awesome! This is the branch that I've been working on: https://github.com/d-torrance/M2/tree/lsp Everything is in M2/Macaulay2/packages/LanguageServer.m2 or the corresponding subdirectory. So far, it can successfully send and receive JSON-RPC messages with the editor, but the initialization step is failing for some reason I never quite figured out. I haven't touched it since last summer, so my memory is a little hazy. :) |
When running M2 from the terminal, if you load a package, all exported package symbols can be tab-auto-completed. In Emacs, however, this doesn't happen.
The reason is clear: Emacs auto-completion is tied to the syntax highlighter which is fixed to the pre-loaded packages. I suspect auto-completion can be made to work. Is it possible for emacs to communicate with readline?
A possible solution might be to also generate per-package syntax-highlighting and auto-completion lists, and somehow making Emacs know to load those additional lists whenever a package is loaded. Is this possible?
The text was updated successfully, but these errors were encountered: