Tags
I've slowly adding more and more lua functions into my neovim configuration, and recently I noticed a pattern for a class of functions that reach out to run shell commands that can be abstracted away.
Telegraph.nvim #
Check out the project readme for the most up to date details on the plugin itself.
Motivation #
I want a simple way to make remaps into shell commands that can open new tmux windows, popups, or just run a command with context from the editor.
For example I want to make remaps to do things like open the current file in lookatme.
# vim :terminal nnoremap <leader>s <cmd>Telegraph pipx run lookatme {filepath} --live-reload --style gruvbox-dark<cmd> # tmux session nnoremap <leader><leader>s <cmd>lua require'telegraph'.telegraph({cmd='pipx run lookatme {filepath} --live-reload --style gruvbox-dark', how='tmux'})<CR> # tmux popup nnoremap <leader><leader>S <cmd>lua require'telegraph'.telegraph({cmd='pipx run lookatme {filepath} --live-reload --style gruvbox-dark', how='tmux_popup'})<CR>
The main goal here is that remaps become one liners that can just be put
directly in my init.vim without creating a whole new lua module for each
shell command I want to bind.
how #
telegraph takes in a how argument to determine where to tun the command.j
term(default) runs command in the built in terminaltmuxruns command in a new tmux session and joins it.tmux_popupruns command in a tmux popup window.tmux_popup_sessionruns command in a tmux session and displays it in a popupsubprocessruns command in a subprocess
Format strings #
The current set of format strings that can be used with telegraph. Placing
these in braces {} within your command will get rendered into something with
context from the editor.
cword- the current word under the cursorcWORD- the current BIG Word under the cursorcline- the current line under the cursorfilepath- the filepath of the current filefilename- the filename of the current fileparent- the parent directory of the current filecurrent_session_name- name of the current tmux sessioncwd- the current working directory
Give it a ⭐ #
Check out the repo and give it a star if its something that interests you.