# Kakoune.cr

**URL:** <https://discuss.kakoune.com/t/kakoune-cr/1605>\
**Category:** Terminal Tools\
**Created:** [February 24, 2021, 10:10am UTC](https://discuss.kakoune.com/t/kakoune-cr/1605 "2021-02-24T10:10:24Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexherbo2](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/alexherbo2/32/1140_2.png) [@alexherbo2](https://discuss.kakoune.com/u/alexherbo2)\
**Post date:** [February 24, 2021, 10:10am UTC](https://discuss.kakoune.com/t/kakoune-cr/1605/1 "2021-02-24T10:10:25Z")

</div>

> **[alexherbo2/kakoune.cr](https://github.com/alexherbo2/kakoune.cr)**
>
> A command-line tool for Kakoune. Contribute to alexherbo2/kakoune.cr development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![scr](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/scr/32/486_2.png) [@scr](https://discuss.kakoune.com/u/scr)\
**Post date:** [February 27, 2021, 12:16am UTC](https://discuss.kakoune.com/t/kakoune-cr/1605/2 "2021-02-27T00:16:59Z")

</div>

Freaking awesome, I was waiting for that since a long time!

I believe this is a HUGE contribution to the kakoune ecosystem, it is going to be more simple to write plugin in any language now.

Much love \<3

---

<div class="post-metadata">

**Author:** ![alexherbo2](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/alexherbo2/32/1140_2.png) [@alexherbo2](https://discuss.kakoune.com/u/alexherbo2)\
**Post date:** [February 27, 2021, 9:45am UTC](https://discuss.kakoune.com/t/kakoune-cr/1605/3 "2021-02-27T09:45:48Z")

</div>

You were asking in [Luar](https://github.com/gustavo-hms/luar) to execute commands and get states in Lua scripts. You can do it with [kakoune.cr](https://github.com/alexherbo2/kakoune.cr) (at the price of a system call).

There is many ways for interacting, letting you use what is more fitting.

---

<div class="post-metadata">

**Author:** ![alexherbo2](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/alexherbo2/32/1140_2.png) [@alexherbo2](https://discuss.kakoune.com/u/alexherbo2)\
**Post date:** [February 27, 2021, 10:54am UTC](https://discuss.kakoune.com/t/kakoune-cr/1605/4 "2021-02-27T10:54:45Z")

</div>

[Here](https://github.com/alexherbo2/kakoune.cr/tree/master/src/commands/fzf) are some examples for extending the CLI with a [fzf](https://github.com/junegunn/fzf) subcommand.

One advantage of `kcr <name>` vs `kcr-<name>` is you can inherit options without implementing them the scripts themselves.

**Example** – Writing a `kcr-example` script:

```auto
#!/bin/sh

kcr get %val{buflist}

```

`kcr example --session poudriere` will get you the buffer list of the `poudriere` session.

---

<div class="post-metadata">

**Author:** ![andreyorst](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/andreyorst/32/29_2.png) [@andreyorst](https://discuss.kakoune.com/u/andreyorst)\
**Post date:** [February 27, 2021, 3:41pm UTC](https://discuss.kakoune.com/t/kakoune-cr/1605/5 "2021-02-27T15:41:08Z")

</div>

This is looking great! Although I’m a bit concerned with it depending on Crystal, and I’m unfamiliar with this language, but maybe there’s a way to provide standalone executable, so end users will not be required to install development dependencies? Especially if many plugins will be based off Kakoune.cr, this would ease the process of installation a lot.

---

<div class="post-metadata">

**Author:** ![robertmeta](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/robertmeta/32/833_2.png) [@robertmeta](https://discuss.kakoune.com/u/robertmeta)\
**Post date:** [February 27, 2021, 3:49pm UTC](https://discuss.kakoune.com/t/kakoune-cr/1605/6 "2021-02-27T15:49:05Z")

</div>

> [@andreyorst](#):
>
> provide standalone executable, so end users will not be required to install development dependencies?

Sadly it doesn’t create stand-alone executables in the vein of go or rust. But it does have a minimum set of very common system requirements that most modern Linux or Mac systems can fulfill, which dovetails very well with where Kakoune runs.

---

<div class="post-metadata">

**Author:** ![andreyorst](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/andreyorst/32/29_2.png) [@andreyorst](https://discuss.kakoune.com/u/andreyorst)\
**Post date:** [February 27, 2021, 3:55pm UTC](https://discuss.kakoune.com/t/kakoune-cr/1605/7 "2021-02-27T15:55:10Z")

</div>

> [@robertmeta](#):
>
> But it does have a minimum set of very common system requirements that most modern Linux or Mac systems can fulfill

This can be said about a very wide range of languages though.

---

<div class="post-metadata">

**Author:** ![alexherbo2](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/alexherbo2/32/1140_2.png) [@alexherbo2](https://discuss.kakoune.com/u/alexherbo2)\
**Post date:** [February 27, 2021, 4:25pm UTC](https://discuss.kakoune.com/t/kakoune-cr/1605/8 "2021-02-27T16:25:45Z")

</div>

It’s like Ruby, typed and native.

[![](https://discuss.kakoune.com/uploads/default/original/1X/61318aba9480d71b3deb5525b6171eaaaee3ebc7.jpeg "Meet Crystal") ](https://www.youtube.com/watch?v=tAw5puTcGhA)

---

<div class="post-metadata">

**Author:** ![basbebe](https://discuss.kakoune.com/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@basbebe](https://discuss.kakoune.com/u/basbebe)\
**Post date:** [February 27, 2021, 6:23pm UTC](https://discuss.kakoune.com/t/kakoune-cr/1605/9 "2021-02-27T18:23:07Z")

</div>

adding it to [Homebrew](https://brew.sh/index_de) (mac) would be a great move and would make installing it on a mac even quicker and easier (similar to kak-lsp)

---

<div class="post-metadata">

**Author:** ![alexherbo2](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/alexherbo2/32/1140_2.png) [@alexherbo2](https://discuss.kakoune.com/u/alexherbo2)\
**Post date:** [February 27, 2021, 9:06pm UTC](https://discuss.kakoune.com/t/kakoune-cr/1605/10 "2021-02-27T21:06:30Z")

</div>

[https://crystal-lang.org/reference/using\_the\_compiler#creating-a-statically-linked-executable](https://crystal-lang.org/reference/using_the_compiler#creating-a-statically-linked-executable)

For [webextension-shell](https://github.com/alexherbo2/webextension-shell), I was using the following [`Dockerfile`](https://github.com/alexherbo2/webextension-shell/blob/master/host/Dockerfile) and [command](https://github.com/alexherbo2/webextension-shell/blob/master/host/scripts/build-static).

---

<div class="post-metadata">

**Author:** ![gustavo-hms](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/gustavo-hms/32/598_2.png) [@gustavo-hms](https://discuss.kakoune.com/u/gustavo-hms)\
**Post date:** [March 3, 2021, 12:20pm UTC](https://discuss.kakoune.com/t/kakoune-cr/1605/11 "2021-03-03T12:20:19Z")

</div>

Hi, @alexherbo2!

I miss a more informative README in the project repository. Just reading the current one, I can’t tell exactly what this tool does. I guess it has something to do with your previous work on `connect.kak`, but since I’ve never used it, I can’t understand how `Kakoune.cr` is meant to be used, apart from some more or less obvious examples. Perhaps it’s easier for those with some background, but for me (and possibly others new to this kind of tool) it’s very hard to understand what it does and how to use it.

Since you are so involved in it, I understand it’s hard for you to see how difficult it is for a novice to understand it. So, I’m gonna try to give you some examples of my difficulties to make it easier for you to see the problem from the eyes of an outsider. I hope it helps =)

## An excessive short description

The only description about the project is

> kakoune.cr (kcr) is a command-line tool for [Kakoune](https://kakoune.org).

OK. A command-line tool. But what does it do? It would be of great help if that sentence would be followed by a paragraph describing the big picture: the main features, what it is supposed to do, how a normal Kakoune user would benefit from it, if it’s meant to be used for scripting or for interactive text editing… that sort of thing.

## Unhelpful examples and docstrings

In the `Configuration` section, it’s written:

```auto
map -docstring 'New terminal' global normal <c-n> ': connect-terminal<ret>'

```

What does `connect-terminal` do? I can’t say, since it wasn’t mentioned before. So, trying to figure it out, if I have been following the README, at this point I have

```auto
evaluate-commands %sh{
  kcr init kakoune
}

```

in my `kakrc`. So I can type `:connect-terminal` in the prompt to see its docstring. And its only description is “Connect a terminal”. It doesn’t help.

Now, if I press `<ret>` to run this command, it opens another terminal and… what now? What do I do now? It appears to be just a regular terminal…

Next, in the `Commands` section, there is a

```auto
kcr install commands

```

What does it do? Which commands does it installs? Where are these commands installed?

Then, in the next lines, there is:

```auto
kcr install desktop

```

I guess this command installs a `.desktop` file at `~/.local/share/applications`. But a `.desktop` file for what? For Kakoune? Is it for being able to launch Kakoune from my system launcher? or is there some additional functionality?

Additionally, there’s this commentary:

> See [#2](https://github.com/alexherbo2/kakoune.cr/issues/2) for `'connect' no such command: 'popup'` error.

When I jump to the issue, I can read:

> Im closing the issue, i just found this sweat\_smile :
> 
> hook global ModuleLoaded x11 %{  
> alias global popup x11-terminal  
> }

Is it something I have to insert in my `kakrc`? Is this `x11-terminal` the only option or are there others? What is it supposed to do?

## Conclusions

I hope you can see how hard it is for someone not familiar with this kind of tool to understand its scope and how to use it based solely on the docs. Even if I’ve shown some examples, there are others that could be shown, so the point is that the general communication could be improved, not just the ones from the examples I’ve given here.

All in all, I look forward to experiment with this tool. My guess is that it’s very useful indeed.

Thanks! =D

---

<div class="post-metadata">

**Author:** ![useredsa](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/useredsa/32/419_2.png) [@useredsa](https://discuss.kakoune.com/u/useredsa)\
**Post date:** [March 3, 2021, 1:34pm UTC](https://discuss.kakoune.com/t/kakoune-cr/1605/12 "2021-03-03T13:34:02Z")

</div>

The fastest solution is probably to read [connect.kak](https://github.com/kakounedotcom/connect.kak)’s docs.

I would add the questions, @alexherbo2, what’s the benefit of kcr vs connect.

---

<div class="post-metadata">

**Author:** ![CharlesGueunet](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/charlesgueunet/32/428_2.png) [@CharlesGueunet](https://discuss.kakoune.com/u/CharlesGueunet)\
**Post date:** [March 5, 2021, 8:13am UTC](https://discuss.kakoune.com/t/kakoune-cr/1605/13 "2021-03-05T08:13:33Z")

</div>

Thanks a lot for this plugin ! There is however one point, the Crystal dependency, that is really blocking for me. Kakoune only requires a C++ compiler to work and this is really important for people deploying it on various setups (eventually without root access to install packages). I am not familiar enough with Crystal, is there really no way we could have a statically linked standalone executable for `kcr` ?

---

<div class="post-metadata">

**Author:** ![robertmeta](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/robertmeta/32/833_2.png) [@robertmeta](https://discuss.kakoune.com/u/robertmeta)\
**Post date:** [March 5, 2021, 10:57am UTC](https://discuss.kakoune.com/t/kakoune-cr/1605/14 "2021-03-05T10:57:43Z")

</div>

> [@CharlesGueunet](#):
>
> is there really no way we could have a statically linked standalone executable for `kcr`

**(The below paragraph is incorrect, see next comment, left for posterity)**  
Sadly, no, even with the static support Crystal offers, it has certain gaps on Linux (glibc) and MacOS (system libraries). That said, I believe for the vast majority of use cases, a Crystal binary will “just work”.

* * *

Two decades in the Vim community has proven to me, over and over that plugins with no dependencies almost always win – even if functionally worse. I am not saying it is even a functional issue, or purely logical – it is emotional. Adding this with binaries or system requirements “feels bad” and people trend away from it.

I happen to have certain old Redhat machines I use Kakoune on (even had issues compiling Kakoune statically to work on them) – so staring down the barrel of another binary not provided by the distro that I have to make functional was a huge part of why I created the [KPMS: Kakoune.com Plugin Maintainers Squad](https://discuss.kakoune.com/t/looking-for-help-kpms-kakoune-com-plugin-maintainers-squad/1606) and moved connect.kak into it (with @alexherbo2 help and blessing).

Connect.kak is the single most important plugin, it works amazingly and stays out of my way – and works everywhere I need it to.

---

<div class="post-metadata">

**Author:** ![TeddyDD](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/teddydd/32/21_2.png) [@TeddyDD](https://discuss.kakoune.com/u/TeddyDD)\
**Post date:** [March 5, 2021, 9:28pm UTC](https://discuss.kakoune.com/t/kakoune-cr/1605/15 "2021-03-05T21:28:20Z")

</div>

> [@robertmeta](#):
>
> Sadly, no, even with the static support Crystal offers, it has certain gaps on Linux (glibc) and MacOS (system libraries). That said, I believe for the vast majority of use cases, a Crystal binary will “just work”.

Huh?

`kakoune.cr/.github/workflows/crystal.yml`

```yaml
name: Crystal CI

on:
  push:
    branches: [master]
  pull_request:
    branches: [master]

jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    container:
      image: crystallang/crystal:latest-alpine
    steps:
    - uses: actions/checkout@v2
    - name: Install dependencies
      run: shards install
    - name: Build
      run: shards build --production --static --release --progress

    - uses: "marvinpinto/action-automatic-releases@latest"
      with:
        repo_token: "${{ secrets.GITHUB_TOKEN }}"
        automatic_release_tag: "latest"
        prerelease: true
        title: "Development Build"
        files: |
          ./bin/kcr

```

The result is statically linked binary (with musl libc) and should work everywhere. Tested on Ubuntu 20.04 and Centos 7. Dunno if GH Actions allow building Mac binaries (and honestly I don’t care). @alexherbo2 feel free to use the code above.

---

<div class="post-metadata">

**Author:** ![robertmeta](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/robertmeta/32/833_2.png) [@robertmeta](https://discuss.kakoune.com/u/robertmeta)\
**Post date:** [March 5, 2021, 10:56pm UTC](https://discuss.kakoune.com/t/kakoune-cr/1605/16 "2021-03-05T22:56:51Z")

</div>

@TeddyDD Thanks for the correction, I must have been working off of old info. I thought it had issues it apparently doesn’t.

---

<div class="post-metadata">

**Author:** ![scr](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/scr/32/486_2.png) [@scr](https://discuss.kakoune.com/u/scr)\
**Post date:** [March 7, 2021, 5:00pm UTC](https://discuss.kakoune.com/t/kakoune-cr/1605/17 "2021-03-07T17:00:26Z")

</div>

> [@CharlesGueunet](#):
>
> There is however one point, the Crystal dependency, that is really blocking for me.

I feel that this is a inherent part of kakoune UNIX design, when you allow people to write plugins in any language. The other solution is to write plugin in “kakscript” which is not optimal neither.

---

<div class="post-metadata">

**Author:** ![alexherbo2](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/alexherbo2/32/1140_2.png) [@alexherbo2](https://discuss.kakoune.com/u/alexherbo2)\
**Post date:** [March 9, 2021, 12:02am UTC](https://discuss.kakoune.com/t/kakoune-cr/1605/18 "2021-03-09T00:02:11Z")

</div>

Yo @gustavo-hms,

I’ve updated the README with a better documentation and added a playground.

---

<div class="post-metadata">

**Author:** ![alexherbo2](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/alexherbo2/32/1140_2.png) [@alexherbo2](https://discuss.kakoune.com/u/alexherbo2)\
**Post date:** [March 9, 2021, 12:15am UTC](https://discuss.kakoune.com/t/kakoune-cr/1605/19 "2021-03-09T00:15:31Z")

</div>

For end users, they are quite comparable, but in terms of expressivity and robustness, connect.kak is nowhere near kakoune.cr.

I’m also curious to know how other people compare them.

---

<div class="post-metadata">

**Author:** ![gustavo-hms](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/gustavo-hms/32/598_2.png) [@gustavo-hms](https://discuss.kakoune.com/u/gustavo-hms)\
**Post date:** [March 9, 2021, 12:35pm UTC](https://discuss.kakoune.com/t/kakoune-cr/1605/20 "2021-03-09T12:35:09Z")

</div>

Thank you for taking my observations into account, @alexherbo2! The README is much better now, and the `kcr play` is of great help (very good idea indeed).

I really like this program. It seems we can now somehow script Kakoune [the way I would like to do](https://discuss.kakoune.com/t/a-lua-command-for-kakoune/1003/16).

People are complaining about it’s being written in Crystal, but I don’t see it as a problem (specially if you can provide binaries in its releases). Quite the contrary: it opens up the opportunity to be much more flexible in which languages you use to script Kakoune. As noted by @scr, this is exactly the Kakoune and POSIX way of doing things. If you want an inclusive community, you must to be open to tools written in whatever language the author is more familiar with. Diversity is the key.

Regarding `kcr play`, it’s worthy of notice that it works only with Kakoune compiled from `master` and not with the last release, since the latter lacks the `-method` switch of the `write` command.

[Next page](https://discuss.kakoune.com/t/kakoune-cr/1605.md?page=2)
