mirror of
https://github.com/tomasriveral/NoteWrapper.git
synced 2026-08-12 10:20:46 +02:00
Merge (#5) from tomasriveral/micro. Adds micro support
Micro: added initial support
This commit is contained in:
@@ -44,6 +44,7 @@ You must also have a [supported editor (and their associated plugin if needed)](
|
|||||||
|
|
||||||
* `helix`
|
* `helix`
|
||||||
* `kakoune`
|
* `kakoune`
|
||||||
|
* `micro`
|
||||||
* `nano`
|
* `nano`
|
||||||
* `neovim`
|
* `neovim`
|
||||||
* `vim`
|
* `vim`
|
||||||
@@ -141,13 +142,14 @@ 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 |
|
||||||
| --------- | ----------- | ------- | ------------ | --------------------------------------------------------|
|
| --------- | ----------- | ------- | ------------ | ---------------------------------------------------------|
|
||||||
| Helix | ❌ | ❌ | ✅ | — |
|
| Helix | ❌ | ❌ | ✅ | — |
|
||||||
| Kakoune | ❌ | ❌ | ✅ | — |
|
| Kakoune | ❌ | ❌ | ✅ | — |
|
||||||
| Nano | ❌ | ❌ | ✅ | — |
|
| Micro | ❌ | ✅ | ✅ | [micro-vivify](https://codeberg.org/gibbert/micro-vivify) and [modifications to your `init.lua`](./docs/micro.md)|
|
||||||
| Neovim | ✅ | ✅ | ✅ | [vivify-vim](https://github.com/jannis-baum/vivify.vim) |
|
| Nano | ❌ | ❌ | ✅ | — |
|
||||||
| Vim | ✅ | ✅ | ✅ | [vivify-vim](https://github.com/jannis-baum/vivify.vim) |
|
| 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)
|
[How to add support for another editor](./CONTRIBUTING.md#adding-editor-support)
|
||||||
|
|
||||||
@@ -204,5 +206,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 (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`)
|
* [ ] 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`, `nvi`, `dit`, `zile`, `moe`, `joe`)
|
||||||
* [ ] Default to $EDITOR
|
* [ ] Default to $EDITOR
|
||||||
|
|||||||
@@ -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).
|
||||||
|
|
||||||
+26
-2
@@ -1,8 +1,8 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
const char *supportedEditor[] = {"helix", "kakoune", "nano", "neovim", "vim"};
|
const char *supportedEditor[] = {"helix", "kakoune", "micro", "nano", "neovim", "vim"};
|
||||||
const int numEditors = 5;
|
const int numEditors = 6;
|
||||||
|
|
||||||
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;
|
||||||
@@ -376,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.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user