-- Change files in place vim.o.backupcopy = 'yes' -- Disable auto comment vim.cmd.autocmd('FileType', '*', 'setlocal', 'formatoptions-=cro') -- Disable double spaces when joining vim.o.joinspaces = false -- Code folding vim.o.foldmethod = 'indent' vim.o.foldlevel = 99 -- Indentation vim.o.tabstop = 2 vim.o.shiftwidth = 2 vim.o.softtabstop = -1 vim.o.expandtab = true -- Visible line breaks vim.o.list = true vim.o.listchars = 'eol:¬' -- Relative line numbers vim.o.number = true vim.o.relativenumber = true -- 80 character indication vim.o.colorcolumn = '80' -- Status window height vim.o.previewheight = 30 -- Theme vim.o.termguicolors = true vim.cmd.colorscheme('slate') -- Keyboard shortcuts vim.keymap.set('n', '', ':bn', { silent = true }) vim.keymap.set('n', '', ':bp', { silent = true }) vim.keymap.set('n', '', ':noh') vim.keymap.set('n', 'gp', "'[V']", { remap = true }) vim.keymap.set('i', '', '{}', { silent = true } ) vim.keymap.set('i', ' ', '{ }', { silent = true } ) vim.keymap.set('i', '', '{}O', { silent = true } ) vim.keymap.set('i', '', '', { remap = true }) -- Add command to show help in current window vim.api.nvim_create_user_command('Help', function(a) -- Create empty 'help' buffer vim.cmd.enew() vim.o.buftype = 'help' local buf = vim.fn.bufnr('%') -- Show help and handle errors ok, msg = pcall(vim.cmd.help, a.fargs[1] or "help.txt") if not ok then vim.notify(msg, vim.log.levels.ERROR); vim.cmd.bp() end -- Wipe out empty buffer if not taken over if vim.fn.bufnr('%') ~= buf then vim.cmd.bwipeout(buf) end end, { nargs = '?', bar = true, complete = 'help' }) -- Add command line abbreviations if at start of line for i, word in ipairs { 'h', 'he', 'hel', 'help' } do vim.cmd.cabbrev { word, string.format( '=(getcmdtype() == ":" && getcmdpos() == 1) ? "Help" : "%s"', word )} end -- Source init directory vim.cmd 'runtime! init/*.lua'