diff options
Diffstat (limited to 'neovim/.config/nvim/lua/config')
| -rw-r--r-- | neovim/.config/nvim/lua/config/autocmds.lua | 22 | ||||
| -rw-r--r-- | neovim/.config/nvim/lua/config/keymaps.lua | 37 | ||||
| -rw-r--r-- | neovim/.config/nvim/lua/config/lazy.lua | 17 | ||||
| -rw-r--r-- | neovim/.config/nvim/lua/config/options.lua | 36 |
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 | ||
| 2 | local 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) | ||
| 9 | end | ||
| 10 | |||
| 11 | vim.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 @@ | |||
| 1 | local map = vim.keymap.set | ||
| 2 | |||
| 3 | -- Switch windows with <C-[direction]> | ||
| 4 | map("n", "<C-j>", "<C-w>j") | ||
| 5 | map("n", "<C-k>", "<C-w>k") | ||
| 6 | map("n", "<C-h>", "<C-w>h") | ||
| 7 | map("n", "<C-l>", "<C-w>l") | ||
| 8 | |||
| 9 | -- Never use the arrow keys | ||
| 10 | for _, key in ipairs({ "<Up>", "<Down>", "<Left>", "<Right>" }) do | ||
| 11 | map({ "n", "i" }, key, "<Nop>") | ||
| 12 | end | ||
| 13 | |||
| 14 | -- Disable ex mode | ||
| 15 | map("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.) | ||
| 19 | vim.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 | ||
| 26 | local 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 }) | ||
| 36 | end | ||
| 37 | map("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 @@ | |||
| 1 | local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" | ||
| 2 | if 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 | }) | ||
| 11 | end | ||
| 12 | vim.opt.rtp:prepend(lazypath) | ||
| 13 | |||
| 14 | require("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 | |||
| 5 | local opt = vim.opt | ||
| 6 | |||
| 7 | opt.number = true | ||
| 8 | opt.relativenumber = true | ||
| 9 | opt.list = true | ||
| 10 | opt.modeline = true | ||
| 11 | opt.background = "dark" | ||
| 12 | opt.foldmethod = "indent" | ||
| 13 | opt.listchars = { trail = "·", tab = "▸ ", eol = "¬" } | ||
| 14 | opt.scrolloff = 1 | ||
| 15 | opt.backspace = { "indent", "eol", "start" } | ||
| 16 | opt.cursorline = true | ||
| 17 | opt.hidden = true -- already Neovim's default; set explicitly for parity with the vimrc | ||
| 18 | opt.wildmenu = true -- already Neovim's default; set explicitly for parity with the vimrc | ||
| 19 | |||
| 20 | -- Faster gutter updates (signify) and snappier <Esc> | ||
| 21 | opt.updatetime = 100 | ||
| 22 | opt.ttimeoutlen = 10 | ||
| 23 | |||
| 24 | -- Persistent undo across sessions | ||
| 25 | local undodir = vim.fn.stdpath("data") .. "/undo" | ||
| 26 | if vim.fn.isdirectory(undodir) == 0 then | ||
| 27 | vim.fn.mkdir(undodir, "p", "0700") | ||
| 28 | end | ||
| 29 | opt.undofile = true | ||
| 30 | opt.undodir = undodir | ||
| 31 | |||
| 32 | -- Search-related things | ||
| 33 | opt.hlsearch = true | ||
| 34 | opt.incsearch = true | ||
| 35 | opt.ignorecase = true | ||
| 36 | opt.smartcase = true | ||
