dotfiles/dot_config/nvim/init.lua

78 lines
2 KiB
Lua
Raw Normal View History

2022-07-30 07:17:12 +02:00
-- vim:fdm=marker
pcall(require, "impatient")
pcall(require, "plugins")
pcall(require, "lsp")
2022-07-30 07:17:12 +02:00
-- true colors
vim.o.termguicolors = true
-- map leader to space
2022-07-30 07:17:12 +02:00
vim.g.mapleader = " "
2022-10-18 10:02:19 +02:00
vim.o.cmdheight = 1
-- line numbers
2022-10-17 17:13:31 +02:00
vim.o.mouse = ""
vim.o.number = true
vim.o.relativenumber = true
-- scroll offsets
vim.o.scrolloff = 5
vim.o.sidescrolloff = 15
-- show leading/trailing whitespace
vim.o.list = true
-- always show status & tab line
vim.o.laststatus = 3
vim.o.showtabline = 2
-- completion height
vim.o.pumheight = 15
-- split directions
vim.o.splitbelow = true
vim.o.splitright = true
2022-07-30 07:17:12 +02:00
-- redefine word boundaries - '_' is a word seperator, this helps with snake_case
vim.opt.iskeyword:remove("_")
2022-07-30 07:17:12 +02:00
2022-10-17 17:13:31 +02:00
function Map(mode, shortcut, command, opt)
opt = opt or { noremap = true, silent = true }
vim.keymap.set(mode, shortcut, command, opt)
end
2022-10-11 07:40:50 +02:00
2022-10-17 17:13:31 +02:00
-- easier split navigation
Map("n", "<C-J>", "<C-W>j")
Map("n", "<C-K>", "<C-W>k")
Map("n", "<C-L>", "<C-W>l")
Map("n", "<C-H>", "<C-W>h")
Map("n", "<C-W>\\", ":vsplit<CR>")
Map("n", "<C-W>-", ":split<CR>")
Map("n", "<C-W>x", ":q<CR>")
2022-10-11 07:40:50 +02:00
-- merge conflicts
2022-10-17 17:13:31 +02:00
Map("n", "<leader>gd", ":Gvdiff!<CR>")
Map("n", "gdh", ":diffget //2<CR>")
Map("n", "gdl", ":diffget //3<CR>")
-- clipboard
Map("n", "<leader>p", '"+p')
Map("n", "<leader>y", '"+y')
2022-07-30 07:17:12 +02:00
-- escape :terminal easier
vim.cmd([[tnoremap <Esc> <C-\><C-n>]])
-- indentations settings
vim.o.shiftwidth = 2
vim.o.tabstop = 2
2022-10-17 17:13:31 +02:00
vim.o.softtabstop = 0
vim.o.expandtab = true
2022-07-30 07:17:12 +02:00
vim.cmd([[
2022-10-11 07:40:50 +02:00
autocmd FileType html,lua,css,js,jsreact,ts,tsreact,json,yaml setlocal ts=2 sw=2 sts=0 et
autocmd FileType go setlocal ts=4 sw=4 sts=4 noet
2022-07-30 07:17:12 +02:00
autocmd FileType python,rust setlocal ts=4 sw=4 sts=4 et
autocmd FileType markdown let g:table_mode_corner='|'
2022-07-30 07:17:12 +02:00
]])
2022-10-11 07:40:50 +02:00
vim.api.nvim_create_autocmd("VimResized", {
pattern = "*",
command = "wincmd =",
desc = "Automatically resize windows when the host window size changes.",
2022-07-30 07:17:12 +02:00
})
2022-10-17 17:13:31 +02:00
vim.api.nvim_create_autocmd("TextYankPost", {
pattern = "*",
callback = function()
vim.highlight.on_yank({ higroup = "IncSearch", timeout = 200 })
end,
desc = "Highlight yanked text",
})