Plugins ideas

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.

I thought the same about LSP support but @ulis has proven me wrong. I’d rater use snippets example to figure out how to improve plugin API to make implementation possible. I think we agree that with current %sh scopes it would be madness to write something that complex.

Plugin like Ultisnip needs to have quite unrestricted access to editor’s internal state.
There was short discussion about this topic on Github:

Maybe we should open new thread, here on the forum to discuss it further?

Or maybe I’m wrong and I think from perspective of other editors? Maybe this is possible with current system, I’m just not clever enough to figure it out.

It doesn’t, feel free to file an issue to add support if you hit language server which doesn’t support stdio and works only via sockets.

You could also implement a simple netcat wrapper around the language server, like such: https://github.com/languagetool-language-server/languagetool-languageserver/issues/3

1 Like

Another free plugin idea for somebody with some time on their hands: word completion for natural language courtesy of a spell-checker.

When given a word on standard input, followed by a newline, the hunspell tool will check it and print a response line. If the response line begins with & (ampersand), the word is misspelled and hunspell provides suggestions:

$ echo 'fud' | hunspell -d en_AU
Hunspell 1.7.0
& fud 15 0: FUD, food, dud, feud, fund, fed, fad, fun, fur, fut, cud, fug, fum, mud, pud

After &, the fields are:

  • the input word
  • the number of suggestions
  • the character offset of the word from the beginning of the line
  • : (colon)
  • the suggestions, separated by , (comma) and space

It should be pretty straight-forward to transform the hunspell output into a completions option (much like racer.kak so we can have sensible completions for plain-text documents.

Right now, I have a hack that reads all of /usr/share/dict/words into the static_words option, which works but it can make Kakoune quite sluggish, and Kakoune’s ranking of completions isn’t really tuned for natural language. I suspect using a tool designed for the task would probably do a better job.

Some git related things I miss, which are probably a bit easier:

  • Open 2 windows with git status and git diff to assist in authoring a commit. (https://github.com/rhysd/committia.vim)
  • Lint/Format/Highlight the message according to rules.
  • kakdiff, but I believe this was already discussed/thought about.

Some git related things I miss:

Though I understand that this is insane task to make magit clone for Kakoune

1 Like

I am loving Kakoune and want to thank everyone involved and all the contributors. I wish Kakoune would become a mainstream editor.
I am a web developer and I would like a plugin that would work better with HTML.
map -docstring "xml tag object" global object t %{c<lt>([\w.]+)\b[^>]*?(?<lt>!/)>,<lt>/([\w.]+)\b[^>]*?(?<lt>!/)><ret>}

This helps, but theres only so much it can do. A plugin to traverse HTML documents, create, select and manipulate tags would be awesome for web development.
BTW emmet-cli is awesome @Delapouite. Thanks.

One approach to select and edit HTML tags could be to let kak-tree handle it: https://github.com/ul/kak-tree

Also, I can’t remember where I read it, but a tree-sitter like feature may soon be offered by LSP servers themselves, so we may be able to rely on only 1 tool https://github.com/ul/kak-lsp/

2 Likes

Github Copilot plugin, I know some people don’t like it, but it really helps a lot.