From e7e37c8dc8008d6efeb80bd29b8f6761d0842c84 Mon Sep 17 00:00:00 2001 From: Job79 Date: Wed, 24 Jun 2026 19:47:32 +0200 Subject: [PATCH] refactor: options --- plugin/10_options.lua | 166 ++++++++++++------------------------------ 1 file changed, 47 insertions(+), 119 deletions(-) diff --git a/plugin/10_options.lua b/plugin/10_options.lua index 0e734e4..78acb27 100644 --- a/plugin/10_options.lua +++ b/plugin/10_options.lua @@ -1,129 +1,57 @@ --- ┌──────────────────────────┐ --- │ Built-in Neovim behavior │ --- └──────────────────────────┘ --- --- This file defines Neovim's built-in behavior. The goal is to improve overall --- usability in a way that works best with MINI. --- --- Here `vim.o.xxx = value` sets default value of option `xxx` to `value`. --- See `:h 'xxx'` (replace `xxx` with actual option name). --- --- Option values can be customized on a per buffer or window basis. --- See 'after/ftplugin/' for common example. --- --- Notes: --- - Some options (like `:h 'exrc'`) need to be set before this file is sourced. --- Set them directly at the bottom of the 'init.lua' file. +-- General ===================================================================== +vim.g.mapleader = ' ' -- Use `` as key +vim.o.undofile = true -- Enable persistent undo --- stylua: ignore start --- The next part (until `-- stylua: ignore end`) is aligned manually for easier --- reading. Consider preserving this or remove `-- stylua` lines to autoformat. +-- UI ========================================================================== +vim.o.breakindent = true -- Indent wrapped lines to match line start +vim.o.breakindentopt = 'list:-1' -- Add padding for lists (if 'wrap' is set) +vim.o.cursorline = true -- Enable current line highlighting +vim.o.linebreak = true -- Wrap lines at 'breakat' (if 'wrap' is set) +vim.o.list = true -- Show helpful text indicators +vim.o.number = true -- Show line numbers +vim.o.pumheight = 10 -- Make popup menu smaller +vim.o.pummaxwidth = 100 -- Make popup menu not too wide +vim.o.shortmess = 'CFOSWaco' -- Disable some built-in completion messages +vim.o.signcolumn = 'yes' -- Always show signcolumn (less flicker) +vim.o.splitbelow = true -- Horizontal splits will be below +vim.o.splitkeep = 'screen' -- Reduce scroll during window split +vim.o.splitright = true -- Vertical splits will be to the right +vim.o.wrap = false -- Don't visually wrap lines (toggle with \w) +vim.o.cmdheight = 0 -- Hide the command line when not in use. --- General ==================================================================== -vim.g.mapleader = ' ' -- Use `` as key +-- Editing ===================================================================== +vim.o.expandtab = true -- Convert tabs to spaces +vim.o.formatoptions = 'rqnl1j' -- Improve comment editing +vim.o.ignorecase = true -- Ignore case during search +vim.o.infercase = true -- Infer case in built-in completion +vim.o.shiftwidth = 2 -- Use this number of spaces for indentation +vim.o.smartcase = true -- Respect case if search pattern has upper case +vim.o.spelloptions = 'camel' -- Treat camelCase word parts as separate words +vim.o.tabstop = 2 -- Show tab as this number of spaces +vim.o.virtualedit = 'block' -- Allow going past end of line in blockwise mode -vim.o.mouse = 'a' -- Enable mouse -vim.o.mousescroll = 'ver:25,hor:6' -- Customize mouse scroll -vim.o.switchbuf = 'usetab' -- Use already opened buffers when switching -vim.o.undofile = true -- Enable persistent undo - -vim.o.shada = "'100,<50,s10,:1000,/100,@100,h" -- Limit ShaDa file (for startup) - --- Enable all filetype plugins and syntax (if not enabled, for better startup) -vim.cmd('filetype plugin indent on') -if vim.fn.exists('syntax_on') ~= 1 then vim.cmd('syntax enable') end - --- UI ========================================================================= -vim.o.breakindent = true -- Indent wrapped lines to match line start -vim.o.breakindentopt = 'list:-1' -- Add padding for lists (if 'wrap' is set) -vim.o.colorcolumn = '+1' -- Draw column on the right of maximum width -vim.o.cursorline = true -- Enable current line highlighting -vim.o.linebreak = true -- Wrap lines at 'breakat' (if 'wrap' is set) -vim.o.list = true -- Show helpful text indicators -vim.o.number = true -- Show line numbers -vim.o.pumborder = 'single' -- Use border in popup menu -vim.o.pumheight = 10 -- Make popup menu smaller -vim.o.pummaxwidth = 100 -- Make popup menu not too wide -vim.o.ruler = false -- Don't show cursor coordinates -vim.o.shortmess = 'CFOSWaco' -- Disable some built-in completion messages -vim.o.showmode = false -- Don't show mode in command line -vim.o.signcolumn = 'yes' -- Always show signcolumn (less flicker) -vim.o.splitbelow = true -- Horizontal splits will be below -vim.o.splitkeep = 'screen' -- Reduce scroll during window split -vim.o.splitright = true -- Vertical splits will be to the right -vim.o.winborder = 'single' -- Use border in floating windows -vim.o.wrap = false -- Don't visually wrap lines (toggle with \w) - -vim.o.cursorlineopt = 'screenline,number' -- Show cursor line per screen line - --- Special UI symbols. More is set via 'mini.basics' later. -vim.o.fillchars = 'eob: ,fold:╌' -vim.o.listchars = 'extends:…,nbsp:␣,precedes:…,tab:> ' - --- Folds (see `:h fold-commands`, `:h zM`, `:h zR`, `:h zA`, `:h zj`) -vim.o.foldlevel = 10 -- Fold nothing by default; set to 0 or 1 to fold -vim.o.foldmethod = 'indent' -- Fold based on indent level -vim.o.foldnestmax = 10 -- Limit number of fold levels -vim.o.foldtext = '' -- Show text under fold with its highlighting - --- Editing ==================================================================== -vim.o.autoindent = true -- Use auto indent -vim.o.expandtab = true -- Convert tabs to spaces -vim.o.formatoptions = 'rqnl1j'-- Improve comment editing -vim.o.ignorecase = true -- Ignore case during search -vim.o.incsearch = true -- Show search matches while typing -vim.o.infercase = true -- Infer case in built-in completion -vim.o.shiftwidth = 2 -- Use this number of spaces for indentation -vim.o.smartcase = true -- Respect case if search pattern has upper case -vim.o.smartindent = true -- Make indenting smart -vim.o.spelloptions = 'camel' -- Treat camelCase word parts as separate words -vim.o.tabstop = 2 -- Show tab as this number of spaces -vim.o.virtualedit = 'block' -- Allow going past end of line in blockwise mode - -vim.o.iskeyword = '@,48-57,_,192-255,-' -- Treat dash as `word` textobject part - --- Pattern for a start of numbered list (used in `gw`). This reads as --- "Start of list item is: at least one special character (digit, -, +, *) --- possibly followed by punctuation (. or `)`) followed by at least one space". -vim.o.formatlistpat = [[^\s*[0-9\-\+\*]\+[\.\)]*\s\+]] +-- Pattern for a start of numbered list (used in `gw`). +vim.o.formatlistpat = [[^\s*[0-9\-\+\*]\+[\.\)]*\s\+]] -- Built-in completion vim.o.complete = '.,w,b,kspell' -- Use less sources vim.o.completeopt = 'menuone,noselect,fuzzy,nosort' -- Use custom behavior vim.o.completetimeout = 100 -- Limit sources delay --- Autocommands =============================================================== +-- Autocommands ================================================================ +Config.autocmd('TextYankPost', '*', function() vim.hl.hl_op() end, 'Highlight yanked text') +Config.autocmd('TermOpen', '*', function() vim.cmd('startinsert') end, 'Start insert mode when terminal opens') --- Don't auto-wrap comments and don't insert comment leader after hitting 'o'. --- Do on `FileType` to always override these changes from filetype plugins. -local f = function() vim.cmd('setlocal formatoptions-=c formatoptions-=o') end -Config.new_autocmd('FileType', nil, f, "Proper 'formatoptions'") - --- There are other autocommands created by 'mini.basics'. See 'plugin/30_mini.lua'. - --- Diagnostics ================================================================ - --- Neovim has built-in support for showing diagnostic messages. This configures --- a more conservative display while still being useful. --- See `:h vim.diagnostic` and `:h vim.diagnostic.config()`. -local diagnostic_opts = { - -- Show signs on top of any other sign, but only for warnings and errors - signs = { priority = 9999, severity = { min = 'WARN', max = 'ERROR' } }, - - -- Show all diagnostics as underline (for their messages type `ld`) - underline = { severity = { min = 'HINT', max = 'ERROR' } }, - - -- Show more details immediately for errors on the current line - virtual_lines = false, - virtual_text = { - current_line = true, - severity = { min = 'ERROR', max = 'ERROR' }, - }, - - -- Don't update diagnostics when typing - update_in_insert = false, -} - --- Use `later()` to avoid sourcing `vim.diagnostic` on startup -Config.later(function() vim.diagnostic.config(diagnostic_opts) end) --- stylua: ignore end +-- Diagnostics ================================================================= +Config.later(function() + vim.diagnostic.config({ + signs = { priority = 9999, severity = { min = 'WARN', max = 'ERROR' } }, + underline = { severity = { min = 'HINT', max = 'ERROR' } }, + virtual_lines = false, + virtual_text = { + current_line = true, + severity = { min = 'ERROR', max = 'ERROR' }, + }, + update_in_insert = false, + }) +end)