nixos/pkgs/pkgsets/emacs/lsp.nix

55 lines
1.4 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
mkIf (elem "emacs::lsp" config.machine.pkgs) {
programs.emacs.init.usePackage = {
lsp-mode = {
enable = true;
command = [ "lsp-mode" ];
bind = {
"C-c r r" = "lsp-rename";
"C-c r f" = "lsp-format-buffer";
};
config = ''
(setq lsp-eldoc-render-all nil)
(defvar lsp-language-id-configuration '(
${optionalString (elem "emacs::rust" config.machine.pkgs
''(rust-mode . "rust")'')}
))
'';
};
lsp-ui = {
enable = true;
after = [ "lsp" ];
command = [ "lsp-ui-mode" "lsp-ui-sideline-mode" ];
config = ''
(setq lsp-ui-sideline-enable t
lsp-ui-sideline-show-symbol nil
lsp-ui-sideline-show-hover nil
lsp-ui-sideline-show-code-actions t
lsp-ui-sideline-update-mode 'point)
'';
};
lsp-ui-flycheck = {
enable = true;
after = [ "lsp-ui" ]
++ optional (elem "emacs::flycheck" config.machine.pkgs) "flycheck";
};
lsp-java = {
enable = (elem "emacs::java" config.machine.pkgs);
command = [ "lsp-java-enable" ];
hook = [ ''
(java-mode . (lambda ()
(lsp-java-enable)
(lsp-ui-sideline-mode)
(lsp-ui-flycheck-enable t)
(setq-local company-backends (list 'company-lsp))))
'' ];
};
};
}