-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HELIX: Add Scheme config and :alt implementation
This leverages helix-editor/helix#8675 to implement a typed command :alt which switches between C++ source and header files.
- Loading branch information
Showing
3 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
helix/*.scm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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://"))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|