Giter Site home page Giter Site logo

alive-lsp's Introduction

Alive Language Server

This is the language server for Alive: The Average Lisp VSCode Environment.

Running the server

For newcomers it could be difficult to start with Common LISP specially if the tech stack is not known yet. These instructions helps to have the server up and running as easy as possible. Steps are:

  1. Install your LISP Implementation
  2. Install a library/package manager
  3. Clone this repository
  4. Load the alive-lsp project and start the server

Install your LISP Implementation

Here let's assume we install sbcl

# debian
apt-get install sbcl

# macos
brew install sbcl

Install a library/package manager

Here let's assume we use quicklisp

curl -O https://beta.quicklisp.org/quicklisp.lisp
curl -O https://beta.quicklisp.org/quicklisp.lisp.asc
gpg --verify quicklisp.lisp.asc quicklisp.lisp
sbcl --load quicklisp.lisp
# ....
* (quicklisp-quickstart:install)
# it is also advisable to:
* (ql:add-to-init-file)

Clone this repository

Previous step should have created a directory in your home directory: ~/quicklisp, unless you decided to install it in another directory

(quicklisp-quickstart:install :path "~/.quicklisp")

just keep in mind the directory, let's called here $QUICKLISP_HOME. Let's clone this repository in $QUICKLISP_HOME/local-projects, so that it will be discovered automatically by Quicklisp when loading the project:

git clone [email protected]:nobody-famous/alive-lsp.git $QUICKLISP_HOME/local-projects/alive-lsp

Load the alive-lsp project and start the server

sbcl
This is SBCL 2.2.11, 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"
.
("alive-lsp")
* (alive/server::start :port 8006)
#<SB-THREAD:THREAD "Alive LSP Server" RUNNING {70069B3BE3}>

Your language server works! You can stop it now (Ctrl + C) and proceed to properly configure you Alive Extension in vscode:

{
    "alive.lsp.startCommand": [
        "sbcl",
        "--eval",
        "(require :asdf)",
        "--eval",
        "(asdf:load-system :alive-lsp)",
        "--eval",
        "(alive/server:start)"
    ]
}

note that alive.lsp.startCommand could also be the one used before in the REPL session, something like:

{
    "alive.lsp.remote.port": "8006",
    "alive.lsp.startCommand": [
        "sbcl",
        "--noinform",
        "--eval",
        "ql:quickload \"alive-lsp\")",
        "--eval",
        "(alive/server::start :port 8006)"
    ]
}

just be sure to also configure the port if you specify one on the command for starting the server.

Using the server outside of vscode

Take a look at thread #31

Developing Alive-lsp Code

If you are interesting in making changes to Alive-lsp you should take a look at the Development Notes.

alive-lsp's People

Contributors

nobody-famous avatar madkins23 avatar davidmpaz avatar

Stargazers

 avatar watarum avatar  avatar Tom Vogels avatar  avatar axt43 avatar Daniel avatar  avatar O B avatar  avatar  avatar ian avatar  avatar Zhao Xiaohong avatar Peter Roehlen avatar Thomas Jacob Trabue avatar Antonio Solana avatar Avishek Yadav avatar Gerrit Kruse avatar Zebreus avatar Carlos Leon avatar paku avatar  avatar Yi Cao avatar  avatar Filip Jakub Sowa avatar  avatar Louis Brauer avatar  avatar  avatar  avatar  avatar  avatar Mihai avatar  avatar Mark Gerarts avatar Matt Nish-Lapidus avatar Doğu Us avatar Glyphli avatar James Brown avatar Luis Rangel avatar  avatar Shingo Onobori avatar Bob⚡James avatar Bracken Spencer avatar Felix Wang avatar  avatar Dustin  Neumann avatar  avatar Mike Delago avatar Andrey Piskunov avatar Jiho Lee avatar vindarel avatar nodrygo avatar Brad Svercl avatar Erick G. Islas-Osuna avatar Józef Piątkiewicz avatar

Watchers

vindarel avatar  avatar  avatar

alive-lsp's Issues

No handler for $/cancelRequest

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

Symbol "CREATE" not found in the ALIVE/SERVER package.

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?

Difficulty killing runaway threads

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.

REPL package does not change when (in-package package-name) is called

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.

Doesn't work with SBCL 2.4.5

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

Thoughts On Extending This For Use Outside Of Alive?

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.

2022-09-29_13-33-18

'alive:XXXX' not found in VSCode

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

Release binaries?

Can we build this project to executable? So it's easier to use in other editors.

For example:

$ alive-lsp --stdio

Cannot start LSP on linux, neither on Manjaro nor in Debian-Bulleyes-Docker image. Fails with ERROR

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] `

grafik

Add documentation for newbies

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

Non-aligned loop keyword formatting

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.

(defparameter *loop-keys* '("do" "for" "while" "until" "=" "from" "to" "with" "finally" "repeat" "collect" "into" "using"
"being" "the" "hash-keys" "of"))

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

As another comparison, here's the "silly" loop example from Practical Common Lisp.
;; 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?

REPL: (y-or-n-p) outputs retry prompt twice for one invalid input

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.

How are packages evaluated in the VSCode extension and LSP server?

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.