37 lines
1.6 KiB
Nix
37 lines
1.6 KiB
Nix
|
{ config, lib, ... }:
|
||
|
|
||
|
with lib;
|
||
|
|
||
|
mkIf (elem "emacs::elpy" config.machine.pkgs) {
|
||
|
programs.emacs.init.usePackage.elpy = {
|
||
|
enable = true;
|
||
|
after = [ "python" ];
|
||
|
command = [ "elpy-enable" ];
|
||
|
hook = [ ''
|
||
|
(elpy-mode
|
||
|
. (lambda ()
|
||
|
(set (make-local-variable 'company-backends)
|
||
|
'((company-dabbrev-code company-yasnippet elpy-company-backend)))))
|
||
|
'' ]
|
||
|
++ (optional (elem "emacs::flyspell" config.machine.pkgs) "(elpy-mode . (lambda () (flyspell-prog-mode)))")
|
||
|
++ (optional (elem "emacs::flycheck" config.machine.pkgs) "(elpy-mode . (lambda () (flycheck-mode)))");
|
||
|
bindLocal = { elpy-mode-map = {
|
||
|
"<tab>" = "company-indent-or-complete-common";
|
||
|
};};
|
||
|
init = ''(with-eval-after-load 'python (elpy-enable))'';
|
||
|
config = ''
|
||
|
(setq elpy-project-root-finder-functions '(elpy-project-find-git-root elpy-project-find-python-root elpy-project-find-hg-root elpy-project-find-svn-root))
|
||
|
(setq elpy-rpc-backend "jedi")
|
||
|
(setq python-shell-interpreter "ipython"
|
||
|
python-shell-interpreter-args "-i --simple-prompt")
|
||
|
|
||
|
${optionalString (elem "emacs::flycheck" config.machine.pkgs) ''
|
||
|
;; manually set what python-mypy is and configure it to ignore 3rd party imports
|
||
|
(setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
|
||
|
(setq-default flycheck-checker 'python-pylint)
|
||
|
(flycheck-add-next-checker 'python-pylint 'python-mypy t)
|
||
|
(flycheck-add-next-checker 'python-mypy 'python-flake8 t)''}
|
||
|
'';
|
||
|
};
|
||
|
}
|