Files
code/core/nvim/init.lua
2023-06-10 14:34:28 +02:00

73 lines
2.0 KiB
Lua
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- 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 abbreviations if at start of line
for i, word in ipairs { 'h', 'he', 'hel', 'help' } do
vim.cmd.cabbrev { word, string.format(
'<c-r>=(getcmdtype() == ":" && getcmdpos() == 1) ? "Help" : "%s"<cr>',
word
)}
end
-- Source init directory
vim.cmd 'runtime! init/*.lua'