Skip to content

Commit

Permalink
Add variable VIM and LUA
Browse files Browse the repository at this point in the history
  • Loading branch information
uga-rosa committed Dec 23, 2023
1 parent 6427b02 commit 35787f3
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
8 changes: 8 additions & 0 deletions denops/denippet/variable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,11 @@ register("LINE_COMMENT", async (denops) => {
}
return "";
});

register("VIM", async (denops, text) => {
return String(await denops.eval(text).catch(() => ""));
});

register("LUA", async (denops, text) => {
return String(await denops.call("luaeval", text).catch(() => ""));
});
18 changes: 18 additions & 0 deletions denops/denippet/variable_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,5 +274,23 @@ test({
assertEquals(actual, "//");
},
});

await t.step({
name: "VIM",
fn: async () => {
const actual = await V.call(denops, "VIM", "['foo', 'bar'][0]");
assertEquals(actual, "foo");
},
});

if (denops.meta.host === "nvim") {
await t.step({
name: "LUA",
fn: async () => {
const actual = await V.call(denops, "LUA", "math.floor(1.234)");
assertEquals(actual, "1");
},
});
}
},
});
10 changes: 10 additions & 0 deletions doc/denippet.txt
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,16 @@ Variables ~
A list of variables is here.
https://code.visualstudio.com/docs/editor/userdefinedsnippets#_variables

The original variables are as follows:
- VIM Eval default string as Vim script. >
${VIM:['foo', 'bar'][0]}
// -> foo
<
- LUA Eval default string as Lua. >
${LUA:math.floor(1.234)}
// -> 1
<

Transformer ~

Variable-Transform ~
Expand Down

0 comments on commit 35787f3

Please sign in to comment.