From 7e935b12c09358adad480a566988b9cbfaf5999e Mon Sep 17 00:00:00 2001
From: Oliver Davies <oliver@oliverdavies.uk>
Date: Thu, 1 Sep 2022 22:01:42 +0100
Subject: [PATCH] feat(nvim): improve C-d and C-u mappings

Move up or down by half a page but also automatically re-center the
screen so that the cursor is always within a consistent positiion.
---
 roles/neovim/files/lua/opdavies/options.lua | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/roles/neovim/files/lua/opdavies/options.lua b/roles/neovim/files/lua/opdavies/options.lua
index bf0ec9fd..8073ced4 100644
--- a/roles/neovim/files/lua/opdavies/options.lua
+++ b/roles/neovim/files/lua/opdavies/options.lua
@@ -100,6 +100,10 @@ local function set_key_mappings()
   nmap { "<M-k>", ":m .-2<CR>==", opts }
   vmap { "<M-j>", ":m '>+1<CR>gv=gv", opts }
   vmap { "<M-k>", ":m '<-2<CR>gv=gv", opts }
+
+  -- Move half a screen up or down and re-center.
+  nmap { "<C-d>", "<C-d>zz" }
+  nmap { "<C-u>", "<C-u>zz" }
 end
 
 local function set_highlights()