Add more Neovim plugins and config

This commit is contained in:
Lexi / Zoe 2026-09-01 19:48:28 +02:00
parent 29e053af75
commit b5bd437512
Signed by: binaryDiv
GPG key ID: F8D4956E224DA232
5 changed files with 676 additions and 50 deletions

View file

@ -1,8 +1,10 @@
-- Config shortcuts
local o = vim.o
local opt = vim.opt
local keymap = vim.keymap
-- Autocommand group for this file to allow config reloading
local augroup = vim.api.nvim_create_augroup('init', { clear = true })
------------------
-- GENERAL OPTIONS
@ -36,9 +38,20 @@ o.softtabstop = -1
-- Don't auto-insert comment leader when entering insert mode with o/O
vim.api.nvim_create_autocmd('FileType', {
group = augroup,
command = 'set formatoptions-=o',
})
-- Open new split windows at the bottom / right side
o.splitbelow = true
o.splitright = true
-- Pseudo-transparency for floating windows
o.winblend = 10
-- Show inline diagnostics (LSP)
vim.diagnostic.config { virtual_text = true }
-------------
-- FILE TYPES
@ -54,6 +67,13 @@ vim.filetype.add {
vim.g.html_indent_autotags = 'html,body'
vim.g.html_indent_inctags = 'p'
-- In filetypes that use tab indentation, render tabs as 4 spaces
vim.api.nvim_create_autocmd('FileType', {
group = augroup,
pattern = 'go',
command = 'setlocal tabstop=4',
})
-----------
-- MAPPINGS
@ -61,22 +81,26 @@ vim.g.html_indent_inctags = 'p'
-- For keys that are safe to be mapped, see: https://vim.fandom.com/wiki/Unused_keys
-- Exit insert mode with jk
-- Exit insert/command mode with jk
keymap.set('i', 'jk', '<Esc>')
keymap.set('c', 'jk', '<Esc>')
-- Quick exit with Ctrl-q
keymap.set('n', '<C-q>', ':q<CR>')
-- Quick exit (:qall) with Ctrl-q
keymap.set('n', '<C-q>', '<Cmd>qall<CR>')
-- Close current buffer (:q) with Alt-q
keymap.set('n', '<A-q>', '<Cmd>q<CR>')
-- Quick save all open buffers with Ctrl-s
keymap.set('n', '<C-s>', ':wall<CR>')
keymap.set('i', '<C-s>', '<C-o>:wall<CR>')
keymap.set('n', '<C-s>', '<Cmd>wall<CR>')
keymap.set('i', '<C-s>', '<C-o><Cmd>wall<CR>')
-- Simple copy and paste to/from system clipboard with Ctrl-c in visual mode
-- and Ctrl-v in insert mode
keymap.set('v', '<C-c>', '"+y')
keymap.set('i', '<C-v>', '<C-\\><C-o>"+P')
-- Navigate between windows with Alt and hjkl
-- Navigate between windows in normal mode with Alt and hjkl
keymap.set('n', '<A-h>', '<C-w>h')
keymap.set('n', '<A-j>', '<C-w>j')
keymap.set('n', '<A-k>', '<C-w>k')
@ -92,32 +116,61 @@ keymap.set('n', '<A-Right>', '<C-w>4>')
keymap.set({'n', 'x'}, 'H', '^')
keymap.set({'n', 'x'}, 'L', '$')
-- Use comma (,) as a "modifier prefix" for alternative functions of regular
-- commands (e.g. yank to system clipboard) or for random shortcuts.
-- TODO: Comma or semicolon or single quote?
keymap.set({'n', 'x'}, ',', '<Nop>')
-- Move cursor in insert mode with Alt and hjkl
keymap.set('i', '<A-h>', '<Left>')
keymap.set('i', '<A-j>', '<Down>')
keymap.set('i', '<A-k>', '<Up>')
keymap.set('i', '<A-l>', '<Right>')
-- Prefix yank/delete/change/paste commands with "," to use system clipboard
keymap.set({'n', 'x'}, ',y', '"+y')
keymap.set({'n', 'x'}, ',Y', '"+y$')
keymap.set({'n', 'x'}, ',d', '"+d')
keymap.set({'n', 'x'}, ',D', '"+D')
keymap.set({'n', 'x'}, ',c', '"+c')
keymap.set({'n', 'x'}, ',C', '"+C')
keymap.set({'n', 'x'}, ',p', '"+p')
keymap.set({'n', 'x'}, ',P', '"+P')
-- Visual mode: Extend selection to parent node with "."
-- ("an" will be remapped to "around next" by mini.ai)
local _an_keymap = vim.fn.maparg('an', 'x', false, true)
keymap.set('x', '.', _an_keymap.callback, { desc = 'Extend selection to parent node' })
-- Visual mode: Move selected lines upwards/downwards with Alt-j/k
keymap.set('x', '<A-j>', ":m '>+1<CR>gv=gv")
keymap.set('x', '<A-k>', ":m '<-2<CR>gv=gv")
-- Visual mode: Stay in visual mode when indenting
keymap.set('v', '<', '<gv')
keymap.set('v', '>', '>gv')
-- Use space as a "modifier prefix" for alternative functions of regular commands
-- (e.g. yank to system clipboard) or for random shortcuts.
keymap.set({'n', 'x'}, ' ', '<Nop>')
-- Prefix yank/delete/change/paste commands to use system clipboard
keymap.set({'n', 'x'}, ' y', '"+y', { desc = 'Yank (clipboard)' })
keymap.set({'n', 'x'}, ' Y', '"+y$', { desc = 'Yank rest of line (clipboard)' })
keymap.set({'n', 'x'}, ' d', '"+d', { desc = 'Delete (clipboard)' })
keymap.set({'n', 'x'}, ' D', '"+D', { desc = 'Delete rest of line (clipboard)' })
keymap.set({'n', 'x'}, ' c', '"+c', { desc = 'Change (clipboard)' })
keymap.set({'n', 'x'}, ' C', '"+C', { desc = 'Change rest of line (clipboard)' })
keymap.set({'n', 'x'}, ' p', '"+p', { desc = 'Paste after cursor (clipboard)' })
keymap.set({'n', 'x'}, ' P', '"+P', { desc = 'Paste before cursor (clipboard)' })
-- Paste from system clipboard on a new line (before/after the current line)
keymap.set('n', ' lp', '<Cmd>:put +<CR>', { desc = 'Paste on new line below cursor (clipboard)' })
keymap.set('n', ' lP', '<Cmd>:put! +<CR>', { desc = 'Paste on new line above cursor (clipboard)' })
-- Select previously changed or yanked text (e.g. pasted text) in visual mode
keymap.set('n', ' v', '`[v`]', { desc = 'Select previously changed/yanked text' })
-- Insert empty line(s) below or above current line without moving the cursor
keymap.set('n', ',o', function()
keymap.set('n', ' o', function()
local line = vim.api.nvim_win_get_cursor(0)[1]
local repeated = vim.fn['repeat']({''}, vim.v.count1)
vim.api.nvim_buf_set_lines(0, line, line, true, repeated)
end)
keymap.set('n', ',O', function()
end, { desc = 'Insert empty line below cursor' })
keymap.set('n', ' O', function()
local line = vim.api.nvim_win_get_cursor(0)[1] - 1
local repeated = vim.fn['repeat']({''}, vim.v.count1)
vim.api.nvim_buf_set_lines(0, line, line, true, repeated)
end)
end, { desc = 'Insert empty line above cursor' })
-- LSP mappings (more in plugins.lua)
keymap.set('n', 'K', vim.lsp.buf.hover)
keymap.set('n', 'gq', vim.lsp.buf.format, { desc = 'Auto-format file (LSP)' })
----------