From 269bfc8f9703930b81a67eba060789820fdfb9c0 Mon Sep 17 00:00:00 2001 From: Zynh0722 Date: Tue, 29 Aug 2023 03:23:09 -0700 Subject: [PATCH] centered scrolling --- lua/config/keymaps.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua index 2c134f7..e6db343 100644 --- a/lua/config/keymaps.lua +++ b/lua/config/keymaps.lua @@ -1,3 +1,20 @@ -- Keymaps are automatically loaded on the VeryLazy event -- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua -- Add any additional keymaps here + +local function map(mode, lhs, rhs, opts) + local keys = require("lazy.core.handler").handlers.keys + ---@cast keys LazyKeysHandler + -- do not create the keymap if a lazy keys handler exists + if not keys.active[keys.parse({ lhs, mode = mode }).id] then + opts = opts or {} + opts.silent = opts.silent ~= false + if opts.remap and not vim.g.vscode then + opts.remap = nil + end + vim.keymap.set(mode, lhs, rhs, opts) + end +end + +map("n", "", "zz", { desc = "Centered Half Page Up", remap = true }) +map("n", "", "zz", { desc = "Centered Half Page Down", remap = true })