Skip to content

Commit 168a6cf

Browse files
committed
Add support for eglot, make lsp-mode optional
1 parent 1ef68ca commit 168a6cf

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,7 @@ This is how the "Hello World" example from Slint looks like:
2424
## Prerequisites
2525

2626
- Emacs: I've tested this with GNU Emacs 28.2. ymmv. Please file an issue if you run into any problems.
27-
- [lsp-mode](https://emacs-lsp.github.io/lsp-mode/): Adds LSP support to Emacs. Can be installed via melpa.
2827
- [slint-lsp](https://github.com/slint-ui/slint/blob/master/tools/lsp/README.md): The slint language server. Follow the link for installation instructions.
28+
- (*Optional*) [lsp-mode](https://emacs-lsp.github.io/lsp-mode/): LSP support for Emacs (alternative to built-in eglot). Can be installed via melpa.
29+
30+
`slint-mode` should work with both `lsp-mode` and `eglot`.

slint-mode.el

+12-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
;; Author: Niklas Cathor <[email protected]>
66
;; Keywords: languages
77
;; Version: 0
8-
;; Package-Requires: ((emacs "24.4") (lsp-mode "6.0"))
8+
;; Package-Requires: ((emacs "24.4"))
99
;; Homepage: https://github.com/nilclass/slint-mode
1010

1111
;; This program is free software; you can redistribute it and/or modify
@@ -23,8 +23,6 @@
2323

2424
;;; Code:
2525

26-
(require 'lsp-mode)
27-
2826
(defgroup slint nil
2927
"Major mode for Slint UI files."
3028
:tag "Slint"
@@ -110,13 +108,18 @@
110108
(set-syntax-table slint-mode-syntax-table)
111109
(set (make-local-variable 'font-lock-defaults) '(slint-font-lock-keywords)))
112110

113-
(add-to-list 'lsp-language-id-configuration
114-
'(slint-mode . "slint"))
111+
(with-eval-after-load 'lsp-mode
112+
(add-to-list 'lsp-language-id-configuration
113+
'(slint-mode . "slint"))
114+
115+
(lsp-register-client
116+
(make-lsp-client :new-connection (lsp-stdio-connection "slint-lsp")
117+
:activation-fn (lsp-activate-on "slint")
118+
:server-id 'slint)))
115119

116-
(lsp-register-client
117-
(make-lsp-client :new-connection (lsp-stdio-connection "slint-lsp")
118-
:activation-fn (lsp-activate-on "slint")
119-
:server-id 'slint))
120+
(with-eval-after-load 'eglot
121+
(add-to-list 'eglot-server-programs
122+
'(slint-mode . ("slint-lsp"))))
120123

121124
;;;###autoload
122125
(add-to-list 'auto-mode-alist '("\\.slint\\'" . slint-mode))

0 commit comments

Comments
 (0)