dev: merging main into personal branch
This commit is contained in:
commit
5a5e7690d9
4 changed files with 31 additions and 20 deletions
|
@ -25,8 +25,8 @@ be formatted and returned to the buffer using
|
||||||
** Module flags
|
** Module flags
|
||||||
- +onsave ::
|
- +onsave ::
|
||||||
Enable reformatting of a buffer when it is saved. See
|
Enable reformatting of a buffer when it is saved. See
|
||||||
[[var:+format-on-save-disabled-modes]] to control what major modes to (or not to)
|
[[var:+format-on-save-disabled-modes]] to disable format on save for certain
|
||||||
format on save.
|
major modes.
|
||||||
|
|
||||||
** Packages
|
** Packages
|
||||||
- [[doom-package:apheleia]]
|
- [[doom-package:apheleia]]
|
||||||
|
@ -60,8 +60,9 @@ When this flag is enabled, you shouldn't need to do anything other than write
|
||||||
code and save it.
|
code and save it.
|
||||||
|
|
||||||
** Without +onsave
|
** Without +onsave
|
||||||
Without the flag, formatting will only occur when either =apheleia-format-buffer=
|
Without the flag, formatting will only occur when either =+format/buffer=
|
||||||
or =+format/buffer= is called.
|
or =apheleia-format-buffer= is called. The difference between them is
|
||||||
|
=+format/buffer= will use a LSP server if configured and available.
|
||||||
|
|
||||||
* Configuration
|
* Configuration
|
||||||
|
|
||||||
|
@ -113,11 +114,11 @@ This behaviour is controlled via [[var:+format-on-save-disabled-modes]] thus;
|
||||||
|
|
||||||
In this case, =emacs-lisp-mode=, =sql-mode=, =tex-mode= and =latex-mode= will not be
|
In this case, =emacs-lisp-mode=, =sql-mode=, =tex-mode= and =latex-mode= will not be
|
||||||
formatted on save, but can still be formatted by manually invoking the commands
|
formatted on save, but can still be formatted by manually invoking the commands
|
||||||
=apheleia-format-buffer= or =+format/buffer=.
|
=+format/buffer= or =apheleia-format-buffer=.
|
||||||
|
|
||||||
** Disabling the LSP formatter
|
** Disabling the LSP formatter
|
||||||
If you are in a buffer with ~lsp-mode~ enabled and a server that supports
|
If you are in a buffer with ~lsp-mode~ enabled and a server that supports
|
||||||
=textDocument/formatting=, it will be used instead of [[doom-package:format-all]]'s formatter.
|
=textDocument/formatting=, it will be used instead of [[doom-package:apheleia]]'s formatter.
|
||||||
|
|
||||||
+ To disable this behavior universally use: ~(setq +format-with-lsp nil)~
|
+ To disable this behavior universally use: ~(setq +format-with-lsp nil)~
|
||||||
+ To disable this behavior in one mode: ~(setq-hook! 'python-mode-hook
|
+ To disable this behavior in one mode: ~(setq-hook! 'python-mode-hook
|
||||||
|
|
|
@ -5,11 +5,10 @@
|
||||||
tex-mode ; latexindent is broken
|
tex-mode ; latexindent is broken
|
||||||
latex-mode
|
latex-mode
|
||||||
org-msg-edit-mode) ; doesn't need a formatter
|
org-msg-edit-mode) ; doesn't need a formatter
|
||||||
"A list of major modes in which to reformat the buffer upon saving.
|
"A list of major modes in which to not reformat the buffer upon saving.
|
||||||
If this list begins with `not', then it negates the list.
|
If it is t, it is disabled in all modes, the same as if the +onsave flag
|
||||||
If it is `t', it is enabled in all modes.
|
wasn't used at all.
|
||||||
If nil, it is disabled in all modes, the same as if the +onsave flag wasn't
|
If nil, formatting is enabled in all modes.
|
||||||
used at all.
|
|
||||||
Irrelevant if you do not have the +onsave flag enabled for this module.")
|
Irrelevant if you do not have the +onsave flag enabled for this module.")
|
||||||
|
|
||||||
(defvar +format-preserve-indentation t
|
(defvar +format-preserve-indentation t
|
||||||
|
@ -22,7 +21,8 @@ Indentation is always preserved when formatting regions.")
|
||||||
"If non-nil, format with LSP formatter if it's available.
|
"If non-nil, format with LSP formatter if it's available.
|
||||||
|
|
||||||
This can be set buffer-locally with `setq-hook!' to disable LSP formatting in
|
This can be set buffer-locally with `setq-hook!' to disable LSP formatting in
|
||||||
select buffers.")
|
select buffers.
|
||||||
|
This has no effect on the +onsave flag, apheleia will always be used there.")
|
||||||
|
|
||||||
(defvaralias '+format-with 'apheleia-formatter
|
(defvaralias '+format-with 'apheleia-formatter
|
||||||
"Set this to explicitly use a certain formatter for the current buffer.")
|
"Set this to explicitly use a certain formatter for the current buffer.")
|
||||||
|
@ -34,19 +34,20 @@ select buffers.")
|
||||||
(when (modulep! +onsave)
|
(when (modulep! +onsave)
|
||||||
(add-hook 'doom-first-file-hook #'apheleia-global-mode))
|
(add-hook 'doom-first-file-hook #'apheleia-global-mode))
|
||||||
|
|
||||||
(defun +format-inhibit-maybe-h ()
|
(defun +format-maybe-inhibit-h ()
|
||||||
"Enable formatting on save in certain major modes.
|
"Check if formatting should be disabled for current buffer.
|
||||||
This is controlled by `+format-on-save-disabled-modes'."
|
This is controlled by `+format-on-save-disabled-modes'."
|
||||||
(or (eq major-mode 'fundamental-mode)
|
(or (eq major-mode 'fundamental-mode)
|
||||||
(string-blank-p (buffer-name))
|
(string-blank-p (buffer-name))
|
||||||
|
(eq +format-on-save-disabled-modes t)
|
||||||
(not (null (memq major-mode +format-on-save-disabled-modes)))))
|
(not (null (memq major-mode +format-on-save-disabled-modes)))))
|
||||||
|
|
||||||
|
|
||||||
(after! apheleia-core
|
(after! apheleia
|
||||||
(add-to-list 'doom-debug-variables '(apheleia-log-only-errors . nil))
|
(add-to-list 'doom-debug-variables '(apheleia-log-only-errors . nil))
|
||||||
|
|
||||||
(when (modulep! +onsave)
|
(when (modulep! +onsave)
|
||||||
(add-to-list 'apheleia-inhibit-functions #'+format-inhibit-maybe-h)))
|
(add-to-list 'apheleia-inhibit-functions #'+format-maybe-inhibit-h)))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -102,16 +102,23 @@ If no viewer is found, `latex-preview-pane-mode' is used.")
|
||||||
(add-hook! '(tex-mode-local-vars-hook
|
(add-hook! '(tex-mode-local-vars-hook
|
||||||
latex-mode-local-vars-hook)
|
latex-mode-local-vars-hook)
|
||||||
:append #'lsp!))
|
:append #'lsp!))
|
||||||
|
;; Define a function to compile the project.
|
||||||
|
(defun +latex/compile ()
|
||||||
|
(interactive)
|
||||||
|
(TeX-save-document (TeX-master-file))
|
||||||
|
(TeX-command TeX-command-default 'TeX-master-file -1))
|
||||||
(map! :localleader
|
(map! :localleader
|
||||||
:map latex-mode-map
|
:map latex-mode-map
|
||||||
:desc "View" "v" #'TeX-view
|
:desc "View" "v" #'TeX-view
|
||||||
:desc "Compile" "c" #'TeX-command-run-all
|
:desc "Compile" "c" #'+latex/compile
|
||||||
|
:desc "Run all" "a" #'TeX-command-run-all
|
||||||
:desc "Run a command" "m" #'TeX-command-master)
|
:desc "Run a command" "m" #'TeX-command-master)
|
||||||
(map! :after latex
|
(map! :after latex
|
||||||
:localleader
|
:localleader
|
||||||
:map LaTeX-mode-map
|
:map LaTeX-mode-map
|
||||||
:desc "View" "v" #'TeX-view
|
:desc "View" "v" #'TeX-view
|
||||||
:desc "Compile" "c" #'TeX-command-run-all
|
:desc "Compile" "c" #'+latex/compile
|
||||||
|
:desc "Run all" "a" #'TeX-command-run-all
|
||||||
:desc "Run a command" "m" #'TeX-command-master))
|
:desc "Run a command" "m" #'TeX-command-master))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
(set-repl-handler! 'swift-mode #'run-swift)
|
(set-repl-handler! 'swift-mode #'run-swift)
|
||||||
|
|
||||||
(when (modulep! +lsp)
|
(when (modulep! +lsp)
|
||||||
(add-hook 'swift-mode-local-vars-hook #'lsp! 'append))
|
(add-hook 'swift-mode-local-vars-hook #'lsp! 'append)
|
||||||
|
(when (modulep! :tools lsp +eglot)
|
||||||
|
(set-eglot-client! swift-mode 'swift-mode '("sourcekit-lsp"))))
|
||||||
(when (modulep! +tree-sitter)
|
(when (modulep! +tree-sitter)
|
||||||
(add-hook 'swift-mode-local-vars-hook #'tree-sitter! 'append)))
|
(add-hook 'swift-mode-local-vars-hook #'tree-sitter! 'append)))
|
||||||
|
|
||||||
|
@ -25,7 +27,7 @@
|
||||||
|
|
||||||
|
|
||||||
(use-package! lsp-sourcekit
|
(use-package! lsp-sourcekit
|
||||||
:when (modulep! +lsp)
|
:when (and (modulep! +lsp) (not (modulep! :tools lsp +eglot)))
|
||||||
:after swift-mode
|
:after swift-mode
|
||||||
:init (add-hook 'swift-mode-local-vars-hook #'lsp! 'append)
|
:init (add-hook 'swift-mode-local-vars-hook #'lsp! 'append)
|
||||||
:config
|
:config
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue