Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose lsp-bash-allowed-shell and improve warning #4620

Merged
merged 5 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.org
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
* Add TypeSpec support
* Add Tree-sitter query support
* Add [[https://github.com/mrjosh/helm-ls][helm-ls]] (YAML Kubernetes Helm) support.
* Add ~lsp-bash-allowed-shells~ to configure supported ~sh-shell~ values.
* Add hint about ~activation-fn~ for unsupported buffers.

** 9.0.0
* Add language server config for QML (Qt Modeling Language) using qmlls.
Expand Down
14 changes: 10 additions & 4 deletions clients/lsp-bash.el
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
:link '(url-link "https://github.com/bash-lsp/bash-language-server")
:package-version '(lsp-mode . "6.2"))

(defcustom lsp-bash-allowed-shells '(sh bash)
"List of allowed `sh-shell` values that LSP will be enabled for."
:type '(list symbol)
:group 'lsp-bash
:package-version '(lsp-mode . "9.0.1"))

(defcustom lsp-bash-explainshell-endpoint nil
"The endpoint to use explainshell.com to answer `onHover' queries.
See instructions at https://marketplace.visualstudio.com/items?itemName=mads-hartmann.bash-ide-vscode"
Expand Down Expand Up @@ -65,11 +71,11 @@ See instructions at https://marketplace.visualstudio.com/items?itemName=mads-har
(defvar sh-shell)

(defun lsp-bash-check-sh-shell (&rest _)
"Check whether `sh-shell' is sh or bash.
"Check whether `sh-shell' is supported.

This prevents the Bash server from being turned on in zsh files."
(and (memq major-mode '(sh-mode bash-ts-mode ebuild-mode envrc-file-mode))
(memq sh-shell '(sh bash))))
This prevents the Bash server from being turned on for unsupported dialects, e.g. `zsh`."
(and (boundp 'sh-shell)
(memq sh-shell lsp-bash-allowed-shells)))

(lsp-register-client
(make-lsp-client
Expand Down
7 changes: 4 additions & 3 deletions lsp-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -9495,9 +9495,10 @@ You may find the installation instructions at https://emacs-lsp.github.io/lsp-mo
This issue might be caused by:
1. The language you are trying to use does not have built-in support in `lsp-mode'. You must install the required support manually. Examples of this are `lsp-java' or `lsp-metals'.
2. The language server that you expect to run is not configured to run for major mode `%s'. You may check that by checking the `:major-modes' that are passed to `lsp-register-client'.
3. `lsp-mode' doesn't have any integration for the language behind `%s'. Refer to https://emacs-lsp.github.io/lsp-mode/page/languages and https://langserver.org/ .
4. You are over `tramp'. In this case follow https://emacs-lsp.github.io/lsp-mode/page/remote/.
5. You have disabled the `lsp-mode' clients for that file. (Check `lsp-enabled-clients' and `lsp-disabled-clients').
3. The language server that you expect to run has an `:activation-fn` passed to `lsp-register-client` that prevents it supporting this buffer.
4. `lsp-mode' doesn't have any integration for the language behind `%s'. Refer to https://emacs-lsp.github.io/lsp-mode/page/languages and https://langserver.org/ .
5. You are over `tramp'. In this case follow https://emacs-lsp.github.io/lsp-mode/page/remote/.
6. You have disabled the `lsp-mode' clients for that file. (Check `lsp-enabled-clients' and `lsp-disabled-clients').
You can customize `lsp-warn-no-matched-clients' to disable this message."
major-mode major-mode major-mode))))))

Expand Down
Loading