Comments (15)
I added a Pr for your emacs script Aloxaf#1
Thanks!
I think I want to see if I can rework the script system so everything is guaranteed by the type system, since currently bug like this are easy to make and their manifestation are actually random.
That would be nice.
from irust.
Hello,
Thanks for checking this project out!
Yes, Adding custom keybindings support is a good idea, I imagine it will be supported via scripting, but for that to happens, a couple of changes are needed:
1- The handling of events here https://github.com/sigmaSd/IRust/blob/master/crates/irust/src/irust/events.rs should return a command instead of executing the code directly, (inspired by nushell)
enum Command
HandleChar,
HandlerEnter,
HandlerCtrll
This will make it possible for a script to invoke them.
2- https://github.com/sigmaSd/IRust/blob/master/crates/irust/src/irust.rs#L128 here we can add something like,
if let Some(Command) = self.scriptmg.on_input_hook(ev) {
self.engine.execute(command);
return
}
Now script support can be added, this one might need to run as a daemon for performance since its called each keystroke, that sacrifices "hot reloading" but we'll see how this goes.
from irust.
from irust.
Well, that's pretty good!
from irust.
IRust version 1.9.0 now supports input event hook, feel free to check out the vim mode example https://github.com/sigmaSd/IRust/blob/master/scripts_examples/script2/input_event/src/main.rs
from irust.
Thanks for your quick work!
I am trying to write an Emacs mode, and come across these problems:
- Some command name not very intuitive. For example,
Eval
may be a better name compared toHandleCtrlE
? GlobalVariables
is lack of something like current suggestion state (to use enter both for accept suggestions and accept-line) and current session id (to avoid state conflict between different irust session).
from irust.
1- The names are just placeholder for now, they definitly need to change and be commented now they are part of the public api
2- I can add is_sugesstion_active to GlobalVariables and a AcceptSugesstion command to the api
For the session_id, currently all irust instances share the same underlying repl, for this to work some changes are needed before to irust_repl crate, do you think this is a good feature? Im not sure if there is an important benefit to making sessions unique
Btw thanks for making the emacs extention, this showcases the api shortcommings, feel free to open a pr with it!
from irust.
Also I want to add that Im still experimenting with scripting, my next idea is ( for scriptv3)
- Remove the binary names constraint
- At startup make IRust search script directory for any executable and run it, it should respond with what hooks its interested in and what is its execution type (oneshot/daemon)
- save its path and desired hooks in a map if its a oneshot / Run it if its a daemon and save the child process and desired hooks in another map
- Now each time a hook is triggered , look for a script that asked for it and activate it
from irust.
For the session_id, currently all irust instances share the same underlying repl, for this to work some changes are needed before to irust_repl crate, do you think this is a good feature? Im not sure if there is an important benefit to making sessions unique
I just mean to have an id (PID is enough) so that I can create a file like /tmp/input_event_ID/mode
. Without this, if an instance enter normal mode, other instances will also enter normal mode.
Or let the script can run in daemon mode will also be OK.
The scriptv3 seems will solve this problem and improve performance, that's great!
from irust.
For now I added pid
and is_racer_suggestion_active
to Globals and AcceptSuggestion
to Commands 14c771c
from irust.
I added script v3 and a bunch of new commands, here is the new vim script https://github.com/sigmaSd/IRust/blob/master/scripts_examples/script3/irust_vim/src/main.rs
from irust.
Nice!
I am implementing an Emacs keybinding based on script3 now: https://github.com/Aloxaf/IRust/blob/irust_emacs/scripts_examples/script3/irust_emacs/src/main.rs
from irust.
Nice, Your emacs script is way more organized!
If you find that some important features/commands are missing, feel free to list them here so I can adress it when I can
from irust.
I added a Pr for your emacs script Aloxaf#1
I think I want to see if I can rework the script system so everything is guaranteed by the type system, since currently bug like this are easy to make and their manifestation are actually random.
from irust.
I added a section about keybindings here https://sigmasd.github.io/irust_book/custom-keybindings/
I tried adding more compile time guarantees but it was not straightforward, and made the scripting system weaker.
I think I'll just keep it like this for now and improve it Iteratively.
I'll close this issue for now since keybindings are possible, feel free to reopen it if something is missing or open a different issue.
from irust.
Related Issues (20)
- Add :cargo command
- Add predefined themes
- Rework how irust server works
- Use `rustyline` or `reedline` for input? HOT 1
- Move theme settings from config.toml to themes config
- Improve Jupyter kernel support HOT 7
- typing twice in windows with crossterm-0.26+ HOT 2
- Can irust repl evaluate code with release mode instead of debug mode? HOT 3
- Cannot use two `irust_repl`s at the same time. HOT 27
- Rust analyzer is not working on Windows HOT 6
- Interactive usage HOT 3
- Check statements with cargo check HOT 1
- how make irust works with nightly ? error: toolchain 'stable-x86_64-unknown-linux-gnu' is not installed HOT 2
- Using IRust for live scripting of a host HOT 8
- [Feature Request]: Support for `proc_macro` APIs HOT 7
- [Feature Request]: Ability to load custom `Cargo.toml` HOT 2
- Async repl not working properly HOT 5
- irust v1.50.0 failed to compile HOT 2
- Use `rust-analyser` instead of `racer` for autocompletion HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from irust.