From adbc56fb36cf53404bb0730b33bdbb8a0940dbb7 Mon Sep 17 00:00:00 2001 From: Tomas Rivera Date: Tue, 21 Apr 2026 19:17:05 +0200 Subject: [PATCH 1/2] Kakoune: added initial documentation --- README.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index eec4284..4596598 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ Before building NoteWrapper, you must install the following dependencies: You must also have a [supported editor (and their associated plugin if needed)](#editor-support) installed: * `helix` +* `kakoune` * `nano` * `neovim` * `vim` @@ -140,12 +141,13 @@ The first two features depend on [Vivify's editor integration](https://github.co If your editor does not support these features, you can implement a plugin using [Vivify's API](https://github.com/jannis-baum/Vivify?tab=readme-ov-file#editor-support). -| Editor | Bufferless | Cursor | Jump to end | Plugin required | -| ------ | ----------- | ------- | ------------ | --------------------------------------------------------| -| Helix | ❌ | ❌ | ✅ | — | -| Nano | ❌ | ❌ | ✅ | — | -| Neovim | ✅ | ✅ | ✅ | [vivify-vim](https://github.com/jannis-baum/vivify.vim) | -| Vim | ✅ | ✅ | ✅ | [vivify-vim](https://github.com/jannis-baum/vivify.vim) | +| Editor | Bufferless | Cursor | Jump to end | Plugin required | +| --------- | ----------- | ------- | ------------ | --------------------------------------------------------| +| Helix | ❌ | ❌ | ✅ | — | +| Kakoune | ❌ | ❌ | ✅ | — | +| Nano | ❌ | ❌ | ✅ | — | +| Neovim | ✅ | ✅ | ✅ | [vivify-vim](https://github.com/jannis-baum/vivify.vim) | +| Vim | ✅ | ✅ | ✅ | [vivify-vim](https://github.com/jannis-baum/vivify.vim) | [How to add support for another editor](./CONTRIBUTING.md#adding-editor-support) @@ -202,5 +204,5 @@ It is recommended to use a browser different from your main one for rendering. * [ ] A converter between journal types * [ ] Support multiple vault directories -* [ ] Port NoteWrapper to other editors (non-exhaustive list of planned ports: `emacs -nw`, `micro`, `jed`, kakoune, `ad`, flow-control, `ee`, `amp`, `dte`, `cano`, `mle`, `zee`, `ptext`, `kibi`, `ox`, `ne`, `nvi`, `dit`, `zile`, `moe`, `joe`) +* [ ] Port NoteWrapper to other editors (non-exhaustive list of planned ports: `emacs -nw`, `micro`, `jed`, `ad`, flow-control, `ee`, `amp`, `dte`, `cano`, `mle`, `zee`, `ptext`, `kibi`, `ox`, `ne`, `nvi`, `dit`, `zile`, `moe`, `joe`) * [ ] Default to $EDITOR From 3190da3cc52a1d2e282978cd4e43f3d3649b22a9 Mon Sep 17 00:00:00 2001 From: Tomas Rivera Date: Tue, 21 Apr 2026 19:24:27 +0200 Subject: [PATCH 2/2] Kakoune: added initial support --- src/utils.c | 49 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/src/utils.c b/src/utils.c index 3194bae..4b6ed62 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,9 +1,8 @@ #include "utils.h" #include "string.h" -#include -const char *supportedEditor[] = {"helix", "nano", "neovim", "vim"}; -const int numEditors = 4; +const char *supportedEditor[] = {"helix", "kakoune", "nano", "neovim", "vim"}; +const int numEditors = 5; int compareString(const void *a, const void *b) { const char *str1 = *(const char **)a; @@ -207,6 +206,8 @@ int doesEditorExist (char *editorToCheck, int shouldDebug) { // Some exectua editor = strdup("nvim"); // we must use strdup and not just copy as we would have modified editorToOpen in main } else if (strcmp(editorToCheck, "helix") == 0) { editor = strdup("hx"); + } else if (strcmp(editorToCheck, "kakoune") == 0) { + editor = strdup("kak"); } else { editor = strdup(editorToCheck); } @@ -411,6 +412,7 @@ if (editor_pid == 0) { } error(1, "program", "execlp() failed."); + // ---- HELIX ---- } else if (strcmp(editor, "helix") == 0) { // If render enabled → spawn viv in parallel @@ -451,9 +453,48 @@ if (editor_pid == 0) { error(1, "program", "execlp() failed."); } + // ---- kakoune ---- + else if (strcmp(editor, "kakoune") == 0) { + + // If render enabled → spawn viv in parallel + if (render) { + debug("Running the editor..."); + pid_t viv_pid = fork(); + error(viv_pid < 0, "program", "fork() failed."); + + if (viv_pid == 0) { + // GRANDCHILD → viv + + + char viv_path[PATH_MAX]; + strncpy(viv_path, path, PATH_MAX - 1); + viv_path[PATH_MAX - 1] = '\0'; + + if (shouldJumpToEndOfFile) { + strncat(viv_path, ":99999", + PATH_MAX - strlen(viv_path) - 1); + } + + debug("Running viv %s", viv_path); + execlp("viv", "viv", viv_path, NULL); + error(1, "program", "execlp() failed."); + } + // IMPORTANT: do NOT wait for viv + } + + // Now run nano (this replaces the child process) + if (shouldJumpToEndOfFile) { + debug("Running kak + %s", path); + execlp("kak", "kak", "+", path, NULL); + } else { + debug("Running kak %s", path); + execlp("kak", "kak", path, NULL); + } + + error(1, "program", "execlp() failed."); // ---- UNKNOWN EDITOR ---- - else { + } else { error(1, "program", "Unknown editor."); } }