diff --git a/nvim/init.lua b/nvim/init.lua index 0fa6f10..bdabe8d 100755 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -1,4 +1,5 @@ require("options") require("keybinds") +require("wins") require("lazy-conf") require("filetypes") diff --git a/nvim/lua/keybinds.lua b/nvim/lua/keybinds.lua index c0f3850..fdcf7c4 100755 --- a/nvim/lua/keybinds.lua +++ b/nvim/lua/keybinds.lua @@ -3,7 +3,7 @@ local opts = utils.opts local keymap = vim.keymap -keymap.set({ 'n', 'i', 'v' }, "", function () +keymap.set({ "n", "i", "v" }, "", function() vim.show_pos() end, opts("Show inspect")) @@ -40,8 +40,8 @@ keymap.set("n", "dd", ":t.", opts("Duplicate line")) -- LaTeX mappings keymap.set("n", "lc", utils.run_vim_cmd("VimtexCompile"), opts("Compile latex document")) -- Compile LaTeX file -keymap.set("n", "lv", utils.run_vim_cmd("VimtexView"), opts("View compiled latex pdf")) -- View compiled PDF -keymap.set("n", "lq", utils.run_vim_cmd("VimtexStop"), opts("Stop Compiling document")) -- Stop compilation +keymap.set("n", "lv", utils.run_vim_cmd("VimtexView"), opts("View compiled latex pdf")) -- View compiled PDF +keymap.set("n", "lq", utils.run_vim_cmd("VimtexStop"), opts("Stop Compiling document")) -- Stop compilation -- window navigation keymap.set("n", "", "h", opts()) @@ -82,9 +82,18 @@ keymap.set( ) -- Migrate from function to const-arrow function (js) -keymap.set("n", "fs", ":%s/\\v(async )@ {/g", opts("Migrate to const-arrow func (sync)")) -keymap.set("n", "fa", ":%s/\\vasync function (.*) \\((.*)\\)(.*) \\{/const \\1 = async (\\2)\\3 => {/g", opts("Migrate to const-arrow func (async)")) - +keymap.set( + "n", + "fs", + ":%s/\\v(async )@ {/g", + opts("Migrate to const-arrow func (sync)") +) +keymap.set( + "n", + "fa", + ":%s/\\vasync function (.*) \\((.*)\\)(.*) \\{/const \\1 = async (\\2)\\3 => {/g", + opts("Migrate to const-arrow func (async)") +) -- select all keymap.set("n", "a", "ggVG", opts("select all")) diff --git a/nvim/lua/plugins/snacks/keys/keys.lua b/nvim/lua/plugins/snacks/keys/keys.lua index 04f9944..dc00751 100644 --- a/nvim/lua/plugins/snacks/keys/keys.lua +++ b/nvim/lua/plugins/snacks/keys/keys.lua @@ -59,7 +59,7 @@ return { }, -- Tree { - "e", + "E", function() Snacks.explorer() end, diff --git a/nvim/lua/plugins/util/diffview.lua b/nvim/lua/plugins/util/diffview.lua deleted file mode 100644 index e9fd802..0000000 --- a/nvim/lua/plugins/util/diffview.lua +++ /dev/null @@ -1,10 +0,0 @@ -return { - -- Diffview - "sindrets/diffview.nvim", - keys = { - { "gdd", ":DiffviewOpen", desc = "Open diffview" }, - { "gdh", ":DiffviewFileHistory", desc = "View file history" }, - { "gdc", ":DiffviewClose", desc = "Close diffview" }, - { "gdr", ":DiffviewRefresh", desc = "Refresh diffview" }, - }, -} diff --git a/nvim/lua/wins.lua b/nvim/lua/wins.lua new file mode 100644 index 0000000..6e5d95b --- /dev/null +++ b/nvim/lua/wins.lua @@ -0,0 +1,28 @@ +local utils = require("utils") +local opts = utils.opts + +local keymap = vim.keymap +keymap.set({ "n" }, "e", function() + local width = math.ceil(math.min(150, vim.o.columns * 0.8)) + local height = math.ceil(math.min(35, vim.o.lines * 0.8)) + local row = math.ceil(vim.o.lines - height) * 0.5 - 1 + local col = math.ceil(vim.o.columns - width) * 0.5 - 1 + + local float_config = { + width = width, + height = height, + row = row, + col = col, + relative = "editor", + border = "rounded", + } + + local buf = vim.api.nvim_create_buf(false, false) + vim.api.nvim_open_win(buf, true, float_config) + vim.api.nvim_command(":Explore") +end, opts("Open file browser")) + +keymap.set({ "n" }, "u", function() + vim.api.nvim_command(":packadd nvim.undotree") + vim.api.nvim_command(":Undotree") +end, opts("Open file browser"))