Skip to content

Commit

Permalink
Merge pull request #7 from cutonbuminband/main
Browse files Browse the repository at this point in the history
Add variable to track which langs in code blocks should be formatted
  • Loading branch information
christophermadsen authored Nov 27, 2024
2 parents 9851dea + 4f8567b commit f7f6975
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lazy-ruff.el
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@
(defvar lazy-ruff-only-check-region nil
"When non-nil (e.g. t), only lint the code in a region without formatting fixes.")

(defvar lazy-ruff-org-src-languages '("python")
"Defines which languages in code blocks are eligible for formatting and linting")

(defun lazy-ruff-run-commands (temp-file only-format only-check)
"Run the appropriate ruff commands on TEMP-FILE.
Expand Down Expand Up @@ -113,7 +115,7 @@ Ensures cursor position is maintained. Requires `ruff` in system's PATH."
(goto-char (org-element-property :end element))
(search-backward "#+END_SRC")
(line-beginning-position))))
(if (not (string= lang "python"))
(if (not (member lang lazy-ruff-org-src-languages))
(message "The source block is not Python")
(with-temp-file temp-file (insert code))
(lazy-ruff-run-commands temp-file (eq lazy-ruff-only-format-block t) (eq lazy-ruff-only-check-block t))
Expand Down

0 comments on commit f7f6975

Please sign in to comment.