Compare commits

...

3 Commits

1 changed files with 30 additions and 17 deletions

View File

@ -606,6 +606,12 @@
(when (executable-find "rust-analyzer")
(setq lsp-rust-server 'rust-analyzer))
(lsp-register-custom-settings
'(("pylsp.plugins.pyls_mypy.enabled" t t)
("pylsp.plugins.pyls_mypy.live_mode" nil t)
("pylsp.plugins.ruff.enabled" t t)))
(defun lsp-compile-in-root ()
"Do compilation in the root dir of a project"
(interactive)
@ -634,8 +640,6 @@
(apply orig-fun args)))
(advice-add 'lsp-ui-doc--display :around #'adjust-lsp-ui-doc-frame-pos))
(use-package lsp-python-ms :demand :if (package-installed-p 'lsp-python-ms))
(use-package lsp-java :demand :if (package-installed-p 'lsp-java)
:config
(setq lsp-java-save-action-organize-imports nil)))
@ -1001,15 +1005,6 @@
(which-key-posframe-mode)
(set-face-background 'which-key-posframe "#333333")))
(use-package prettier-js
:hook ((js2-mode typescript-mode web-mode json-mode) . prettier-js-mode-maybe)
:commands prettier-js
:init
(defun prettier-js-mode-maybe ()
(interactive)
(when (= 0 (call-process "prettier" nil nil nil "--find-config-path" (buffer-file-name)))
(prettier-js-mode t))))
(use-package show-marks
:config
:bind ("C-S-<left>" . backward-mark)
@ -1039,12 +1034,6 @@
:bind (:map typescript-mode-map
("<M-return>" . c-indent-new-comment-line)))
(use-package blacken
:hook (python-mode . blacken-mode)
:delight
:config
(setq blacken-only-if-project-is-blackened t))
(use-package rustic
:config
(setq rustic-format-on-save t
@ -1069,6 +1058,30 @@
(define-fringe-bitmap 'git-gutter-fr:modified [224] nil nil '(center repeated))
(define-fringe-bitmap 'git-gutter-fr:deleted [224] nil nil '(center repeated))))
(use-package apheleia :demand :if (package-installed-p 'apheleia)
:config
(setf (alist-get 'djlint apheleia-formatters) '("djlint" "--reformat" "-"))
(setf (alist-get "\\.dj\\.html$" apheleia-mode-alist) '(djlint))
(defun apheleia--pyproject-contains-section (section)
(when-let (parent (locate-dominating-file default-directory "pyproject.toml"))
(with-temp-buffer
(insert-file-contents (concat parent "pyproject.toml"))
(re-search-forward (concat "^\\[" section "\\]$") nil t 1))))
(defun apheleia--check-formatter-configured ()
"Disable apheleia when a formatter's configuration does not exist"
(not (let ((formatters (apheleia--get-formatters)))
(cond
((member 'black formatters) (apheleia--pyproject-contains-section "tool.black"))
((member 'djlint formatters) (apheleia--pyproject-contains-section "tool.djlint"))
((member 'prettier formatters)
(= 0 (call-process "prettier" nil nil nil "--find-config-path" (buffer-file-name))))))))
(add-to-list 'apheleia-inhibit-functions 'apheleia--check-formatter-configured)
(apheleia-global-mode t))
;;; Local Variables
(add-to-list 'safe-local-eval-forms '(outline-hide-body))
;; Local Variables: