New to Kakoune, I have some questions!

Hi, I have just heard of this text editor and I wanted to ask some questions:

  1. How does it differ from vim/neovim/spacevim? Which one would be better to use?
  2. Am I able to script extensions? if so which languages can I use? Can I use Rust in particular to script it?
  3. If I can script Kakoune, then which one is easier to script in, vimscripting or Kakoune scripting?

Hi, and welcome to the community!

Vim, neovim, and spacevim are the same text editors. Vim and Neovim have some differences on the implementation level, but the surface level is the same. Spacevim is a Vim distribution, which means that it is a preconfigured Vim, oriented at offering more things than Vim has out of the box.

Kakoune is not Vim in this both of these senses – it is completely different project, with different implementation. On the surface it is similar to Vim, in a sense that you have modes, like normal and insert, and you have editing language, as in Vim. However Kakoune inverts the verb-object paradigm of Vim into object-verb form, which is one of the main surface differences from Vim. I recommend you to read Why Kakoune article by Kakoune author, which explains a lot of this stuff.

Kakoune doesn’t feature it’s own scripting language, like Vim. Instead, Kakoune exposes it’s state to the shell that your system is using (Bash for example), and from the shell you can call whatever language you want.

For example, some of plugins I wrote use Perl, becase it is preinstalled on most systems where Kakoune runs, and I felt that portability is more important than programming experience in this particular cases. Many other plugins use various languages from something very basic like shell itself, or Awk, to something more complex like Scheme or Rust. The basic idea here is that since you can call shell, and you can propagate Kakoune’s state into it, you can make this state available for any other programming language. And you can communicate back to Kakoune by using pipes.

In my opinion this is by far the greatest aspect of extension model Kakoune provides. I wrote some plugins for Vim in Vimscript, and some code for Emacs in Emacs Lisp, and I gonna say that I’ve enjoyed Kakoune more than Vimscript by a large amount. I still like Emacs Lisp more, because it is a Lisp, but nothing prevents me from writing plugins for kakoune in any Lisp language I want.

I’ve partly answered this in previous paragraph, but one thing you should keep in mind is that some things may be easier to do in Vimscript, but the outcome will not be simpler by any means. Vimscript is a quite convoluted language in my opinion.

Kakoune makes it really easy to reach the shell, and by using appropriate language for the job, you can make things really simple on the implementation level, because all you need is to consume some input and send output back to Kakoune via pipe. And you can create tools that can be useful outside of Kakoune as well.

Or you could integrate existing tool with Kakoune. A great example here is Tmux – Kakoune doesn’t have it’s own windowing capabilities like Vim does. So you can’t create splits or windows. But if you run Kakoune inside Tmux, you have this ability, because Kakoune detects that it runs in Tmux, and all commands that support windowing now work in terms of Tmux. When not using Tmux, Kakoune uses X11 or your terminal app windowing capabilities, depending on what you’re using.

So this is a much more open system, which makes it really easy to script the editor in anything.

6 Likes

Thank you my brother =D

I see interesting thanks for the link I will check it out.

That sounds honestly better.

I see what pluggins did you write if I may ask?

So is it more customisable compared to neovim or more? For example this was made in neovim:

In your opinion how come?

Should I run it through Tmux then?

Is it more customisable than emacs or the same?

here’s the full list

Well, it is quite customizeable but Neovim is more mature in this regard. Here’s my Kakoune:

Neovim decoupled the UI, so you can use different UIs, like OniVim. Kakoune has JSON RPC for this, but no stable non terminal UI exists at the moment AFAIK

Well, there some obscure concepts in the language itself, and pretty stupid backwards companibility policy.

On the screenshot it seems that you’re using tiling window manager, and Kakoune works good with those too. So give it a shot outside of TMUX as well.

I highly doubt that anything what exists today is more customizeable than Emacs. Emacs is not a text editor, it is a Lisp Machine that happens to have a text editor in it. You can target Emacs as a platform the same way you target Linux or Windows as platforms when developing applications.

For example, Emacs has working NES emulator implemented in Emacs lisp. Why? Because. :slight_smile:

1 Like

I have come to say something that has been repeated a thousand times in this forum, but I will say it once again.

As @andreyorst has pointed out, Kakoune integrates with other tools seamlessly. For instance, in the following screenshot, I have opened dolphin (my file manager), zathura (my pdf viewer) and a terminal and they interact with kakoune very well. Because I have opened everything from kakoune, when I select a file in the editor it opens in my current session. When I control+click on the pdf I go to the corresponding line in the text. When I type gp (goto pdf) in kakoune the viewer moves to the corresponding line in the pdf and when I compile inside kakoune I see the result appear in the terminal below (which becomes larger and but hides again automatically if the command is succesful).

Of course, this features are not only thanks to kakoune, but integrating everything together is very easy.

2 Likes

@jane934 Kakoune to me is about a the unix philosophy, many small tools tied together in sane ways.

Sometimes this makes this feel painful for shallow things, like simply incrementing a number requires shelling out to the console tool bc which at first blush feels bad. Vim has a built-in for incrementing! But, because you are using a tool, not a feature, you realize now you have the full power of bc at your fingertips, you can do all sorts of math on those numbers.

This pattern repeats over and over again, at first when you try to do something simple and have to pay the price of the “external tool” – but then as the task naturally grows more complicated, the value you extract from the external tool grows. bc, jq are two that I constantly find deeper uses for.

4 Likes

Regarding using Rust for Kakoune plugins, you might want to take a look at projects like parinfer-rust and kak-lsp as examples. Both are popular Kakoune plugins written in Rust.

1 Like

I’ve been using Vim for over 10 years now but I never really got the hang of Vimscript even though I’ve done a lot of it. I do a lot of shell scripting so scripting in Kakoune feels more natural to me eve though I’ve only been using it a few months.

1 Like