nvim-keymap-migrator 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/report.js ADDED
@@ -0,0 +1,81 @@
1
+ // translation report generator
2
+
3
+ function formatKeymap(item) {
4
+ return `${item.lhs ?? "<unknown>"} -> ${item.command ?? item.intent ?? item.raw_rhs ?? "??"}`;
5
+ }
6
+
7
+ export function generateReport(data = {}) {
8
+ const target = data.target ?? "unknown";
9
+ const configPath = data.configPath ?? "unknown";
10
+ const leader = data.leader ?? "<unknown>";
11
+ const translated = Array.isArray(data.translated) ? data.translated : [];
12
+ const pureVim = Array.isArray(data.pureVim) ? data.pureVim : [];
13
+ const manualPlugin = Array.isArray(data.manualPlugin)
14
+ ? data.manualPlugin
15
+ : [];
16
+ const manualOther = Array.isArray(data.manualOther) ? data.manualOther : [];
17
+ const unsupported = Array.isArray(data.unsupported) ? data.unsupported : [];
18
+ const outputs = Array.isArray(data.outputs) ? data.outputs : [];
19
+ const total = Number.isFinite(data.total)
20
+ ? data.total
21
+ : translated.length +
22
+ pureVim.length +
23
+ manualPlugin.length +
24
+ manualOther.length +
25
+ unsupported.length;
26
+
27
+ const lines = [];
28
+ lines.push("=== nvim-keymap-migrator ===");
29
+ lines.push(`Target: ${target}`);
30
+ lines.push(`Config: ${configPath}`);
31
+ lines.push(`Leader: ${leader}`);
32
+ lines.push("");
33
+
34
+ lines.push(`IDE actions (${translated.length}):`);
35
+ if (translated.length === 0) {
36
+ lines.push(" (none)");
37
+ } else {
38
+ translated.forEach((item) => lines.push(` ${formatKeymap(item)}`));
39
+ }
40
+ lines.push("");
41
+
42
+ lines.push(`Pure Vim mappings (${pureVim.length}):`);
43
+ if (pureVim.length === 0) {
44
+ lines.push(" (none)");
45
+ } else {
46
+ pureVim.forEach((item) => lines.push(` ${formatKeymap(item)}`));
47
+ }
48
+ lines.push("");
49
+
50
+ lines.push(`Manual plugin mappings (${manualPlugin.length}):`);
51
+ if (manualPlugin.length === 0) {
52
+ lines.push(" (none)");
53
+ } else {
54
+ manualPlugin.forEach((item) => lines.push(` ${formatKeymap(item)}`));
55
+ }
56
+ lines.push("");
57
+
58
+ lines.push(`Manual (other) mappings (${manualOther.length}):`);
59
+ if (manualOther.length === 0) {
60
+ lines.push(" (none)");
61
+ } else {
62
+ manualOther.forEach((item) => lines.push(` ${formatKeymap(item)}`));
63
+ }
64
+ lines.push("");
65
+
66
+ lines.push(`Unsupported (no intent) (${unsupported.length}):`);
67
+ if (unsupported.length === 0) {
68
+ lines.push(" (none)");
69
+ } else {
70
+ unsupported.forEach((item) => lines.push(` ${formatKeymap(item)}`));
71
+ }
72
+ lines.push("");
73
+
74
+ if (outputs.length > 0) {
75
+ lines.push("Outputs:");
76
+ outputs.forEach((output) => lines.push(` ${output}`));
77
+ lines.push("");
78
+ }
79
+
80
+ return `${lines.join("\n")}\n`;
81
+ }
package/src/utils.js ADDED
@@ -0,0 +1,36 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ const ROOT = fileURLToPath(new URL("..", import.meta.url));
6
+ const TEMPLATES_DIR = join(ROOT, "templates");
7
+
8
+ const MODE_TO_MAP = {
9
+ n: { noremap: "nnoremap", map: "nmap" },
10
+ i: { noremap: "inoremap", map: "imap" },
11
+ v: { noremap: "vnoremap", map: "vmap" },
12
+ x: { noremap: "xnoremap", map: "xmap" },
13
+ s: { noremap: "snoremap", map: "smap" },
14
+ o: { noremap: "onoremap", map: "omap" },
15
+ c: { noremap: "cnoremap", map: "cmap" },
16
+ t: { noremap: "tnoremap", map: "tmap" },
17
+ };
18
+
19
+ function truthy(value) {
20
+ return value === true || value === 1;
21
+ }
22
+
23
+ function readString(value) {
24
+ return typeof value === "string" ? value.trim() : "";
25
+ }
26
+
27
+ function loadDefaults() {
28
+ try {
29
+ const raw = readFileSync(join(TEMPLATES_DIR, "defaults.json"), "utf8");
30
+ return JSON.parse(raw);
31
+ } catch {
32
+ return { keymaps: [] };
33
+ }
34
+ }
35
+
36
+ export { ROOT, TEMPLATES_DIR, MODE_TO_MAP, truthy, readString, loadDefaults };
@@ -0,0 +1,31 @@
1
+ {
2
+ "find files": "navigation.find_files",
3
+ "find file": "navigation.find_files",
4
+ "find-files": "navigation.find_files",
5
+ "switch buffer": "navigation.buffers",
6
+ "buffers": "navigation.buffers",
7
+ "recent files": "navigation.recent_files",
8
+ "recent file": "navigation.recent_files",
9
+ "live grep": "navigation.live_grep",
10
+ "grep": "navigation.live_grep",
11
+ "search in file": "navigation.grep_string",
12
+ "grep string": "navigation.grep_string",
13
+ "go to definition": "lsp.definition",
14
+ "goto definition": "lsp.definition",
15
+ "definition": "lsp.definition",
16
+ "go to references": "lsp.references",
17
+ "find references": "lsp.references",
18
+ "references": "lsp.references",
19
+ "hover": "lsp.hover",
20
+ "show hover": "lsp.hover",
21
+ "rename": "lsp.rename",
22
+ "code action": "lsp.code_action",
23
+ "quick fix": "lsp.code_action",
24
+ "format": "editing.format",
25
+ "format document": "editing.format",
26
+ "comment": "editing.comment_toggle",
27
+ "comment toggle": "editing.comment_toggle",
28
+ "move line up": "editing.move_line_up",
29
+ "move line down": "editing.move_line_down",
30
+ "delete line": "editing.delete_line"
31
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "keymaps": [
3
+ { "lhs": "gd", "mode": "n", "intent": "lsp.definition" },
4
+ { "lhs": "gD", "mode": "n", "intent": "lsp.declaration" },
5
+ { "lhs": "gr", "mode": "n", "intent": "lsp.references" },
6
+ { "lhs": "gi", "mode": "n", "intent": "lsp.implementation" },
7
+ { "lhs": "<C-k>", "mode": "n", "intent": "lsp.signature_help" },
8
+ { "lhs": "[d", "mode": "n", "intent": "lsp.diagnostic_prev" },
9
+ { "lhs": "]d", "mode": "n", "intent": "lsp.diagnostic_next" }
10
+ ]
11
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "editing.format": {
3
+ "vscode": "editor.action.formatDocument",
4
+ "intellij": "ReformatCode"
5
+ },
6
+ "editing.comment_toggle": {
7
+ "vscode": "editor.action.commentLine",
8
+ "intellij": "CommentByLineComment"
9
+ },
10
+ "editing.delete_line": {
11
+ "vscode": "editor.action.deleteLines",
12
+ "intellij": "EditorDeleteLine"
13
+ },
14
+ "editing.move_line_up": {
15
+ "vscode": "editor.action.moveLinesUpAction",
16
+ "intellij": "MoveLineUp"
17
+ },
18
+ "editing.move_line_down": {
19
+ "vscode": "editor.action.moveLinesDownAction",
20
+ "intellij": "MoveLineDown"
21
+ },
22
+ "editing.duplicate_line": {
23
+ "vscode": "editor.action.copyLinesDownAction",
24
+ "intellij": "DuplicateLines"
25
+ },
26
+ "editing.join_lines": {
27
+ "vscode": "editor.action.joinLines",
28
+ "intellij": "JoinLines"
29
+ },
30
+ "editing.replace_with_yank": {
31
+ "vscode": "editor.action.clipboardPasteAction",
32
+ "intellij": "$Paste"
33
+ }
34
+ }
@@ -0,0 +1,38 @@
1
+ {
2
+ "git.fugitive": {
3
+ "vscode": "git.openRepository",
4
+ "intellij": "Vcs.ShowVersionControlIntegration"
5
+ },
6
+ "git.status": {
7
+ "vscode": "git.openChange",
8
+ "intellij": "ActivateVersionControlToolWindow"
9
+ },
10
+ "git.push": {
11
+ "vscode": "git.push",
12
+ "intellij": "Vcs.Push"
13
+ },
14
+ "git.pull": {
15
+ "vscode": "git.pull",
16
+ "intellij": "Vcs.Update"
17
+ },
18
+ "git.commit": {
19
+ "vscode": "git.commit",
20
+ "intellij": "ActivateCommitToolWindow"
21
+ },
22
+ "git.add": {
23
+ "vscode": "git.stage",
24
+ "intellij": "Vcs.Add"
25
+ },
26
+ "git.blame": {
27
+ "vscode": "git.openFile",
28
+ "intellij": "Annotate"
29
+ },
30
+ "git.diff": {
31
+ "vscode": "git.openChange",
32
+ "intellij": "ShowDiff"
33
+ },
34
+ "git.log": {
35
+ "vscode": "git.viewHistory",
36
+ "intellij": "Vcs.ShowTabbedFileHistory"
37
+ }
38
+ }
@@ -0,0 +1,62 @@
1
+ {
2
+ "lsp.definition": {
3
+ "vscode": "editor.action.revealDefinition",
4
+ "intellij": "GotoDeclaration"
5
+ },
6
+ "lsp.declaration": {
7
+ "vscode": "editor.action.goToDeclaration",
8
+ "intellij": "GotoDeclaration"
9
+ },
10
+ "lsp.implementation": {
11
+ "vscode": "editor.action.goToImplementation",
12
+ "intellij": "GotoImplementation"
13
+ },
14
+ "lsp.references": {
15
+ "vscode": "editor.action.goToReferences",
16
+ "intellij": "FindUsages"
17
+ },
18
+ "lsp.hover": {
19
+ "vscode": "editor.action.showHover",
20
+ "intellij": "QuickImplementations"
21
+ },
22
+ "lsp.rename": {
23
+ "vscode": "editor.action.rename",
24
+ "intellij": "RenameElement"
25
+ },
26
+ "lsp.code_action": {
27
+ "vscode": "editor.action.quickFix",
28
+ "intellij": "ShowIntentionActions"
29
+ },
30
+ "lsp.format": {
31
+ "vscode": "editor.action.formatDocument",
32
+ "intellij": "ReformatCode"
33
+ },
34
+ "lsp.signature_help": {
35
+ "vscode": "editor.action.triggerParameterHints",
36
+ "intellij": "ParameterInfo"
37
+ },
38
+ "lsp.type_definition": {
39
+ "vscode": "editor.action.goToTypeDefinition",
40
+ "intellij": "GotoTypeDeclaration"
41
+ },
42
+ "lsp.add_workspace_folder": {
43
+ "vscode": "workbench.action.addRootFolder",
44
+ "intellij": "AddNewProjectToWorkspace"
45
+ },
46
+ "lsp.remove_workspace_folder": {
47
+ "vscode": "workbench.action.removeRootFolder",
48
+ "intellij": "RemoveProjectFromWorkspace"
49
+ },
50
+ "lsp.diagnostic_next": {
51
+ "vscode": "editor.action.marker.next",
52
+ "intellij": "GotoNextError"
53
+ },
54
+ "lsp.diagnostic_prev": {
55
+ "vscode": "editor.action.marker.prev",
56
+ "intellij": "GotoPreviousError"
57
+ },
58
+ "lsp.diagnostic_setloclist": {
59
+ "vscode": "workbench.actions.view.problems",
60
+ "intellij": "ViewProblems"
61
+ }
62
+ }
@@ -0,0 +1,50 @@
1
+ {
2
+ "navigation.file_explorer": {
3
+ "vscode": "workbench.action.toggleSidebarVisibility",
4
+ "intellij": "ActivateProjectToolWindow"
5
+ },
6
+ "navigation.find_files": {
7
+ "vscode": "workbench.action.quickOpen",
8
+ "intellij": "GotoFile"
9
+ },
10
+ "navigation.live_grep": {
11
+ "vscode": "workbench.action.findInFiles",
12
+ "intellij": "FindInPath"
13
+ },
14
+ "navigation.buffers": {
15
+ "vscode": "workbench.action.showAllEditors",
16
+ "intellij": "RecentFiles"
17
+ },
18
+ "navigation.recent_files": {
19
+ "vscode": "workbench.action.openRecent",
20
+ "intellij": "RecentFiles"
21
+ },
22
+ "navigation.help_tags": {
23
+ "vscode": "workbench.action.openDocumentation",
24
+ "intellij": "HelpTopics"
25
+ },
26
+ "navigation.keymaps": {
27
+ "vscode": "workbench.action.openGlobalKeybindings",
28
+ "intellij": "KeymapReference"
29
+ },
30
+ "navigation.grep_string": {
31
+ "vscode": "editor.action.search.selection.wildcard",
32
+ "intellij": "FindWordAtCaret"
33
+ },
34
+ "navigation.buffer_search": {
35
+ "vscode": "editor.actions.findWithArgs",
36
+ "intellij": "Find"
37
+ },
38
+ "navigation.resume_search": {
39
+ "vscode": "workbench.action.quickOpenNavigateNext",
40
+ "intellij": "SearchAgain"
41
+ },
42
+ "navigation.diagnostics": {
43
+ "vscode": "workbench.actions.view.problems",
44
+ "intellij": "ViewProblems"
45
+ },
46
+ "navigation.command_history": {
47
+ "vscode": "workbench.action.openRecent",
48
+ "intellij": "GotoAction"
49
+ }
50
+ }