Compare commits

...
16 Commits
Author SHA1 Message Date
tomasrandGitHub 0eac451751 Merge (#6) from tomasriveral/vi. Adds vi support
Vi: added initial support
2026-04-22 19:18:16 +02:00
tomasr 9d7e2efe17 Vi: added initial support 2026-04-22 19:15:02 +02:00
tomasr 0b92270e15 Vi: added initial documentation 2026-04-22 19:06:48 +02:00
tomasr 7db5bfb44a Docs: updated list of planned ports 2026-04-22 19:04:54 +02:00
tomasrandGitHub eceaf723f1 Merge (#5) from tomasriveral/micro. Adds micro support
Micro: added initial support
2026-04-22 18:41:01 +02:00
tomasr cb6ac9bce6 Micro: added initial support 2026-04-22 18:37:31 +02:00
tomasr 847f0dae5d Micro: added initial documentation 2026-04-22 18:24:35 +02:00
tomasrandGitHub 411ed0939a Merge (#4) from tomasriveral/backup-broken. Fixes (#3)
Backup: Fix (#3) rsync arguments were not stored correcly
2026-04-22 12:03:39 +02:00
tomasr 83008d8da8 Backup: Fix (#3) rsync arguments were not stored correcly 2026-04-22 12:00:47 +02:00
tomasrandGitHub 44f14803e0 Merge (#2) from tomasriveral/kakoune. Adds Kakoune support.
Kakoune: added initial support
2026-04-21 19:26:49 +02:00
tomasr 3190da3cc5 Kakoune: added initial support 2026-04-21 19:24:27 +02:00
tomasr adbc56fb36 Kakoune: added initial documentation 2026-04-21 19:17:05 +02:00
tomasrandGitHub 9ad71fb4f5 Merge (#1) from tomasriveral/helix. Adds helix support.
Helix: added initial support
2026-04-20 18:44:29 +02:00
tomasr 5aee1f540c Helix: added initial support 2026-04-20 18:41:32 +02:00
tomasr f131316fa7 Docs: Reformatted editor support 2026-04-20 17:55:06 +02:00
tomasr 7ced9e735f Doc: Added planned editors 2026-04-20 12:06:11 +02:00
4 changed files with 210 additions and 18 deletions
+19 -10
View File
@@ -22,7 +22,7 @@ The goal was to create a terminal-based interface for accessing vaults and notes
* Journal support with flexible entry formats * Journal support with flexible entry formats
* Real-time Markdown rendering via Vivify * Real-time Markdown rendering via Vivify
* Backup support using `rsync` * Backup support using `rsync`
* Supports multiple editors (vim, neovim, nano) * Supports multiple editors
--- ---
@@ -40,11 +40,15 @@ Before building NoteWrapper, you must install the following dependencies:
* `ripgrep` * `ripgrep`
* `fzf` * `fzf`
You must also have a [supported editor](#editor-support) installed: You must also have a [supported editor (and their associated plugin if needed)](#editor-support) installed:
* `vim` * `helix`
* `neovim` * `kakoune`
* `micro`
* `nano` * `nano`
* `neovim`
* `vi`
* `vim`
--- ---
@@ -139,11 +143,15 @@ 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). 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 | | Editor | Bufferless | Cursor | Jump to end | Aditional requirements |
| ------ | ---------- | ------ | ----------- | ------------------------------------------------------- | | --------- | ----------- | ------- | ------------ | ---------------------------------------------------------|
| Neovim | | | ✅ | [vivify-vim](https://github.com/jannis-baum/vivify.vim) | | Helix | | | ✅ | |
| Vim | | | ✅ | [vivify-vim](https://github.com/jannis-baum/vivify.vim) | | Kakoune | | | ✅ | |
| Nano | ❌ | | ✅ | | | Micro | ❌ | | ✅ | [micro-vivify](https://codeberg.org/gibbert/micro-vivify) and [modifications to your `init.lua`](./docs/micro.md)|
| Nano | ❌ | ❌ | ✅ | — |
| Neovim | ✅ | ✅ | ✅ | [vivify-vim](https://github.com/jannis-baum/vivify.vim) |
| Vi | ❌ | ❌ | ✅ | |
| Vim | ✅ | ✅ | ✅ | [vivify-vim](https://github.com/jannis-baum/vivify.vim) |
[How to add support for another editor](./CONTRIBUTING.md#adding-editor-support) [How to add support for another editor](./CONTRIBUTING.md#adding-editor-support)
@@ -200,4 +208,5 @@ It is recommended to use a browser different from your main one for rendering.
* [ ] A converter between journal types * [ ] A converter between journal types
* [ ] Support multiple vault directories * [ ] Support multiple vault directories
* [ ] Port NoteWrapper to other editors * [ ] Port NoteWrapper to other editors (non-exhaustive list of planned ports: `emacs -nw`, `jed`, `ad`, flow-control, `ee`, `amp`, `dte`, `cano`, `mle`, `zee`, `ptext`, `kibi`, `ox`, `ne`, `dit`, `zile`, `moe`, `joe`, `pico`, `vis`)
* [ ] Default to $EDITOR
+28
View File
@@ -0,0 +1,28 @@
You must add the following code to your `init.lua`:
```lua
local buffer = import("micro/buffer")
local shell = import("micro/shell")
function vivifyOpen(buf)
local cursor = buf:GetActiveCursor()
local line = cursor.Loc.Y + 1
shell.ExecCommand("viv", string.format("%s:%d", buf.AbsPath, line))
end
function onBufferOpen(buf)
if os.getenv("MICRO_VIVIFY") ~= "1" then
return
end
if buf.Type.Kind == buffer.BTDefault then
vivifyOpen(buf)
end
end
```
This enables Vivify to run automatically when a file is opened, effectively simulating “startup” behavior (since Micro does not provide a true startup command hook for this use case).
Big thanks to @Andriamanitra for answering [my questions](https://github.com/micro-editor/micro/discussions/4078).
+4 -1
View File
@@ -221,11 +221,14 @@ arg_next:
cJSON *rsyncArgsJSON = cJSON_GetObjectItem(backupJSON, "rsyncArgs"); cJSON *rsyncArgsJSON = cJSON_GetObjectItem(backupJSON, "rsyncArgs");
if (rsyncArgsJSON && cJSON_IsArray(rsyncArgsJSON)) { // if it is what we expected if (rsyncArgsJSON && cJSON_IsArray(rsyncArgsJSON)) { // if it is what we expected
rsyncArgsNumber = cJSON_GetArraySize(rsyncArgsJSON); rsyncArgsNumber = cJSON_GetArraySize(rsyncArgsJSON);
debug("In %s, rsyncArgsNumber is calculated to %d.", configPath, rsyncArgsNumber);
rsyncArgs = realloc(rsyncArgs, (size_t)rsyncArgsNumber); rsyncArgs = realloc(rsyncArgs, (size_t)rsyncArgsNumber);
debug("In %c, rsyncArgs are:", configPath);
for (int i = 0; i < rsyncArgsNumber; i++) { for (int i = 0; i < rsyncArgsNumber; i++) {
cJSON *argJSON = cJSON_GetArrayItem(rsyncArgsJSON, i); cJSON *argJSON = cJSON_GetArrayItem(rsyncArgsJSON, i);
if (argJSON && cJSON_IsString(argJSON)) { if (argJSON && cJSON_IsString(argJSON)) {
rsyncArgs[i] = cJSON_GetStringValue(argJSON); rsyncArgs[i] = strdup(cJSON_GetStringValue(argJSON));
altDebug("%s\n", rsyncArgs[i]);
} else {error(1, "user", "One element in rsyncArgs array in %s is not a string", configPath);} } else {error(1, "user", "One element in rsyncArgs array in %s is not a string", configPath);}
} }
} else {error(1, "user", "%s did not contained a rsyncArgs array inside the backup section or the value is from an unexpected type", configPath);} } else {error(1, "user", "%s did not contained a rsyncArgs array inside the backup section or the value is from an unexpected type", configPath);}
+159 -7
View File
@@ -1,8 +1,8 @@
#include "utils.h" #include "utils.h"
#include <stddef.h> #include "string.h"
const char *supportedEditor[] = {"neovim", "vim", "nano"}; const char *supportedEditor[] = {"helix", "kakoune", "micro", "nano", "neovim", "vi", "vim"};
const int numEditors = 3; const int numEditors = 7;
int compareString(const void *a, const void *b) { int compareString(const void *a, const void *b) {
const char *str1 = *(const char **)a; const char *str1 = *(const char **)a;
@@ -73,6 +73,7 @@ void _error(const int shouldDebug, const int condition, const char *type, const
static void copyDir(const char *source, const char *destination, const char **rsyncArgs, const int rsyncArgsNumber, const int shouldDebug) { static void copyDir(const char *source, const char *destination, const char **rsyncArgs, const int rsyncArgsNumber, const int shouldDebug) {
debug("Backuping... source: %s and destination: %s", source, destination); debug("Backuping... source: %s and destination: %s", source, destination);
debug("Rsync has %d extra arguments", rsyncArgsNumber);
pid_t pid = fork(); pid_t pid = fork();
error(pid < 0, "program", "fork() faild. pid = %d", pid); error(pid < 0, "program", "fork() faild. pid = %d", pid);
@@ -87,6 +88,11 @@ static void copyDir(const char *source, const char *destination, const char **rs
args[i+2] = (char*)source; args[i+2] = (char*)source;
args[i+3] = (char*)destination; args[i+3] = (char*)destination;
args[i+4] = NULL; // execvp expect last arg to be NULL args[i+4] = NULL; // execvp expect last arg to be NULL
debug("rsync command:");
for (int k = 0; k <= i+4; k++) {
altDebug("%s ", args[k]);
}
altDebug("\n");
} }
} }
execvp("rsync", args); execvp("rsync", args);
@@ -204,8 +210,11 @@ int doesEditorExist (char *editorToCheck, int shouldDebug) { // Some exectua
char *editor; char *editor;
if (strcmp(editorToCheck, "neovim") == 0) { if (strcmp(editorToCheck, "neovim") == 0) {
editor = strdup("nvim"); // we must use strdup and not just copy as we would have modified editorToOpen in main 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) {
else { editor = strdup("hx");
} else if (strcmp(editorToCheck, "kakoune") == 0) {
editor = strdup("kak");
} else {
editor = strdup(editorToCheck); editor = strdup(editorToCheck);
} }
char *path_env = getenv("PATH"); char *path_env = getenv("PATH");
@@ -338,6 +347,8 @@ int openEditor(char *path, char *editor, int render, int shouldJumpToEndOfFile,
pid_t editor_pid = fork(); pid_t editor_pid = fork();
error(editor_pid < 0, "program", "fork() failed."); error(editor_pid < 0, "program", "fork() failed.");
// instead of reusing part of the codes, for any new editor copy an example and adapt it. This is in case we need a custom fix for an editor.
if (editor_pid == 0) { if (editor_pid == 0) {
// ========================= // =========================
// CHILD: launch editor // CHILD: launch editor
@@ -365,6 +376,30 @@ if (editor_pid == 0) {
} }
} }
error(1, "program", "execlp() failed.");
// ---- MICRO ----
} else if (strcmp(editor, "micro") == 0) {
if (render) {
if (shouldJumpToEndOfFile) {
debug("Running MICRO_VIVIFY=1 micro %s +99999", path);
setenv("MICRO_VIVIFY", "1", 1);
execlp("micro", "micro", path, "+999999", NULL);
} else {
debug("Running MICRO_VIVIFY=1 micro %s", path);
setenv("MICRO_VIVIFY", "1", 1);
execlp("micro", "micro", path, NULL);
}
} else {
if (shouldJumpToEndOfFile) {
debug("Running micro %s +999999", path);
execlp("micro", "micro", path, "+999999", NULL);
} else {
debug("Running micro %s", path);
execlp("micro", "micro", path, NULL);
}
}
error(1, "program", "execlp() failed."); error(1, "program", "execlp() failed.");
} }
@@ -407,10 +442,127 @@ if (editor_pid == 0) {
} }
error(1, "program", "execlp() failed."); error(1, "program", "execlp() failed.");
} // ---- HELIX ----
} else if (strcmp(editor, "helix") == 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 helix (this replaces the child process)
if (shouldJumpToEndOfFile) {
strncat(path, ":99999", PATH_MAX);
debug("Running hx %s", path);
execlp("hx", "hx", path, NULL);
} else {
debug("Running hx %s", path);
execlp("hx", "hx", path, NULL);
}
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.");
// ---- VI ----
} else if (strcmp(editor, "vi") == 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 vi (this replaces the child process)
if (shouldJumpToEndOfFile) {
debug("Running vi +:$ %s", path);
execlp("vi", "vi", "+:$", path, NULL);
} else {
debug("Running vi %s", path);
execlp("vi", "vi", path, NULL);
}
error(1, "program", "execlp() failed.");
// ---- UNKNOWN EDITOR ---- // ---- UNKNOWN EDITOR ----
else { } else {
error(1, "program", "Unknown editor."); error(1, "program", "Unknown editor.");
} }
} }