From 6a47ac33f5959651fb5a050c05c55ece722fc536 Mon Sep 17 00:00:00 2001 From: sgoudham Date: Sun, 9 Jul 2023 01:55:59 +0100 Subject: [PATCH] feat: add VsCode config --- home/apps/vscode/keybindings.json | 224 ++++++++++++++++++++++++++++++ home/apps/vscode/settings.json | 202 +++++++++++++++++++++++++++ home/default.nix | 5 + 3 files changed, 431 insertions(+) create mode 100644 home/apps/vscode/keybindings.json create mode 100644 home/apps/vscode/settings.json diff --git a/home/apps/vscode/keybindings.json b/home/apps/vscode/keybindings.json new file mode 100644 index 0000000..52d2c63 --- /dev/null +++ b/home/apps/vscode/keybindings.json @@ -0,0 +1,224 @@ +// Place your key bindings in this file to override the defaults +[ + // Explorer - Functionality + { + "key": "l", + "command": "workbench.explorer.fileView.focus", + "when": "!editorFocus && !inputFocus" + }, + { + "key": "a", + "command": "explorer.newFile", + "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !inputFocus" + }, + { + "key": "shift+a", + "command": "explorer.newFolder", + "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !inputFocus" + }, + { + "key": "y", + "command": "filesExplorer.copy", + "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !inputFocus" + }, + { + "key": "x", + "command": "filesExplorer.cut", + "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !inputFocus" + }, + { + "key": "p", + "command": "filesExplorer.paste", + "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceReadonly && !inputFocus" + }, + { + "key": "r", + "command": "renameFile", + "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus" + }, + { + "key": "d", + "command": "moveFileToTrash", + "when": "explorerResourceMoveableToTrash && explorerViewletVisible && filesExplorerFocus && !explorerResourceReadonly && !inputFocus" + }, + { + "key": "shift+d", + "command": "deleteFile", + "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceReadonly && !inputFocus" + }, + { + "key": "c", + "command": "workbench.files.action.collapseExplorerFolders", + "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceReadonly && !inputFocus" + }, + { + "key": "s", + "command": "explorer.openToSide", + "when": "explorerViewletFocus && explorerViewletVisible && !inputFocus" + }, + { + "key": "f", + "command": "revealFileInOS", + "when": "explorerViewletFocus && explorerViewletVisible && !inputFocus" + }, + { + "key": "t", + "command": "openInTerminal", + "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !inputFocus" + }, + { + "key": "u", + "command": "copyFilePath", + "when": "explorerViewletFocus && explorerViewletVisible && !inputFocus" + }, + { + "key": "i", + "command": "copyRelativeFilePath", + "when": "explorerViewletFocus && explorerViewletVisible && !inputFocus" + }, + { + "key": "enter", + "command": "list.select", + "when": "explorerViewletFocus && explorerViewletVisible && !inputFocus" + }, + { + "key": "alt+-", + "command": "workbench.view.explorer", + "when": "vim.active && vim.mode != 'Insert'" + }, + { + "key": "alt+-", + "command": "-workbench.view.explorer", + "when": "explorerViewletVisible" + }, + { + "key": "ctrl+n", + "command": "workbench.action.toggleSidebarVisibility", + "when": "vim.active && vim.mode != 'Insert'" + }, + + // Terminal + { + "key": "ctrl+k", + "command": "workbench.action.togglePanel" + }, + { + "key": "alt+=", + "command": "workbench.action.terminal.focus", + "when": "vim.active && vim.mode != 'Insert'" + }, + { + "key": "alt+=", + "command": "workbench.action.focusActiveEditorGroup", + "when": "terminalFocus" + }, + + // Tabs/Editors + { + "key": "alt+q", + "command": "workbench.action.closeActiveEditor" + }, + { + "key": "alt+a", + "command": "workbench.action.closeAllEditors" + }, + { + "key": "alt+,", + "command": "workbench.action.closeOtherEditors" + }, + + // Page Navigation + { + "key": "alt+n", + "command": "scrollLineDown", + "when": "textInputFocus" + }, + { + "key": "alt+p", + "command": "scrollLineUp", + "when": "textInputFocus" + }, + { + "key": "alt+n", + "command": "scrollPageDown", + "when": "textInputFocus" + }, + { + "key": "alt+p", + "command": "scrollPageUp", + "when": "textInputFocus" + }, + + // Move Around Editors + { + "key": "ctrl+h", + "command": "workbench.action.previousEditor", + "when": "vim.active && vim.mode != 'Insert'" + }, + { + "key": "ctrl+l", + "command": "workbench.action.nextEditor", + "when": "vim.active && vim.mode != 'Insert'" + }, + { + "key": "alt+h", + "command": "workbench.action.focusLeftGroup", + "when": "editorTextFocus && vim.active && vim.mode != 'Insert'" + }, + { + "key": "alt+l", + "command": "workbench.action.focusRightGroup", + "when": "editorTextFocus && vim.active && vim.mode != 'Insert'" + }, + { + "key": "alt+k", + "command": "workbench.action.focusAboveGroup", + "when": "editorTextFocus && vim.active && vim.mode != 'Insert'" + }, + { + "key": "alt+j", + "command": "workbench.action.focusBelowGroup", + "when": "editorTextFocus && vim.active && vim.mode != 'Insert'" + }, + + // Down Motion + { + "key": "alt+j", + "command": "selectNextSuggestion", + "when": "suggestWidgetVisible" + }, + { + "key": "alt+j", + "command": "workbench.action.quickOpenSelectNext", + "when": "inQuickOpen" + }, + { + "key": "alt+j", + "command": "selectNextCodeAction", + "when": "codeActionMenuVisible" + }, + + // Up Motion + { + "key": "alt+k", + "command": "selectPrevSuggestion", + "when": "suggestWidgetVisible" + }, + { + "key": "alt+k", + "command": "workbench.action.quickOpenSelectPrevious", + "when": "inQuickOpen" + }, + { + "key": "alt+k", + "command": "selectPrevCodeAction", + "when": "codeActionMenuVisible" + }, + + // LSP + { + "key": "shift+k", + "command": "editor.action.showDefinitionPreviewHover", + "when": "editorTextFocus && vim.active && vim.mode != 'Insert'" + } +] \ No newline at end of file diff --git a/home/apps/vscode/settings.json b/home/apps/vscode/settings.json new file mode 100644 index 0000000..48207f8 --- /dev/null +++ b/home/apps/vscode/settings.json @@ -0,0 +1,202 @@ +{ + "workbench.startupEditor": "none", + "workbench.reduceMotion": "on", + "workbench.commandPalette.preserveInput": true, + "files.autoSave": "afterDelay", + "files.autoSaveDelay": 10, + // Theme + "workbench.colorTheme": "Catppuccin Mocha", + "catppuccin.italicComments": false, + "catppuccin.italicKeywords": false, + "catppuccin.accentColor": "pink", + "window.titleBarStyle": "custom", + "workbench.iconTheme": "catppuccin-mocha", + // Editor + "editor.fontSize": 14, + "editor.fontFamily": "Iosevka Term, Symbols Nerd Font, monospace", + "editor.fontWeight": "bold", + "editor.tabSize": 2, + "editor.lineNumbers": "relative", + "editor.smoothScrolling": true, + "editor.cursorSmoothCaretAnimation": "on", + "editor.mouseWheelZoom": true, + "editor.minimap.autohide": true, + "editor.inlayHints.padding": true, + "editor.acceptSuggestionOnEnter": "smart", + "editor.bracketPairColorization.independentColorPoolPerBracketType": false, + "editor.formatOnSave": false, + "editor.suggest.preview": true, + "errorLens.fontFamily": "Iosevka Term, Symbols Nerd Font, monospace", + "errorLens.fontWeight": "bold", + // Terminal + "terminal.integrated.defaultProfile.linux": "fish", + "terminal.integrated.fontSize": 14, + "terminal.integrated.fontWeight": "bold", + // Nix + "nix.enableLanguageServer": true, // Enable LSP. + "nix.serverPath": "/home/hammy/.nix-profile/bin/nil", // The path to the LSP server executable. + "[nix]": { + "editor.defaultFormatter": "kamadorueda.alejandra", + "editor.formatOnPaste": true, + "editor.formatOnSave": true, + "editor.formatOnType": false + }, + "alejandra.program": "/home/hammy/.nix-profile/bin/alejandra", + // Vim + "vim.leader": "", + "vim.easymotion": true, + "vim.easymotionDimBackground": false, + "vim.useSystemClipboard": false, + "vim.hlsearch": true, + "vim.incsearch": true, + "vim.handleKeys": { + "": false, // select all + "": false, // copy + "": false, // cut + "": false, // paste + "": false // find + }, + "vim.useCtrlKeys": true, + "vim.visualModeKeyBindings": [ + { + "before": [">"], + "commands": ["editor.action.indentLines"] + }, + { + "before": ["<"], + "commands": ["editor.action.outdentLines"] + } + ], + "vim.normalModeKeyBindingsNonRecursive": [ + // Make sure to use VsCode's undo stack -> https://github.com/VSCodeVim/Vim/issues/1490 + { + "before": ["u"], + "commands": ["undo"] + }, + { + "before": [""], + "commands": ["redo"] + }, + // Helpful Stuff + { + "before": ["/"], + "commands": ["actions.find"] + }, + { + "before": [""], + "after": ["o", ""] + }, + { + "before": ["0"], + "after": ["^"] + }, + { + "before": ["", "q"], + "commands": ["workbench.action.closeActiveEditor"] + }, + { + "before": ["", "w"], + "commands": ["workbench.action.files.save"] + }, + { + "before": ["", "f", "f"], + "commands": ["workbench.action.quickOpen"] + }, + { + "before": ["[", "c"], + "commands": ["workbench.action.editor.previousChange"] + }, + { + "before": ["]", "c"], + "commands": ["workbench.action.editor.nextChange"] + }, + { + "before": ["[", "d"], + "commands": ["editor.action.marker.prev"] + }, + { + "before": ["]", "d"], + "commands": ["editor.action.marker.next"] + }, + { + "before": ["", "a"], + "commands": ["workbench.action.showCommands"] + }, + // EasyMotion + { + "before": ["s"], + "after": ["", ""] + }, + // Git + { + "before": ["", "g", "g"], + "commands": ["workbench.view.scm"] + }, + { + "before": ["", "g", "h"], + "commands": ["toggle.diff.renderSideBySide"] + }, + { + "before": ["", "g", "p"], + "commands": ["git.openChange"] + }, + // LSP + { + "before": ["", "l", "f"], + "commands": ["editor.action.formatDocument"] + }, + { + "before": ["", "l", "r"], + "commands": ["editor.action.rename"] + }, + { + "before": ["", ""], + "commands": ["editor.action.quickFix"] + }, + // Tabs + { + "before": ["", "o"], + "commands": ["workbench.action.closeOtherEditors"] + } + ], + "[python]": { + "editor.formatOnType": false + }, + "[typescript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[markdown]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "git.autofetch": true, + "redhat.telemetry.enabled": false, + "[yaml]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[json]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "explorer.confirmDragAndDrop": false, + "[jsonc]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "git.confirmSync": false, + "diffEditor.ignoreTrimWhitespace": false, + "[scss]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[css]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "editor.inlineSuggest.enabled": true, + "github.copilot.enable": { + "*": true, + "plaintext": false, + "markdown": true, + "scminput": false + }, + "rust-analyzer.check.command": "clippy", + "[html]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + } +} diff --git a/home/default.nix b/home/default.nix index a5543c4..c1143c6 100644 --- a/home/default.nix +++ b/home/default.nix @@ -52,6 +52,11 @@ }; xdg.configFile."ideavim/ideavimrc".source = config.lib.file.mkOutOfStoreSymlink "${flakePath}/home/apps/ideavim/ideavimrc"; + xdg.configFile = { + "Code/User/keybindings.json".source = config.lib.file.mkOutOfStoreSymlink "${flakePath}/home/apps/vscode/keybindings.json"; + "Code/User/settings.json".source = config.lib.file.mkOutOfStoreSymlink "${flakePath}/home/apps/vscode/settings.json"; + }; + xdg.mime.enable = true; # turn off if on nixos (you have bigger problems than that if you get to this point) targets.genericLinux.enable = true;