Skip to content

Instantly share code, notes, and snippets.

@kensleDev
Last active May 3, 2024 14:56
Show Gist options
  • Save kensleDev/704c75fc22863a1c3a20fdc6e935e5e0 to your computer and use it in GitHub Desktop.
Save kensleDev/704c75fc22863a1c3a20fdc6e935e5e0 to your computer and use it in GitHub Desktop.
VSCode + Neovim config
// Place your key bindings in this file to override the defaults
[
// Switches
{
"key": "alt+i",
"command": "workbench.action.toggleMaximizedPanel"
},
{
"key": "alt+b",
"command": "extension.toggleBool",
"when": "editorTextFocus"
},
{
"key": "space",
"command": "whichkey.show",
"when": "neovim.init && neovim.mode == normal && editorTextFocus"
},
// focus
{
"key": "ctrl+shift+c",
"command": "workbench.panel.chat.view.copilot.focus"
},
// navigation
{
"key": "alt+m",
"command": "workbench.action.navigateLeft"
},
{
"key": "alt+,",
"command": "workbench.action.navigateDown"
},
{
"key": "alt+.",
"command": "workbench.action.navigateUp"
},
{
"key": "alt+/",
"command": "workbench.action.navigateRight"
},
// File tree / explorer
{
"key": "r",
"command": "renameFile",
"when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
},
{
"key": "d",
"command": "deleteFile",
"when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
},
{
"key": "c",
"command": "explorer.newFile",
"when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
},
{
"key": "shift+c",
"command": "explorer.newFolder",
"when": "filesExplorerFocus && !inputFocus"
},
{
"key": ",",
"command": "list.focusDown",
"when": "listFocus && explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
},
{
"key": ".",
"command": "list.focusUp",
"when": "listFocus && explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
},
{
"key": "enter",
"command": "list.select",
"when": "explorerViewletVisible && filesExplorerFocus"
},
{
"key": "h",
"command": "list.collapse",
"when": "explorerViewletVisible && filesExplorerFocus && !inputFocus"
}
]
"workbench.sideBar.location": "right",
"extensions.experimental.affinity": {
"asvetliakov.vscode-neovim": 1
},
"explorer.confirmPasteNative": false,
// which key
"whichkey.delay": 0,
"whichkey.sortOrder": "alphabetically",
"whichkey.bindings": [
// general
{
"key": "w",
"name": "Write File",
"type": "command",
"command": "workbench.action.files.save"
},
{
"key": "q",
"name": "Close file",
"type": "command",
"command": "workbench.action.closeActiveEditor"
},
{
"key": "n",
"name": "Previous Editor",
"type": "command",
"command": "workbench.action.previousEditor"
},
{
"key": "m",
"name": "Next Editor",
"type": "command",
"command": "workbench.action.nextEditor"
},
{
"key": "x",
"name": "Close editor",
"type": "command",
"command": "workbench.action.closeWindow"
},
{
"key": "a",
"name": "💀 Action",
"type": "bindings",
"bindings": [
{
"key": ";",
"name": "Next error",
"type": "command",
"command": "editor.action.marker.next"
},
{
"key": "j",
"name": "Previous error",
"type": "command",
"command": "editor.action.marker.prev"
}
]
},
{
"key": "g",
"name": "➕ Git",
"type": "bindings",
"bindings": [
{
"key": "g",
"name": "Git View",
"type": "command",
"command": "workbench.view.scm"
},
{
"key": "g",
"name": "Git Graph",
"type": "command",
"command": "git-graph.view"
},
{
"key": "c",
"name": "Git Commit",
"type": "command",
"command": "extension.conventionalCommits"
}
]
},
{
"key": "f",
"name": "🔎 Find/Files",
"type": "bindings",
"bindings": [
{
"key": "n",
"name": "New file",
"type": "command",
"command": "extension.advancedNewFile"
},
{
"key": "a",
"name": "In files",
"type": "command",
"command": "workbench.action.findInFiles"
},
{
"key": "r",
"name": "Replace in file",
"type": "command",
"command": "editor.action.startFindReplaceAction"
},
{
"key": "R",
"name": "Replace in files",
"type": "command",
"command": "workbench.action.replaceInFiles"
}
]
},
{
"key": "t",
"name": "➕ Terminal",
"type": "bindings",
"bindings": [
{
"key": "c",
"name": "Create",
"type": "command",
"command": "workbench.action.terminal.new"
},
{
"key": "n",
"name": "Next",
"type": "command",
"command": "workbench.action.terminal.focusNext"
},
{
"key": "p",
"name": "Previous",
"type": "command",
"command": "workbench.action.terminal.focusPrevious"
},
{
"key": "x",
"name": "Kill",
"type": "command",
"command": "workbench.action.terminal.kill"
},
{
"key": "v",
"name": "Split",
"type": "command",
"command": "workbench.action.terminal.split"
}
// {
// "key": "m",
// "name": "Maximize",
// "type": "command",
// "command": "macros.viewTerminal"
// },
]
}
],
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[rust]": {
"editor.tabSize": 2,
"editor.wordWrapColumn": 100,
"editor.rulers": [100]
},
"[lua]": {
"editor.wordWrapColumn": 100,
"editor.tabSize": 2,
"editor.rulers": [100]
},
"editor.rulers": [80],
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"workbench.colorTheme": "SynthWave '84",
"svelte.enable-ts-plugin": true
}
-- options
--
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
-- keymaps
--
vim.opt.hlsearch = true
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
local opts = {
noremap = true,
silent = true
}
vim.api.nvim_set_keymap('n', 'j', 'h', opts)
vim.api.nvim_set_keymap('n', 'k', 'j', opts)
vim.api.nvim_set_keymap('n', 'l', 'k', opts)
vim.api.nvim_set_keymap('n', ';', 'l', opts)
-- plugins
--
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
vim.fn.system {'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath}
end ---@diagnostic disable-next-line: undefined-field
vim.opt.rtp:prepend(lazypath)
-- require("lazy").setup("plugins")
require("lazy").setup({{
'folke/flash.nvim',
event = 'VeryLazy',
vscode = true,
---@type Flash.Config
opts = {},
-- stylua: ignore
keys = {{
"s",
mode = {"n", "x", "o"},
function()
require("flash").jump()
end,
desc = "Flash"
}, {
"S",
mode = {"n", "o", "x"},
function()
require("flash").treesitter()
end,
desc = "Flash Treesitter"
}, {
"r",
mode = "o",
function()
require("flash").remote()
end,
desc = "Remote Flash"
}, {
"R",
mode = {"o", "x"},
function()
require("flash").treesitter_search()
end,
desc = "Treesitter Search"
}, {
"<c-s>",
mode = {"c"},
function()
require("flash").toggle()
end,
desc = "Toggle Flash Search"
}}
}, { -- Collection of various small independent plugins/modules
'echasnovski/mini.nvim',
config = function()
-- Better Around/Inside textobjects
--
-- Examples:
-- - va) - [V]isually select [A]round [)]paren
-- - yinq - [Y]ank [I]nside [N]ext [']quote
-- - ci' - [C]hange [I]nside [']quote
require('mini.ai').setup {
n_lines = 500
}
-- require('mini.braketed').setup()
require('mini.surround').setup({
mappings = {
add = '<leader>sa', -- Add surrounding in Normal and Visual modes
delete = '<leader>sd', -- Delete surrounding
find = '<leader>sf', -- Find surrounding (to the right)
find_left = '<leader>sF', -- Find surrounding (to the left)
highlight = '<leader>sh', -- Highlight surrounding
replace = '<leader>sr', -- Replace surrounding
update_n_lines = '<leader>sn', -- Update `n_lines`
suffix_last = 'p', -- Suffix to search with "prev" method
suffix_next = 'n' -- Suffix to search with "next" method
}
})
end
}, {
"monaqa/dial.nvim",
keys = {{
"<c-a>",
mode = "n",
function()
require("dial.map").manipulate("increment", "normal")
end,
desc = "Increment"
}, {
"<c-x>",
mode = "n",
function()
require("dial.map").manipulate("decrement", "normal")
end,
desc = "Decrement"
}, {
"g<c-a>",
mode = "n",
function()
require("dial.map").manipulate("increment", "gnormal")
end,
desc = "Increment (jump)"
}, {
"g<c-x>",
mode = "n",
function()
require("dial.map").manipulate("decrement", "gnormal")
end,
desc = "Decrement (jump)"
}}
}})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment