forked from emacs-elsa/Elsa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
elsa-lsp.el
42 lines (36 loc) · 1.34 KB
/
elsa-lsp.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
(require 'eieio)
(eval-and-compile (setq eieio-backward-compatibility nil))
(require 'elsa-lsp-core)
(setq elsa-is-language-server t)
(defun elsa-lsp-stdin-loop ()
"Reads from standard input in a loop and process incoming requests."
(elsa-load-config)
(require 'elsa-startup)
(-> (lgr-get-logger "elsa")
(lgr-reset-appenders)
(lgr-add-appender
(-> (elsa-lsp-appender)
(lgr-set-layout (elsa-plain-layout))
(lgr-set-threshold lgr-level-info)))
(lgr-add-appender
(-> (lgr-appender)
(lgr-set-layout (lgr-layout-format :format "[%K] (%n) %m"))))
(lgr-set-threshold lgr-level-debug))
(prettify-symbols-mode -1)
(let ((input (read-from-minibuffer ""))
(has-header nil))
(while input
;; (append-to-log-file (concat ">> " input))
(cond
((equal input ""))
((string-match-p (rx "content-length: " (group (1+ digit))) input)
(setq has-header t))
(has-header
(-let* (((&JSONResponse :params :method :id) (lsp--read-json input)))
(condition-case err
(elsa-lsp--on-request id method params)
(error (lgr-error (lgr-get-logger "elsa")
"Elsa lsp error: %s"
(error-message-string err)))))))
(setq input (read-from-minibuffer "")))))
(provide 'elsa-lsp)