Closed skx closed 1 year ago
This is a little bigger than I'd like, but it does three things:
yal-mode
.lsp-deferred
is called as a hook when entering that mode.After all that we then do the LSP-magic:
yal -lsp
as a language-server, for files in yal-mode
.And we configure "C-c TAB" to do dynamic completions, though pausing after typing "prin" or "pad:" is sufficient to make it work. Yay.
Sample code:
;;; yal.el -- Sample configuration for using Emacs LSP-mode with YAL
;; Create a keyboard-map for use within YAL files
(defvar yal-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c TAB") 'completion-at-point)
map))
;; Define a hook which will run when entering YAL mode.
(add-hook 'yal-mode-hook 'lsp-deferred)
;; Now create a trivial "yal-mode"
(define-derived-mode yal-mode
lisp-mode "YAL"
"Major mode for working with yet another lisp, YAL.")
;; yal-mode will be invoked for *.yal files
(add-to-list 'auto-mode-alist '("\\.yal\\'" . yal-mode))
;; Register an LSP helper
(require 'lsp-mode)
(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection '("yal" "-lsp"))
:major-modes '(yal-mode)
:priority -1
:server-id 'yal-ls))
(add-to-list 'lsp-language-id-configuration '(yal-mode . "yal"))
Screensot:
https://github.com/tliron/glsp is awesome and made the completion support almost trivial.
Looks like showing documentation on hover requires parsing the file and doing location-testing. I'll see if I can make that good enough to be useful, but definitely completion is worth having and very simple :)
I need to provide a configuration for at least one other editor. neovim looks simple:
LSP is a big thing that makes editors and languages work well together, in a portable way.
What better way to make LISP cool than to add LSP?
For the next release the focus will be upon implementing a yal-LSP server:
Ideally we'll allow
yal -lsp
to launch the server, but there are probably additional options required - for network-socket vs. unix-socket, etc.We must ship sample configuration for emacs, and at least one more editor.