From 17ef0c937484874555f02423bb90105bcb94370d Mon Sep 17 00:00:00 2001 From: nil Date: Sun, 4 Aug 2024 22:31:07 +0800 Subject: [PATCH] base --- README.md | 4 +--- init.lua | 2 ++ lua/keymaps.lua | 47 +++++++++++++++++++++++++++++++++++++++++++++++ lua/options.lua | 28 ++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 init.lua create mode 100644 lua/keymaps.lua create mode 100644 lua/options.lua diff --git a/README.md b/README.md index b6f28b2..4b1b857 100644 --- a/README.md +++ b/README.md @@ -1,3 +1 @@ -# nvim - -Neovim config \ No newline at end of file +# `Neovim Config` diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..82c5d3f --- /dev/null +++ b/init.lua @@ -0,0 +1,2 @@ +require("options") +require("keymaps") \ No newline at end of file diff --git a/lua/keymaps.lua b/lua/keymaps.lua new file mode 100644 index 0000000..8a2efbb --- /dev/null +++ b/lua/keymaps.lua @@ -0,0 +1,47 @@ +-- define common options +local opts = { + noremap = true, -- non-recursive + silent = true, -- do not show message +} +local keymap = vim.keymap.set + +vim.g.mapleader = " " --set leader key + +--------------- +-- View Mode -- +--------------- +keymap("v", "J", ":m '>+1gv=gv", opts) -- move line down +keymap("v", "K", ":m '<-2gv=gv", opts) -- move line up +-- Hint: start visual mode with the same area as the previous area and the same mode +keymap("v", "", ">gv", opts) -- indent right +keymap("v", "", "==", opts) -- move line down +keymap("n", "K", ":m .-2==", opts) -- move line up +keymap("n", "o", "o", opts) -- insert new line below +keymap("n", "O", "O", opts) -- insert new line above +keymap("n", "nh", ":nohlsearch", opts) -- clear search highlight +keymap("n", "", ">>", opts) -- indent right +keymap("n", "", "<<", opts) -- indent left +-- Window Navigation +keymap("n", "", "h", opts) -- move to left window +keymap("n", "", "j", opts) -- move to down window +keymap("n", "", "k", opts) -- move to up window +keymap("n", "", "l", opts) -- move to right window +keymap("n", "wh", "s", opts) -- split window horizontally +keymap("n", "wv", "v", opts) -- split window vertically +keymap("n", "wq", "q", opts) -- close window +keymap("n", "wc", "c", opts) -- close window +-- Resize with arrows +-- delta: 2 lines +keymap("n", "", ":resize -2", opts) +keymap("n", "", ":resize +2", opts) +keymap("n", "", ":vertical resize -2", opts) +keymap("n", "", ":vertical resize +2", opts) + +----------------- +-- Insert Mode -- +----------------- diff --git a/lua/options.lua b/lua/options.lua new file mode 100644 index 0000000..ed1ecd9 --- /dev/null +++ b/lua/options.lua @@ -0,0 +1,28 @@ +local opt = vim.opt + +-- Hint: use `:h