nixos/pkgsets/emacs/lsp.nix

60 lines
2 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"];
config = ''
(setq lsp-keymap-prefix "C-c")
(setq lsp-eldoc-render-all nil)
(defvar lsp-language-id-configuration '(
${optionalString (elem "emacs::rust" config.machine.pkgs)
''(rust-mode . "rust")''}
))
${optionalString (elem "emacs::rust" config.machine.pkgs) ''
(setq lsp-rust-clippy-preference "on")
''}
${optionalString (elem "emacs::web-mode" config.machine.pkgs) ''
(setq lsp-clients-deno-enable-unstable 't)
(setq lsp-clients-deno-import-map "./import_map.json")
(setq lsp-clients-deno-config "./deno.json")
''}
${optionalString (elem "emacs::php-mode" config.machine.pkgs) ''
(setq lsp-intelephense-php-version "8.2")
(setq lsp-intelephense-server-command `("${pkgs.nodePackages.intelephense}/bin/intelephense" "--stdio"))
''}
'';
};
lsp-ui = {
enable = true;
after = ["lsp-mode"];
config = ''
(setq lsp-ui-sideline-enable 't)
(setq lsp-ui-sideline-show-symbol nil)
(setq lsp-ui-sideline-show-hover nil)
(setq lsp-ui-doc-show-with-cursor 't)
(setq lsp-ui-doc-delay 1)
(setq lsp-ui-sideline-show-code-actions 't)
(setq lsp-ui-sideline-update-mode 'point)
(define-key lsp-ui-mode-map [remap xref-find-definitions] #'lsp-ui-peek-find-definitions)
(define-key lsp-ui-mode-map [remap xref-find-references] #'lsp-ui-peek-find-references)
'';
};
lsp-ui-flycheck = {
enable = true;
package = epkgs: [epkgs.lsp-ui];
after =
["lsp-ui"]
++ optional (elem "emacs::flycheck" config.machine.pkgs) "flycheck";
};
};
}