70 lines
1.9 KiB
Lua
70 lines
1.9 KiB
Lua
-- 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', '<c-n>', ':bn<cr>', { silent = true })
|
||
vim.keymap.set('n', '<c-p>', ':bp<cr>', { silent = true })
|
||
vim.keymap.set('n', '<c-l>', ':noh<cr><c-l>')
|
||
vim.keymap.set('n', 'gp', "'[V']", { remap = true })
|
||
vim.keymap.set('i', '<c-b>', '{}<left>', { silent = true } )
|
||
vim.keymap.set('i', '<c-b> ', '{ }<left><left>', { silent = true } )
|
||
vim.keymap.set('i', '<c-b><cr>', '{<cr>}O', { silent = true } )
|
||
vim.keymap.set('i', '<c-space>', '<space>', { 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 abbreviation if at start of line
|
||
vim.cmd.cabbrev { 'help',
|
||
'<c-r>=(getcmdtype() == ":" && getcmdpos() == 1) ? "Help" : "help"<cr>'
|
||
}
|
||
|
||
-- Source init directory
|
||
vim.cmd 'runtime! init/*.lua'
|