Hi,
I released new versions of my scheme LSP server and some LSP clients. The biggest change is that they now have Gambit support :) Thanks Marc for the help.
The software is still in an early stage of development. You can find the LSP server here: https://codeberg.org/rgherdt/scheme-lsp-server Some important notes regarding Gambit:
- only Gambit 4.9.4+ is supported. I recommend installing Gambit from its master branch, since it has important bug fixes for GSC regarding some R7RS forms this library relies on (particularly `guard`). If you want to stick to Gambit 4.9.4, don't compile the library after installing it, otherwise it won't work. - I only tested this on Linux, but would expect that it also works on Mac. - some of the LSP clients listed below will prompt for automatically installing the LSP server if needed.
Currently following LSP clients are available:
* Emacs - lsp-scheme Available in MELPA. The extension will prompt for installing the LSP server if it's not found. Here the source code: https://codeberg.org/rgherdt/emacs-lsp-scheme - eglot Follow these instructions to activate the LSP server for eglot: https://codeberg.org/rgherdt/scheme-lsp-server#emacs-eglot-https-github-com-...
* VSCode/VSCodium - vscode-scheme-lsp Available both in VSCode's and VSCodium's marketplaces under the name Scheme LSP. The extension will prompt for auto-installing the LSP server if it's not found. Source code: https://codeberg.org/rgherdt/vscode-scheme-lsp
After installing any of these extensions, don't forget to configure it for Gambit before start using it. Refer to the corresponding docs to see how to do this.
Let me know if you have any trouble using them.
Regards,
Ricardo
Afficher les réponses par date
Hello Ricardo. First of all thank you so much for your work towards LSP support for Gambit. I am eager to try it out!
When I tried to run the LSP server I hit this error:
(import (codeberg.org/rgherdt/scheme-lsp-server lsp-server))
*** ERROR IN "../../../.gambit_userlib/codeberg.org/rgherdt/scheme-lsp-server/@/gambit/util.scm"@25.9 -- Duplicate import of identifier with-exception-handler
I think the cause may be the recent change in Gambit to support the R7RS `guard` form. Gambit has its own semantics for `guard`, `raise`, and `with-exception-handler` that is slightly different from R7RS. So both the `(scheme base)` and `(gambit)` libraries export these identifiers. The library `(scheme base)` maps `with-exception-handler` to `r7rs-with-exception-handler` which has the R7RS semantics. If you want to import `(gambit)` and also `(scheme base)` then you have to choose which of the exception handling forms you want. Probably this:
(import (scheme base) (except (gambit) with-exception-handler raise guard))
Regarding `guard` I looked at the file `gambit.scm` quickly and I found:
(let ((proc (if (symbol? identifier) (guard (condition (#t (write-log 'info (format "procedure not found: ~a" identifier)) #f)) (eval identifier)) ; safe 'cause only a symbol #f))) (if (and proc (procedure? proc))
Is there any reason for using `#t` instead of an `else` in the `guard` to catch all exceptions?
Also, there’s a more direct way in Gambit to get the value of a global variable and check if it is undefined:
(let ((val (##global-var-ref (##make-global-var identifier))))) (if (##unbound? val) …
It is much faster than using `eval` and `guard`. Moreover, `eval` will be sensitive to any `(namespace …)` forms that have been evaluated in the past (at the REPL or with `eval`).
Marc
On Sep 15, 2022, at 2:09 AM, Ricardo G. Herdt r.herdt@posteo.de wrote:
Hi,
I released new versions of my scheme LSP server and some LSP clients. The biggest change is that they now have Gambit support :) Thanks Marc for the help.
The software is still in an early stage of development. You can find the LSP server here: https://codeberg.org/rgherdt/scheme-lsp-server Some important notes regarding Gambit:
- only Gambit 4.9.4+ is supported. I recommend installing Gambit from its master branch, since it has important bug fixes for GSC regarding some R7RS forms this library relies on (particularly `guard`). If you want to stick to Gambit 4.9.4, don't compile the library after installing it, otherwise it won't work.
- I only tested this on Linux, but would expect that it also works on Mac.
- some of the LSP clients listed below will prompt for automatically installing the LSP server if needed.
Currently following LSP clients are available:
- Emacs
- lsp-scheme
Available in MELPA. The extension will prompt for installing the LSP server if it's not found. Here the source code: https://codeberg.org/rgherdt/emacs-lsp-scheme
- eglot
Follow these instructions to activate the LSP server for eglot: https://codeberg.org/rgherdt/scheme-lsp-server#emacs-eglot-https-github-com-...
- VSCode/VSCodium
- vscode-scheme-lsp
Available both in VSCode's and VSCodium's marketplaces under the name Scheme LSP. The extension will prompt for auto-installing the LSP server if it's not found. Source code: https://codeberg.org/rgherdt/vscode-scheme-lsp
After installing any of these extensions, don't forget to configure it for Gambit before start using it. Refer to the corresponding docs to see how to do this.
Let me know if you have any trouble using them.
Regards,
Ricardo
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://mailman.iro.umontreal.ca/cgi-bin/mailman/listinfo/gambit-list
Hi Marc, thanks for the suggestions.
When I tried to run the LSP server I hit this error:
(import (codeberg.org/rgherdt/scheme-lsp-server lsp-server))
*** ERROR IN "../../../.gambit_userlib/codeberg.org/rgherdt/scheme-lsp-server/@/gambit/util.scm"@25.9 -- Duplicate import of identifier with-exception-handler
Strange, I don't get this exception (tried it with Gambit 4.9.4 and master). Are you using some flag to start gsi? Anyway, I removed the dependency on (scheme base) since it was not actually needed in gambit/util.
Regarding `guard` I looked at the file `gambit.scm` quickly and I found: [...]
Is there any reason for using `#t` instead of an `else` in the `guard` to catch all exceptions?
I had a problem with Guile that 'else' was not recognized. It turns out, I experienced that because (scheme base) was not included. I replaced all #t's by else's in guard calls, thx.
Also, there’s a more direct way in Gambit to get the value of a global variable and check if it is undefined:
(let ((val (##global-var-ref (##make-global-var identifier))))) (if (##unbound? val) …
Done.
I pushed the changes. Can you please try it again?
BTW, I have a question. Is there some way to trigger compilation during the install process with `gsi`? Currently I'm doing this with a script that compiles all modules separately, and then compiles the server. I also tried to statically build gambit-lsp-server, but didn't figure out how to do that properly. Not a big deal, but I would like to learn what's possible in this direction.
Best,
Ricardo