-
Notifications
You must be signed in to change notification settings - Fork 127
/
Copy pathvscode.vim
89 lines (73 loc) · 3.48 KB
/
vscode.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
" ------------------------
" VSCode / Cursor Mappings
" ------------------------
lua << EOF
local vscode = require('vscode')
function action(method, opts)
return function()
vscode.action(method, opts)
end
end
function actions(methods, opts)
return function()
for _, method in ipairs(methods) do
vscode.action(method, opts)
end
end
end
-- Search
vim.keymap.set('n', '<leader>,', actions(
{'workbench.action.quickOpenPreviousRecentlyUsedEditorInGroup',
'workbench.action.acceptSelectedQuickOpenItem'}
))
vim.keymap.set('n', '<leader>fd', action('workbench.actions.view.problems'))
vim.keymap.set('n', '<leader>fR', action('editor.action.goToReferences'))
vim.keymap.set('n', '<leader>m', action('workbench.action.showAllEditorsByMostRecentlyUsed'))
-- Basic
vim.keymap.set('n', '<enter>', action('workbench.action.files.save'))
vim.keymap.set('n', 'gF', action('editor.action.formatDocument'))
vim.keymap.set('n', '<leader>gd', action('git.openChange'))
-- Keep undo/redo in sync with VSCode (for persistent undo and fixes auto
-- write happening with undo)
-- https://github.com/vscode-neovim/vscode-neovim/issues/1139
vim.keymap.set('n', 'u', action('undo'))
vim.keymap.set('n', 'U', action('redo'))
vim.keymap.set('n', '<leader>ss', action('workbench.scm.focus'))
-- LSP
vim.keymap.set('n', '<leader>rn', action('editor.action.rename'))
vim.keymap.set('n', 'gD', action('editor.action.showHover'))
vim.keymap.set('n', '<leader>bb', actions({'editor.action.marker.next', 'editor.action.quickFix'}))
-- Splits
vim.keymap.set('n', '<leader>hs', actions({'workbench.action.splitEditorDown', 'workbench.action.evenEditorWidths'}))
vim.keymap.set('n', '<leader>vs', actions({'workbench.action.splitEditorRight', 'workbench.action.evenEditorWidths'}))
-- Navigation
vim.keymap.set('n', '<f3>', action('workbench.action.focusActiveEditorGroup'))
vim.keymap.set('n', '<f4>', action('workbench.action.terminal.toggleTerminal'))
vim.keymap.set('n', '<leader>nn', action('workbench.action.toggleSidebarVisibility'))
vim.keymap.set('n', '<leader>nf', action('workbench.files.action.showActiveFileInExplorer'))
vim.keymap.set('n', '<up>', '17k', { noremap = true, silent = true })
vim.keymap.set('n', '<down>', '17j', { noremap = true, silent = true })
vim.keymap.set('n', 'gn', actions({'editor.action.marker.next', 'closeMarkersNavigation'}))
vim.keymap.set('n', 'gN', actions({'editor.action.marker.prev', 'closeMarkersNavigation'}))
vim.keymap.set('n', '<leader>gn', action('workbench.action.editor.nextChange'))
vim.keymap.set('n', '<leader>gN', action('workbench.action.editor.previousChange'))
-- Unmap q because I keep getting stuck in macro recording accidentally
vim.keymap.set('n', 'q', '<nop>', { noremap = true })
-- Testing
vim.keymap.set('n', '<leader>tt', action('testing.runAtCursor'))
vim.keymap.set('n', '<leader>td', action('testing.debugAtCursor'))
vim.keymap.set('n', '<leader>tT', action('testing.runCurrentFile'))
vim.keymap.set('n', '<leader>tn', action('testing.goToNextMessage'))
vim.keymap.set('n', '<leader>tN', action('testing.goToPreviousMessage'))
vim.keymap.set('n', '<leader>tc', action('testing.toggleContinuousRunForTest'))
vim.keymap.set('n', '<leader>tf', action('workbench.view.testing.focus'))
-- ----------
-- Extensions
-- ----------
-- Neovim Extension Itself
vim.keymap.set('n', '<leader>nr', action('vscode-neovim.restart'))
-- Periscope
vim.keymap.set('n', '<leader>fr', action('periscope.search'))
-- LazyGit
vim.keymap.set('n', '<leader>gg', action('lazygit-vscode.toggle'))
EOF