1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
local map = vim.keymap.set
-- Switch windows with <C-[direction]>, from Normal mode or from inside a
-- terminal buffer (e.g. claude-code.nvim's split) without leaving it first.
-- Terminal mode passes keys straight to the running process by default, so
-- <C-w><direction> alone never reaches Neovim there - <C-\><C-n> escapes to
-- Normal mode before running the window command.
map("n", "<C-j>", "<C-w>j")
map("n", "<C-k>", "<C-w>k")
map("n", "<C-h>", "<C-w>h")
map("n", "<C-l>", "<C-w>l")
map("t", "<C-j>", [[<C-\><C-n><C-w>j]])
map("t", "<C-k>", [[<C-\><C-n><C-w>k]])
map("t", "<C-h>", [[<C-\><C-n><C-w>h]])
map("t", "<C-l>", [[<C-\><C-n><C-w>l]])
-- Copy to clipboard
map("v", "<leader>y", '"+y')
map("n", "<leader>Y", '"+yg_')
map("n", "<leader>y", '"+y')
map("n", "<leader>yy", '"+yy')
-- Paste from clipboard
map("n", "<leader>p", '"+p')
map("n", "<leader>P", '"+P')
map("v", "<leader>p", '"+p')
map("v", "<leader>P", '"+P')
-- Never use the arrow keys
for _, key in ipairs({ "<Up>", "<Down>", "<Left>", "<Right>" }) do
map({ "n", "i" }, key, "<Nop>")
end
-- Disable ex mode
map("n", "Q", "<Nop>")
-- Expand :git to fugitive's :Git, but only as a whole command.
-- (No Lua-native abbreviation API exists, so this stays a thin vim.cmd call.)
vim.cmd([[cnoreabbrev <expr> git (getcmdtype() ==# ':' && getcmdline() ==# 'git') ? 'Git' : 'git']])
-- Note: the vimrc's `w!!` sudo-save abbreviation is deliberately NOT ported
-- here — its own comment says it doesn't work under Neovim (sudo can't
-- prompt for a password there).
-- Append modeline when pressing <leader>ml
local function append_modeline()
local modeline = string.format(
" vim: set ts=%d sw=%d tw=%d %set :",
vim.bo.tabstop,
vim.bo.shiftwidth,
vim.bo.textwidth,
vim.bo.expandtab and "" or "no"
)
modeline = vim.bo.commentstring:gsub("%%s", modeline)
vim.api.nvim_buf_set_lines(0, -1, -1, false, { modeline })
end
map("n", "<leader>ml", append_modeline, { silent = true })
|