diff --git a/nvim/init.lua b/nvim/init.lua index 11f4a7f..0046bf5 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -11,7 +11,11 @@ function init_lazy_nvim() }) end vim.opt.rtp:prepend(lazypath) - require("lazy").setup(PLUGINS, opts) + require("lazy").setup(PLUGINS, { + defaults = { + cond = vim.g.vscode, + }, + }) end function define_keymaps() @@ -69,6 +73,27 @@ function define_keymaps() vim.keymap.set("n", "u", builtin.lsp_references, {}) end +function define_vscode_keymaps() + local vscode = require("vscode") + + local function action(command) + return function() + vscode.action(command) + end + end + + vim.api.nvim_set_keymap("n", "J", "10j", { noremap = true, silent = true }) + vim.keymap.set("n", "e", action("editor.action.showHover")) + vim.keymap.set("n", "d", action("editor.action.revealDefinition")) + vim.keymap.set("n", "F", action("workbench.action.quickOpen")) + vim.keymap.set("n", "f", action("workbench.view.explorer")) + vim.keymap.set("n", "r", action("editor.action.rename")) + vim.keymap.set("n", "g", action("workbench.action.findInFiles")) + vim.keymap.set("n", "[d", action("editor.action.marker.prevInFiles")) + vim.keymap.set("n", "]d", action("editor.action.marker.nextInFiles")) + vim.keymap.set("n", "", action("workbench.action.closeSidebar")) +end + function setup_plugins() require("nvim-treesitter.configs").setup({ -- A list of parser names, or "all" (the five listed parsers should always be installed) @@ -598,6 +623,7 @@ PLUGINS = { "windwp/nvim-autopairs", event = "InsertEnter", config = true, + cond = vim.g.vscode, }, { "windwp/nvim-ts-autotag" }, { @@ -610,7 +636,12 @@ PLUGINS = { init_lazy_nvim() setup_plugins() -define_keymaps() config_vim() +if vim.g.vscode then + define_vscode_keymaps() +else + define_keymaps() +end + vim.cmd("source ~/dotfiles/nvim/macmap.vim")