mv
/mkdir
/rm
/etc. plugin
I remember seeing a plugin that had these “basics” of unix commands implemented, but I can’t remember what it was called.
These are fairly trivial to implement myself but eh I rather install something that handles e.g. buffer moves, than reinvent.
attach to server on cd into project dir
To replace cd
in terminal → start kakoune, flow:
To handle :cd <dir><ret>
into a directory with a running kakoune server and attaching to that automatically, or creating a server if a .git
dir exists (i.e. it’s a project dir).
mru buffers
I made a terrible most-recently-used files list for myself but I realize now that I only want to see open buffers in it. I can’t figure out how to use arrange-buffers
myself, seems to do nothing? I want the list in order of most recent first.
I don’t think this is possible. The :cd
command is always executed by a Kakoune server, and a server can’t merge itself to a different server.
:arrange-buffers
affects the content of %val{buflist}
and therefore the behaviour of :buffer-next
and :buffer-prev
. The completions for the :buffer
command are always sorted alphabetically, :arrange-buffers
doesn’t help with that.
If you start Kakoune with kak a b c d e
then %val{buflist}
will be:
*debug* a b c d e
:arrange-buffers
takes the buffers you name and moves them to the front of the buffer list. If you do :arrange-buffers d c
, then %val{buflist}
becomes:
d c *debug* a b e
If you set up a hook to move the current buffer to the front of the list every time you switch buffers, like this:
hook global WinDisplay .* %{ arrange-buffers %val{hook_param} }
…then %val{buflist}
will always list buffers in most-recently-used order.
Of course, %val{buflist}
is a session-global value, so if you have multiple clients connected to the same session, switching buffers in one client will affect %val{buflist}
in the others, which might not be what you want. Maintaining an MRU list of buffers per-client would be a lot more involved.
2 Likes
hook global WinDisplay .* %{ arrange-buffers %val{hook_param} }
This combined with peneira
(GitHub - gustavo-hms/peneira: A fuzzy finder crafted for Kakoune) works pretty well already, big thanks!
map global goto A '<esc>: peneira-mru-buffers<ret>' -docstring 'MRU buffers'
define-command -override peneira-mru-buffers %{
peneira 'buffers: ' %{ printf '%s\n' $kak_quoted_buflist } %{
buffer %arg{1}
}
}
hook global WinDisplay .* %{ arrange-buffers %val{hook_param} }
Though as you mention, typically a per-client mru list comes handy but I’ll have to see.
arrange-buffers %val{hook_param}
is genius
1 Like
About unix tools, I have some of them implemented here: dotfiles/.local/share/kak/autoload/tools at master · alexherbo2/dotfiles · GitHub
Currently, :cp
, :find
, :grep
, :ls
, :make
, :mkdir
, :mv
, :nohup
, :pwd
, :rm
, :sh
, :sort
and :unlink
.
1 Like
Perfect, must’ve been where I saw them in the first place Thanks!
Some more I’m looking for:
jj plugin: kakoune-boost/jj.kak at master · krobelus/kakoune-boost · GitHub
jupyter_ascending (wip, I’ll only rarely use it; it’s a start): GitHub - losnappas/jupyter_ascending.kak: Kakoune plugin to run [jupyter_ascending](https://github.com/imbue-ai/jupyter_ascending/)
Although I’m considering figuring a way to run regular .py files in notebook, like vscode’s jupyter extension does, via # %%
semantics (e.g. jupytext), because jupyter_ascending is a pain for my uses.