我试了 lsp-wl. lsp-mode 参考 这里, 写的是:
(add-to-list 'lsp-language-id-configuration '(wolfram-mode . "Mathematica"))
(lsp-register-client
(make-lsp-client :language-id 'wolfram
;; :new-connection (lsp-stdio-connection
;; '("/usr/bin/wolframscript" ;; or "wolframscript"
;; "-file" ;; or "-file"
;; "~/log/lsp-wl/init.wls"
;; ))
:new-connection (lsp-tcp-server-command
(lambda (port)
`("/usr/bin/wolframscript" ;; or "wolframscript"
"-file" ;; or "-file"
"~/log/lsp-wl/init.wls"
,(concat
"--socket="
(number-to-string port)
))))
:major-modes '(wolfram-mode)
:server-id 'lsp-wl
))
报错是:
LSP :: Waiting for connection for lsp-wl, retries: 0
...
Failed to create connection to lsp-wl on port 39603
注释是我参考 这里 写的, 按注释写, 那不会报错, 但也不会 work.
我又试了 eglot 配置. eglot 参考 这里, 写的是:
(let ((wlserver (expand-file-name "~/log/lsp-wl/init.wls")))
(when (and (file-exists-p wlserver) (executable-find "wolframscript"))
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs
`(wolfram-mode . ("/usr/bin/wolframscript" "-f" ,wlserver
"--tcp-server" :autoport))))))
但在一个 wolfram-mode 启动, 报错是:
[eglot] Trying to connect to localhost and port 45283 (attempt 1)
eglot--error: [eglot] Could not start and connect to server started with (/usr/bin/wolframscript -f /home/quebec/log/lsp-wl/init.wls --tcp-server 45283)
直接执行 /usr/bin/wolframscript -f /home/quebec/log/lsp-wl/init.wls --tcp-server 45283
是没有问题的.