Skip to content

Commit

Permalink
HELIX: Add Scheme config and :alt implementation
Browse files Browse the repository at this point in the history
This leverages helix-editor/helix#8675 to
implement a typed command :alt which switches between C++ source and
header files.
  • Loading branch information
3541 committed Aug 26, 2024
1 parent bcc707d commit d10c8c4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions home/helix/dot-config/helix/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
helix/*.scm
34 changes: 34 additions & 0 deletions home/helix/dot-config/helix/helix.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
(require "helix/editor.scm")
(require "helix/misc.scm")
(require (prefix-in helix. "helix/commands.scm"))
(require (prefix-in helix.static. "helix/static.scm"))

(provide open-helix-scm open-init-scm alt)

;;@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)))

(define (editor-get-doc-if-exists doc-id)
(if (editor-doc-exists? doc-id) (editor->get-document doc-id) #f))

(define (current-path)
(let* ([focus (editor-focus)]
[focus-doc-id (editor->doc-id focus)]
[document (editor-get-doc-if-exists focus-doc-id)])

(if document (Document-path document) #f)))

;;@doc
;; Toggles between C/C++ source and header files
(define (alt)
(send-lsp-command "clangd" "textDocument/switchSourceHeader"
(hash "uri" (string-append "file://" (current-path)))
(lambda (result)
(helix.open (trim-start-matches result "file://")))))
1 change: 1 addition & 0 deletions home/helix/dot-config/helix/init.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

0 comments on commit d10c8c4

Please sign in to comment.