Skip to content

Commit 193c714

Browse files
authored
feat: Add Lisp support (#4385)
1 parent 8903da3 commit 193c714

File tree

5 files changed

+106
-1
lines changed

5 files changed

+106
-1
lines changed

CHANGELOG.org

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
* Add [[https://docs.trunk.io][Trunk]] support
114114
* Add Cucumber support.
115115
* Add COBOL support.
116+
* Add Common Lisp support.
116117

117118
** Release 8.0.0
118119
* 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.

clients/lsp-lisp.el

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
;;; lsp-lisp.el --- LSP client for Lisp -*- lexical-binding: t; -*-
2+
3+
;; Copyright (C) 2024 Shen, Jen-Chieh
4+
5+
;; This file is not part of GNU Emacs.
6+
7+
;; This program is free software: you can redistribute it and/or modify
8+
;; it under the terms of the GNU General Public License as published by
9+
;; the Free Software Foundation, either version 3 of the License, or
10+
;; (at your option) any later version.
11+
12+
;; This program is distributed in the hope that it will be useful,
13+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
;; GNU General Public License for more details.
16+
17+
;; You should have received a copy of the GNU General Public License
18+
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
20+
;;; Commentary:
21+
;;
22+
;; LSP client for Lisp.
23+
;;
24+
25+
;;; Code:
26+
27+
(require 'lsp-mode)
28+
29+
(defgroup lsp-lisp nil
30+
"LSP support for Lisp."
31+
:group 'lsp-mode
32+
:package-version `(lsp-mode . "8.0.1"))
33+
34+
(defcustom lsp-lisp-active-modes
35+
'( lisp-mode)
36+
"List of major mode that work with lisp."
37+
:type 'list
38+
:group 'lsp-lisp)
39+
40+
(defcustom lsp-lisp-alive-port 8006
41+
"Port to connect server to."
42+
:type 'integer
43+
:group 'lsp-lisp)
44+
45+
;;
46+
;;; Server
47+
48+
;;;###autoload
49+
(add-hook 'lisp-mode-hook #'lsp-lisp-alive-start-ls)
50+
51+
;;;###autoload
52+
(defun lsp-lisp-alive-start-ls ()
53+
"Start the alive-lsp."
54+
(interactive)
55+
(when-let ((exe (executable-find "sbcl"))
56+
((lsp--port-available "localhost" lsp-lisp-alive-port)))
57+
(lsp-async-start-process #'ignore #'ignore
58+
exe
59+
"--noinform"
60+
"--eval"
61+
"(ql:quickload \"alive-lsp\")"
62+
"--eval"
63+
(format "(alive/server::start :port %s)"
64+
lsp-lisp-alive-port))))
65+
66+
;;
67+
;;; Core
68+
69+
(defun lsp-lisp-alive--tcp-connect-to-port ()
70+
"Define a TCP connection to language server."
71+
(list
72+
:connect
73+
(lambda (filter sentinel name _environment-fn _workspace)
74+
(let* ((host "localhost")
75+
(port lsp-lisp-alive-port)
76+
(tcp-proc (lsp--open-network-stream host port (concat name "::tcp"))))
77+
78+
;; TODO: Same :noquery issue (see above)
79+
(set-process-query-on-exit-flag tcp-proc nil)
80+
(set-process-filter tcp-proc filter)
81+
(set-process-sentinel tcp-proc sentinel)
82+
(cons tcp-proc tcp-proc)))
83+
:test? (lambda () t)))
84+
85+
(lsp-register-client
86+
(make-lsp-client
87+
:new-connection (lsp-lisp-alive--tcp-connect-to-port)
88+
:major-modes lsp-lisp-active-modes
89+
:priority -1
90+
:server-id 'alive-lsp))
91+
92+
(lsp-consistency-check alive-lsp)
93+
94+
(provide 'lsp-lisp)
95+
;;; lsp-lisp.el ends here

docs/lsp-clients.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,14 @@
504504
"installation-url": "https://github.com/fwcd/kotlin-language-server/blob/master/BUILDING.md",
505505
"debugger": "Not available"
506506
},
507+
{
508+
"name": "lisp",
509+
"full-name": "Lisp",
510+
"server-name": "alive-lsp",
511+
"server-url": "https://github.com/nobody-famous/alive-lsp",
512+
"installation-url": "https://github.com/nobody-famous/alive-lsp?tab=readme-ov-file#running-the-server",
513+
"debugger": "Not available"
514+
},
507515
{
508516
"name": "ltex",
509517
"full-name": "LanguageTool",

lsp-mode.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ As defined by the Language Server Protocol 3.16."
181181
lsp-emmet lsp-erlang lsp-eslint lsp-fortran lsp-fsharp lsp-gdscript lsp-go
182182
lsp-golangci-lint lsp-gleam lsp-glsl lsp-graphql lsp-hack lsp-grammarly
183183
lsp-groovy lsp-haskell lsp-haxe lsp-idris lsp-java lsp-javascript lsp-json
184-
lsp-kotlin lsp-latex lsp-ltex lsp-lua lsp-markdown lsp-marksman lsp-mdx
184+
lsp-kotlin lsp-latex lsp-lisp lsp-ltex lsp-lua lsp-markdown lsp-marksman lsp-mdx
185185
lsp-mint lsp-move lsp-nginx lsp-nim lsp-nix lsp-magik lsp-mojo lsp-metals
186186
lsp-mssql lsp-nushell lsp-ocaml lsp-openscad lsp-pascal lsp-perl lsp-perlnavigator
187187
lsp-pls lsp-php lsp-pwsh lsp-pyls lsp-pylsp lsp-pyright lsp-python-ms

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ nav:
100100
- Julia: page/lsp-julia.md
101101
- Kotlin: page/lsp-kotlin.md
102102
- LanguageTool (LTEX): page/lsp-ltex.md
103+
- Lisp: page/lsp-lisp.md
103104
- Lua (EmmyLua): page/lsp-emmy-lua.md
104105
- Lua (Lua Language Server): page/lsp-lua-language-server.md
105106
- Lua (Lua-Lsp): page/lsp-lua-lsp.md

0 commit comments

Comments
 (0)