-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Steel as an optional plugin system #8675
Draft
mattwparas
wants to merge
140
commits into
helix-editor:master
Choose a base branch
from
mattwparas:steel-event-system
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+6,515
−242
Draft
Changes from 89 commits
Commits
Show all changes
140 commits
Select commit
Hold shift + click to select a range
ddca44e
work in progress adding of steel
mattwparas 798c6a5
line up stuff
mattwparas c0ea1eb
a little more behind the scenes stuff
mattwparas 7dd0424
add scheme indentation
mattwparas ba1a38d
more integration
mattwparas 15886de
more integration
mattwparas 4213328
more reworking
mattwparas c768780
update to use safer APIs
mattwparas 4aac10f
get compiling again
mattwparas a0153fb
checkpoint
mattwparas e063c58
working file tree
mattwparas 76181da
file tree with better prompts and callbacks
mattwparas 3414449
Merge branch 'master' into mwp-steel-integration
mattwparas 3ee5829
buffer specific keybindings
mattwparas 0f96fea
remove exported identifiers interface
mattwparas ca346b1
fix versions
mattwparas 1fb2df4
wip
mattwparas 6fdb717
clean up keymap api
mattwparas db5bf12
remove dead code
mattwparas d0d9f7b
more integration, not pretty but still making progress
mattwparas 08ab867
indent stuff
mattwparas 72aa2d9
indenting full in steel now
mattwparas d384501
basic instructions for usage
mattwparas 4544bff
extra stuff
mattwparas 20d7d6a
update instructions
mattwparas a73e212
fixes
mattwparas 42c9997
merge in master
mattwparas fe4d6ce
fix formatting
mattwparas 5fbc086
add back missing command
mattwparas 79f5b25
patch info
mattwparas 67a5266
engine shouldn't panic when helix.scm file fails to load
mattwparas 7da809a
fix borrow mut errors
mattwparas ecfce4c
clean up
mattwparas 768b483
more dead code
mattwparas 7b6e733
remove dead code
mattwparas f808fa0
cut out more code
mattwparas 8124324
nuke the dlopen stuff
mattwparas 279f5ed
add feature flag
mattwparas 69302c2
some extra comments
mattwparas 18fa67d
more clean up
mattwparas 7d63468
cleanup
mattwparas 0eb0be5
slim down interfact even more
mattwparas e5e6c3b
update readme
mattwparas cb93a68
fix borrow mut error
mattwparas c680721
flake: add Security apple framework
evanrichter 3060bcc
Merge pull request #1 from evanrichter/mwp-steel-integration
mattwparas 15f88ad
Add hook/event system
pascalkuthe 2d4bc31
reorganize top level to use precedence for multiple plugins
mattwparas 500963b
clean up warnings
mattwparas db3e9ed
Merge remote-tracking branch 'origin' into mwp-steel-integration
mattwparas 6a9d0b3
reverse keymap overlay
mattwparas 4759b18
fix toolchain
mattwparas baa7531
add more functions for document and editor api
mattwparas 0b107d6
deprecate old keybinding scheme
mattwparas 76de40c
have some comments on the global search
mattwparas dbfa2a6
refactor completion and signature help using hooks
pascalkuthe c0fdbc1
start theme api
mattwparas 575046c
merge from master
mattwparas 30dba6a
add one more keybinding
mattwparas cc65e58
checkpoint before event system
mattwparas fbabc40
merge with event system
mattwparas 4550faf
fix build issues
mattwparas 0b5501d
clean up
mattwparas 775e5e2
bump to use latest master branch of steel
mattwparas 726f4f4
bump to use latest master branch of steel again, fixes msrv issue
mattwparas 01996b2
No more passing around the helix context for every function call
mattwparas d6c3804
use in memory representation of configuration
mattwparas 392275d
merge latest from master
mattwparas a414582
address more comments
mattwparas c902a23
unbork toml
mattwparas 38f344c
removing the language and theme configurations in favor of a better i…
mattwparas eb20adb
add new xtask for code generation of core libraries
mattwparas cf967ed
addressing more comments
mattwparas fd4c689
address comments on rope library
mattwparas 759d32e
remove repr c
mattwparas 88be9f9
another rogue repr c
mattwparas d7ef482
remove global keybindings thread local
mattwparas a77da12
remove unnecessary import
mattwparas f9ad6ef
remove unnecessary keybinding functions
mattwparas 76d665b
address more comments
mattwparas e552cc0
Continue to expand on component API
mattwparas f90f939
component api
mattwparas a92f147
remove some extra logging
mattwparas ab62d83
working terminal library
mattwparas fb81eab
update from master
mattwparas a1b13e5
add dynamic component names
mattwparas 95ad1fe
escape paths correctly when loading the modules
mattwparas ce3959a
rebase from latest
mattwparas 8c0391f
take latest branch of steel
mattwparas 3938a6d
point to the latest steel version
mattwparas 4a8c4fb
update instructions
mattwparas 039526b
update instructions
mattwparas 0d1b350
remove reload module from the instructions
mattwparas b478e60
one more outdated line in the instruction removed
mattwparas 41c487d
update steel to latest
mattwparas 14cd995
update instructions, include steel submodule
mattwparas b045c30
Add switch-replace command to be able to switch to an existing buffer
voidcontext ac4bf24
fix instructions
mattwparas a068243
Implement editor-switch-action instead of hardcoded replace
voidcontext d611f7f
Create type constructor functions for editor::Action
voidcontext 4f1d35d
Follow naming conventions
voidcontext d1da0f5
Merge pull request #2 from voidcontext/switch-replace
mattwparas 7848327
another instruction update
mattwparas 773ae95
another instruction update
mattwparas 25a8f03
update shell command in docs
mattwparas 9ea77a2
merge in latest from master
mattwparas d348397
update submodule
mattwparas 416fa96
update steel to latest
mattwparas 314ebe0
update steel to latest
mattwparas 39e5220
fix build
mattwparas d3b14f9
update steel to latest
mattwparas a632904
add enqueueing expressions function
mattwparas 199c9c2
add partial documentation generation
mattwparas 884e958
first pass at lsp extensions
mattwparas dd2d562
fix recent file picker
mattwparas 87496a8
Optionally load init.scm and helix.scm from .helix/
MatrixManAtYrService 5b4a047
Adding helix-cogs as a flake output
MatrixManAtYrService b55e3c4
fix recent file picker empty space
mattwparas b699f39
refactor the steel rope api
mattwparas 4c82a21
Merge pull request #6 from MatrixManAtYrService/load-from-local
mattwparas 7ebfd90
Merge remote-tracking branch 'upstream/master' into steel-event-system
tobiaskohlbau ad79e8d
Merge pull request #9 from tobiaskohlbau/steel-event-system
mattwparas 29ce6ff
Merge pull request #7 from MatrixManAtYrService/cogs-output
mattwparas c1d7755
general improvements
mattwparas 23470e6
merge latest changes
mattwparas e6d5787
add some comments
mattwparas 848cb91
general updates
mattwparas f68eb02
event system updates
mattwparas 38e9e87
point to git
mattwparas 7d4f918
Merge pull request #10 from mattwparas/mwp-steel-upgrades
mattwparas 30824f6
update STEEL.md
mattwparas 749f3eb
add documentation after deserializing
mattwparas ee3035a
change string for missing documentation
mattwparas 68d090c
update steel
mattwparas 8ba225f
update steel
mattwparas 0f8ab5f
add lsp configuration code gen
mattwparas 7cbde09
instrument theme API
mattwparas 4eb2587
make sure arbitrary keys can be added to themes after construction
mattwparas 11338b9
bug fixes with builtin lsp generation
mattwparas 72dc7e1
add function to extract buffer dimensions
mattwparas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,200 @@ | ||
# Building | ||
|
||
You will need a handful of things: | ||
|
||
* A clone of this fork, on the branch `mwp-steel-integration` | ||
* A clone of the steel git repo -> https://github.com/mattwparas/steel, on the branch `master` (default) | ||
|
||
I also cannot promise that this will work on windows. I develop off of ubuntu and mac, so for now you can probably safely assume it will work on unix. | ||
|
||
The `Cargo.toml` for helix points to a local development version of steel. Set this up so that it points to wherever you've cloned steel: | ||
|
||
``` | ||
[workspace.dependencies] | ||
# CHANGE 'path = ...' to point to the path to steel-core | ||
steel-core = { path = "../../steel/crates/steel-core", version = "0.5.0", features = ["modules", "anyhow", "dylibs", "colors"] } | ||
``` | ||
|
||
Since I'm actively developing steel alongside the helix integration in order to make things as smooth as possible, its not referencing a published version yet. | ||
|
||
## Installing Steel | ||
|
||
Follow the instructions here https://github.com/mattwparas/steel and https://github.com/mattwparas/steel/issues/71 | ||
|
||
Setting a `STEEL_HOME` env var, then running `cargo run -- cogs/install.scm` in the root of that repo will set up the steel core libraries so that helix can reference them. | ||
|
||
## Installing helix | ||
|
||
Once you're set up with steel, just run | ||
|
||
`cargo install --path helix-term --locked` | ||
|
||
To install the `hx` executable, with steel as the plugin language. | ||
|
||
|
||
## Setting up configurations for helix | ||
|
||
Note, this API is entirely subjet to change, and I promise absolutely 0 backwards compatibility while this is in development. | ||
|
||
There are 2 important files you'll want: | ||
|
||
* `~/.config/helix/helix.scm` | ||
* `~/.config/helix/init.scm` | ||
|
||
Note - these both live inside the same directory that helix sets up for runtime configurations. | ||
|
||
|
||
### `helix.scm` | ||
|
||
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. For example: | ||
|
||
|
||
```scheme | ||
# helix.scm | ||
|
||
(require-builtin helix/core/typable as helix.) | ||
(require-builtin helix/core/static as helix.static.) | ||
(require-builtin helix/core/keybindings as helix.keybindings.) | ||
|
||
(provide shell git-add open-helix-scm open-init-scm reload-helix-scm) | ||
|
||
;;@doc | ||
;; Specialized shell implementation, where % is a wildcard for the current file | ||
(define (shell cx . args) | ||
;; Replace the % with the current file | ||
(define expanded (map (lambda (x) (if (equal? x "%") (current-path cx) x)) args)) | ||
(helix.run-shell-command cx expanded helix.PromptEvent::Validate)) | ||
|
||
;;@doc | ||
;; Adds the current file to git | ||
(define (git-add cx) | ||
(shell cx "git" "add" "%")) | ||
|
||
|
||
;; Functions to assist with the above | ||
|
||
(define (editor-get-doc-if-exists editor doc-id) | ||
(if (editor-doc-exists? editor doc-id) (editor->get-document editor doc-id) #f)) | ||
|
||
(define (current-path cx) | ||
(let* ([editor (cx-editor! cx)] | ||
[focus (editor-focus editor)] | ||
[focus-doc-id (editor->doc-id editor focus)] | ||
[document (editor-get-doc-if-exists editor focus-doc-id)]) | ||
|
||
(if document (Document-path document) #f))) | ||
|
||
|
||
;;@doc | ||
;; Reload the helix.scm file | ||
(define (reload-helix-scm cx) | ||
(helix.static.run-in-engine! cx | ||
(string-append "(require \"" (helix.static.get-helix-scm-path) "\")"))) | ||
|
||
;;@doc | ||
;; Open the helix.scm file | ||
(define (open-helix-scm cx) | ||
(helix.open cx (list (helix.static.get-helix-scm-path)) helix.PromptEvent::Validate)) | ||
|
||
;;@doc | ||
;; Opens the init.scm file | ||
(define (open-init-scm cx) | ||
(helix.open cx (list (helix.static.get-init-scm-path)) helix.PromptEvent::Validate)) | ||
|
||
|
||
|
||
|
||
``` | ||
|
||
Now, if you'd like to add the current file you're editing to git, simply type `:git-add` - you'll see the doc pop up with it since we've annotated the function | ||
with the `@doc` symbol. Hitting enter will execute the command. | ||
|
||
You can also conveniently open the `helix.scm` file by using the typed command `:open-helix-scm`. | ||
|
||
|
||
### `init.scm` | ||
|
||
The `init.scm` file is run at the top level, immediately after the `helix.scm` module is `require`d. The helix context is available here, so you can interact with the editor. | ||
|
||
The helix context is bound to the top level variable `*helix.cx*`. | ||
|
||
For example, if we wanted to select a random theme at startup: | ||
|
||
```scheme | ||
# init.scm | ||
|
||
(require-builtin steel/random as rand::) | ||
(require-builtin helix/core/static as helix.static.) | ||
(require-builtin helix/core/typable as helix.) | ||
|
||
|
||
(define rng (rand::thread-rng!)) | ||
|
||
|
||
;; Picking one from the possible themes | ||
(define possible-themes '("ayu_mirage" "tokyonight_storm" "catppuccin_macchiato")) | ||
|
||
(define (select-random lst) | ||
(let ([index (rand::rng->gen-range rng 0 (length lst))]) (list-ref lst index))) | ||
|
||
(define (randomly-pick-theme options) | ||
;; Randomly select the theme from the possible themes list | ||
(helix.theme *helix.cx* (list (select-random options)) helix.PromptEvent::Validate)) | ||
|
||
(randomly-pick-theme possible-themes) | ||
|
||
``` | ||
|
||
### Libraries for helix | ||
|
||
There are a handful of extra libraries in development for extending helix, and can be found here https://github.com/mattwparas/helix-config. | ||
|
||
If you'd like to use them, create a directory called `cogs` in your `.config/helix` directory, and copy the files in there. In particular, `keymaps.scm` and `options.scm` are working well. | ||
|
||
### options.scm | ||
|
||
If you'd like to override configurations from your toml config: | ||
|
||
|
||
```scheme | ||
# init.scm | ||
|
||
(require (only-in "cogs/options.scm" apply-options)) | ||
|
||
(define *config-map* '((file-picker.hidden false) (cursorline true) (soft-wrap.enable true))) | ||
(apply-options *helix.cx* *config-map*) | ||
|
||
``` | ||
|
||
|
||
### keymaps.scm | ||
|
||
Applying custom keybindings for certain file extensions: | ||
|
||
|
||
```scheme | ||
# init.scm | ||
|
||
(require "cogs/keymaps.scm") | ||
|
||
|
||
(define scm-keybindings | ||
(hash | ||
"insert" | ||
(hash "ret" ':scheme-indent))) | ||
|
||
|
||
;; Grab whatever the existing keybinding map is | ||
(define standard-keybindings (helix-current-keymap)) | ||
|
||
;; Overlay the scm keybindings on top of the standard keybindings. This does a little mutation here, so its a bit funky looking. | ||
(merge-keybindings standard-keybindings scm-keybindings) | ||
|
||
;; For .scm files, use this keybinding set insteead | ||
(set-global-buffer-or-extension-keymap (hash "scm" standard-keybindings)) | ||
|
||
``` | ||
|
||
In insert mode, this overrides the `ret` keybinding to instead use a custom scheme indent function. Functions _must_ be available as typed commands, and are referred to | ||
as symbols. So in this case, the `scheme-indent` function was exported by my `helix.scm` module. |
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
helix/core/keybindings
seems renamed tohelix/core/keymaps