First version

This commit is contained in:
SepehrYahyaee
2026-04-13 13:41:22 +03:30
commit 8b25fb90bf
11 changed files with 826 additions and 0 deletions

23
lua/user/cursor.lua Normal file
View File

@@ -0,0 +1,23 @@
-- Terminal cursor shapes (Vim t_SI / t_EI / t_SR). Many Neovim builds no longer define these; pcall skips safely.
local esc = '\27'
local function set_termcap(name, value)
pcall(function()
vim.o[name] = value
end)
end
if vim.env.TMUX then
set_termcap('t_SI', esc .. 'Ptmux;' .. esc .. esc .. '[6 q' .. esc .. '\\')
set_termcap('t_EI', esc .. 'Ptmux;' .. esc .. esc .. '[2 q' .. esc .. '\\')
else
set_termcap('t_SI', esc .. '[6 q') -- insert: bar
set_termcap('t_EI', esc .. '[2 q') -- normal: block
end
set_termcap('t_SR', esc .. '[4 q') -- replace: underline
-- Modern Neovim uses guicursor for mode shapes (also in many terminals/UIs).
-- Keep operator-pending block so d/c don't look like replace mode.
vim.opt.guicursor = 'n-v-c-sm:block,i-ci-ve:ver25,r-cr:hor20,o:block'

81
lua/user/keymaps.lua Normal file
View File

@@ -0,0 +1,81 @@
-- WASD-style layout (ported from Vim). Uses same keys as your vimrc; 'x' = visual (vnoremap).
local function n(lhs, rhs, opts)
vim.keymap.set('n', lhs, rhs, opts or {})
end
local function x(lhs, rhs)
vim.keymap.set('x', lhs, rhs)
end
local function o(lhs, rhs, opts)
vim.keymap.set('o', lhs, rhs, opts or {})
end
-- Movement (normal, visual, operator-pending)
for _, lhs in ipairs({ 'w', 's', 'a', 'd' }) do
local rhs = ({ w = 'k', s = 'j', a = 'h', d = 'l' })[lhs]
n(lhs, rhs)
x(lhs, rhs)
o(lhs, rhs)
end
-- Word motions (normal + operator; visual keeps native w/W/e/E on i,I,j,J now remapped)
for _, mode in ipairs({ 'n', 'o' }) do
local opts = mode == 'o' and { nowait = true } or {}
vim.keymap.set(mode, 'i', 'w', opts)
vim.keymap.set(mode, 'I', 'W', opts)
vim.keymap.set(mode, 'j', 'e', opts)
vim.keymap.set(mode, 'J', 'E', opts)
end
-- Operator-pending fixes so combos behave as expected:
-- cw -> ci, ce -> cj, and rk does nothing.
o('w', 'i', { nowait = true })
o('e', 'j', { nowait = true })
o('k', '<Nop>', { nowait = true })
-- Insert / append
n('e', 'i')
n('E', 'a')
n('D', 'A')
n('A', 'I')
-- Operators
n('r', 'd', { nowait = true })
n('R', 'D')
o('r', 'd', { nowait = true })
n('c', 'c')
o('c', 'c')
n('f', 's')
n('F', 'S')
n('t', 'r')
n('T', 'R')
-- Open lines
n('W', 'O')
n('S', 'o')
-- Visual mode entry from normal
n('H', 'V')
n('h', '<Nop>')
-- Find / motion
n('l', 'f')
n('L', 'F')
n('p', 't')
n('P', 'T')
o('l', 'f', { nowait = true })
o('L', 'F', { nowait = true })
o('p', 't', { nowait = true })
o('P', 'T', { nowait = true })
-- Paste
n('v', 'p')
n('V', 'P')
n('o', 'p')
n('K', '<Nop>')
n('k', '<Nop>')
n('O', '<Nop>')
x('O', '<Nop>')
o('O', '<Nop>')

15
lua/user/options.lua Normal file
View File

@@ -0,0 +1,15 @@
-- Line numbers
vim.opt.number = true
vim.opt.relativenumber = true
-- Indent width4 (spaces); new lines inherit current indent
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true
vim.opt.softtabstop = -1 -- follow shiftwidth (Neovim)
vim.opt.autoindent = true
vim.opt.copyindent = true
vim.opt.smartindent = true -- pressing Enter after `{` indents the next line
vim.cmd('filetype plugin indent on')