Plugins ideas

Usually we announce plugins we wrote, but this time let’s try something different.
Let’s list plugins we wish to see in Kakoune. I think this is nice idea for two reasons: this thread might be nice place to start collaboration on plugin and exchange ideas how it can be implemented. It can also help to avoid duplicate work - maybe plugin you wish to see already exist or somebody is already working on it? :slight_smile:

Let me start:

language tool integration:

Language Tool is grammar and spell checker. It has cli written in java. It could work like spell command. CLI has json output, there is also lsp implementation but it seems it only supports VSCode.

No link?

Anything with an LSP should work with kak-lsp, if kak-lsp is configured to start it for the right filetypes.

Sorry, added links :slight_smile: Does kak-lsp support communication via sockets?

:help / :helpgrep plugin – it is something I am working on casually. I am still tracking down how I want to do it with asciidoc, etc. I currently understand (but loathe) the help system in Kakoune. I think the inline assistance is great, but :doc is rough.

It is fairly simple (on the surface) what I want. :help m takes you to m in keys. help a-m to alt-m – basically lots of indexes to get you to the right place. Asciidoc has some support for this I think via the indexes. :helpgrep is easier but far less useful day to day. :help matching might show a choice between m and the options matching.

I am actually looking for any good ideas on how to implement this…

(random aside, the :doc keys m which I thought would work fails on my current build with No such anchor '992'.)

1 Like

Vim does this by having a specific markup pattern for each namespace: commands always begin with :, options are always surrounded in single quotes, keys are always surrounded by *, etc. and then all those special patterns are indexed in a ctags file which :help consults, and uses for completion.

You could probably do something similar with Kakoune by noting that useful terms generally match ^=+ (.*?)$ or ^\*(.*?)\*.*?:: and indexing those to start with.

I don’t think kak-lsp communicates with language-servers via socket, but via stdin/stdout. However, judging by its default config file it already works with dozens of language-servers, so that seems to be pretty widely supported.

I’ve downloaded a copy of Language Tool and I hope to get around to poking at it soon.

First, since it communicates via stdin/stdout, then it will communicate with sockets if netcat is installed (or socat).

Second, LSP uses a weird JSON-RPC with headers. You could probably implement a shell driver that interprets the weird JSON-RPC and passes things along, though. kak-lsp doesn’t support stacking drivers, though.

Is your :help idea something like documentation command discussed in this issue?

Edit by Admin: Moved github link to its own line so it can inline the preview.

I think no. I believe that @robertmeta essentially means a help system similar to vim, where you could “grep” through all help manuals for certain feature, while I’ve proposed a general way to store plugin documentations in single place, so Kakoune could use it’s builtin commands to open desired doc.

I wish to have a plugin similar to tagbar. And comprehensive snippet support, similar to Emac’s yasnippet, or VSCode snippet system. That’s like the main features that are lacking for me

I’d love to see some interactive git plugin with basic stuff like partial staging/unstaging and conflict solving. I doubt anything like Magit will be possible, but being able to stage few lines from editor is huge qol improvement.

TIG kinda does this, but it can be quirky and has weird bindings.

I would be fine with this being an external app rather than a plugin. I looked around and surprising couldn’t find anything similar standalone. Would be nice to just have in a tmux to the left or right.

TIG is a bit odd – but once you suffer the learning curve it is actually fantastic and very powerful.

Vim has a lot of identation-related settings: expandtab and softtabstop and smarttab.

Kakoune has none of these; all you get is tabstop, indentwidth and the @ and <a-@> keys. Together, they can be used to simulate all the various combinations of Vim options, but you have to write the hooks yourself. The wiki contains recipes for some specific combinations, but definitely not all of them.

It’d be great if somebody could write a plugin that created Vim-like options (or perhaps better-thought-out options, since we don’t have Vim’s backwards-compatibility constraints) for these things, with a BufSetOption or WinSetOption hook that respect all the options and install a hook to make identing do the expected thing.

That would also make it easier to create a Kakoune plugin like vim-sleuth that analyzes the kinds of indenting used in the buffer, picks the most common common one, and sets the indenting options to match it.

(this is the sort of thing that new Kakoune users ask about on IRC)

1 Like

kak-lsp has just added lsp-workspace-symbol so there may be way to retrieve the data needed to build such plugin: implement lsp-workspace-symbol; close #104 · kak-lsp/kak-lsp@dd339ef · GitHub

I would be fine with this being an external app rather than a plugin. I looked around and surprising couldn’t find anything similar standalone. Would be nice to just have in a tmux to the left or right.

I don’t think so. Well kinda you’re right that this could be standalone app controlled by Kakoune with hooks, but there’s some problems:

Tagbar not just displays tags in sidebar buffer, it allows folding, sorting, jumping, searching, therefore we will need a buffer where such tag-app output will be parsed by Kakoune, so we could jump to tag in the actual file we’re editing and do other related stuff.
Tagbar also displays active tag that our cursor is inside, which is very helpful too. So again lots of hooks are needed inside of Kakoune, which pretty much makes it unnecessary to be a standalone plugin.

I still think that Tagbar was one of the most important plugins in my workflow:
Fuzzy semantic autocompletion - check, builtin;
Linting code in the background - check, builtin;
LSP - check;
Source outline viewer - ???
Snippets - ???

Folding, sorting, jumping, searching all would be great in an external standalone app. The “in-function” obviously seems like great feature for such an app – could be a fairly light integration with any editor not just Kakoune.

I see. I think it is possible to make a standalone app with ncurses for example, with mappable keys, ability to set a command to send to an exyernal program via shell, and some listener to get info from the editor, like filename. It’s just trickier compared to native implimentation inside the editor itself since all editor should be supported. Maybe I’ll start working on it, I’ve always wanted to try out developing cli app with ncurses.

I don’t think it makes things harder. You need to figure out what kind of information will be passed between Kakoune and Tagbar (probably file path and selection description) and write integration .kak script. Users of other editors can integrate it at will. I bet popular editors are capable of reading/writing data to the socket.

About snippets: I took a look at yasnippet docs and I watched Ultisnip screencasts. Writing something like this for Kakoune will be a challenge.

  • snippets should be scriptable (and using shell is probably bad idea due to escaping hell)
  • snippet engine have to remap some keys on the fly, also have to detect when user finished filling gaps / leaved snippet area

About snippets: I took a look at yasnippet docs and I watched Ultisnip screencasts. Writing something like this for Kakoune will be a challenge.

  • snippets should be scriptable (and using shell is probably bad idea due to escaping hell)
  • snippet engine have to remap some keys on the fly, also have to detect when user finished filling gaps / leaved snippet area

And then you have nested snippets, moving snippets around by adding lines before them, increasing snippet’s size by adding lines inside them, visual placeholders, mirroring nested placeholders, real-time update of EVERYTHING like transformations, script fields, and more to go, and most importantly still being fast and responsive.

I’ve gave up on making those features in my snippet manager for vim.

And that’s exactly why I feel that snippets should be a part of an editor rather a plugin, because implementation of such functional usually means that there will be so many hacks to make it feel native.