------------------------------------------------------------ -- Filip's neovim config ------------------------------------------------------------ ------------------------------------------------------------ -- General / UI settings ------------------------------------------------------------ vim.opt.number = true vim.opt.relativenumber = true vim.opt.title = true vim.opt.background = "dark" vim.opt.laststatus = 2 vim.opt.showmode = true vim.opt.showcmd = false vim.opt.ruler = true vim.opt.cursorline = true -- Modern / visual quality vim.opt.termguicolors = true vim.opt.signcolumn = "yes" vim.opt.pumblend = 10 vim.opt.winblend = 10 ------------------------------------------------------------ -- Window / split behavior ------------------------------------------------------------ vim.opt.splitbelow = true vim.opt.splitright = true ------------------------------------------------------------ -- Timing & performance related ------------------------------------------------------------ vim.opt.updatetime = 50 vim.opt.timeoutlen = 400 vim.opt.ttimeoutlen = 10 ------------------------------------------------------------ -- Backup, swap, undo ------------------------------------------------------------ vim.opt.undofile = true vim.opt.swapfile = false vim.opt.backup = false vim.opt.writebackup = false ------------------------------------------------------------ -- Search and highlighting ------------------------------------------------------------ vim.opt.hlsearch = false vim.opt.ignorecase = true vim.opt.smartcase = true vim.opt.incsearch = true vim.opt.wildignore = { "*.o", "*.obj", "*.bak", "*.exe" } ------------------------------------------------------------ -- Indentation and formatting ------------------------------------------------------------ vim.opt.autoindent = true vim.opt.cindent = true vim.opt.smartindent = true vim.opt.wrap = false vim.opt.scrolloff = 5 vim.opt.completeopt = { "menuone", "noinsert" } ------------------------------------------------------------ -- Clipboard and mouse ------------------------------------------------------------ vim.opt.clipboard:append("unnamedplus") vim.opt.mouse = "a" ------------------------------------------------------------ -- Session and history (shada = viminfo replacement) ------------------------------------------------------------ vim.opt.shada = "'100,<50,s10,h" vim.opt.shadafile = vim.fn.expand("~/.local/state/nvim/shada/main.shada") ------------------------------------------------------------ -- Miscellaneous ------------------------------------------------------------ vim.opt.spelllang = { "en", "pl" } vim.cmd("syntax on") vim.opt.termguicolors = true vim.cmd.colorscheme("pablo") -- Transparency vim.api.nvim_set_hl(0, "Normal", { bg = "none", ctermbg = "none" }) vim.api.nvim_set_hl(0, "NormalFloat",{ bg = "none", ctermbg = "none" }) vim.api.nvim_set_hl(0, "SignColumn", { bg = "none" }) vim.api.nvim_set_hl(0, "FoldColumn", { bg = "none" }) ------------------------------------------------------------ -- Autocommands ------------------------------------------------------------ local augroup = vim.api.nvim_create_augroup("UserAutocmds", { clear = true }) -- Reload any .lua file on save vim.api.nvim_create_autocmd("BufWritePost", { group = augroup, pattern = vim.fn.stdpath("config") .. "/**/*.lua", callback = function() vim.cmd("source %") vim.notify("Lua config reloaded", vim.log.levels.INFO) end, }) -- Remove trailing whitespace & final newlines, keep cursor vim.api.nvim_create_autocmd("BufWritePre", { group = augroup, pattern = "*", callback = function() local pos = vim.fn.getpos(".") vim.cmd([[%s/\s\+$//e]]) vim.cmd([[%s/\n\+\%$//e]]) vim.fn.setpos(".", pos) end, }) vim.api.nvim_create_autocmd("BufWritePost", { pattern = "*.tex", callback = function() -- Run tex-fmt on the current file vim.cmd("silent !tex-fmt %") -- Reload the buffer to reflect formatting changes vim.cmd("edit!") end, }) ------------------------------------------------------------ -- Key mappings ------------------------------------------------------------ vim.g.mapleader = " " -- Helper function for cleaner keymap definitions -- Defaults: noremap = true, silent = true local function map(mode, lhs, rhs, opts) opts = opts or {} opts.noremap = opts.noremap ~= false -- default true opts.silent = opts.silent ~= false -- default true opts.desc = opts.desc or nil -- optional description vim.keymap.set(mode, lhs, rhs, opts) end -- Delete char before cursor + char under cursor map('n', '', 'dBx', { desc = "Delete char before + under cursor" }) -- Insert blank line below current line and center view map('n', 's', 'okzz', { desc = "Insert blank line below + center" }) -- Start substitute on current line (pre-filled :%s//g) map('n', 'S', ':%s//g', { silent = false, desc = "Substitute on current line" }) -- Note: silent = false because it enters command-line mode -- Yank to end of line (consistent with D and C behavior) map('n', 'Y', 'y$', { desc = "Yank to end of line" }) -- Swap current line with the one below map('n', '-', 'ddp', { desc = "Swap line with next" }) -- Swap current line with the one above map('n', '_', 'ddkP', { desc = "Swap line with previous" }) -- System clipboard yank & paste (line / WORD) map('n', '', '"+yy', { desc = "Yank line to system clipboard" }) map('n', '', '"+yW', { desc = "Yank WORD to system clipboard" }) map('n', '', '"+p', { desc = "Paste from system clipboard after cursor" }) -- Yank selection to system clipboard map('v', '', '"+y', { desc = "Yank selection to system clipboard" }) -- Toggle buffers map('n', '', '', { desc = "Toggle last / alternate buffer" }) ------------------------------------------------------------ -- Tabs & indentation ------------------------------------------------------------ vim.opt.tabstop = 4 vim.opt.shiftwidth = 4 vim.opt.expandtab = true ------------------------------------------------------------ -- Filetype-specific mappings ------------------------------------------------------------ vim.api.nvim_create_autocmd("FileType", { group = augroup, pattern = "python", command = "map :w:!python3 %", }) ------------------------------------------------------------ -- lazy.nvim ------------------------------------------------------------ require("config.lazy") ------------------------------------------------------------ -- luasnip ------------------------------------------------------------ require("luasnip").config.set_config({ -- Setting LuaSnip config -- Enable autotriggered snippets enable_autosnippets = true, -- Use Tab (or some other key if you prefer) to trigger visual selection store_selection_keys = "", }) vim.cmd[[ " Use Tab to expand and jump through snippets imap luasnip#expand_or_jumpable() ? 'luasnip-expand-or-jump' : '' smap luasnip#jumpable(1) ? 'luasnip-jump-next' : '' " Use Shift-Tab to jump backwards through snippets imap luasnip#jumpable(-1) ? 'luasnip-jump-prev' : '' smap luasnip#jumpable(-1) ? 'luasnip-jump-prev' : '' ]] -- Load snippets from fiadra/chadsnips require("luasnip.loaders.from_vscode").lazy_load()