nobody-famous / alive-lsp Goto Github PK
View Code? Open in Web Editor NEWLanguage Server Protocol implementation for use with the Alive extension
Language Server Protocol implementation for use with the Alive extension
Thanks for this extension. This is maybe a low priority issue but I thought I'd log it in case it's a symptom of something worth fixing:
The standard function (y-or-n-p)
outputs any retry prompt twice for any single non-valid input. In the below example, I only entered the letter 'a' once in response to the first prompt:
(y-or-n-p)
(y or n) <--- I entered "a" here
Please type "y" for yes or "n" for no.
(y or n)
Please type "y" for yes or "n" for no.
(y or n)
In the SBCL REPL, I only get the retry prompt once as expected.
Good day,
Periodically VS Code sends a $/cancelRequest
to Alive LSP, for which it does not have a handler. This results in an error message from the Alive LSP: No handler for $/cancelRequest
.
Does it make sense to implement a handler for $/cancelRequest
in Alive LSP (cf. https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#dollarRequests)? Or perhaps $-requests could be explicitly discarded, so they don't cause an error message?
(Happy to take a swing at a PR for the above, just want to get your thoughts as I'm not familiar with the LSP spec.)
Kind regards,
Dennis
Not so much an issue but curious what your thoughts are on having the lsp function with other editors? Not really saying you need to support that use case directly but wondering how specific to vsCode the alive LSP is?
I was able to connect it to emacs via eglot. All I did was load the alive-lsp project evaluate and evaluate
(alive/server::start :port 6008)
from the lisp repl and
(push '(lisp-mode . ("localhost" 6008)) eglot-server-programs)
in emacs then type M-x eglot
and boom. Not everything is working but at least completion is as seen bellow.
Can we build this project to executable? So it's easier to use in other editors.
For example:
$ alive-lsp --stdio
I'm working through Practical Common Lisp and just got to Chap. 21 - Packages and Symbols. I came across unexpected package evaluation behavior and wanted to clarify if this is intended.
Suppose you're developing in a file test.lisp
with the following code:
(defpackage :cake
(:use :common-lisp))
(in-package :cake)
(defun hello () (format t "Hello from cake"))
(hello)
(defpackage :rice
(:use :common-lisp))
(in-package :rice)
(defun hello () (format t "Hello from rice"))
(hello)
If I evaluate (using "Send to REPL") only the two definitions of hello
, without evaluating the defpackage
or in-package
forms, both functions are evaluated in their respective packages. I'm verifying this by running the two invocations of (hello)
, also with "Send to REPL", and they print as if the entire file is being evaluated.
Can you clear up my confusion as to why this is happening? Apologies if this is extremely trivial, I just didn't expect evaluation of those forms to be aware of their context in the file.
Running on an Intel Mac with brew's SBCL (2.2.11) I get the above error.
The tests fail as well, it can't find 'clue'.
I tried installing with roswell too just in case it was on the lisp side.
Am I doing something wrong do you think?
Unfortuantely, I cannot start the LSP server with ALIVE. Not from vscode, nor with the (test) shell scripts that come with the LSP.
I came with either version, installing all the "cl-*" packages on Bulleyes or with Quicklisp on Manjaro, to the point with the following debug error message:
`This is SBCL 2.2.4, an implementation of ANSI Common Lisp.
More information about SBCL is available at http://www.sbcl.org/.
SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
WARNING: System definition file #P"/root/quicklisp/dists/quicklisp/software/cl-json-20220220-git/cl-json.asd" contains definition for system "cl-json.test". Please only define "cl-json" and secondary systems with a name starting with "cl-json/" (e.g. "cl-json/test") in that file.
WARNING: System definition file #P"/usr/share/common-lisp/source/cl-flexi-streams/flexi-streams.asd" contains definition for system "flexi-streams-test". Please only define "flexi-streams" and secondary systems with a name starting with "flexi-streams/" (e.g. "flexi-streams/test") in that file.
debugger invoked on a SB-KERNEL:CASE-FAILURE @5351C1DD in thread
#<THREAD "main thread" RUNNING {1004E48073}>:
:LOCAL-NICKNAMES fell through ECASE expression.
Wanted one of (:USE :MIX :REEXPORT :USE-REEXPORT :MIX-REEXPORT :IMPORT-FROM
:SHADOWING-IMPORT-FROM :NICKNAMES :DOCUMENTATION :SHADOW
:EXPORT :INTERN ...).
Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [RETRY ] Retry ASDF operation.
1: [CLEAR-CONFIGURATION-AND-RETRY] Retry ASDF operation after resetting the
configuration.
2: Retry ASDF operation.
3: Retry ASDF operation after resetting the
configuration.
4: [CONTINUE ] Ignore runtime option --eval "(asdf:load-system :alive-lsp)".
5: [ABORT ] Skip rest of --eval and --load options.
6: Skip to toplevel READ/EVAL/PRINT loop.
7: [EXIT ] Exit SBCL (calling #'EXIT, killing the process).
(ASDF/PACKAGE-INFERRED-SYSTEM::PACKAGE-DEPENDENCIES (DEFPACKAGE :ALIVE/POSITION (:USE :CL) (:EXPORT :CREATE :LINE :COL :LESS-THAN :LESS-OR-EQUAL :FROM-WIRE) (:LOCAL-NICKNAMES (:TYPES :ALIVE/TYPES))))
source: (ECASE OPTION
((:USE :MIX :REEXPORT :USE-REEXPORT :MIX-REEXPORT)
(DOLIST (P ARGUMENTS) (DEP (STRING P))))
((:IMPORT-FROM :SHADOWING-IMPORT-FROM)
(DEP (STRING (FIRST ARGUMENTS))))
((:NICKNAMES :DOCUMENTATION :SHADOW :EXPORT :INTERN :UNINTERN
:RECYCLE)))
0] `
The following:
(in-package :cl-user)
(defun infinity ()
(loop do (progn (print "Hello, World!")) (sleep 1)))
(infinity)
can be killed using the Threads tree view without any issue. It happens immediately.
Removing the sleep
call:
(in-package :cl-user)
(defun infinity ()
(loop do (progn (print "Hello, World!"))))
(infinity)
seems to lock up the LSP, making it virtually impossible to kill the thread. It is necessary to restart the LSP using Developer: Reload Window or kill VSCode and restart it. Even that takes a non-trivial amount of time.
There may be nothing to do here other than avoiding code with tight infinite loops.
I'm very new to Common Lisp, so watch out for incorrect/naive assumptions!
Following on from this issue about the formatting of conditional clauses in loop
nobody-famous/alive#130. Just to recap, here's some real code with a hand formatted loop.
(defun lookup (map value)
(loop for (dst src len) in map
when (and (>= value src) (< value (+ src len)))
do (return (+ dst (- value src)))
finally (return value)))
When I use Alive as a formatter, it indents the when
keyword.
(defun lookup (map value)
(loop for (dst src len) in map
when (and (>= value src) (< value (+ src len)))
do (return (+ dst (- value src)))
finally (return value)))
Trying to work out why these conditional clauses aren't indented to match the rest of the loop.
Digging into the formatting code I noticed that they aren't actually included in the list of loop keywords.
Lines 26 to 27 in 763633b
Without going on a deeper dive, I'm not sure whether this happens because the when
keyword isn't included in *loop-keys*
or some other mechanism.
There are quite a few more loop clauses that are also not included: https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node240.html
;; Before formatting
(loop for i from 1 to 100
if (evenp i)
minimize i into min-even and
maximize i into max-even and
unless (zerop (mod i 4))
sum i into even-not-fours-total
end
and sum i into even-total
else
minimize i into min-odd and
maximize i into max-odd and
when (zerop (mod i 5))
sum i into fives-total
end
and sum i into odd-total
do (update-analysis min-even
max-even
min-odd
max-odd
even-total
odd-total
fives-total
even-not-fours-total))
;; After formatting
(loop for i from 1 to 100
if (evenp i)
minimize i into min-even and
maximize i into max-even and
unless (zerop (mod i 4))
sum i into even-not-fours-total
end
and sum i into even-total
else
minimize i into min-odd and
maximize i into max-odd and
when (zerop (mod i 5))
sum i into fives-total
end
and sum i into odd-total
do (update-analysis min-even
max-even
min-odd
max-odd
even-total
odd-total
fives-total
even-not-fours-total))
Getting the nested indentation correct between each if
/else
/when
/end
seems quite tricky, but it does seem strange for do
to be the only clause that is aligned with for
.
I would assume this was intentional behaviour, but if not, would you accept a PR that would fix the alignment?
I followed the directions to install and it fails on the (ql:quickload "alive-lsp")
step:
This is SBCL 2.4.5, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.
SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
* (ql:quickload "alive-lsp")
To load "alive-lsp":
Load 1 ASDF system:
alive-lsp
; Loading "alive-lsp"
..................................................
[package alive/sbcl/file];
; caught ERROR:
; READ error during COMPILE-FILE:
;
; Lock on package SB-EXT violated when interning SIMPLE-STYLE-WARNING while in
; package ALIVE/SBCL/FILE.
; See also:
; The SBCL Manual, Node "Package Locks"
;
; (in form starting at line: 81, column: 0, position: 2535)
debugger invoked on a UIOP/LISP-BUILD:COMPILE-FILE-ERROR in thread
#<THREAD tid=259 "main thread" RUNNING {7008380473}>:
COMPILE-FILE-ERROR while
compiling #<CL-SOURCE-FILE "alive-lsp" "src" "compat/sbcl/file">
Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [RETRY ] Retry
compiling #<CL-SOURCE-FILE "alive-lsp" "src" "compat/sbcl/file">.
1: [ACCEPT ] Continue, treating
compiling #<CL-SOURCE-FILE "alive-lsp" "src" "compat/sbcl/file">
as having been successful.
2: Retry ASDF operation.
3: [CLEAR-CONFIGURATION-AND-RETRY] Retry ASDF operation after resetting the
configuration.
4: Retry ASDF operation.
5: Retry ASDF operation after resetting the
configuration.
6: [ABORT ] Give up on "alive-lsp"
7: [REGISTER-LOCAL-PROJECTS ] Register local projects and try again.
8: Exit debugger, returning to top level.
(UIOP/LISP-BUILD:CHECK-LISP-COMPILE-RESULTS NIL T T "~/asdf-action::format-action/" ((#<ASDF/LISP-ACTION:COMPILE-OP > . #<ASDF/LISP-ACTION:CL-SOURCE-FILE "alive-lsp" "src" "compat/sbcl/file">)))
; File has been modified since compilation:
; SYS:CONTRIB;ASDF;UIOP.LISP.NEWEST
; Using form offset instead of character position.
source: (ERROR 'COMPILE-FILE-ERROR :CONTEXT-FORMAT CONTEXT-FORMAT
:CONTEXT-ARGUMENTS CONTEXT-ARGUMENTS)
0]
I downgraded to sbcl 2.3.11 and it works exactly as described.
OS: Mac OS Sonoma 14.3.1
Hardware: Apple M2 Max
Hi,
thanks for this project, a bit more documentation on how to get the LSP installed, up and running would be much appreciated.
As I see, for you everything is trivial now, that's the only reason I can imagine why not even a README file exist :), but I would like to try this while building some Dev Stack for lisp and find the start quite difficult.
Thanks in advance,
David
Hi,
I have isntalled alive as descrided in the installation guide and I can run a server at the port 8006.
However, whatever alive command in VSCode I try to run I get 'alive:XXXX' not found in VSCode
Have just started recently using Alive. Have been enjoying it quite a bit, however I've noticed that the REPL does not change the package when you run (in-package package-name). The prompt remains cl-user >
, whereas I would expect it to update to package-name >
and enable us to use symbols from that package without needing to explicitly call in-package
every time.
Is this intended? I think this should function similar to the way the Swank server works.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.