Skip to content

Commit

Permalink
Merge pull request #1153 from informalsystems/gabriela/emacs-lsp-client
Browse files Browse the repository at this point in the history
Emacs client for quint language server
  • Loading branch information
bugarela authored Sep 6, 2023
2 parents 15437c2 + dbf324d commit c7d733d
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
18 changes: 18 additions & 0 deletions editor-plugins/emacs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Emacs support

We have 2 packages for enabling support for Quint in Emacs.

1. `quint-mode` is a major mode that enables simple syntax highlighting
2. `lsp-quint` is a client for `lsp-mode`, enabling IDE features provided by `quint-language-server`

These packages are not published anywhere for the moment. You can clone this git repo and add a configuration like the following (which uses `use-package`):

```elisp
(load-file "<path-to-quint-repo>/editor-plugins/emacs/quint-mode.el")
(load-file "<path-to-quint-repo>/editor-plugins/emacs/lsp-quint.el")
(require 'quint-mode)
(add-to-list 'auto-mode-alist '("\\.qnt" . quint-mode))
(use-package lsp-quint
:ensure t
:hook (quint-mode . lsp))
```
56 changes: 56 additions & 0 deletions editor-plugins/emacs/lsp-quint.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
;;; lsp-quint.el --- Quint LSP Client settings
;;;
;; Copyright (C) 2023 Gabriela Moreira

;; Author: Gabriela Moreira ([email protected])
;; URL: https://github.com/informalsystems/quint
;; Version: 1.0.0
;; Created: 28 Aug 2023
;; Updated 21 Aug 2023
;; Keywords: languages

;; This file is not part of GNU Emacs.

;;; Commentary:

;; A client for lsp-mode for the Quint Specification Language, using the quint language server.

;;; Code:

(require 'lsp-mode)
(require 'lsp-completion)

(defgroup lsp-quint nil
"LSP support for the Quint Specification Language, using the quint language server."
:link '(url-link "https://github.com/informalsystems/quint")
:group 'lsp-mode
:package-version '(lsp-mode . "6.3.2"))

(lsp-dependency 'quint-language-server
'(:system "quint-language-server")
'(:npm :package "@informalsystems/quint-language-server"
:path "quint-language-server"))

(add-to-list 'lsp-language-id-configuration '(quint-mode . "quint"))
(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection
(lambda () (list (lsp-package-path 'quint-language-server) "--stdio")))
:major-modes '(quint-mode)
:activation-fn (lsp-activate-on "quint")
:language-id "quint"
:priority 0
:server-id 'quint-language-server
:completion-in-comments? t
:download-server-fn (lambda (_client callback error-callback _update?)
(lsp-package-ensure
'quint-language-server
(-partial #'lsp-package-ensure
'quint-language-server
callback
error-callback)
error-callback))))

(lsp-consistency-check lsp-quint)

(provide 'lsp-quint)
;;; lsp-quint.el ends here

0 comments on commit c7d733d

Please sign in to comment.