Skip to content
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
wants to merge 140 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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 May 8, 2023
798c6a5
line up stuff
mattwparas May 9, 2023
c0ea1eb
a little more behind the scenes stuff
mattwparas May 10, 2023
7dd0424
add scheme indentation
mattwparas May 15, 2023
ba1a38d
more integration
mattwparas May 30, 2023
15886de
more integration
mattwparas May 31, 2023
4213328
more reworking
mattwparas Jun 6, 2023
c768780
update to use safer APIs
mattwparas Jun 25, 2023
4aac10f
get compiling again
mattwparas Jun 25, 2023
a0153fb
checkpoint
mattwparas Jun 29, 2023
e063c58
working file tree
mattwparas Jun 30, 2023
76181da
file tree with better prompts and callbacks
mattwparas Jul 2, 2023
3414449
Merge branch 'master' into mwp-steel-integration
mattwparas Jul 3, 2023
3ee5829
buffer specific keybindings
mattwparas Jul 12, 2023
0f96fea
remove exported identifiers interface
mattwparas Jul 12, 2023
ca346b1
fix versions
mattwparas Jul 13, 2023
1fb2df4
wip
mattwparas Aug 10, 2023
6fdb717
clean up keymap api
mattwparas Aug 11, 2023
db5bf12
remove dead code
mattwparas Aug 11, 2023
d0d9f7b
more integration, not pretty but still making progress
mattwparas Aug 18, 2023
08ab867
indent stuff
mattwparas Aug 19, 2023
72aa2d9
indenting full in steel now
mattwparas Aug 20, 2023
d384501
basic instructions for usage
mattwparas Aug 20, 2023
4544bff
extra stuff
mattwparas Aug 20, 2023
20d7d6a
update instructions
mattwparas Aug 22, 2023
a73e212
fixes
mattwparas Aug 23, 2023
42c9997
merge in master
mattwparas Aug 23, 2023
fe4d6ce
fix formatting
mattwparas Aug 23, 2023
5fbc086
add back missing command
mattwparas Aug 23, 2023
79f5b25
patch info
mattwparas Aug 23, 2023
67a5266
engine shouldn't panic when helix.scm file fails to load
mattwparas Aug 24, 2023
7da809a
fix borrow mut errors
mattwparas Aug 24, 2023
ecfce4c
clean up
mattwparas Aug 24, 2023
768b483
more dead code
mattwparas Aug 24, 2023
7b6e733
remove dead code
mattwparas Aug 24, 2023
f808fa0
cut out more code
mattwparas Aug 24, 2023
8124324
nuke the dlopen stuff
mattwparas Aug 24, 2023
279f5ed
add feature flag
mattwparas Aug 25, 2023
69302c2
some extra comments
mattwparas Aug 25, 2023
18fa67d
more clean up
mattwparas Aug 25, 2023
7d63468
cleanup
mattwparas Aug 27, 2023
0eb0be5
slim down interfact even more
mattwparas Aug 27, 2023
e5e6c3b
update readme
mattwparas Aug 29, 2023
cb93a68
fix borrow mut error
mattwparas Aug 29, 2023
c680721
flake: add Security apple framework
evanrichter Sep 6, 2023
3060bcc
Merge pull request #1 from evanrichter/mwp-steel-integration
mattwparas Sep 8, 2023
15f88ad
Add hook/event system
pascalkuthe Aug 17, 2023
2d4bc31
reorganize top level to use precedence for multiple plugins
mattwparas Sep 14, 2023
500963b
clean up warnings
mattwparas Sep 14, 2023
db3e9ed
Merge remote-tracking branch 'origin' into mwp-steel-integration
mattwparas Sep 14, 2023
6a9d0b3
reverse keymap overlay
mattwparas Sep 15, 2023
4759b18
fix toolchain
mattwparas Sep 15, 2023
baa7531
add more functions for document and editor api
mattwparas Sep 19, 2023
0b107d6
deprecate old keybinding scheme
mattwparas Sep 26, 2023
76de40c
have some comments on the global search
mattwparas Sep 26, 2023
dbfa2a6
refactor completion and signature help using hooks
pascalkuthe Aug 20, 2023
c0fdbc1
start theme api
mattwparas Sep 27, 2023
575046c
merge from master
mattwparas Sep 27, 2023
30dba6a
add one more keybinding
mattwparas Oct 1, 2023
cc65e58
checkpoint before event system
mattwparas Oct 3, 2023
fbabc40
merge with event system
mattwparas Oct 3, 2023
4550faf
fix build issues
mattwparas Oct 3, 2023
0b5501d
clean up
mattwparas Oct 31, 2023
775e5e2
bump to use latest master branch of steel
mattwparas Nov 1, 2023
726f4f4
bump to use latest master branch of steel again, fixes msrv issue
mattwparas Nov 5, 2023
01996b2
No more passing around the helix context for every function call
mattwparas Jan 2, 2024
d6c3804
use in memory representation of configuration
mattwparas Jan 21, 2024
392275d
merge latest from master
mattwparas Jan 31, 2024
a414582
address more comments
mattwparas Jan 31, 2024
c902a23
unbork toml
mattwparas Jan 31, 2024
38f344c
removing the language and theme configurations in favor of a better i…
mattwparas Feb 4, 2024
eb20adb
add new xtask for code generation of core libraries
mattwparas Feb 14, 2024
cf967ed
addressing more comments
mattwparas Feb 15, 2024
fd4c689
address comments on rope library
mattwparas Feb 20, 2024
759d32e
remove repr c
mattwparas Feb 20, 2024
88be9f9
another rogue repr c
mattwparas Feb 20, 2024
d7ef482
remove global keybindings thread local
mattwparas Feb 20, 2024
a77da12
remove unnecessary import
mattwparas Feb 20, 2024
f9ad6ef
remove unnecessary keybinding functions
mattwparas Feb 20, 2024
76d665b
address more comments
mattwparas Feb 21, 2024
e552cc0
Continue to expand on component API
mattwparas Feb 22, 2024
f90f939
component api
mattwparas Mar 10, 2024
a92f147
remove some extra logging
mattwparas Mar 10, 2024
ab62d83
working terminal library
mattwparas Mar 29, 2024
fb81eab
update from master
mattwparas Mar 29, 2024
a1b13e5
add dynamic component names
mattwparas Apr 4, 2024
95ad1fe
escape paths correctly when loading the modules
mattwparas Apr 5, 2024
ce3959a
rebase from latest
mattwparas May 4, 2024
8c0391f
take latest branch of steel
mattwparas May 4, 2024
3938a6d
point to the latest steel version
mattwparas Jun 23, 2024
4a8c4fb
update instructions
mattwparas Jun 29, 2024
039526b
update instructions
mattwparas Jul 1, 2024
0d1b350
remove reload module from the instructions
mattwparas Jul 1, 2024
b478e60
one more outdated line in the instruction removed
mattwparas Jul 1, 2024
41c487d
update steel to latest
mattwparas Jul 4, 2024
14cd995
update instructions, include steel submodule
mattwparas Jul 5, 2024
b045c30
Add switch-replace command to be able to switch to an existing buffer
voidcontext Jul 6, 2024
ac4bf24
fix instructions
mattwparas Jul 6, 2024
a068243
Implement editor-switch-action instead of hardcoded replace
voidcontext Jul 6, 2024
d611f7f
Create type constructor functions for editor::Action
voidcontext Jul 6, 2024
4f1d35d
Follow naming conventions
voidcontext Jul 6, 2024
d1da0f5
Merge pull request #2 from voidcontext/switch-replace
mattwparas Jul 6, 2024
7848327
another instruction update
mattwparas Jul 6, 2024
773ae95
another instruction update
mattwparas Jul 6, 2024
25a8f03
update shell command in docs
mattwparas Jul 10, 2024
9ea77a2
merge in latest from master
mattwparas Jul 16, 2024
d348397
update submodule
mattwparas Jul 16, 2024
416fa96
update steel to latest
mattwparas Jul 18, 2024
314ebe0
update steel to latest
mattwparas Jul 18, 2024
39e5220
fix build
mattwparas Jul 20, 2024
d3b14f9
update steel to latest
mattwparas Jul 20, 2024
a632904
add enqueueing expressions function
mattwparas Jul 24, 2024
199c9c2
add partial documentation generation
mattwparas Aug 13, 2024
884e958
first pass at lsp extensions
mattwparas Aug 25, 2024
dd2d562
fix recent file picker
mattwparas Sep 3, 2024
87496a8
Optionally load init.scm and helix.scm from .helix/
MatrixManAtYrService Sep 2, 2024
5b4a047
Adding helix-cogs as a flake output
MatrixManAtYrService Sep 16, 2024
b55e3c4
fix recent file picker empty space
mattwparas Sep 19, 2024
b699f39
refactor the steel rope api
mattwparas Sep 23, 2024
4c82a21
Merge pull request #6 from MatrixManAtYrService/load-from-local
mattwparas Oct 5, 2024
7ebfd90
Merge remote-tracking branch 'upstream/master' into steel-event-system
tobiaskohlbau Oct 9, 2024
ad79e8d
Merge pull request #9 from tobiaskohlbau/steel-event-system
mattwparas Oct 15, 2024
29ce6ff
Merge pull request #7 from MatrixManAtYrService/cogs-output
mattwparas Oct 23, 2024
c1d7755
general improvements
mattwparas Oct 24, 2024
23470e6
merge latest changes
mattwparas Oct 24, 2024
e6d5787
add some comments
mattwparas Oct 24, 2024
848cb91
general updates
mattwparas Oct 24, 2024
f68eb02
event system updates
mattwparas Oct 28, 2024
38e9e87
point to git
mattwparas Oct 28, 2024
7d4f918
Merge pull request #10 from mattwparas/mwp-steel-upgrades
mattwparas Oct 28, 2024
30824f6
update STEEL.md
mattwparas Oct 30, 2024
749f3eb
add documentation after deserializing
mattwparas Oct 31, 2024
ee3035a
change string for missing documentation
mattwparas Oct 31, 2024
68d090c
update steel
mattwparas Nov 3, 2024
8ba225f
update steel
mattwparas Nov 5, 2024
0f8ab5f
add lsp configuration code gen
mattwparas Nov 6, 2024
7cbde09
instrument theme API
mattwparas Nov 13, 2024
4eb2587
make sure arbitrary keys can be added to themes after construction
mattwparas Nov 13, 2024
11338b9
bug fixes with builtin lsp generation
mattwparas Nov 13, 2024
72dc7e1
add function to extract buffer dimensions
mattwparas Nov 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,228 changes: 836 additions & 392 deletions Cargo.lock

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,17 @@ default-members = [
"helix-term"
]

