The authors of this Wiki assume people want to use even more files (.dir-locals.el
in this case) which I find to be a very strange assumption. Emacs and Spacemacs are complex enough already. We could use much more self-sufficient (single-file / single-function) examples and they’ll be far more useful.
Complete working example on disabling elixir-ls
running Dialyzer, with context:
(defun dotspacemacs/user-config ()
;; Use LSP.
(use-package lsp-mode
:commands lsp
:ensure t
:diminish lsp-mode
:hook
(elixir-mode . lsp)
:init
(add-to-list 'exec-path "~/bin/elixir-ls/release")
)
;; Set Elixir LSP hooks (in this case, format on save).
(add-hook 'elixir-mode-hook
(lambda ()
(add-hook 'before-save-hook #'lsp-format-buffer nil t)))
;; Disable Dialyzer in `elixir-ls`.
(defvar lsp-elixir--config-options (make-hash-table))
(puthash "dialyzerEnabled" :json-false lsp-elixir--config-options)
(add-hook 'lsp-after-initialize-hook
(lambda ()
(lsp--set-configuration `(:elixirLS, lsp-elixir--config-options))))
;; ...all your other user initialization code/config goes here...
)
This worked for me and Spacemacs stopped thrashing my server-grade workstation to a halt on literally every save. Spacemacs feels more snappy now.