navi icon indicating copy to clipboard operation
navi copied to clipboard

I would like to publish my Navi extension

Open bimlas opened this issue 4 years ago • 5 comments

Not the right title, but I can’t better articulate what it is: I created a TiddlyWiki plugin that exports the code blocks in the notes to Navi, so you can access the one-liners in your notes directly in Navi.

https://bimlas.gitlab.io/tw5-navi-cheatsheet

I wish others knew about this option, but I don’t know where the link should be placed. If you like the plugin and agree to be included in the Navi description, please post a link.

bimlas avatar May 18 '21 05:05 bimlas

I also post this here: I found a way to use Tmux to insert snippets stored in Navi into any program besides the shell (Vim, MyCLI for example).

~/.tmux.conf

bind-key -T prefix C-g split-window \
  "$SHELL --login -i -c 'navi --print | tmux load-buffer -b tmp - ; tmux paste-buffer -p -t {last} -b tmp -d'"

EDIT

If you had the option to use fzf-tmux instead of fzf in Navi, this could be done more easily.

EDIT

Added -p option to paste-buffer to insert multiline text without executing it.

EDIT

Screencast added:

https://user-images.githubusercontent.com/7034200/119162781-0eeaef00-ba5b-11eb-97f4-1c94d82925a5.mp4

bimlas avatar May 19 '21 21:05 bimlas

The Tmux solution can be used for even more than I originally thought: you can give Vim / NeoVim a list of searchable commands that can be found in Emacs or VSCode. For example if you forgot how to use folds, you can search for it in Navi like in the Ctrl+Shift+P menu in VSCode or in M-x menu in Emacs Helm / Ivy.

Example cheatsheet:

# Close all folds recursively
normal zM

# Open all folds recursively
normal zR

# Open folds of cursor
normal zv

# Preview GitGutter hunk
GitGutterPreviewHunk

To use these commands in Vim, set the Tmux binding mentioned above, press : <tmux prefix><C-g> in Vim to display Navi. You can select the desired command, which is immediately copied to the Vim command line.

https://user-images.githubusercontent.com/7034200/123385463-d7112300-d595-11eb-9cf5-5a30e0d7374d.mp4

I think the Tmux integration should definitely be included in the documentation because Tmux makes an ultimate tool from Navi.

bimlas avatar Jun 25 '21 07:06 bimlas

Sorry for taking so much time to reply.

This looks awesome!

I've been somewhat busy at work lately so I don't think I'll be able to write docs about this in the following days but, if you find some time to open a PR with this info, I'll gladly review/merge it!

denisidoro avatar Jun 29 '21 20:06 denisidoro

bind-key -T prefix C-g split-window \
  "$SHELL --login -i -c 'navi --print | tmux load-buffer -b tmp - ; tmux paste-buffer -p -t {last} -b tmp -d'"

I believe this can be shortened to

bind-key -T prefix C-g split-window \
  "tmux send-keys -t {last} \"$(navi --print)\""

vashirov avatar Jul 20 '21 15:07 vashirov

Hello @bimlas thanks for sharing your extension I am using it for a long time. It's useful while executing navi snippets on remote server.

I did small addition to you tmux code which useful for me.

-  bind-key -T prefix C-g split-window \
+  bind-key -T prefix g split-window -h \
-  "$SHELL --login -i -c 'navi --print | tmux load-buffer -b tmp - ; tmux paste-buffer -p -t {last} -b tmp -d'"
+  "$SHELL --login -i -c 'navi --print | tmux load-buffer -b tmp - ; tmux paste-buffer -p -t {last} -b tmp -d -s\\ '"

First line is nothing fancy just opens the tmux horizontal(It's easy to see) Second line I change Carriage Return with space character (by using -s \ ) so it does not execute selected navi command directly so I can make some changes on the code before execution.

BR

enisozgen avatar Oct 09 '21 17:10 enisozgen