Skip to content

Commit 178d2ab

Browse files
authored
feat: Add config to disable '_' keybind (#50)
1 parent 893ee80 commit 178d2ab

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
{
109109
"command": "oil-code.openCwd",
110110
"key": "shift+-",
111-
"when": "editorTextFocus && editorLangId == oil && vim.mode == 'Normal'"
111+
"when": "editorTextFocus && editorLangId == oil && vim.mode == 'Normal' && !config.oil-code.disableUnderscoreOpenCwd"
112112
},
113113
{
114114
"command": "oil-code.preview",
@@ -146,6 +146,11 @@
146146
"default": false,
147147
"description": "Disable all Vim keymaps for oil.code. Default is false. Set this to true if you want to set your own keymaps. Reload after changing this setting."
148148
},
149+
"oil-code.disableUnderscoreOpenCwd": {
150+
"type": "boolean",
151+
"default": false,
152+
"description": "Disable the '_' (underscore) keybind for opening the current working directory in oil buffers. When disabled, '_' will behave as normal Vim motion (first non-blank character of line). Default is false. Reload after changing this setting."
153+
},
149154
"oil-code.disableOpenCwdNothingOpen": {
150155
"type": "boolean",
151156
"default": false,

src/utils/settings.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ export function getDisableOpenCwdNothingOpenSetting(): boolean {
1010
return config.get<boolean>("disableOpenCwdNothingOpen") || false;
1111
}
1212

13+
export function getdisableUnderscoreOpenCwdSetting(): boolean {
14+
const config = vscode.workspace.getConfiguration("oil-code");
15+
return config.get<boolean>("disableUnderscoreOpenCwd") || false;
16+
}
17+
1318
export function getEnableWorkspaceEditSetting(): boolean {
1419
const config = vscode.workspace.getConfiguration("oil-code");
1520
return config.get<boolean>("enableWorkspaceEdit") || false;

src/vim/oil.code.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ vim.api.nvim_create_autocmd({'FileType'}, {
1212
pattern = {"oil"},
1313
callback = function()
1414
map("n", "-", function() vscode.action('oil-code.openParent') end)
15-
map("n", "_", function() vscode.action('oil-code.openCwd') end)
15+
16+
local disableUnderscoreOpenCwd = vscode.get_config('oil-code.disableUnderscoreOpenCwd')
17+
if not disableUnderscoreOpenCwd then
18+
map("n", "_", function() vscode.action('oil-code.openCwd') end)
19+
end
20+
1621
map("n", "<CR>", function() vscode.action('oil-code.select') end)
1722
map("n", "<C-t>", function() vscode.action('oil-code.selectTab') end)
1823
map("n", "<C-l>", function() vscode.action('oil-code.refresh') end)

0 commit comments

Comments
 (0)