From 193c714c1d74afeee154b255fbe85025cc4ee690 Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Wed, 20 Mar 2024 10:16:10 -0700 Subject: [PATCH] feat: Add Lisp support (#4385) --- CHANGELOG.org | 1 + clients/lsp-lisp.el | 95 +++++++++++++++++++++++++++++++++++++++++++ docs/lsp-clients.json | 8 ++++ lsp-mode.el | 2 +- mkdocs.yml | 1 + 5 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 clients/lsp-lisp.el diff --git a/CHANGELOG.org b/CHANGELOG.org index 4099bd2a87..c2ce9f5766 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -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. diff --git a/clients/lsp-lisp.el b/clients/lsp-lisp.el new file mode 100644 index 0000000000..f69db58db9 --- /dev/null +++ b/clients/lsp-lisp.el @@ -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 . + +;;; 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 diff --git a/docs/lsp-clients.json b/docs/lsp-clients.json index 4a87d272ac..f5be0b03cb 100644 --- a/docs/lsp-clients.json +++ b/docs/lsp-clients.json @@ -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", diff --git a/lsp-mode.el b/lsp-mode.el index 649259da39..1737d7ff3a 100644 --- a/lsp-mode.el +++ b/lsp-mode.el @@ -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 diff --git a/mkdocs.yml b/mkdocs.yml index 13700faba7..11861f1e4a 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -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