aboutsummaryrefslogtreecommitdiffstats
path: root/neovim/.config/nvim/lua/config
diff options
context:
space:
mode:
Diffstat (limited to 'neovim/.config/nvim/lua/config')
-rw-r--r--neovim/.config/nvim/lua/config/autocmds.lua22
-rw-r--r--neovim/.config/nvim/lua/config/keymaps.lua37
-rw-r--r--neovim/.config/nvim/lua/config/lazy.lua17
-rw-r--r--neovim/.config/nvim/lua/config/options.lua36
4 files changed, 112 insertions, 0 deletions
diff --git a/neovim/.config/nvim/lua/config/autocmds.lua b/neovim/.config/nvim/lua/config/autocmds.lua
new file mode 100644
index 0000000..7bc4f6b
--- /dev/null
+++ b/neovim/.config/nvim/lua/config/autocmds.lua
@@ -0,0 +1,22 @@
1-- Remove trailing spaces on save, preserving cursor and search pattern
2local function strip_trailing_whitespace()
3 if vim.list_contains({ "markdown", "diff" }, vim.bo.filetype) then
4 return
5 end
6 local view = vim.fn.winsaveview()
7 vim.cmd([[keeppatterns %s/\s\+$//e]])
8 vim.fn.winrestview(view)
9end
10
11vim.api.nvim_create_autocmd("BufWritePre", {
12 pattern = "*",
13 callback = strip_trailing_whitespace,
14})
15
16-- Note: the colorscheme (with its "desert" fallback) is applied from
17-- lua/plugins/colorscheme.lua's own `config` function, not here — under
18-- lazy.nvim that's the natural place to react to "the plugin is now loaded".
19--
20-- Note: the vimrc's "reload vimrc on save" autocmd has no clean Lua
21-- equivalent (module caching means `require()`-based configs aren't simply
22-- re-sourceable) and is deliberately not ported.
diff --git a/neovim/.config/nvim/lua/config/keymaps.lua b/neovim/.config/nvim/lua/config/keymaps.lua
new file mode 100644
index 0000000..f0bfbec
--- /dev/null
+++ b/neovim/.config/nvim/lua/config/keymaps.lua
@@ -0,0 +1,37 @@
1local map = vim.keymap.set
2
3-- Switch windows with <C-[direction]>
4map("n", "<C-j>", "<C-w>j")
5map("n", "<C-k>", "<C-w>k")
6map("n", "<C-h>", "<C-w>h")
7map("n", "<C-l>", "<C-w>l")
8
9-- Never use the arrow keys
10for _, key in ipairs({ "<Up>", "<Down>", "<Left>", "<Right>" }) do
11 map({ "n", "i" }, key, "<Nop>")
12end
13
14-- Disable ex mode
15map("n", "Q", "<Nop>")
16
17-- Expand :git to fugitive's :Git, but only as a whole command.
18-- (No Lua-native abbreviation API exists, so this stays a thin vim.cmd call.)
19vim.cmd([[cnoreabbrev <expr> git (getcmdtype() ==# ':' && getcmdline() ==# 'git') ? 'Git' : 'git']])
20
21-- Note: the vimrc's `w!!` sudo-save abbreviation is deliberately NOT ported
22-- here — its own comment says it doesn't work under Neovim (sudo can't
23-- prompt for a password there).
24
25-- Append modeline when pressing <leader>ml
26local function append_modeline()
27 local modeline = string.format(
28 " vim: set ts=%d sw=%d tw=%d %set :",
29 vim.bo.tabstop,
30 vim.bo.shiftwidth,
31 vim.bo.textwidth,
32 vim.bo.expandtab and "" or "no"
33 )
34 modeline = vim.bo.commentstring:gsub("%%s", modeline)
35 vim.api.nvim_buf_set_lines(0, -1, -1, false, { modeline })
36end
37map("n", "<leader>ml", append_modeline, { silent = true })
diff --git a/neovim/.config/nvim/lua/config/lazy.lua b/neovim/.config/nvim/lua/config/lazy.lua
new file mode 100644
index 0000000..5a645c1
--- /dev/null
+++ b/neovim/.config/nvim/lua/config/lazy.lua
@@ -0,0 +1,17 @@
1local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
2if not vim.uv.fs_stat(lazypath) then
3 vim.fn.system({
4 "git",
5 "clone",
6 "--filter=blob:none",
7 "https://github.com/folke/lazy.nvim.git",
8 "--branch=stable",
9 lazypath,
10 })
11end
12vim.opt.rtp:prepend(lazypath)
13
14require("lazy").setup("plugins", {
15 install = { colorscheme = { "janah", "desert" } },
16 checker = { enabled = false },
17})
diff --git a/neovim/.config/nvim/lua/config/options.lua b/neovim/.config/nvim/lua/config/options.lua
new file mode 100644
index 0000000..be614e1
--- /dev/null
+++ b/neovim/.config/nvim/lua/config/options.lua
@@ -0,0 +1,36 @@
1-- Ported from vim/.vim/vimrc's "DEFAULT VIM SETTINGS" block. `syntax on` and
2-- `filetype plugin indent on` are intentionally omitted: both are Neovim
3-- defaults (see `:help nvim-defaults`).
4
5local opt = vim.opt
6
7opt.number = true
8opt.relativenumber = true
9opt.list = true
10opt.modeline = true
11opt.background = "dark"
12opt.foldmethod = "indent"
13opt.listchars = { trail = "·", tab = "▸ ", eol = "¬" }
14opt.scrolloff = 1
15opt.backspace = { "indent", "eol", "start" }
16opt.cursorline = true
17opt.hidden = true -- already Neovim's default; set explicitly for parity with the vimrc
18opt.wildmenu = true -- already Neovim's default; set explicitly for parity with the vimrc
19
20-- Faster gutter updates (signify) and snappier <Esc>
21opt.updatetime = 100
22opt.ttimeoutlen = 10
23
24-- Persistent undo across sessions
25local undodir = vim.fn.stdpath("data") .. "/undo"
26if vim.fn.isdirectory(undodir) == 0 then
27 vim.fn.mkdir(undodir, "p", "0700")
28end
29opt.undofile = true
30opt.undodir = undodir
31
32-- Search-related things
33opt.hlsearch = true
34opt.incsearch = true
35opt.ignorecase = true
36opt.smartcase = true