An experiment to see if I can make an LSP server for Twelf code.
It currently relies on a version of twelf still in a branch.
npm install
make
- 🚨 definitely not a real usable LSP server yet 🚨
- Can react to
textDocument/didChange
by parsing the text of the document withtwelf.wasm
, and storing the results - Can respond to
textDocument/definition
by looking for a constructor declaration that contains the current point, and jumping to the previous constructor declaration.
I'm testing the mode using eglot
in emacs. Here's the elisp I added to my config for that purpose, where ".../twelf-lsp/twelf-lsp"
is replaced by the absolute path to the twelf-lsp
script in this repository.
(use-package eglot)
(defvar fictional-mode-map
(let ((map (make-sparse-keymap)))
map)
"Keymap for fictional-mode.")
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs
'(fictional-mode . (".../twelf-lsp/twelf-lsp"))))
;; Define the mode
(define-derived-mode fictional-mode prog-mode "Fictional"
"A major mode for testing purposes."
)
(add-to-list 'auto-mode-alist '("\\.fiction\\'" . fictional-mode))
(defun jcreed-fictional-mode-hook ()
(interactive)
(eglot)
(define-key fictional-mode-map (kbd "M-.") 'xref-find-definitions))
(add-hook 'fictional-mode-hook 'jcreed-fictional-mode-hook)