Enable experimental support for lsp within the shell-scripts layer
Note that this is only valid for bash scripts, since it uses the `bash-language-server` defined in `lsp-clients.el`
This commit is contained in:
parent
f170c732d7
commit
724eb908a8
|
@ -2567,6 +2567,8 @@ Other:
|
||||||
- Added insert commands from sh-script package to major mode menu
|
- Added insert commands from sh-script package to major mode menu
|
||||||
(thanks to Maximilian Wolff)
|
(thanks to Maximilian Wolff)
|
||||||
- Added org-mode support (thanks to Josh Santos)
|
- Added org-mode support (thanks to Josh Santos)
|
||||||
|
- Added LSP support, which can be used by enabling the =lsp= layer and setting
|
||||||
|
the =shell-scripts= layer's =shell-scripts-backend= variable to =lsp=
|
||||||
**** Slack
|
**** Slack
|
||||||
- New layer variable =slack-spacemacs-layout-name= to customize the name of
|
- New layer variable =slack-spacemacs-layout-name= to customize the name of
|
||||||
the custom layer for Slack buffers (thanks to Benjamin Reynolds)
|
the custom layer for Slack buffers (thanks to Benjamin Reynolds)
|
||||||
|
|
|
@ -8,8 +8,12 @@
|
||||||
- [[#description][Description]]
|
- [[#description][Description]]
|
||||||
- [[#features][Features:]]
|
- [[#features][Features:]]
|
||||||
- [[#install][Install]]
|
- [[#install][Install]]
|
||||||
|
- [[#layer][Layer]]
|
||||||
- [[#linting][Linting]]
|
- [[#linting][Linting]]
|
||||||
- [[#style-checking][Style checking]]
|
- [[#style-checking][Style checking]]
|
||||||
|
- [[#setting-the-backend][Setting the backend]]
|
||||||
|
- [[#backend][Backend]]
|
||||||
|
- [[#language-server-protocol][Language Server Protocol]]
|
||||||
- [[#key-bindings][Key bindings]]
|
- [[#key-bindings][Key bindings]]
|
||||||
|
|
||||||
* Description
|
* Description
|
||||||
|
@ -25,8 +29,10 @@ Supported scripting files:
|
||||||
- Auto-completion using [[https://github.com/Alexander-Miller/company-shell][company-shell]]
|
- Auto-completion using [[https://github.com/Alexander-Miller/company-shell][company-shell]]
|
||||||
- =Sh= scripts linting using [[https://www.shellcheck.net/][shellcheck]]
|
- =Sh= scripts linting using [[https://www.shellcheck.net/][shellcheck]]
|
||||||
- =Sh= scripts style checking using [[https://github.com/openstack-dev/bashate][bashate]]
|
- =Sh= scripts style checking using [[https://github.com/openstack-dev/bashate][bashate]]
|
||||||
|
- Support for the [[https://langserver.org/][Language Server Protocol]] (experimental)
|
||||||
|
|
||||||
* Install
|
* Install
|
||||||
|
** Layer
|
||||||
To use this configuration layer, add it to your =~/.spacemacs=. You will need to
|
To use this configuration layer, add it to your =~/.spacemacs=. You will need to
|
||||||
add =shell-scripts= to the existing =dotspacemacs-configuration-layers= list in this
|
add =shell-scripts= to the existing =dotspacemacs-configuration-layers= list in this
|
||||||
file.
|
file.
|
||||||
|
@ -37,6 +43,26 @@ In order to enable =sh= scripts linting, install [[https://www.shellcheck.net/][
|
||||||
** Style checking
|
** Style checking
|
||||||
In order to enable =sh= scripts style checking, install [[https://github.com/openstack-dev/bashate][bashate]].
|
In order to enable =sh= scripts style checking, install [[https://github.com/openstack-dev/bashate][bashate]].
|
||||||
|
|
||||||
|
** Setting the backend
|
||||||
|
To activate the backend set the layer variable =shell-scripts-backend=:
|
||||||
|
|
||||||
|
#+BEGIN_SRC elisp
|
||||||
|
(shell-scripts :variables shell-scripts-backend 'lsp)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
For spacemacs to use lsp you also need to add =lsp= to the
|
||||||
|
=dotspacemacs-configuration-layers= in your =~/.spacemacs= file.
|
||||||
|
|
||||||
|
* Backend
|
||||||
|
** Language Server Protocol
|
||||||
|
You have to install the bash language server:
|
||||||
|
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
npm i -g bash-language-server
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
You can find further information on the project's [[https://github.com/mads-hartmann/bash-language-server][GitHub page]].
|
||||||
|
|
||||||
* Key bindings
|
* Key bindings
|
||||||
|
|
||||||
| Key binding | Description |
|
| Key binding | Description |
|
||||||
|
|
|
@ -12,3 +12,6 @@
|
||||||
;; variables
|
;; variables
|
||||||
|
|
||||||
(spacemacs|define-jump-handlers sh-mode)
|
(spacemacs|define-jump-handlers sh-mode)
|
||||||
|
|
||||||
|
(defvar shell-scripts-backend nil
|
||||||
|
"The backend to use for IDE features. Possible values are `lsp'.")
|
||||||
|
|
|
@ -18,3 +18,17 @@
|
||||||
(require 'insert-shebang)
|
(require 'insert-shebang)
|
||||||
(insert-shebang-get-extension-and-insert
|
(insert-shebang-get-extension-and-insert
|
||||||
(file-name-nondirectory (buffer-file-name))))
|
(file-name-nondirectory (buffer-file-name))))
|
||||||
|
|
||||||
|
|
||||||
|
;; lsp
|
||||||
|
|
||||||
|
(defun spacemacs//shell-scripts-setup-backend ()
|
||||||
|
"Conditionally setup shell-scripts backend."
|
||||||
|
(pcase shell-scripts-backend
|
||||||
|
(`lsp (spacemacs//shell-scripts-setup-lsp))))
|
||||||
|
|
||||||
|
(defun spacemacs//shell-scripts-setup-lsp ()
|
||||||
|
"Setup lsp backend."
|
||||||
|
(if (configuration-layer/layer-used-p 'lsp)
|
||||||
|
(lsp)
|
||||||
|
(message "`lsp' layer is not installed, please add `lsp' layer to your dotfile.")))
|
||||||
|
|
|
@ -84,7 +84,8 @@
|
||||||
(when (and buffer-file-name
|
(when (and buffer-file-name
|
||||||
(string-match-p "\\.zsh\\'" buffer-file-name))
|
(string-match-p "\\.zsh\\'" buffer-file-name))
|
||||||
(sh-set-shell "zsh")))
|
(sh-set-shell "zsh")))
|
||||||
(add-hook 'sh-mode-hook 'spacemacs//setup-shell))))
|
(add-hook 'sh-mode-hook 'spacemacs//setup-shell)
|
||||||
|
(add-hook 'sh-mode-hook 'spacemacs//shell-scripts-setup-backend))))
|
||||||
|
|
||||||
(defun shell-scripts/post-init-ggtags ()
|
(defun shell-scripts/post-init-ggtags ()
|
||||||
(add-hook 'sh-mode-local-vars-hook #'spacemacs/ggtags-mode-enable))
|
(add-hook 'sh-mode-local-vars-hook #'spacemacs/ggtags-mode-enable))
|
||||||
|
|
Loading…
Reference in a new issue