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

Development -> Master (0.10.0-dev) #27

Merged
merged 20 commits into from
Jun 1, 2024
Merged

Development -> Master (0.10.0-dev) #27

merged 20 commits into from
Jun 1, 2024

Conversation

vinnymeller
Copy link
Owner

@vinnymeller vinnymeller commented May 31, 2024

Improvements & Features

Performance

twm is multithreaded now, using jwalk instead of WalkDir and using Rayon directly to process workspace matches.

Didn't do any super scientific benchmarks but I've seen anywhere from a 0%-300% improvement depending on configuration and hardware, but more commonly 100%-200%.

In the most extreme cases with search depths of 10+, it can be 10x more performant than before.

Streaming workspaces to the picker asynchronously

The old implementation searched for all workspaces synchronously and then send them to a Skim picker. If you were on slow hardware, had a lot of workspaces, a complicated workspace-search configuration, or just a high max_search_depth, there could be a noticeable delay. Especially if you met multiple of those criteria.

In the new version, we ditched the dependency on Skim and used Helix's Nucleo picker with Ratatui/Crossterm to implement the TUI picker.

The new implementation spawns a second thread for finding workspaces and streams them into the picker, so the picker opens ~instantly always now, no matter your config/hardware. You can type, move around, and make your selection while the background thread is still streaming results in. This has been great for me so far where I have muscle memory and I know that to get to a certain workspace I need to just type .n or z, etc. I can now open those up as fast as I can type the letters

Note: one annoying thing that I haven't found a way to work around yet is that the matching algorithm is different & seemingly less configurable out-of-the-box than Skim's was. This results in a having to relearn muscle memory for some of my workspaces. I will spend more time looking into this to see if I can make it more consistent. I hope it isn't too big of a problem.

Opening a new session in a group without -g

Instead of just pressing Enter on your selection in the main workspace picker, you can use Shift/Ctrl/Alt + Enter to attempt to open the path as a new session in an existing group. If no existing session for that path is found, it is opened normally. If one is found, it opens in a group (same as it would with twm -g).

Open to taking other suggestions for what key(s) should invoke this behavior. It seems that none of these are super consistently supported by Crossterm across platforms&terminals. Alt+Enter seems consistent on Linux. I haven't had a chance to try other OS yet

CLI

--make-default-config
writes a default configuration file and accompanying schema, by default to $XDG_CONFIG_HOME/twm/{twm.yaml,twm.schema.json}. if you pass -p/--path <PATH> with this, it will write to the directory given.

We first check that neither of the files we intend to write, and won't overwrite existing files, asking the user to move/rename existing files and try again.

I originally never wanted to bother adding something like this, but since I discovered the schemars crate to automatically export the configuration file's schema, it feels like there is value here now, since calling this flag will set up a configuration file with up-to-date schema validation for free.

--make-default-layout-config
writes a default config file for a .twm.yaml layout file

This one does not include a .twm.schema.json file, because the whole schema is contained in the default template. If desired, you can use twm --print-layout-config-schema > schema.json

--print-config-schema
prints the JSON-formatted configuration schema to stdout

Useful for same as above. If you update twm every so often you could twm --print-config-schema > ~/.config/twm/twm.schema.json to get updated editor completion/validation when editing your config

--print-layout-config-schema
prints the JSON-formatted layout configuration to stdout

I don't imagine I'd need this that often but just because I don't write custom layouts in .twm.yaml files that often I sometimes forget the exact format.

--print-bash-completion, --print-zsh-completion, --print-fish-completion
prints the respective completion code to stdout

can be used to setup completions manually or by packagers (as is done in this flake) to install the completion files with twm. Adds completion! Pretty self explanatory. Seeing the little completion popups in my terminal for twm just makes me happy

--print-man
prints man(1) page content to stdout

same as above, can install the man page manually or have it be installed with the package. this repo's flake does these for you so if you install twm via nix+this flake there is nothing to set up

Flake

Updates the Nix dependencies & packages the man pages & shell completions with the binary

vinnymeller and others added 14 commits May 28, 2024 00:11
- Use Nucleo/Ratatui for better customization
- Immediately open picker and stream workspace matches into the picker
  - This feels snappier + allows you to make a selection before the list
    is done loading
- Allow to open a workspace in a group from the main workspace finder
  - Currently we have implemented a `tmm -g` flag that opens a finder
    showing existing sessions which, when selected, opens a new session
    in a group with the selected session.
  - Something this change adds experimental support for is clicking
    `Ctrl/Shift/Alt` + Enter from the main workspace finder to *attempt*
    to open the selected workspace as a new group  session. twm will
    search for a twm-generated session with `TWM_ROOT` set to the path
    of the selected workspace and if found, open your new  session in a
    group with it. Otherwise, it behaves normally.
  - This hasn't really been tested much yet, and it seems(?) crossterm
    doesn't support `Ctrl/Shift` + `Enter` on Linux (or is it just some
    terminals?), but `Alt` + `Enter` is working for me. I've left all 3
    options in currently to try testing on more systems/terminals.
)

* Add CLI flags to print configuration schemas

- Adds a `--schema` and `--layout-schema` flag that print the
  configuration file specifications for the `twm.yaml` configuration and
  `.twm.yaml` layout files respectively

* add option to write a default config file with the schema defined

* Add config file path override

Adds the option to override the search path(s) for the `twm.yaml` config
file by setting the environment variable `TWM_CONFIG_FILE`. This should
simply be the path to the desired configuration.
* Add flags to print shell completions

* Add flag to print man page

* Update some cli args & make the flake install comppletions & man page
vinnymeller and others added 4 commits May 30, 2024 23:03
- Replaces WalkDir with jwalk
- Uses rayon for multithreading when checking if directories match our
  workspace definitions

My current setup on current development branch `twm` takes about ~0.15
seconds to load all workspace matches into the picker.
With this change it is nearly instant & I can't even see the number
climb

The difference this makes on my old slow laptop is huge.

For low depth searches, it's about the same in my tests so far.
@vinnymeller vinnymeller merged commit fcdb009 into master Jun 1, 2024
1 check passed
@vinnymeller vinnymeller deleted the development branch June 1, 2024 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant