mirror of
https://github.com/Swarsel/.dotfiles.git
synced 2025-12-06 09:07:21 +01:00
feat: enable nix formatting for org code blocks
This commit is contained in:
parent
a8baed9ba0
commit
e66e4978ff
1 changed files with 41 additions and 0 deletions
|
|
@ -7682,6 +7682,38 @@ This function searches for common delimiters in region and removes them, summari
|
||||||
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
**** Nix formatters
|
||||||
|
|
||||||
|
This formats the org code block at =point= in accordance to the =nixpkgs-fmt= formatter
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
|
||||||
|
(defun swarsel/org-nixpkgs-fmt-block-lite ()
|
||||||
|
(interactive)
|
||||||
|
(org-babel-mark-block)
|
||||||
|
(call-interactively 'nixpkgs-fmt-region))
|
||||||
|
|
||||||
|
|
||||||
|
(defun swarsel/org-nixpkgs-fmt-block ()
|
||||||
|
(interactive)
|
||||||
|
(save-excursion
|
||||||
|
(let* ((element (org-element-at-point))
|
||||||
|
(begin (org-element-property :begin element))
|
||||||
|
(end (org-element-property :end element))
|
||||||
|
(lang (org-element-property :language element)))
|
||||||
|
(when lang
|
||||||
|
(goto-char begin)
|
||||||
|
(forward-line)
|
||||||
|
(insert "{")
|
||||||
|
(goto-char end)
|
||||||
|
(forward-line -1)
|
||||||
|
(beginning-of-line)
|
||||||
|
(forward-char -1)
|
||||||
|
(insert "}")
|
||||||
|
(org-babel-mark-block)
|
||||||
|
(call-interactively 'nixpkgs-fmt-region)))))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
*** Custom Keybindings
|
*** Custom Keybindings
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:CUSTOM_ID: h:2b827c27-0de7-45ed-9d9e-6c511e2c6bb5
|
:CUSTOM_ID: h:2b827c27-0de7-45ed-9d9e-6c511e2c6bb5
|
||||||
|
|
@ -9086,6 +9118,15 @@ This adds a rudimentary nix-mode to Emacs. I have not really tried this out, as
|
||||||
(use-package nix-mode
|
(use-package nix-mode
|
||||||
:mode "\\.nix\\'")
|
:mode "\\.nix\\'")
|
||||||
|
|
||||||
|
#+end_src
|
||||||
|
*** nixpkgs-fmt
|
||||||
|
|
||||||
|
Adds functions for formatting nix code.
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
|
||||||
|
(use-package nixpkgs-fmt)
|
||||||
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
*** Markdown Mode
|
*** Markdown Mode
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue