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