From 19511564e6a185715b7730b12833411876d677ba Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Mon, 7 Aug 2023 15:57:47 -0600 Subject: [PATCH] [NixOS] [Emacs] Configure black python formatting --- dotfiles/emacs.d/README.org | 39 +++++++++++++------------------------ nixos/code.nix | 1 + 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/dotfiles/emacs.d/README.org b/dotfiles/emacs.d/README.org index c3f6baa2..df7dc98e 100644 --- a/dotfiles/emacs.d/README.org +++ b/dotfiles/emacs.d/README.org @@ -2193,7 +2193,7 @@ I don't use auto-complete at all, so I have set up a hook to automatically disab ** format-all #+begin_src emacs-lisp (use-package format-all - :commands format-all-buffer) + :commands (format-all-buffer format-all-mode)) #+end_src ** cliphist #+BEGIN_SRC emacs-lisp @@ -2298,18 +2298,21 @@ I don't use auto-complete at all, so I have set up a hook to automatically disab *** python #+BEGIN_SRC emacs-lisp (defvar imalison:use-lsp-python t) +(defvar imalison:use-black nil) + (use-package python :commands python-mode :mode ("\\.py\\'" . python-mode) :preface (defun imalison:python-mode () - (setq show-trailing-whitespace t) - ;; Remove default python completion, as we are going to rely on - ;; company-jedi or company-lsp. - ;; (remove-hook 'completion-at-point-functions - ;; 'python-completion-complete-at-point 'local) - (if imalison:use-lsp-python - (lsp-deferred))) + (add-hook 'hack-local-variables-hook + (lambda () + (when imalison:use-black + (setq format-all-formatters nil) + (add-to-list 'format-all-formatters '("Python" . (black))) + (format-all-mode)) + (when imalison:use-lsp-python + (lsp-deferred))) nil t)) :config (progn (use-package lsp-mode @@ -2317,6 +2320,7 @@ I don't use auto-complete at all, so I have set up a hook to automatically disab (progn (require 'lsp-pylsp) (setq lsp-pylsp-plugins-pydocstyle-enabled nil))) + (use-package sphinx-doc) (unbind-key "C-j" python-mode-map) (add-hook 'python-mode-hook #'imalison:python-mode))) @@ -2941,24 +2945,7 @@ The following is taken from [[https://github.com/syl20bnr/spacemacs/blob/a650877 #+END_SRC *** C/C++ #+BEGIN_SRC emacs-lisp -(use-package cc-mode - :disabled t - :preface - (defun imalison:cc-mode-hook () - (when (derived-mode-p 'c-mode 'c++-mode 'java-mode 'asm-mode) - (ggtags-mode 1))) - :config - (progn - (use-package ggtags - :demand t - :bind (:map ggtags-mode-map - ("C-c g s" . ggtags-find-other-symbol) - ("C-c g h" . ggtags-view-tag-history) - ("C-c g r" . ggtags-find-reference) - ("C-c g f" . ggtags-find-file) - ("C-c g c" . ggtags-create-tags) - ("C-c g u" . ggtags-update-tags))) - (add-hook 'c-mode-common-hook 'imalison:cc-mode-hook))) +(use-package cc-mode) #+END_SRC *** C-- #+BEGIN_SRC emacs-lisp diff --git a/nixos/code.nix b/nixos/code.nix index 5fcc449d..5f26de9b 100644 --- a/nixos/code.nix +++ b/nixos/code.nix @@ -42,6 +42,7 @@ # python poetry + black # dhall haskellPackages.dhall