-- Use Lazy.nvim as the plugin manager local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not (vim.uv or vim.loop).fs_stat(lazypath) then local lazyrepo = "https://github.com/folke/lazy.nvim.git" local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) if vim.v.shell_error ~= 0 then vim.api.nvim_echo({ { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, { out, "WarningMsg" }, { "\nPress any key to exit..." }, }, true, {}) vim.fn.getchar() os.exit(1) end end vim.opt.rtp:prepend(lazypath) -- Clipboard vim.opt.clipboard = "unnamedplus" -- use system clipboard -- Searching vim.opt.incsearch = true -- search as characters are entered vim.opt.hlsearch = true -- do not highlight matches vim.opt.ignorecase = true -- ignore case in searches by default vim.opt.smartcase = true -- but make it case sensitive if an uppercase is entered -- Tab width vim.opt.tabstop = 4 -- number of visual spaces per TAB vim.opt.softtabstop = 4 -- number of spacesin tab when editing vim.opt.shiftwidth = 4 -- insert 4 spaces on a tab vim.opt.expandtab = true -- tabs are spaces, mainly because of python -- Leader and Local Leader vim.g.mapleader = " " -- set leader key to space vim.g.maplocalleader = "\\" -- set local leader key to space local vscode = require("vscode") vim.notify = vscode.notify -- Code Folding local fold = { unfoldAll = function() vscode.action("editor.unfoldAll") end, foldAll = function() vscode.action("editor.foldAll") end, toggleFold = function() vscode.action("editor.toggleFold") end, } vim.keymap.set("n", "zR", fold.unfoldAll, { desc = "Fold All" }) vim.keymap.set("n", "zM", fold.foldAll, { desc = "Unfold All" }) vim.keymap.set("n", "za", fold.toggleFold, { desc = "Toggle Fold" }) -- Toggle VSCode Zen Mode local zenMode = { toggle = function() vscode.action("workbench.action.toggleZenMode") end, } vim.keymap.set("n", "z", zenMode.toggle, { desc = "Toggle Zen Mode" }) -- Toggle VSCode Sidebar local sidebar = { toggleVisibility = function() vscode.action("workbench.action.toggleSidebarVisibility") end, togglePosition = function() vscode.action("workbench.action.toggleSidebarPosition") end, openExplorer = function() vscode.action("workbench.view.explorer") end, openSearch = function() vscode.action("workbench.view.search") end } vim.keymap.set("n", "b", sidebar.toggleVisibility, { desc = "Toggle Sidebar Vidibility" }) vim.keymap.set("n", "B", sidebar.togglePosition, { desc = "Toggle Sidebar Position" }) vim.keymap.set("n", "be", sidebar.openExplorer, { desc = "Open Sidebar Explorer" }) vim.keymap.set("n", "bs", sidebar.openSearch, { desc = "Open Sidebar Explorer" }) -- Toggle Line-Number Mode vim.keymap.set("n", "l", function() local lineNumbMode = vscode.get_config("editor.lineNumbers") if lineNumbMode == "on" then vscode.update_config("editor.lineNumbers", "relative") elseif lineNumbMode == "relative" then vscode.update_config("editor.lineNumbers", "on") else vscode.update_config("editor.lineNumbers", "relative") end end, { desc = "Toggle Line-Number Mode" }) -- Toggle Word Wrap Mode vim.keymap.set("n", "w", function() local wrapMode = vscode.get_config("editor.wordWrap") if wrapMode == "on" then vscode.update_config("editor.wordWrap", "off") else vscode.update_config("editor.wordWrap", "on") end end, { desc = "Toggle Word Wrap Mode" }) -- Code vim.keymap.set("n", "cf", function() vscode.action("editor.action.formatDocument") end, { desc = "Format Code" }) -- Editor local editors = { toggleInGroup = function() vscode.action("workbench.action.quickOpenPreviousRecentlyUsedEditorInGroup") vscode.action("list.select") end, toggleCrossGroups = function() vscode.action("workbench.action.quickOpenPreviousRecentlyUsedEditor") vscode.action("list.select") end, previous = function() vscode.action("workbench.action.quickOpenPreviousRecentlyUsedEditorInGroup") end, least = function() vscode.action("workbench.action.quickOpenLeastRecentlyUsedEditorInGroup") end, select = function() vscode.action("workbench.action.quickOpenPreviousRecentlyUsedEditor") end, close = function() vscode.action("workbench.action.closeActiveEditor") end, moveToNextGroup = function() vscode.action("workbench.action.moveEditorToNextGroup") end, moveToPreviousGroup = function() vscode.action("workbench.action.moveEditorToPreviousGroup") end, } vim.keymap.set("n", "e", editors.toggleInGroup, { desc = "Toggle Between Two Editors inside Group" }) vim.keymap.set("n", "E", editors.toggleCrossGroups, { desc = "Toggle Between Two Editors Cross-Groups" }) vim.keymap.set("n", "eg", editors.select, { desc = "Select Editor Cross-Groups" }) vim.keymap.set("n", "ei", editors.previous, { desc = "Select Editor Inside Group" }) -- vim.keymap.set("n", "ep", editors.previous, { desc = "Select Editor in Group: Previous" }) -- vim.keymap.set("n", "el", editors.least, { desc = "Select Editor in Group: Least" }) vim.keymap.set("n", "ed", editors.close, { desc = "Close Editor" }) vim.keymap.set('n', "en", editors.moveToNextGroup, { desc = "Move Editor to the Next Group" }) vim.keymap.set('n', "ep", editors.moveToPreviousGroup, { desc = "Move Editor to the Previous Group" }) -- Editor Groups -- TODO: gd to delete a group local groups = { toggle = function() vscode.action("workbench.action.focusNextGroup") end, vertical = function() vscode.action("workbench.action.splitEditorRight") -- vscode.action("workbench.action.moveEditorToNextGroup") end, horizontal = function() vscode.action("workbench.action.splitEditorDown") -- vscode.action("workbench.action.moveEditorToPreviousGroup") end, equalGroupSize = function() vscode.action("workbench.action.evenEditorWidths") end, close = function() vscode.action("workbench.action.closeGroup") end, alsoCloseEditors = function() vscode.action("workbench.action.closeEditorsAndGroup") end, } vim.keymap.set("n", "g", groups.toggle, { desc = "Focus Next Group" }) vim.keymap.set("n", "gv", groups.vertical, { desc = "Split Editor Group Vertically" }) vim.keymap.set("n", "gs", groups.horizontal, { desc = "Split Editor Group Horizontally" }) vim.keymap.set("n", "g=", groups.equalGroupSize, { desc = "Equal Group Size" }) vim.keymap.set("n", "gd", groups.close, { desc = "Close Group, Remain Editors" }) vim.keymap.set("n", "gD", groups.alsoCloseEditors, { desc = "Close Group and Editors" }) -- Files local files = { search = function() vscode.action("workbench.action.quickOpen") -- vscode.action("workbench.action.quickOpenNavigateNextInFilePicker") vscode.action("workbench.action.quickOpenSelectNext") end } vim.keymap.set("n", "fs", files.search, { desc = "Search Files with VSCode ctrl-p" }) -- Use Lazy.nvim as the plugin manager require("lazy").setup({ spec = { -- import your plugins { import = "vscodeplugins" }, }, -- Configure any other settings here. See the documentation for more details. -- colorscheme that will be used when installing plugins. install = { colorscheme = { "habamax" } }, -- automatically check for plugin updates checker = { enabled = true }, })