mirror of
https://github.com/jimeh/.emacs.d.git
synced 2026-02-19 13:46:41 +00:00
feat(languages): enable shellcheck linting when using bash language server
Due to how lsp integrates with flycheck, it needs to take over all linting responsibilities. Hence we need to use efm-langserver to execute shellcheck for us. It's a bit messy, but end result works pretty well.
This commit is contained in:
@@ -51,7 +51,34 @@
|
||||
:preface
|
||||
(defun siren-lsp-bash-mode-setup ()
|
||||
(if (member sh-shell '(bash sh))
|
||||
(lsp-deferred))))
|
||||
(lsp-deferred)))
|
||||
|
||||
:config
|
||||
;; Create custom lsp-client for shellcheck diagnostics via efm-langserver.
|
||||
(when (and (executable-find "efm-langserver")
|
||||
(executable-find "shellcheck"))
|
||||
(lsp-register-custom-settings
|
||||
'(("shellcheck.rootMarkers" [".git/"])
|
||||
("shellcheck.languages"
|
||||
((shellscript . [((lintCommand . "shellcheck -f gcc -x -")
|
||||
(lintStdin . t)
|
||||
(lintSource . "shellcheck")
|
||||
(lintFormats . ["%f:%l:%c: %trror: %m"
|
||||
"%f:%l:%c: %tarning: %m"
|
||||
"%f:%l:%c: %tote: %m"]))])))))
|
||||
(lsp-register-client
|
||||
(make-lsp-client :new-connection (lsp-stdio-connection
|
||||
'("efm-langserver"))
|
||||
:priority 0
|
||||
:activation-fn #'lsp-bash-check-sh-shell
|
||||
:initialized-fn
|
||||
(lambda (workspace)
|
||||
(with-lsp-workspace workspace
|
||||
(lsp--set-configuration
|
||||
(gethash "shellcheck"
|
||||
(lsp-configuration-section "shellcheck")))))
|
||||
:server-id 'shellcheck
|
||||
:add-on? t))))
|
||||
|
||||
(use-package shfmt
|
||||
:hook
|
||||
|
||||
Reference in New Issue
Block a user