Skip to content

Commit

Permalink
feat: better mappings for user args
Browse files Browse the repository at this point in the history
  • Loading branch information
danielo515 committed Mar 13, 2023
1 parent 5607e1a commit 422330a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions haxelib.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"externs"
],
"description": "Create neovim plugins using Haxe",
"version": "0.2.1",
"version": "0.2.2",
"classPath": "src/",
"releasenote": "properly working as a lib",
"releasenote": "better user arguments support",
"contributors": [
"danielo515"
],
Expand Down
8 changes: 6 additions & 2 deletions src/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function main() {
desc: "Testing from haxe for completion callback",
force: true,
bang: true,
nargs: ExactlyOne,
nargs: Any,
range: WholeFile,
complete: (lead:String, full:String, x:Int) -> {
Vim.print(lead, full, x);
Expand All @@ -65,7 +65,11 @@ function main() {
command(
"OpenInGh",
"Open the current file in github",
args -> openInGh(args.count > 0 ? ':${args.count}' : "")
args -> openInGh(switch (args.range) {
case 1: ':${args.line1}';
case 2: ':${args.line1}-${args.line2}';
case _: "";
})
);
command(
"CopyGhUrl",
Expand Down
2 changes: 2 additions & 0 deletions src/vim/Api.hx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ typedef CommandCallbackArgs = {
final line1:Int;
final line2:Int;
final count:Int;
/* If the command is a range command, this is the number of range edges 0-2 */
final range:Int;
final reg:String;
final mods:String;
}
Expand Down

0 comments on commit 422330a

Please sign in to comment.