[workspace.dependencies]
# If working locally, use the local path dependency
# steel-core = { path = "../../steel/crates/steel-core", version = "0.6.0", features = ["anyhow", "dylibs"] }
steel-core = { git = "https://github.com/mattwparas/steel.git", version = "0.6.0", features = ["anyhow", "dylibs"] }
tree-sitter = { version = "0.22" }
nucleo = "0.2.0"
slotmap = "1.0.7"

[profile.release]
lto = "thin"
# debug = true
debug = true

[profile.opt]
inherits = "release"
Expand All @@ -36,11 +44,6 @@ package.helix-core.opt-level = 2
package.helix-tui.opt-level = 2
package.helix-term.opt-level = 2

[workspace.dependencies]
tree-sitter = { version = "0.22" }
nucleo = "0.2.0"
slotmap = "1.0.7"

[workspace.package]
version = "24.3.0"
edition = "2021"
Expand Down
200 changes: 200 additions & 0 deletions STEEL.md
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.)
Copy link
Contributor

@shenlebantongying shenlebantongying May 7, 2024

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 to helix/core/keymaps


(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.
3 changes: 2 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@
[lld_13 cargo-flamegraph rust-analyzer]
++ (lib.optional (stdenv.isx86_64 && stdenv.isLinux) pkgs.cargo-tarpaulin)
++ (lib.optional stdenv.isLinux pkgs.lldb)
++ (lib.optional stdenv.isDarwin pkgs.darwin.apple_sdk.frameworks.CoreFoundation);
++ (lib.optional stdenv.isDarwin (with pkgs.darwin.apple_sdk.frameworks;
[CoreFoundation Security]));
shellHook = ''
export HELIX_RUNTIME="$PWD/runtime"
export RUST_BACKTRACE="1"
Expand Down
2 changes: 2 additions & 0 deletions helix-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ homepage.workspace = true
[features]
unicode-lines = ["ropey/unicode_lines"]
integration = []
steel = ["dep:steel-core"]

[dependencies]
helix-stdx = { path = "../helix-stdx" }
Expand Down Expand Up @@ -49,6 +50,7 @@ chrono = { version = "0.4", default-features = false, features = ["alloc", "std"
etcetera = "0.8"
textwrap = "0.16.1"

steel-core = { workspace = true, optional = true }
nucleo.workspace = true
parking_lot = "0.12"
globset = "0.4.14"
Expand Down
Loading
Loading