mirror of https://github.com/helix-editor/helix
update to use safer APIs
parent
4213328ebd
commit
c7687806a4
|
@ -34,8 +34,8 @@ dependencies = [
|
|||
"abi_stable_shared",
|
||||
"as_derive_utils",
|
||||
"core_extensions",
|
||||
"proc-macro2 1.0.56",
|
||||
"quote 1.0.26",
|
||||
"proc-macro2 1.0.60",
|
||||
"quote 1.0.28",
|
||||
"rustc_version",
|
||||
"syn 1.0.109",
|
||||
"typed-arena",
|
||||
|
@ -131,8 +131,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "ff3c96645900a44cf11941c111bd08a6573b0e2f9f69bc9264b179d8fae753c4"
|
||||
dependencies = [
|
||||
"core_extensions",
|
||||
"proc-macro2 1.0.56",
|
||||
"quote 1.0.26",
|
||||
"proc-macro2 1.0.60",
|
||||
"quote 1.0.28",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
|
@ -521,10 +521,10 @@ dependencies = [
|
|||
"cc",
|
||||
"codespan-reporting",
|
||||
"once_cell",
|
||||
"proc-macro2 1.0.56",
|
||||
"quote 1.0.26",
|
||||
"proc-macro2 1.0.60",
|
||||
"quote 1.0.28",
|
||||
"scratch",
|
||||
"syn 2.0.15",
|
||||
"syn 2.0.18",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -539,9 +539,9 @@ version = "1.0.94"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.56",
|
||||
"quote 1.0.26",
|
||||
"syn 2.0.15",
|
||||
"proc-macro2 1.0.60",
|
||||
"quote 1.0.28",
|
||||
"syn 2.0.18",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -778,9 +778,9 @@ version = "0.3.28"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.56",
|
||||
"quote 1.0.26",
|
||||
"syn 2.0.15",
|
||||
"proc-macro2 1.0.60",
|
||||
"quote 1.0.28",
|
||||
"syn 2.0.18",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1964,8 +1964,8 @@ checksum = "a1d849148dbaf9661a6151d1ca82b13bb4c4c128146a88d05253b38d4e2f496c"
|
|||
dependencies = [
|
||||
"beef",
|
||||
"fnv",
|
||||
"proc-macro2 1.0.56",
|
||||
"quote 1.0.26",
|
||||
"proc-macro2 1.0.60",
|
||||
"quote 1.0.28",
|
||||
"regex-syntax 0.6.29",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
@ -2173,9 +2173,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.56"
|
||||
version = "1.0.60"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435"
|
||||
checksum = "dec2b086b7a862cf4de201096214fa870344cf922b2b30c167badb3af3195406"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
@ -2227,11 +2227,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.26"
|
||||
version = "1.0.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc"
|
||||
checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.56",
|
||||
"proc-macro2 1.0.60",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2458,9 +2458,9 @@ version = "1.0.160"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.56",
|
||||
"quote 1.0.26",
|
||||
"syn 2.0.15",
|
||||
"proc-macro2 1.0.60",
|
||||
"quote 1.0.28",
|
||||
"syn 2.0.18",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2480,9 +2480,9 @@ version = "0.1.12"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.56",
|
||||
"quote 1.0.26",
|
||||
"syn 2.0.15",
|
||||
"proc-macro2 1.0.60",
|
||||
"quote 1.0.28",
|
||||
"syn 2.0.18",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2645,6 +2645,7 @@ dependencies = [
|
|||
"serde_json",
|
||||
"slotmap",
|
||||
"smallvec",
|
||||
"steel-derive",
|
||||
"steel-gen",
|
||||
"steel-parser",
|
||||
"termimad",
|
||||
|
@ -2654,6 +2655,15 @@ dependencies = [
|
|||
"which",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "steel-derive"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.60",
|
||||
"quote 1.0.28",
|
||||
"syn 2.0.18",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "steel-gen"
|
||||
version = "0.2.0"
|
||||
|
@ -2702,19 +2712,19 @@ version = "1.0.109"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.56",
|
||||
"quote 1.0.26",
|
||||
"proc-macro2 1.0.60",
|
||||
"quote 1.0.28",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.15"
|
||||
version = "2.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822"
|
||||
checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.56",
|
||||
"quote 1.0.26",
|
||||
"proc-macro2 1.0.60",
|
||||
"quote 1.0.28",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
|
@ -2789,9 +2799,9 @@ version = "1.0.40"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.56",
|
||||
"quote 1.0.26",
|
||||
"syn 2.0.15",
|
||||
"proc-macro2 1.0.60",
|
||||
"quote 1.0.28",
|
||||
"syn 2.0.18",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2893,9 +2903,9 @@ version = "2.0.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.56",
|
||||
"quote 1.0.26",
|
||||
"syn 2.0.15",
|
||||
"proc-macro2 1.0.60",
|
||||
"quote 1.0.28",
|
||||
"syn 2.0.18",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3133,8 +3143,8 @@ dependencies = [
|
|||
"bumpalo",
|
||||
"log",
|
||||
"once_cell",
|
||||
"proc-macro2 1.0.56",
|
||||
"quote 1.0.26",
|
||||
"proc-macro2 1.0.60",
|
||||
"quote 1.0.28",
|
||||
"syn 1.0.109",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
@ -3145,7 +3155,7 @@ version = "0.2.84"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5"
|
||||
dependencies = [
|
||||
"quote 1.0.26",
|
||||
"quote 1.0.28",
|
||||
"wasm-bindgen-macro-support",
|
||||
]
|
||||
|
||||
|
@ -3155,8 +3165,8 @@ version = "0.2.84"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.56",
|
||||
"quote 1.0.26",
|
||||
"proc-macro2 1.0.60",
|
||||
"quote 1.0.28",
|
||||
"syn 1.0.109",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
|
|
|
@ -48,7 +48,7 @@ chrono = { version = "0.4", default-features = false, features = ["alloc", "std"
|
|||
etcetera = "0.7"
|
||||
textwrap = "0.16.0"
|
||||
|
||||
steel-core = { path = "../../../steel/crates/steel-core", version = "0.2.0", features = ["modules", "anyhow", "blocking_requests", "dylibs"] }
|
||||
steel-core = { path = "../../../steel/crates/steel-core", version = "0.2.0", features = ["modules", "anyhow", "blocking_requests"] }
|
||||
|
||||
|
||||
[dev-dependencies]
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
use steel::gc::unsafe_erased_pointers::CustomReference;
|
||||
|
||||
impl steel::rvals::Custom for crate::Position {}
|
||||
|
||||
struct SRopeSlice<'a>(crate::RopeSlice<'a>);
|
||||
|
||||
steel::custom_reference!(SRopeSlice<'a>);
|
||||
impl<'a> CustomReference for SRopeSlice<'a> {}
|
||||
|
||||
impl<'a> SRopeSlice<'a> {
|
||||
pub fn char_to_byte(&self, pos: usize) -> usize {
|
||||
self.0.char_to_byte(pos)
|
||||
|
|
|
@ -67,7 +67,7 @@ grep-regex = "0.1.11"
|
|||
grep-searcher = "0.1.11"
|
||||
|
||||
# plugin support
|
||||
steel-core = { path = "../../../steel/crates/steel-core", version = "0.2.0", features = ["modules", "anyhow", "blocking_requests", "dylibs"] }
|
||||
steel-core = { path = "../../../steel/crates/steel-core", version = "0.2.0", features = ["modules", "anyhow", "blocking_requests"] }
|
||||
dlopen = "0.1.8"
|
||||
dlopen_derive = "0.1.4"
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ use movement::Movement;
|
|||
|
||||
use crate::{
|
||||
args,
|
||||
commands::engine::CallbackQueue,
|
||||
compositor::{self, Component, Compositor},
|
||||
filter_picker_entry,
|
||||
job::Callback,
|
||||
|
@ -189,6 +190,29 @@ macro_rules! static_commands {
|
|||
|
||||
impl MappableCommand {
|
||||
pub fn execute(&self, cx: &mut Context) {
|
||||
log::info!("Running command");
|
||||
|
||||
// TODO: Move this out to a standalone function
|
||||
while let Some(callback) = CallbackQueue::dequeue() {
|
||||
log::info!("Found callback: {}", callback);
|
||||
|
||||
if let Err(e) = ENGINE.with(|x| {
|
||||
let mut guard = x.borrow_mut();
|
||||
|
||||
{
|
||||
let res = guard.run_with_reference::<Context, Context>(
|
||||
cx,
|
||||
"*context*",
|
||||
&format!("({} *context*)", callback),
|
||||
);
|
||||
|
||||
res
|
||||
}
|
||||
}) {
|
||||
cx.editor.set_error(format!("{}", e));
|
||||
}
|
||||
}
|
||||
|
||||
match &self {
|
||||
// TODO: @Matt - Add delegating to the engine to run scripts here
|
||||
Self::Typable { name, args, doc: _ } => {
|
||||
|
|
|
@ -165,6 +165,10 @@ pub fn run_initialization_script(cx: &mut Context) {
|
|||
pub static KEYBINDING_QUEUE: Lazy<SharedKeyBindingsEventQueue> =
|
||||
Lazy::new(|| SharedKeyBindingsEventQueue::new());
|
||||
|
||||
// pub static CALLBACK_QUEUE: Lazy<CallBackQueue> = Lazy::new(|| )
|
||||
|
||||
pub static CALLBACK_QUEUE: Lazy<CallbackQueue> = Lazy::new(|| CallbackQueue::new());
|
||||
|
||||
pub static EXPORTED_IDENTIFIERS: Lazy<ExportedIdentifiers> =
|
||||
Lazy::new(|| ExportedIdentifiers::default());
|
||||
|
||||
|
@ -207,6 +211,27 @@ impl Item for SteelVal {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct CallbackQueue {
|
||||
queue: Arc<Mutex<VecDeque<String>>>,
|
||||
}
|
||||
|
||||
impl CallbackQueue {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
queue: Arc::new(Mutex::new(VecDeque::new())),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn enqueue(value: String) {
|
||||
CALLBACK_QUEUE.queue.lock().unwrap().push_back(value);
|
||||
}
|
||||
|
||||
// Dequeue should probably be a R/W lock?
|
||||
pub fn dequeue() -> Option<String> {
|
||||
CALLBACK_QUEUE.queue.lock().unwrap().pop_front()
|
||||
}
|
||||
}
|
||||
|
||||
/// In order to send events from the engine back to the configuration, we can created a shared
|
||||
/// queue that the engine and the config push and pull from. Alternatively, we could use a channel
|
||||
/// directly, however this was easy enough to set up.
|
||||
|
@ -252,6 +277,8 @@ impl Custom for PromptEvent {}
|
|||
|
||||
impl<'a> CustomReference for Context<'a> {}
|
||||
|
||||
steel::custom_reference!(Context<'a>);
|
||||
|
||||
fn get_editor<'a>(cx: &'a mut Context<'a>) -> &'a mut Editor {
|
||||
cx.editor
|
||||
}
|
||||
|
@ -389,6 +416,8 @@ fn configure_engine() -> std::rc::Rc<std::cell::RefCell<steel::steel_vm::engine:
|
|||
// .to_string(),
|
||||
// );
|
||||
|
||||
engine.register_fn("enqueue-callback!", CallbackQueue::enqueue);
|
||||
|
||||
// Get the current OS
|
||||
engine.register_fn("current-os!", || std::env::consts::OS);
|
||||
engine.register_fn("new-component!", SteelDynamicComponent::new_dyn);
|
||||
|
@ -655,6 +684,20 @@ fn configure_engine() -> std::rc::Rc<std::cell::RefCell<steel::steel_vm::engine:
|
|||
|
||||
let mut module = BuiltInModule::new("helix/core/static".to_string());
|
||||
|
||||
for command in TYPABLE_COMMAND_LIST {
|
||||
let func = |cx: &mut Context| {
|
||||
let mut cx = compositor::Context {
|
||||
editor: cx.editor,
|
||||
scroll: None,
|
||||
jobs: cx.jobs,
|
||||
};
|
||||
|
||||
(command.fun)(&mut cx, &[], PromptEvent::Validate)
|
||||
};
|
||||
|
||||
module.register_fn(command.name, func);
|
||||
}
|
||||
|
||||
// Register everything in the static command list as well
|
||||
// These just accept the context, no arguments
|
||||
for command in MappableCommand::STATIC_COMMAND_LIST {
|
||||
|
|
|
@ -26,4 +26,4 @@ once_cell = "1.17"
|
|||
log = "~0.4"
|
||||
helix-view = { version = "0.6", path = "../helix-view", features = ["term"] }
|
||||
helix-core = { version = "0.6", path = "../helix-core" }
|
||||
steel-core = { path = "../../../steel/crates/steel-core", version = "0.2.0", features = ["modules", "anyhow", "blocking_requests", "dylibs"] }
|
||||
steel-core = { path = "../../../steel/crates/steel-core", version = "0.2.0", features = ["modules", "anyhow", "blocking_requests"] }
|
|
@ -3,3 +3,5 @@ use crate::{buffer::Buffer, widgets::Widget};
|
|||
use steel::{gc::unsafe_erased_pointers::CustomReference, rvals::Custom};
|
||||
|
||||
impl CustomReference for Buffer {}
|
||||
|
||||
steel::custom_reference!(Buffer);
|
|
@ -46,7 +46,7 @@ which = "4.4"
|
|||
parking_lot = "0.12.1"
|
||||
|
||||
# plugin support
|
||||
steel-core = { path = "../../../steel/crates/steel-core", version = "0.2.0", features = ["modules", "anyhow", "blocking_requests", "dylibs"] }
|
||||
steel-core = { path = "../../../steel/crates/steel-core", version = "0.2.0", features = ["modules", "anyhow", "blocking_requests"] }
|
||||
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
|
|
177
helix.scm
177
helix.scm
|
@ -2,70 +2,71 @@
|
|||
(require-builtin helix/core/static as helix.static.)
|
||||
(require-builtin helix/core/keybindings as helix.keybindings.)
|
||||
|
||||
(provide set-theme-dracula
|
||||
set-theme-dracula__doc__
|
||||
set-theme-custom
|
||||
set-theme-custom__doc__
|
||||
theme-then-vsplit
|
||||
theme-then-vsplit__doc__
|
||||
custom-undo
|
||||
custom-undo__doc__
|
||||
lam
|
||||
lam__doc__
|
||||
delete-word-forward
|
||||
insert-string-at-selection
|
||||
highlight-to-matching-paren
|
||||
highlight-to-matching-paren__doc__
|
||||
delete-sexpr
|
||||
delete-sexpr__doc__
|
||||
run-expr
|
||||
run-highlight
|
||||
make-minor-mode!
|
||||
git-status
|
||||
|
||||
(provide
|
||||
set-theme-dracula
|
||||
set-theme-dracula__doc__
|
||||
set-theme-custom
|
||||
set-theme-custom__doc__
|
||||
theme-then-vsplit
|
||||
theme-then-vsplit__doc__
|
||||
custom-undo
|
||||
custom-undo__doc__
|
||||
lam
|
||||
lam__doc__
|
||||
delete-word-forward
|
||||
insert-string-at-selection
|
||||
highlight-to-matching-paren
|
||||
highlight-to-matching-paren__doc__
|
||||
delete-sexpr
|
||||
delete-sexpr__doc__
|
||||
run-expr
|
||||
run-highlight
|
||||
make-minor-mode!
|
||||
git-status
|
||||
reload-helix-scm)
|
||||
|
||||
reload-helix-scm
|
||||
static-format)
|
||||
|
||||
;;@doc
|
||||
;; Sets the theme to be the dracula theme
|
||||
(define (set-theme-dracula cx)
|
||||
(helix.theme cx (list "dracula") helix.PromptEvent::Validate))
|
||||
(helix.theme cx (list "dracula") helix.PromptEvent::Validate))
|
||||
|
||||
(enqueue-callback! 'helix.static.format)
|
||||
(enqueue-callback! 'set-theme-dracula)
|
||||
|
||||
;;@doc
|
||||
;; Sets the theme to be the theme passed in
|
||||
(define (set-theme-custom cx entered-theme)
|
||||
(helix.theme cx (list entered-theme) helix.PromptEvent::Validate))
|
||||
(helix.theme cx (list entered-theme) helix.PromptEvent::Validate))
|
||||
|
||||
;;@doc
|
||||
;; Switch theme to the entered theme, then split the current file into
|
||||
;; a vsplit
|
||||
(define (theme-then-vsplit cx entered-theme)
|
||||
(set-theme-custom cx entered-theme)
|
||||
(helix.vsplit cx '() helix.PromptEvent::Validate))
|
||||
(set-theme-custom cx entered-theme)
|
||||
(helix.vsplit cx '() helix.PromptEvent::Validate))
|
||||
|
||||
;;@doc
|
||||
;; Perform an undo
|
||||
(define (custom-undo cx)
|
||||
(helix.static.undo cx))
|
||||
(helix.static.undo cx))
|
||||
|
||||
;;@doc
|
||||
;; Insert a lambda
|
||||
(define (lam cx)
|
||||
(helix.static.insert_char cx #\λ)
|
||||
(helix.static.insert_mode cx))
|
||||
(helix.static.insert_char cx #\λ)
|
||||
(helix.static.insert_mode cx))
|
||||
|
||||
;;@doc
|
||||
;; Insert the string at the selection and go back into insert mode
|
||||
(define (insert-string-at-selection cx str)
|
||||
(helix.static.insert_string cx str)
|
||||
(helix.static.insert_mode cx))
|
||||
(helix.static.insert_string cx str)
|
||||
(helix.static.insert_mode cx))
|
||||
|
||||
;;@doc
|
||||
;; Delete the word forward
|
||||
(define (delete-word-forward cx)
|
||||
(helix.static.delete_word_forward cx))
|
||||
|
||||
(helix.static.delete_word_forward cx))
|
||||
|
||||
;;@doc
|
||||
;; Registers a minor mode with the registered modifer and key map
|
||||
|
@ -76,102 +77,84 @@
|
|||
;; (hash "P" ":lam"))
|
||||
;; ```
|
||||
(define (make-minor-mode! modifier bindings)
|
||||
(~> (hash "normal" (hash modifier bindings))
|
||||
(value->jsexpr-string)
|
||||
(helix.keybindings.set-keybindings!)))
|
||||
|
||||
|
||||
(~> (hash "normal" (hash modifier bindings))
|
||||
(value->jsexpr-string)
|
||||
(helix.keybindings.set-keybindings!)))
|
||||
|
||||
(define-syntax minor-mode!
|
||||
(syntax-rules (=>)
|
||||
[(minor-mode! modifier (key => function))
|
||||
(make-minor-mode! modifier (minor-mode-cruncher (key => function)))]
|
||||
(syntax-rules (=>)
|
||||
[(minor-mode! modifier (key => function))
|
||||
(make-minor-mode! modifier (minor-mode-cruncher (key => function)))]
|
||||
|
||||
[(minor-mode! modifier (key => (function ...)))
|
||||
(make-minor-mode! modifier (minor-mode-cruncher (key => (function ...))))]
|
||||
[(minor-mode! modifier (key => (function ...)))
|
||||
(make-minor-mode! modifier (minor-mode-cruncher (key => (function ...))))]
|
||||
|
||||
[(minor-mode! modifier (key => function) remaining ...)
|
||||
(make-minor-mode! modifier (minor-mode-cruncher (key => function) remaining ...))]
|
||||
[(minor-mode! modifier (key => function) remaining ...)
|
||||
(make-minor-mode! modifier (minor-mode-cruncher (key => function) remaining ...))]
|
||||
|
||||
[(minor-mode! modifier (key => (function ...)) remaining ...)
|
||||
(make-minor-mode! modifier (minor-mode-cruncher (key => function) ... remaining ...))]
|
||||
|
||||
|
||||
|
||||
))
|
||||
[(minor-mode! modifier (key => (function ...)) remaining ...)
|
||||
(make-minor-mode! modifier (minor-mode-cruncher (key => function) ... remaining ...))]))
|
||||
|
||||
(define-syntax minor-mode-cruncher
|
||||
(syntax-rules (=>)
|
||||
(syntax-rules (=>)
|
||||
|
||||
[(minor-mode-cruncher (key => (function ...)))
|
||||
(hash key (map (lambda (x) (string-append ":" (symbol->string x))) (quote (function ...))))]
|
||||
|
||||
[(minor-mode-cruncher (key => (function ...)))
|
||||
(hash key (map (lambda (x)
|
||||
(string-append ":" (symbol->string x)))
|
||||
(quote (function ...))))]
|
||||
[(minor-mode-cruncher (key => function))
|
||||
(hash key (string-append ":" (symbol->string (quote function))))]
|
||||
|
||||
[(minor-mode-cruncher (key => function))
|
||||
(hash key (string-append ":" (symbol->string (quote function))))]
|
||||
[(minor-mode-cruncher (key => (function ...)) remaining ...)
|
||||
(hash-insert (minor-mode-cruncher remaining ...)
|
||||
key
|
||||
(map (lambda (x) (string-append ":" (symbol->string x))) (quote (function ...))))]
|
||||
|
||||
[(minor-mode-cruncher (key => (function ...)) remaining ...)
|
||||
(hash-insert
|
||||
(minor-mode-cruncher remaining ...)
|
||||
key (map (lambda (x)
|
||||
(string-append ":" (symbol->string x)))
|
||||
(quote (function ...))))]
|
||||
|
||||
[(minor-mode-cruncher (key => function) remaining ...)
|
||||
(hash-insert
|
||||
(minor-mode-cruncher remaining ...)
|
||||
key
|
||||
(string-append ":" (symbol->string (quote function))))]
|
||||
|
||||
|
||||
|
||||
))
|
||||
[(minor-mode-cruncher (key => function) remaining ...)
|
||||
(hash-insert (minor-mode-cruncher remaining ...)
|
||||
key
|
||||
(string-append ":" (symbol->string (quote function))))]))
|
||||
|
||||
;;@doc
|
||||
;; Highlight to the matching paren
|
||||
(define (highlight-to-matching-paren cx)
|
||||
(helix.static.select_mode cx)
|
||||
(helix.static.match_brackets cx))
|
||||
(helix.static.select_mode cx)
|
||||
(helix.static.match_brackets cx))
|
||||
|
||||
(define (run-expr cx)
|
||||
(define current-selection (helix.static.current_selection cx))
|
||||
(when (or (equal? "(" current-selection)
|
||||
(equal? ")" current-selection))
|
||||
(highlight-to-matching-paren cx)
|
||||
(helix.static.run-in-engine! cx (helix.static.current-highlighted-text! cx))
|
||||
(helix.static.normal_mode cx)))
|
||||
|
||||
(define current-selection (helix.static.current_selection cx))
|
||||
(when (or (equal? "(" current-selection) (equal? ")" current-selection))
|
||||
(highlight-to-matching-paren cx)
|
||||
(helix.static.run-in-engine! cx (helix.static.current-highlighted-text! cx))
|
||||
(helix.static.normal_mode cx)))
|
||||
|
||||
(define (run-highlight cx)
|
||||
(helix.static.run-in-engine! cx (helix.static.current-highlighted-text! cx)))
|
||||
(helix.static.run-in-engine! cx (helix.static.current-highlighted-text! cx)))
|
||||
|
||||
;;@doc
|
||||
;; Delete the s-expression matching this bracket
|
||||
;; If the current selection is not on a bracket, this is a no-op
|
||||
(define (delete-sexpr cx)
|
||||
(define current-selection (helix.static.current_selection cx))
|
||||
(when (or (equal? "(" current-selection)
|
||||
(equal? ")" current-selection))
|
||||
(highlight-to-matching-paren cx)
|
||||
(helix.static.delete_selection cx)))
|
||||
(define current-selection (helix.static.current_selection cx))
|
||||
(when (or (equal? "(" current-selection) (equal? ")" current-selection))
|
||||
(highlight-to-matching-paren cx)
|
||||
(helix.static.delete_selection cx)))
|
||||
|
||||
; (minor-mode! "+" ("l" => lam)
|
||||
; ("q" => (set-theme-dracula lam)))
|
||||
|
||||
(minor-mode! "P" ("l" => lam)
|
||||
("p" => highlight-to-matching-paren)
|
||||
("d" => delete-sexpr)
|
||||
("r" => run-expr))
|
||||
(minor-mode! "P"
|
||||
("l" => lam)
|
||||
("p" => highlight-to-matching-paren)
|
||||
("d" => delete-sexpr)
|
||||
("r" => run-expr))
|
||||
|
||||
(make-minor-mode! "+" (hash "l" ":lam"))
|
||||
|
||||
(define (git-status cx)
|
||||
(helix.run-shell-command cx '("git" "status") helix.PromptEvent::Validate))
|
||||
(helix.run-shell-command cx '("git" "status") helix.PromptEvent::Validate))
|
||||
|
||||
(minor-mode! "G" ("s" => git-status))
|
||||
|
||||
(define (reload-helix-scm cx)
|
||||
(helix.static.run-in-engine! cx
|
||||
(string-append "(require \"" (helix.static.get-helix.scm-path) "\")")))
|
||||
(helix.static.run-in-engine! cx
|
||||
(string-append "(require \"" (helix.static.get-helix.scm-path) "\")")))
|
||||
|
|
Loading…
Reference in New Issue