Files
nix-config/home/base/tui/editors/helix/steel/helix.scm
2025-11-23 16:16:02 +08:00

41 lines
1.1 KiB
Scheme

;; The helix.scm module will be loaded first before anything else,
;; the runtime will require this module, and any functions exported
;; will now be available to be used as typed commands, e.g. :git-add :open-helix-scm
(require "helix/editor.scm")
(require (prefix-in helix. "helix/commands.scm"))
(require (prefix-in helix.static. "helix/static.scm"))
(provide shell git-add open-helix-scm open-init-scm)
(define (current-path)
(let* ([focus (editor-focus)]
[focus-doc-id (editor->doc-id focus)])
(editor-document->path focus-doc-id)))
;;@doc
;; Specialized shell implementation, where % is a wildcard for the current file
(define (shell . args)
(helix.run-shell-command
(string-join
;; Replace the % with the current file
(map (lambda (x) (if (equal? x "%") (current-path) x)) args)
" ")))
;;@doc
;; Adds the current file to git
(define (git-add)
(shell "git" "add" "%"))
;;@doc
;; Open the helix.scm file
(define (open-helix-scm)
(helix.open (helix.static.get-helix-scm-path)))
;;@doc
;; Opens the init.scm file
(define (open-init-scm)
(helix.open (helix.static.get-init-scm-path)))