Skip to content

Commit

Permalink
feat: Add Lisp support (#4385)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 authored Mar 20, 2024
1 parent 8903da3 commit 193c714
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.org
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
* Add [[https://docs.trunk.io][Trunk]] support
* Add Cucumber support.
* Add COBOL support.
* Add Common Lisp support.

** Release 8.0.0
* Add ~lsp-clients-angular-node-get-prefix-command~ to get the Angular server from another location which is still has ~/lib/node_modules~ in it.
Expand Down
95 changes: 95 additions & 0 deletions clients/lsp-lisp.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
;;; lsp-lisp.el --- LSP client for Lisp -*- lexical-binding: t; -*-

;; Copyright (C) 2024 Shen, Jen-Chieh

;; This file is not part of GNU Emacs.

;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:
;;
;; LSP client for Lisp.
;;

;;; Code:

(require 'lsp-mode)

(defgroup lsp-lisp nil
"LSP support for Lisp."
:group 'lsp-mode
:package-version `(lsp-mode . "8.0.1"))

(defcustom lsp-lisp-active-modes
'( lisp-mode)
"List of major mode that work with lisp."
:type 'list
:group 'lsp-lisp)

(defcustom lsp-lisp-alive-port 8006
"Port to connect server to."
:type 'integer
:group 'lsp-lisp)

;;
;;; Server

;;;###autoload
(add-hook 'lisp-mode-hook #'lsp-lisp-alive-start-ls)

;;;###autoload
(defun lsp-lisp-alive-start-ls ()
"Start the alive-lsp."
(interactive)
(when-let ((exe (executable-find "sbcl"))
((lsp--port-available "localhost" lsp-lisp-alive-port)))
(lsp-async-start-process #'ignore #'ignore
exe
"--noinform"
"--eval"
"(ql:quickload \"alive-lsp\")"
"--eval"
(format "(alive/server::start :port %s)"
lsp-lisp-alive-port))))

;;
;;; Core

(defun lsp-lisp-alive--tcp-connect-to-port ()
"Define a TCP connection to language server."
(list
:connect
(lambda (filter sentinel name _environment-fn _workspace)
(let* ((host "localhost")
(port lsp-lisp-alive-port)
(tcp-proc (lsp--open-network-stream host port (concat name "::tcp"))))

;; TODO: Same :noquery issue (see above)
(set-process-query-on-exit-flag tcp-proc nil)
(set-process-filter tcp-proc filter)
(set-process-sentinel tcp-proc sentinel)
(cons tcp-proc tcp-proc)))
:test? (lambda () t)))

(lsp-register-client
(make-lsp-client
:new-connection (lsp-lisp-alive--tcp-connect-to-port)
:major-modes lsp-lisp-active-modes
:priority -1
:server-id 'alive-lsp))

(lsp-consistency-check alive-lsp)

(provide 'lsp-lisp)
;;; lsp-lisp.el ends here
8 changes: 8 additions & 0 deletions docs/lsp-clients.json
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,14 @@
"installation-url": "https://github.com/fwcd/kotlin-language-server/blob/master/BUILDING.md",
"debugger": "Not available"
},
{
"name": "lisp",
"full-name": "Lisp",
"server-name": "alive-lsp",
"server-url": "https://github.com/nobody-famous/alive-lsp",
"installation-url": "https://github.com/nobody-famous/alive-lsp?tab=readme-ov-file#running-the-server",
"debugger": "Not available"
},
{
"name": "ltex",
"full-name": "LanguageTool",
Expand Down
2 changes: 1 addition & 1 deletion lsp-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ As defined by the Language Server Protocol 3.16."
lsp-emmet lsp-erlang lsp-eslint lsp-fortran lsp-fsharp lsp-gdscript lsp-go
lsp-golangci-lint lsp-gleam lsp-glsl lsp-graphql lsp-hack lsp-grammarly
lsp-groovy lsp-haskell lsp-haxe lsp-idris lsp-java lsp-javascript lsp-json
lsp-kotlin lsp-latex lsp-ltex lsp-lua lsp-markdown lsp-marksman lsp-mdx
lsp-kotlin lsp-latex lsp-lisp lsp-ltex lsp-lua lsp-markdown lsp-marksman lsp-mdx
lsp-mint lsp-move lsp-nginx lsp-nim lsp-nix lsp-magik lsp-mojo lsp-metals
lsp-mssql lsp-nushell lsp-ocaml lsp-openscad lsp-pascal lsp-perl lsp-perlnavigator
lsp-pls lsp-php lsp-pwsh lsp-pyls lsp-pylsp lsp-pyright lsp-python-ms
Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ nav:
- Julia: page/lsp-julia.md
- Kotlin: page/lsp-kotlin.md
- LanguageTool (LTEX): page/lsp-ltex.md
- Lisp: page/lsp-lisp.md
- Lua (EmmyLua): page/lsp-emmy-lua.md
- Lua (Lua Language Server): page/lsp-lua-language-server.md
- Lua (Lua-Lsp): page/lsp-lua-lsp.md
Expand Down

0 comments on commit 193c714

Please sign in to comment.