vim: nicer setting of options

This commit is contained in:
Fernando Schauenburg 2022-01-24 21:57:11 +01:00
parent 35fbbc1d07
commit 1acd99e2fa

View file

@ -1,113 +1,123 @@
local o = vim.opt -- vim.cmd('let &t_8f = "\\e[38:2:%lu:%lu:%lum"')
-- vim.cmd('let &t_8b = "\\e[48:2:%lu:%lu:%lum"')
-- General local set_options = function(options)
o.belloff = 'all' -- never ring bells local opt = vim.opt
o.hidden = true -- hide abandoned buffers for k, v in pairs(options) do
o.clipboard = 'unnamedplus' -- synchronize with system clipboard opt[k] = v
o.lazyredraw = true -- don't redraw screen during macros end
o.modelines = 0 -- never use modelines end
o.fileformats = 'unix,mac,dos' -- prioritize unix <EOL> format
o.swapfile = false -- don't use swap files set_options {
o.writebackup = true -- Make a backup before writing a file... -- General
o.backup = false -- ...but don't keep it around. belloff = 'all', -- never ring bells
hidden = true, -- hide abandoned buffers
clipboard = 'unnamedplus', -- synchronize with system clipboard
lazyredraw = true, -- don't redraw screen during macros
modelines = 0, -- never use modelines
fileformats = 'unix,mac,dos', -- prioritize unix <EOL> format
o.shortmess:append('I') -- no intro message when starting Vim swapfile = false, -- don't use swap files
o.shada = { writebackup = true, -- Make a backup before writing a file...
"'1000", -- remember marks for this many files backup = false, -- ...but don't keep it around.
"/1000", -- remember this many search patterns
":1000", -- remember this many command line items shortmess = vim.opt.shortmess + 'I', -- no intro message when starting Vim
"<100", -- maximum number of lines to remember per register shada = {
"h", -- disable 'hlsearch' while reading shada file "'1000", -- remember marks for this many files
"s100", -- limit size of remembered items to this many KiB "/1000", -- remember this many search patterns
} ":1000", -- remember this many command line items
"<100", -- maximum number of lines to remember per register
-- Searching "h", -- disable 'hlsearch' while reading shada file
o.ignorecase = true -- Ignore case when searching... "s100", -- limit size of remembered items to this many KiB
o.smartcase = true -- ...unless pattern contains uppercase characters. },
-- Editing -- Searching
o.expandtab = true -- use spaces whe <Tab> is inserted ignorecase = true, -- Ignore case when searching...
o.tabstop = 4 -- tabs are 4 spaces smartcase = true, -- ...unless pattern contains uppercase characters.
o.shiftwidth = 0 -- (auto)indent using 'tabstop' spaces
o.smartindent = true -- use smart autoindenting -- Editing
o.inccommand = 'split' -- preview command partial results expandtab = true, -- use spaces whe <Tab> is inserted
o.joinspaces = false -- use one space after a period whe joining lines tabstop = 4, -- tabs are 4 spaces
o.showmatch = true -- briefly jump to matching bracket if insert one shiftwidth = 0, -- (auto)indent using 'tabstop' spaces
o.virtualedit = 'block' -- position the cursor anywhere in Visual Block mode smartindent = true, -- use smart autoindenting
o.formatlistpat = [[^\s*\(\d\+[\]:.)}\t ]\|[-+*]\|[\[(][ x][\])]\)\s*]] inccommand = 'split', -- preview command partial results
o.formatoptions = o.formatoptions joinspaces = false, -- use one space after a period whe joining lines
- 't' -- Don't auto-wrap on 'textwidth'... showmatch = true, -- briefly jump to matching bracket if insert one
+ 'c' -- ...but do it within comment blocks... virtualedit = 'block', -- position the cursor anywhere in Visual Block mode
+ 'l' -- ...but not if line was already long before entering Insert mode. formatlistpat = [[^\s*\(\d\+[\]:.)}\t ]\|[-+*]\|[\[(][ x][\])]\)\s*]],
+ 'r' -- Insert comment leader when pressing Enter... formatoptions = vim.opt.formatoptions
- 'o' -- ...but not when opening a new line with o & O. - 't' -- Don't auto-wrap on 'textwidth'...
+ 'q' -- allow formatting of comments with gq + 'c' -- ...but do it within comment blocks...
- 'a' -- don't auto-format every time text is inserted + 'l' -- ...but not if line was already long before entering Insert mode.
+ 'n' -- indent lists automatically acc. 'formatlistpat' + 'r' -- Insert comment leader when pressing Enter...
+ 'j' -- remove comment leader when joining lines - 'o' -- ...but not when opening a new line with o & O.
+ '1' -- don't break lines after a one letter word but rather before it + 'q' -- allow formatting of comments with gq
- 'a' -- don't auto-format every time text is inserted
-- Appearance + 'n' -- indent lists automatically acc. 'formatlistpat'
o.showmode = false -- don't show mode (shown in statusline instead) + 'j' -- remove comment leader when joining lines
o.relativenumber = true -- Start off with realtive line numbers... + '1', -- don't break lines after a one letter word but rather before it
o.number = true -- ...but real number for current line.
o.wrap = false -- don't wrap long lines initially -- Appearance
o.textwidth = 79 -- maximum width for text being inserted showmode = false, -- don't show mode (shown in statusline instead)
o.colorcolumn = '+1' -- highlight column after 'textwidth' relativenumber = true, -- Start off with realtive line numbers...
o.cursorline = true -- highlight the line of the cursor number = true, -- ...but real number for current line.
o.showbreak = '' -- prefix for wrapped lines wrap = false, -- don't wrap long lines initially
o.scrolloff = 3 -- min. # of lines above and below cursor textwidth = 79, -- maximum width for text being inserted
o.sidescrolloff = 3 -- min. # of columns to left and right of cursor colorcolumn = '+1', -- highlight column after 'textwidth'
o.list = true -- show invisible characters cursorline = true, -- highlight the line of the cursor
o.listchars = { showbreak = '', -- prefix for wrapped lines
tab = '» ', scrolloff = 3, -- min. # of lines above and below cursor
extends = '', sidescrolloff = 3, -- min. # of columns to left and right of cursor
precedes = '', list = true, -- show invisible characters
trail = '·', listchars = {
conceal = '', tab = '» ',
} extends = '',
precedes = '',
-- Wildcard Expansion trail = '·',
o.wildignore = { conceal = '',
'.git', },
'.svn',
'__pycache__', -- Wildcard Expansion
'**/tmp/**', wildignore = {
'*.DS_Store', '.git',
'*.dll', '.svn',
'*.egg-info', '__pycache__',
'*.exe', '**/tmp/**',
'*.gif', '*.DS_Store',
'*.jpeg', '*.dll',
'*.jpg', '*.egg-info',
'*.o', '*.exe',
'*.obj', '*.gif',
'*.out', '*.jpeg',
'*.png', '*.jpg',
'*.pyc', '*.o',
'*.so', '*.obj',
'*.zip', '*.out',
'*~', '*.png',
} '*.pyc',
o.wildignorecase = true -- ignore case when completing file names '*.so',
o.wildmode = 'longest:full' -- longest common prefix first, then wildmenu '*.zip',
'*~',
-- Window Splitting },
o.splitbelow = true -- :split below current window wildignorecase = true, -- ignore case when completing file names
o.splitright = true -- :vsplit to the right of current window wildmode = 'longest:full', -- longest common prefix first, then wildmenu
o.equalalways = false -- don't resize all windows when splitting
-- Window Splitting
-- Folding splitbelow = true, -- :split below current window
o.foldenable = true -- enable folding splitright = true, -- :vsplit to the right of current window
o.foldlevelstart = 100 -- start with all folds open equalalways = false, -- don't resize all windows when splitting
o.foldmethod = 'syntax' -- fold based on syntax by default
o.foldnestmax = 10 -- limit nested folds to 10 levels -- Folding
foldenable = true, -- enable folding
-- Options for diff mode foldlevelstart = 100, -- start with all folds open
o.diffopt = { -- better side-by-side diffs foldmethod = 'syntax', -- fold based on syntax by default
'filler', -- show filler lines (so text ins vertically synced) foldnestmax = 10, -- limit nested folds to 10 levels
'vertical', -- use vertical splits (files side-by-side)
'closeoff', -- disable diff mode when one window is closed -- Options for diff mode
diffopt = { -- better side-by-side diffs
'filler', -- show filler lines (so text ins vertically synced)
'vertical', -- use vertical splits (files side-by-side)
'closeoff', -- disable diff mode when one window is closed
},
} }