Files
dotfiles/config/nvim/init.lua
T
2026-06-11 09:11:50 +02:00

112 lines
3.3 KiB
Lua

require("vim._core.ui2").enable({})
map = vim.keymap.set
vim.g.termguicolors = true
vim.g.netrw_keepdir = 1
vim.g.netrw_winsize = 30
vim.g.netrw_browse_split = 4
vim.o.nu = true
vim.o.swapfile = false
vim.o.winborder = "single"
vim.o.winblend = 0
vim.o.pumblend = 0
vim.o.scrolloff = 20
vim.o.shiftwidth = 4
vim.o.tabstop = 4
vim.o.softtabstop = 4
vim.o.path = "**"
vim.o.clipboard = "unnamedplus"
vim.o.foldmethod = "expr"
vim.o.foldlevel = 99
vim.o.completeopt = "menuone,noselect,fuzzy,nosort"
vim.opt.listchars:append("tab:> ")
vim.opt.shortmess:append("c")
vim.o.list = true
vim.o.undofile = true
vim.o.undodir = os.getenv("HOME") .. "/.cache/nvim/undodir"
vim.cmd.colorscheme("retrobox")
vim.o.errorformat = "%f(%l:%c) %m,%-G%.%#"
-- -----------------------------
-- @BINDS
-- -----------------------------
map("t", "<ESC><ESC>", "<C-\\><C-n>")
map({"t", "n"}, "<C-h>", "<C-\\><C-n><C-w><C-h>")
map({"t", "n"}, "<C-j>", "<C-\\><C-n><C-w><C-j>")
map({"t", "n"}, "<C-k>", "<C-\\><C-n><C-w><C-k>")
map({"t", "n"}, "<C-l>", "<C-\\><C-n><C-w><C-l>")
map({"i", "n"}, "<C- >", "<C-x><C-o>")
map("n", '<Esc>', '<Cmd>noh<CR><Esc>')
map("v", "J", ":m '>+1<CR>gv=gv")
map("v", "K", ":m '<-2<CR>gv=gv")
map("v", "<S-Tab>", "<gv")
map("v", "<Tab>" , ">gv")
map("n", "<C-p>", ":find ")
map("n", "<C-e>", ":Lex<CR>")
map("n", "<C-x>", ":bd<CR>")
map("i", "<C-h>", vim.lsp.buf.signature_help)
-- -----------------------------
-- @PLUGINS
-- -----------------------------
vim.pack.add({
{ src = 'https://github.com/ibhagwan/fzf-lua' },
{ src = 'https://github.com/neovim/nvim-lspconfig' },
{ src = 'https://github.com/echasnovski/mini.nvim' },
{ src = 'https://github.com/sheerun/vim-polyglot' },
{ src = 'https://github.com/romus204/tree-sitter-manager.nvim' },
{ src = 'https://github.com/xiyaowong/transparent.nvim' },
{ src = "https://github.com/vague-theme/vague.nvim" },
})
require("mini.completion").setup()
require("tree-sitter-manager").setup()
require('vague').setup({ transparent = true, })
vim.cmd.colorscheme('vague')
-- Lsp specific, uses nvim-lspconfigs with the below
vim.lsp.enable({ "gopls", "ols" })
map("n", "gd", ":lua vim.lsp.buf.definition()<CR>")
map("n", "ld", ":lua vim.diagnostic.open_float()<CR>")
map("n", "lr", ":lua vim.lsp.buf.rename()<CR>")
map("n", "la", ":lua vim.lsp.buf.code_action()<CR>")
require("fzf-lua").setup({})
map("n", "<C-p>", ":FzfLua files<CR>")
map("n", "<C-o>", ":FzfLua buffers<CR>")
map("n", "<C-i>", ":FzfLua diagnostics_workspace<CR>")
map("n", "<C-f>", ":FzfLua live_grep<CR>")
map("n", "<C-b>", ":FzfLua grep_curbuf<CR>")
-- -----------------------------
-- @AUTOCMDS
-- -----------------------------
-- Terminals should open with insert mode
vim.api.nvim_create_autocmd({ "BufEnter", "TermEnter", "WinEnter" }, {
pattern = "term://*",
callback = function()
if vim.bo.buftype == "terminal" then
vim.schedule(function()
vim.cmd("startinsert")
end)
end
end
})
-- highlights yanked text
vim.api.nvim_create_autocmd("TextYankPost", {
callback = function()
vim.highlight.on_yank({
higroup = "IncSearch",
timeout = 200,
})
end,
})
-- removes trailing whitespace on save
vim.api.nvim_create_autocmd("BufWritePre", {
callback = function()
local save_cursor = vim.fn.getpos(".")
vim.cmd([[%s/\s\+$//e]])
vim.fn.setpos(".", save_cursor)
end,
})