[NixOS] [Emacs] Configure black python formatting

This commit is contained in:
Ivan Malison 2023-08-07 15:57:47 -06:00
parent fb750e7368
commit 19511564e6
2 changed files with 14 additions and 26 deletions

View File

@ -2193,7 +2193,7 @@ I don't use auto-complete at all, so I have set up a hook to automatically disab
** format-all ** format-all
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package format-all (use-package format-all
:commands format-all-buffer) :commands (format-all-buffer format-all-mode))
#+end_src #+end_src
** cliphist ** cliphist
#+BEGIN_SRC emacs-lisp #+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 *** python
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defvar imalison:use-lsp-python t) (defvar imalison:use-lsp-python t)
(defvar imalison:use-black nil)
(use-package python (use-package python
:commands python-mode :commands python-mode
:mode ("\\.py\\'" . python-mode) :mode ("\\.py\\'" . python-mode)
:preface :preface
(defun imalison:python-mode () (defun imalison:python-mode ()
(setq show-trailing-whitespace t) (add-hook 'hack-local-variables-hook
;; Remove default python completion, as we are going to rely on (lambda ()
;; company-jedi or company-lsp. (when imalison:use-black
;; (remove-hook 'completion-at-point-functions (setq format-all-formatters nil)
;; 'python-completion-complete-at-point 'local) (add-to-list 'format-all-formatters '("Python" . (black)))
(if imalison:use-lsp-python (format-all-mode))
(lsp-deferred))) (when imalison:use-lsp-python
(lsp-deferred))) nil t))
:config :config
(progn (progn
(use-package lsp-mode (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 (progn
(require 'lsp-pylsp) (require 'lsp-pylsp)
(setq lsp-pylsp-plugins-pydocstyle-enabled nil))) (setq lsp-pylsp-plugins-pydocstyle-enabled nil)))
(use-package sphinx-doc) (use-package sphinx-doc)
(unbind-key "C-j" python-mode-map) (unbind-key "C-j" python-mode-map)
(add-hook 'python-mode-hook #'imalison:python-mode))) (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 #+END_SRC
*** C/C++ *** C/C++
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package cc-mode (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)))
#+END_SRC #+END_SRC
*** C-- *** C--
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp

View File

@ -42,6 +42,7 @@
# python # python
poetry poetry
black
# dhall # dhall
haskellPackages.dhall haskellPackages.dhall