Giter Club home page Giter Club logo

Comments (15)

Aloxaf avatar Aloxaf commented on August 19, 2024 1

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.

sigmaSd avatar sigmaSd commented on August 19, 2024

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.

sigmaSd avatar sigmaSd commented on August 19, 2024

#83

from irust.

Aloxaf avatar Aloxaf commented on August 19, 2024

Well, that's pretty good!

from irust.

sigmaSd avatar sigmaSd commented on August 19, 2024

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.

Aloxaf avatar Aloxaf commented on August 19, 2024

Thanks for your quick work!

I am trying to write an Emacs mode, and come across these problems:

  1. Some command name not very intuitive. For example, Eval may be a better name compared to HandleCtrlE?
  2. 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.

sigmaSd avatar sigmaSd commented on August 19, 2024

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.

sigmaSd avatar sigmaSd commented on August 19, 2024

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.

Aloxaf avatar Aloxaf commented on August 19, 2024

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.

sigmaSd avatar sigmaSd commented on August 19, 2024

For now I added pid and is_racer_suggestion_active to Globals and AcceptSuggestion to Commands 14c771c

from irust.

sigmaSd avatar sigmaSd commented on August 19, 2024

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.

Aloxaf avatar Aloxaf commented on August 19, 2024

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.

sigmaSd avatar sigmaSd commented on August 19, 2024

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.

sigmaSd avatar sigmaSd commented on August 19, 2024

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.

sigmaSd avatar sigmaSd commented on August 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.