Closed pablos-here closed 1 year ago
I took a look at https://github.com/bash-lsp/bash-language-server/blob/main/server/src/server.ts and it seems like bash-language-server
does not offer any facilities for auto-formatting source files. eglot
should throw that error if (eglot--server-capable cap)
returns false — so I am assuming that the language server simply doesn’t support auto-formatting.
Hi @6b6279 ,
Thank you for taking the time to do the analysis and provide an explanation.
Please let me know if you'd like me to close this issue or keep it open for the error-checking implementation.
eglot
seems to work as intended: It recognizes that the current language server does not support auto-formatting of source files and informs the user that the called function has failed. I would say this is a wontfix. If you think eglot
should handle this differently, I suggest creating a bug report on the official Emacs bug tracker.
There is already an issue over at the language server repository regarding the missing auto-format feature: bash-lsp/bash-language-server#320
Sounds good!
Hi,
I'm learning about LSPs and eglot. Very wet behind the ears. :)
In the two languages I've tested (
python
andbash
), I'm getting the titled error when trying to format the buffer.The details below are for
bash
as I figured it has the least requirements.Man, I hope I haven't made some boneheaded mistake ... hold my beer, I'm pressing Submit new issue
High-level
# npm -i -g bash-language-server
Recipe
~/.emacs.d
,init.el
and create the test script per below.bash-language-server
\emacs -Q -l init.el
M-x eglot-format-buffer
generates[eglot] Server can't format!
Details
~/.emacs.d and init.el
Start with an empty` ~/.emacs.d` and create the following `init.el` file: ```lisp ;;; minimal-ess-eglot.el -*- lexical-binding: t; -*- (require 'package) (setq package-list '(eglot)) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) (package-initialize) (unless package-archive-contents (package-refresh-contents)) (dolist (package package-list) (unless (package-installed-p package) (package-install package))) (add-hook 'sh-mode-hook #'eglot-ensure) ```Test script
Create ` /var/tmp/who_me` with: ```bash #!/bin/bash echo "hi mom" exit 0 ```M-x eglot-events-buffer (trimmed)
``` .... trimmed .... [client-request] (id:6) Mon Jan 9 09:38:00 2023: (:jsonrpc "2.0" :id 6 :method "textDocument/hover" :params (:textDocument (:uri "file:///var/tmp/who_me") :position (:line 5 :character 0))) [client-request] (id:7) Mon Jan 9 09:38:00 2023: (:jsonrpc "2.0" :id 7 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///var/tmp/who_me") :position (:line 5 :character 0))) [server-notification] Mon Jan 9 09:38:00 2023: (:jsonrpc "2.0" :method "window/logMessage" :params (:type 4 :message "onHover 5:0 word=null")) [server-reply] (id:6) Mon Jan 9 09:38:00 2023: (:jsonrpc "2.0" :id 6 :result nil) [server-notification] Mon Jan 9 09:38:00 2023: (:jsonrpc "2.0" :method "window/logMessage" :params (:type 4 :message "onDocumentHighlight 5:0 word=null")) [server-reply] (id:7) Mon Jan 9 09:38:00 2023: (:jsonrpc "2.0" :id 7 :result []) [client-request] (id:8) Mon Jan 9 09:38:38 2023: (:jsonrpc "2.0" :id 8 :method "textDocument/hover" :params (:textDocument (:uri "file:///var/tmp/who_me") :position (:line 5 :character 0))) [client-request] (id:9) Mon Jan 9 09:38:38 2023: (:jsonrpc "2.0" :id 9 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///var/tmp/who_me") :position (:line 5 :character 0))) [server-notification] Mon Jan 9 09:38:38 2023: (:jsonrpc "2.0" :method "window/logMessage" :params (:type 4 :message "onHover 5:0 word=null")) [server-reply] (id:8) Mon Jan 9 09:38:38 2023: (:jsonrpc "2.0" :id 8 :result nil) [server-notification] Mon Jan 9 09:38:38 2023: (:jsonrpc "2.0" :method "window/logMessage" :params (:type 4 :message "onDocumentHighlight 5:0 word=null")) [server-reply] (id:9) Mon Jan 9 09:38:38 2023: (:jsonrpc "2.0" :id 9 :result []) ```M-x toggle-debug-on-error
``` Debugger entered--Lisp error: (error "[eglot] Server can't format!") signal(error ("[eglot] Server can't format!")) error("[eglot] %s" "Server can't format!") eglot--error("Server can't format!") eglot-format(nil nil) eglot-format-buffer() funcall-interactively(eglot-format-buffer) call-interactively(eglot-format-buffer record nil) command-execute(eglot-format-buffer record) execute-extended-command(nil "eglot-format-buffer" "eglot-format-b") funcall-interactively(execute-extended-command nil "eglot-format-buffer" "eglot-format-b") call-interactively(execute-extended-command nil nil) command-execute(execute-extended-command) ```M-x eglot-stderr-buffer
No buffer was displayed but the following message was produced in the mini-buffer: ``` eglot--current-server-or-lose: jsonrpc-error: "No current JSON-RPC connection", (jsonrpc-error-code . 32603), (jsonrpc-error-message . "No current JSON-RPC connection") ```