config: nvim: rewrite config in lua and use packer as plugin manager

This commit is contained in:
Thomas Preisner 2022-10-13 19:29:40 +02:00
parent 07be5a4e7a
commit 6863d4c2eb
11 changed files with 174 additions and 197 deletions

View file

@ -0,0 +1,74 @@
-- reduce boilerplate by defining some shortcuts
local opt = vim.opt
local cmd = vim.cmd
local autocmd = vim.api.nvim_create_autocmd
--------------------
-- General
--------------------
opt.mouse = 'n' -- enable mouse support in normal mode
opt.clipboard = 'unnamedplus' -- copy/paste to and from system clipboard
opt.wildmode = 'list:longest,full'
opt.wildignorecase = true
opt.wildignore = '*.o,*.d,*.so,*.class,*.aux,*.log,*.out,*.toc,*.pdf,*.pyc'
opt.fileformats = 'unix,dos' -- use identical lineendings for all platforms
opt.secure = true -- disable autocmd for security reasons
--------------------
-- Tabs
--------------------
opt.tabstop = 4 -- 1 tab == N spaces
opt.shiftwidth = 4 -- shift N spaces when pressing tab
opt.smartindent = true -- take syntax into account for applying indentation
--------------------
-- Search
--------------------
opt.ignorecase = true -- ignore capitalization on search
opt.smartcase = true -- ignore capitalication unless word contains a capital
opt.iskeyword:append '-' -- treat hyphenated words as a single word
--------------------
-- Neovim UI
--------------------
opt.number = true -- line numbers
opt.ruler = true -- cursor position in statusbar
opt.showtabline = 2 -- always show vim tabs
opt.showcmd = true -- display currently typed command
opt.termguicolors = true -- enable 24-bit RGB color
-- highlight line at which the cursor is positioned
opt.cursorline = true
cmd 'highlight CursorLine term=bold cterm=bold'
cmd 'highlight CursorLineNR term=bold cterm=bold ctermbg=darkgrey'
-- display warning column at 81 and 121
opt.colorcolumn = '81,121'
cmd 'highlight ColorColumn ctermbg=235 guibg=#2d2d2d'
opt.splitright = true -- horizontal split to the right
opt.splitbelow = true -- vertical split to the bottom
-- define characters to display when using 'set list'
opt.listchars = 'tab:→ ,trail:∙,eol:¬,extends:,precedes:,nbsp:␣'
--------------------
-- Performance
--------------------
opt.hidden = true -- allow buffers with changes to be hidden
opt.updatetime = 300 -- delay (in ms) to wait before triggering event
opt.timeoutlen = 500 -- time (in ms) to wait for event to complete
opt.history = 10000 -- remember N lines of history
--------------------
-- Misc
--------------------
-- remove redundant whitespaces on save
autocmd('BufWritePre', {
pattern = '*',
command = ':%s/\\s\\+$//e'
})