-- -- Copyright (c) 2026 Jan Fooken -- -- 10_options.lua -- -- Configure Neovim's built-in behavior to make it more intuitive -- -- For an overview of options see |option-list| (type :help option-list). -- For a detailed description of an option see |options| (type :help options). -- -- Prefer vim.o over vim.opt, as it gives better errors. Compared to vim.o, -- vim.opt supports associative arrays aka Lua tables. -- See https://github.com/neovim/neovim/issues/20107. local o = vim.o local opt = vim.opt -- General ===================================================================== -- When on, enable project-local configuration. Nvim will execute any .nvim.lua, -- .nvimrc, or .exrc file found in the |current-directory| and all parent -- directories (ordered upwards), if the files are in the |trust| list. Use -- |:trust| to manage trusted files. --o.exrc = false -- (default) -- When on, spell checking will be done. See |spell|. o.spell = true -- A comma-separated list of word list names. When the 'spell' option is on -- spellchecking will be done for these languages. --opt.spelllang = { 'en' } -- (default) -- When a word is CamelCased, assume "Cased" is a separate word: every -- upper-case character in a word that comes after a lower case character -- indicates the start of a new word. opt.spelloptions:append { 'camel' } -- The maximum number of spell suggestions listed for |z=|. opt.spellsuggest:append { '10' } -- When on, splitting a window will put the new window below the current one. -- See |:split| and |CTRL-W_S|. o.splitbelow = true -- When on, splitting a window will put the new window right of the current one. -- See |:vsplit| and |CTRL-W_V|. o.splitright = true -- When switching buffers, jump to the first open window in the current tab page -- that contains the specified buffer (if there is one). Otherwise: Do not -- examine other windows. opt.switchbuf = { 'useopen' } -- When closing tab pages (e.g., using |:tabclose|), go to the previous tab page -- instead of the next one. opt.tabclose = { 'left' } -- Time in milliseconds to wait for a mapped sequence to complete. o.timeoutlen = 500 -- When on, Vim automatically saves undo history to an undo file when writing -- a buffer to a file, and restores undo history from the same file on buffer -- read. o.undofile = true -- If this many milliseconds nothing is typed the swap file will be written to -- disk (see |crash-recovery|). Also used for the |CursorHold| autocommand -- event. o.updatetime = 300 -- Completion ================================================================== -- Comment in to use the system clipboard for yank, delete, change and put -- operations when not connected via SSH. See |clipboard|. --opt.clipboard = vim.env.SSH_CONNECTION and "" or "unnamedplus" -- Use the currently active spell checking |spell| during |ins-completion|. opt.complete:append 'kspell' -- When removed, do not scan the unloaded buffers that are in the buffer list -- during |ins-completion|. --opt.complete:remove('u') -- During |ins-completion|, enable |fuzzy-matching| of completion candidates. -- Always show a menu, even when there is only one match. Don't pre-select -- a match. Keep the original sort order and show additional information about -- matches in a popup window. The value "preinsert" could be interesting when -- using 'autocomplete', but for this "fuzzy" needs to be removed and -- 'infercase' to be enabled when 'ignorecase' is enabled. opt.completeopt = { 'fuzzy', 'menuone', 'noselect', 'nosort', 'popup' } -- When on, ignore case in search patterns and keyword completion. Can be -- overruled by using "\c" or "\C" in the pattern, see |/ignorecase|. o.ignorecase = true -- When on, during keyword completion in insert mode |ins-completion|, and when -- 'ignorecase' is also on, the case of the match is adjusted depending on the -- typed text. --o.infercase = false -- (default) -- When on, override the 'ignorecase' option if the search pattern contains -- upper case characters. o.smartcase = true -- Exclude macOS metadata when expanding |wildcards|, completing file or -- directory names, and influences the result of |expand()|, |glob()| and -- |globpath()|. opt.wildignore:append { '.DS_Store' } -- When on, case is ignored when completing file names and directories during -- |cmdline-completion|. o.wildignorecase = true -- During |cmdline-completion|, show the 'wildmenu' on the first press and -- complete the longest common substring. During the second press, cycle -- through full matches. opt.wildmode = { 'longest', 'full' } -- During |cmdline-completion|, use |fuzzy-matching| to find completion matches. opt.wildoptions:append { 'fuzzy' } -- UI ========================================================================== -- When on, every wrapped line will continue visually indented. Only relevant -- when 'wrap' is on. Behavior can be customized via 'breakindentopt'. o.breakindent = true -- For wrapped lines display the 'showbreak' value before applying the -- additional indent. Only relevant when 'wrap' is on. opt.breakindentopt:append 'sbr' -- On wrapped lines, adds indent for lines that match a numbered or bulleted -- list (using the 'formatlistpat' setting). Only relevant when 'wrap' is on. opt.breakindentopt:append 'list:-1' -- Number of screen lines to use for the command-line. Using the value 0 hides -- the cmdline, but is EXPERIMENTAL and works better with |ui2|. --o.cmdheight = 1 -- (default) -- Screen columns that are highlighted with ColorColumn |hl-ColorColumn|. The -- value "+1" highlights the column after the 'textwidth' column. opt.colorcolumn = { '+1' } -- The column used for 'number' and 'relativenumber' will also be used for the -- 'showbreak' character to signal the presence of of wrapped lines. opt.cpoptions:append 'n' -- When on, highlight the text line of the cursor with CursorLine -- |hl-CursorLine|. o.cursorline = true -- Highlight only the screen line and the line number of the cursor with -- CursorLine |hl-CursorLine|. opt.cursorlineopt = { 'number', 'screenline' } -- Characters to fill the statuslines, vertical separators, special lines in the -- window and truncated text in the |ins-completion-menu|. opt.fillchars:append { fold = '╌' } -- Draw a column to display where folds are. Only draw it when folds are -- present in the file to not waste space. o.foldcolumn = 'auto' -- Sets 'foldlevel' when starting to edit another buffer in a window. Using 99 -- causes all folds to be opened by default. Change the 'foldlevel' value via -- commands like |zc|, |zo|, |zm|, |zM| and |zR|. o.foldlevelstart = 99 -- Comment in to only show a single status line at the bottom. --o.laststatus = 3 -- When on, wrap long lines at a character in 'breakat' rather than at the last -- character that fits on the screen. Only relevant when 'wrap' is on. o.linebreak = true -- When on, show symbols for special characters like and . o.list = true -- Strings to use in 'list' mode and for the |:list| command. When you want to -- highlight leading space, add the "lead" key to the dictionary below. opt.listchars = { tab = '‹ ›', trail = '·', extends = '…', precedes = '…', nbsp = '␣', } -- When on, print the line number in front of each line. o.number = true -- Enables pseudo-transparency for the |popup-menu|. It is possible to override -- the level for individual highlights within the popupmenu using -- |highlight-blend|. o.pumblend = 15 -- Comment in to use single-line box characters with rounded corners as the -- border style of popupmenu windows. See 'winborder' for valid values. --o.pumborder = 'rounded' -- Maximum number of items to show in the popup menu (|ins-completion-menu|). -- Zero means "use available screen space". o.pumheight = 10 -- Maximum width for the popup menu (|ins-completion-menu|). When zero, there -- is no maximum width limit, otherwise the popup menu will never be wider than -- this value. o.pummaxwidth = 98 -- When on, show the line number relative to the line with the cursor in front -- of each line. --o.relativenumber = false -- (default) -- When on, show the line and column number of the cursor position, separated by -- a comma. You want to disable this, when you're using a custom statusline. o.ruler = false -- Minimal number of screen lines to keep above and below the cursor. This will -- make some context visible around where you are working. o.scrolloff = 8 -- Don't give |ins-completion-menu| messages; for example, "-- XXX completion -- (YYY)", "match 1 of 2", "The only match", "Pattern not found", "Back at -- original", etc. See |shm-c|. opt.shortmess:append 'c' -- String to put at the start of lines that have been wrapped. Only relevant -- when 'wrap' is on. o.showbreak = '↩︎ ' -- When on, show (partial) command in the last line of the screen. o.showcmd = false -- When on and if in Insert, Replace or Visual mode put a message on the last -- line. You want to disable this, when you're using a custom statusline. o.showmode = false -- The minimal number of screen columns to keep to the left and to the right of -- the cursor if 'nowrap' is set. o.sidescrolloff = 8 -- Always draw the signcolumn to reduce visual shift. See |signs|. o.signcolumn = 'yes' -- Enables pseudo-transparency for a floating window. o.winblend = 15 -- Comment in to use single-line box characters with rounded corners as the -- border style of floating windows. See 'winborder' for valid values. --o.winborder = 'rounded' -- When on, lines longer than the width of the window will visually wrap and -- displaying continues on the next line. When off, lines will not visually -- wrap and only part of long lines will be displayed. When the cursor is moved -- to a part that is not shown, the screen will scroll horizontally. o.wrap = false -- Editing ===================================================================== -- When on, copy the structure of the existing lines indent when autoindenting -- a new line. See 'preserveindent'. o.copyindent = true -- When on, use the appropriate number of spaces to insert a . To insert -- a real tab when 'expandtab' is on, use CTRL-V. In my opinion is it -- better to utilise EditorConfig for setting preferences on a per project base, -- but you can change filetype defaults, too. For an example refer to the -- git-config filetype plugin found at "after/ftplugin/gitconfig.lua" relative -- to the project root. --o.expandtab = false -- (default) -- Automatically insert the current comment leader after hitting in -- Insert mode. See |fo-r|. opt.formatoptions:append 'r' -- Automatically insert the current comment leader after hitting 'o' or 'O' in -- Normal mode. See |fo-o|. TODO: Maybe remove opt.formatoptions:append 'o' -- When formatting text, recognize numbered lists. This actually uses the -- 'formatlistpat' option, thus any kind of list can be used. See |fo-n|. As -- an alternative setting |fo-2| could be interesting. opt.formatoptions:append 'n' -- Comment in, so long lines are not broken in insert mode: When a line was -- longer than 'textwidth' when the insert command started, Vim does not -- automatically format it. See |fo-l|. --opt.formatoptions:append 'l' -- Don't break a line after a one-letter word. It's broken before it instead -- (if possible). See |fo-1|. opt.formatoptions:append '1' -- Don't break lines at single spaces that follow periods. This is intended to -- complement 'joinspaces' and |cpo-J|, for prose with sentences separated by -- two spaces. NOTE: If you don't write prose like this, it doesn't make sense -- to include this option. Se |fo-p|. opt.formatoptions:append 'p' -- Treat dash as part of the "\k" character class. opt.iskeyword:append '-' -- When on, insert two spaces after a ".", "?" and "!" with a join command. o.joinspaces = true -- Enables mouse support in Normal mode and Visual mode. To enable in Insert -- mode, add "i" or comment the next line in to reset to the defaults. o.mouse = 'nv' -- When on, round indent to multiple of 'shiftwidth'. Applies to |>| and |<| -- commands. o.shiftround = true -- Number of columns that make up one level of (auto)indentation. If set to 0, -- Vim uses the current 'tabstop' value. --o.shiftwidth = 8 -- (default) -- When on, do smart autoindenting when starting a new line. When 'cindent' is -- on or 'indentexpr' is set, setting 'smartindent' has no effect. o.smartindent = true -- Defines the column multiple used to display the Horizontal Tab character -- (ASCII 9). Leave it at 8 unless you have a strong reason (see usr |30.5|). --o.tabstop = 8 -- (default) -- Allow virtual editing in Visual block mode. Virtual editing means that the -- cursor can be positioned where there is no actual character. This can be -- halfway into a tab or beyond the end of the line. Useful for selecting -- a rectangle in Visual mode and editing a table. You can enter Visual Block -- via |CTRL-V|. opt.virtualedit:append { 'block' }