dotfiles/dot_config/nvim/init.lua

93 lines
2.4 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 = " "
-- allow mouse in normal/visual mode
vim.o.mouse = "nv"
-- line numbers
vim.o.number = true
vim.o.relativenumber = true
vim.o.numberwidth = 5
-- 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
-- easier split navigation
Nmap("<C-J>", "<C-W>j")
Nmap("<C-K>", "<C-W>k")
Nmap("<C-L>", "<C-W>l")
Nmap("<C-H>", "<C-W>h")
2022-10-11 07:40:50 +02:00
-- merge conflicts
Nmap("<leader>gd", ":Gvdiff!<CR>")
Nmap("gdh", ":diffget //2<CR>")
Nmap("gdl", ":diffget //3<CR>")
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
vim.o.softtabstop = 2
vim.o.expandtab = true
2022-07-30 07:17:12 +02:00
-- indentation autocmds for some filetypes
vim.cmd([[
" smol spaces for soydev
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
2022-07-30 07:17:12 +02:00
" Tabs, yikes
2022-10-11 07:40:50 +02:00
autocmd FileType go setlocal ts=4 sw=4 sts=4 noet
2022-07-30 07:17:12 +02:00
" Spaces, based languages
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
]])
-- auto-compile when lua files in `~/.config/nvim/*` change
2022-07-30 07:17:12 +02:00
vim.api.nvim_create_autocmd("BufWritePost", {
2022-10-11 07:40:50 +02:00
pattern = "*.lua",
callback = function()
local cfg_path = vim.fn.resolve(vim.fn.stdpath("config"))
vim.defer_fn(function()
if vim.fn.expand("%:p"):match(cfg_path) then
vim.cmd("silent! PackerCompile")
end
end, 0)
end,
})
local wr_group = vim.api.nvim_create_augroup("WinResize", { clear = true })
-- resize splits when vim window is resized
vim.api.nvim_create_autocmd("VimResized", {
group = wr_group,
pattern = "*",
command = "wincmd =",
desc = "Automatically resize windows when the host window size changes.",
2022-07-30 07:17:12 +02:00
})
-- neovide settings {{{
2022-07-30 07:17:12 +02:00
if vim.g.neovide then
2022-10-11 07:40:50 +02:00
vim.cmd("cd $HOME")
vim.g.neovide_cursor_vfx_mode = "ripple"
vim.g.neovide_input_macos_alt_is_meta = true
vim.o.guifont = "VictorMono Nerd Font:h18"
2022-07-30 07:17:12 +02:00
end
-- }}}