feat(emacs): Basic LSP

Includes basic Nix-mode config for the sake of testing the LSP.
This commit is contained in:
Madeleine Sydney
2025-02-12 17:45:58 -07:00
parent f53f58df5a
commit 03491612f2
5 changed files with 75 additions and 0 deletions

View File

@@ -4,6 +4,10 @@
(require 'syd-constants)
(use-package dash)
(require 'dash)
(cl-defmacro syd-define-stub
(name &key (desc "implement me!") interactive)
(let ((todo (format "%s: TODO: %s" name desc)))
@@ -130,4 +134,35 @@ form."
(prog1 (progn ,@body)
(message ""))))))
(defun syd--parse-defadvice-args (arg-list)
"Parses the docstring and keywords provided to `syd-defadvice'."
(let (docstring
advice)
(when (stringp (car-safe arg-list))
(setq docstring (pop arg-list)))
(while (and (length> arg-list 2)
(keywordp (car arg-list)))
(let ((how (pop arg-list))
(sym (pop arg-list)))
(push (cons how sym) advice)))
;; What's left of `arg-list' is the body of the defun.
(list docstring advice arg-list)))
(defmacro syd-defadvice (name params &rest args)
"Define a function and add it as advice."
(declare (indent defun))
(-let (((docstring advice body) (syd--parse-defadvice-args args)))
`(progn (defun ,name ,params
,@(-some-> docstring list)
,@body)
,@(-map (lambda (arg)
(-let (((how . sym) arg))
`(advice-add ,sym ,how #',name)))
advice))))
(syd-defadvice syd-lsp-install-server-a ()
:override #'lsp-install-server
(user-error (concat "Ignoring a call to `lsp-install-server'"
" — tell the caller to use Nix!")))
(provide 'syd-prelude)