From 2357591c14616b15f40d6cabdfc7a526014a97db Mon Sep 17 00:00:00 2001 From: Joe Lencioni Date: Fri, 22 Feb 2019 11:57:52 -0800 Subject: [PATCH] vscode: Configure breadcrumbs to work like vim-vinegar I've been using Vim for a while now and I'm trying out Visual Studio Code. One thing I have been missing a lot is the ability to navigate between files in the way that vim-vinegar enables. Using this plugin in Vim, I can press - and be taken into a file browser, starting in the directory that the current file is in. Selecting a file opens it, and pressing - again traverses up a directory level. https://stackoverflow.com/questions/54834068/replacement-for-vim-vinegar-in-vs-code I think I can replicate the experience I want using breadcrumbs. This commit represents my first attempt at this by: - enabling breadcrumbs - adding a vim normal mode keybinding of `-` to enable and focus breadcrumbs - adding a keyboard shortcut of `-` while breadcrumbs are visible to navigate "up a level" This isn't perfect yet, specifically pressing enter on a directory does nothing, but it is a big step in the right direction. --- vscode/keybindings.json | 7 +++++++ vscode/settings.json | 19 ++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/vscode/keybindings.json b/vscode/keybindings.json index 0d8133d..924c7f1 100644 --- a/vscode/keybindings.json +++ b/vscode/keybindings.json @@ -3,4 +3,11 @@ // From https://code.visualstudio.com/docs/getstarted/userinterface#_working-without-tabs { "key": "cmd+w", "command": "workbench.action.closeEditorsInGroup" }, + + // Make breadcrumbs work more like vim-vinegar + { + "key": "-", + "command": "breadcrumbs.focusPrevious", + "when": "breadcrumbsActive && breadcrumbsVisible", + }, ] diff --git a/vscode/settings.json b/vscode/settings.json index 24bb6be..d003937 100644 --- a/vscode/settings.json +++ b/vscode/settings.json @@ -1,4 +1,6 @@ { + "breadcrumbs.enabled": true, + // Prevent typing things like `.` and `;` from accepting autocomplete suggestions "editor.acceptSuggestionOnCommitCharacter": false, @@ -134,7 +136,22 @@ "args": [] } ] - } + }, + + // vim-vinegar + { + "before": ["-"], + "commands": [ + { + "command": "breadcrumbs.toggleToOn", + "when": "!config.breadcrumbs.enabled", + }, + { + "command": "breadcrumbs.focusAndSelect", + "when": "breadcrumbsPossible", + }, + ], + }, ], /*