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,42 +1,51 @@
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...
backup = false, -- ...but don't keep it around.
shortmess = vim.opt.shortmess + 'I', -- no intro message when starting Vim
shada = {
"'1000", -- remember marks for this many files "'1000", -- remember marks for this many files
"/1000", -- remember this many search patterns "/1000", -- remember this many search patterns
":1000", -- remember this many command line items ":1000", -- remember this many command line items
"<100", -- maximum number of lines to remember per register "<100", -- maximum number of lines to remember per register
"h", -- disable 'hlsearch' while reading shada file "h", -- disable 'hlsearch' while reading shada file
"s100", -- limit size of remembered items to this many KiB "s100", -- limit size of remembered items to this many KiB
} },
-- Searching -- Searching
o.ignorecase = true -- Ignore case when searching... ignorecase = true, -- Ignore case when searching...
o.smartcase = true -- ...unless pattern contains uppercase characters. smartcase = true, -- ...unless pattern contains uppercase characters.
-- Editing -- Editing
o.expandtab = true -- use spaces whe <Tab> is inserted expandtab = true, -- use spaces whe <Tab> is inserted
o.tabstop = 4 -- tabs are 4 spaces tabstop = 4, -- tabs are 4 spaces
o.shiftwidth = 0 -- (auto)indent using 'tabstop' spaces shiftwidth = 0, -- (auto)indent using 'tabstop' spaces
o.smartindent = true -- use smart autoindenting smartindent = true, -- use smart autoindenting
o.inccommand = 'split' -- preview command partial results inccommand = 'split', -- preview command partial results
o.joinspaces = false -- use one space after a period whe joining lines joinspaces = false, -- use one space after a period whe joining lines
o.showmatch = true -- briefly jump to matching bracket if insert one showmatch = true, -- briefly jump to matching bracket if insert one
o.virtualedit = 'block' -- position the cursor anywhere in Visual Block mode virtualedit = 'block', -- position the cursor anywhere in Visual Block mode
o.formatlistpat = [[^\s*\(\d\+[\]:.)}\t ]\|[-+*]\|[\[(][ x][\])]\)\s*]] formatlistpat = [[^\s*\(\d\+[\]:.)}\t ]\|[-+*]\|[\[(][ x][\])]\)\s*]],
o.formatoptions = o.formatoptions formatoptions = vim.opt.formatoptions
- 't' -- Don't auto-wrap on 'textwidth'... - 't' -- Don't auto-wrap on 'textwidth'...
+ 'c' -- ...but do it within comment blocks... + 'c' -- ...but do it within comment blocks...
+ 'l' -- ...but not if line was already long before entering Insert mode. + 'l' -- ...but not if line was already long before entering Insert mode.
@ -46,30 +55,30 @@ o.formatoptions = o.formatoptions
- 'a' -- don't auto-format every time text is inserted - 'a' -- don't auto-format every time text is inserted
+ 'n' -- indent lists automatically acc. 'formatlistpat' + 'n' -- indent lists automatically acc. 'formatlistpat'
+ 'j' -- remove comment leader when joining lines + 'j' -- remove comment leader when joining lines
+ '1' -- don't break lines after a one letter word but rather before it + '1', -- don't break lines after a one letter word but rather before it
-- Appearance -- Appearance
o.showmode = false -- don't show mode (shown in statusline instead) showmode = false, -- don't show mode (shown in statusline instead)
o.relativenumber = true -- Start off with realtive line numbers... relativenumber = true, -- Start off with realtive line numbers...
o.number = true -- ...but real number for current line. number = true, -- ...but real number for current line.
o.wrap = false -- don't wrap long lines initially wrap = false, -- don't wrap long lines initially
o.textwidth = 79 -- maximum width for text being inserted textwidth = 79, -- maximum width for text being inserted
o.colorcolumn = '+1' -- highlight column after 'textwidth' colorcolumn = '+1', -- highlight column after 'textwidth'
o.cursorline = true -- highlight the line of the cursor cursorline = true, -- highlight the line of the cursor
o.showbreak = '' -- prefix for wrapped lines showbreak = '', -- prefix for wrapped lines
o.scrolloff = 3 -- min. # of lines above and below cursor scrolloff = 3, -- min. # of lines above and below cursor
o.sidescrolloff = 3 -- min. # of columns to left and right of cursor sidescrolloff = 3, -- min. # of columns to left and right of cursor
o.list = true -- show invisible characters list = true, -- show invisible characters
o.listchars = { listchars = {
tab = '» ', tab = '» ',
extends = '', extends = '',
precedes = '', precedes = '',
trail = '·', trail = '·',
conceal = '', conceal = '',
} },
-- Wildcard Expansion -- Wildcard Expansion
o.wildignore = { wildignore = {
'.git', '.git',
'.svn', '.svn',
'__pycache__', '__pycache__',
@ -89,25 +98,26 @@ o.wildignore = {
'*.so', '*.so',
'*.zip', '*.zip',
'*~', '*~',
} },
o.wildignorecase = true -- ignore case when completing file names wildignorecase = true, -- ignore case when completing file names
o.wildmode = 'longest:full' -- longest common prefix first, then wildmenu wildmode = 'longest:full', -- longest common prefix first, then wildmenu
-- Window Splitting -- Window Splitting
o.splitbelow = true -- :split below current window splitbelow = true, -- :split below current window
o.splitright = true -- :vsplit to the right of current window splitright = true, -- :vsplit to the right of current window
o.equalalways = false -- don't resize all windows when splitting equalalways = false, -- don't resize all windows when splitting
-- Folding -- Folding
o.foldenable = true -- enable folding foldenable = true, -- enable folding
o.foldlevelstart = 100 -- start with all folds open foldlevelstart = 100, -- start with all folds open
o.foldmethod = 'syntax' -- fold based on syntax by default foldmethod = 'syntax', -- fold based on syntax by default
o.foldnestmax = 10 -- limit nested folds to 10 levels foldnestmax = 10, -- limit nested folds to 10 levels
-- Options for diff mode -- Options for diff mode
o.diffopt = { -- better side-by-side diffs diffopt = { -- better side-by-side diffs
'filler', -- show filler lines (so text ins vertically synced) 'filler', -- show filler lines (so text ins vertically synced)
'vertical', -- use vertical splits (files side-by-side) 'vertical', -- use vertical splits (files side-by-side)
'closeoff', -- disable diff mode when one window is closed 'closeoff', -- disable diff mode when one window is closed
},
} }