I am using "hints" kitten to open file links in terminal vim (in a different tmux pane) and it works really well. In fact, that's the sole reason I switched to kitty (though it's awesome in every other way too).
There are few bits though that I find "hints" is missing:
PostsController#create maps onto a particular line in app/controllers/posts_controller.rbSo I was thinking to have a go at extending "hints" kitten, such that it supports the following contrived config:
map kitty_mod+f kitten hints --type regex-plus \
--regex1 "FILE_WITH_LINE_NUMBER_REGEX" --transform1 ~/return_input_if_file_exists.sh --program1 ~/bin/open_in_vim.sh
--regex2 "RAILS_CONTROLLER_ACTION_REGEX" --transform2 ~/rails_controller_action_to_path.sh --program2 ~/bin/open_in_vim.sh
--regex3 "WEB_URL_REGEX"
If the command specified in --transformX returns an empty string: no hint is shown for the --regexX. Otherwise, the hint is shown and --transformX output is passed into --programX command.
Any thoughts on the above? What are the chances of this getting merged?
Regexes support the OR operator. Simply create a regex that matches all
the things you want to match then pass it to a program that can perform
further filtering/actions as required. This can be made a bit more
ergonomic by changing the hints kitten so that if the regex has named
groups it will pass the name of the group as an additional argument to
the invoked program.
OR operator definitely helps, but some files are difficult to match without going too inclusive (e.g. files without extensions, files in the current directory). One way to solve this could be to pass a match through an arbitrary test - e.g. "does this file exist?" - to weed out false positives and only show the hints that pass. That's what the proposed --transform option is about.
Running a script on every match is way too slow/CPU intensive. If you
want to do this a better way would be to just allow the user to pass in
the path to a python script that defines a match_postprocess() function
the hints kitten can then import that function and use it adjust the
match as needed. The hints kitten already has a framework for this, see
post_processors.
And really might as well go the whole hog, let the user pass in a python
module that defines two entry points.
1) iter_matches(text, args, context_dict)
which yields pairs of start and end positions for all matches.
2) execute_match(match_text, args, context_dict)
which can perform arbitrary actions on the selected match.
Thanks a lot @kovidgoyal for making this happen!
A friend of my is interested in using it, but he's not the kind of guy who builds his own terminals :) When can we expect this change to make it in a release?
For the reference, working example: https://github.com/artemave/myrcs/blob/fe1a29d17750cb55f828de163a29403b94c2fdeb/.config/kitty/tmux_send_to_vim.py
soonish, I am suposed to be migrting the kitty binary build system to
use bypy, once that is dne I will make the next reease.
Thanks a lot @kovidgoyal for making this happen!
A friend of my is interested in using it, but he's not the kind of guy who builds his own terminals :) When can we expect this change to make it in a release?
For the reference, working example: https://github.com/artemave/myrcs/blob/fe1a29d17750cb55f828de163a29403b94c2fdeb/.config/kitty/tmux_send_to_vim.py
What if I wanted to copy the whole screen to a new buffer in vim?
kitty has dedicated features for that, see https://sw.kovidgoyal.net/kitty/launch.html
or https://sw.kovidgoyal.net/kitty/remote-control.html
On Sat, Dec 14, 2019 at 05:25:50PM -0800, Yusuf Taha wrote:
Thanks a lot @kovidgoyal for making this happen!
A friend of my is interested in using it, but he's not the kind of guy who builds his own terminals :) When can we expect this change to make it in a release?
For the reference, working example: https://github.com/artemave/myrcs/blob/fe1a29d17750cb55f828de163a29403b94c2fdeb/.config/kitty/tmux_send_to_vim.py
What if I wanted to send the whole screen to vim?
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
https://github.com/kovidgoyal/kitty/issues/2124#issuecomment-565768293
--
Dr. Kovid Goyal
https://www.kovidgoyal.net
https://calibre-ebook.com
I summed it all up in a blog post - https://featurist.co.uk/blog/file-links-in-terminal/ (reddit thread: https://www.reddit.com/r/programming/comments/empexg/file_links_in_the_terminal/ )
Cool :)
Most helpful comment
I summed it all up in a blog post - https://featurist.co.uk/blog/file-links-in-terminal/ (reddit thread: https://www.reddit.com/r/programming/comments/empexg/file_links_in_the_terminal/ )