diff --git a/init.lua b/init.lua index 51155c2..6452cd6 100644 --- a/init.lua +++ b/init.lua @@ -1,31 +1,64 @@ +-- Set mapleader vim.g.mapleader = "" +-- Lazy require("config.lazy") +-- Line numbers +vim.opt.cursorline = true +vim.wo.relativenumber = true +vim.wo.number = true +vim.api.nvim_set_hl(0, "LineNr", { fg = "#6c7086" }) -- overlay0 +vim.api.nvim_set_hl(0, "CursorLineNr", { fg = "#cba6f7", bold = true }) -- mauve + +-- Windows vim.opt.splitbelow = true vim.opt.splitright = true - vim.o.winborder = "rounded" +-- Sane keymaps vim.keymap.set("i", "jj", "") vim.keymap.set("n", "q:", ":", { noremap = true, silent = true }) +vim.keymap.set("n", "bq", "bd", { noremap = true, silent = true }) +-- Sane tab management vim.opt.tabstop = 4 vim.opt.softtabstop = 4 vim.opt.shiftwidth = 4 vim.opt.expandtab = true +-- Undo management vim.opt.swapfile = false vim.opt.backup = false vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" vim.opt.undofile = true +-- Better Highlighting vim.opt.hlsearch = false vim.opt.incsearch = true +-- Colorcheme vim.cmd.colorscheme("catppuccin-mocha") +-- Scrolloff +vim.opt.scrolloff = 8 + +-- Force proper keybindings vim.keymap.set("n", "", 'echo "Use h to move!!"') vim.keymap.set("n", "", 'echo "Use l to move!!"') vim.keymap.set("n", "", 'echo "Use k to move!!"') vim.keymap.set("n", "", 'echo "Use j to move!!"') + +-- Center cursor after scrolling with Ctrl-d / Ctrl-u +vim.keymap.set("n", "", "zz", { noremap = true, silent = true }) +vim.keymap.set("n", "", "zz", { noremap = true, silent = true }) + +-- C-BS for deleting whole word in insert mode +vim.keymap.set("i", "", "", { noremap = true }) + +-- Keybinds for saving and stuff +vim.keymap.set("n", "qq", "qa!", { noremap = true }) +vim.keymap.set("n", "qs", function() + vim.cmd("AutoSession save") + vim.cmd("wqa") +end, { noremap = true }) diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua index dc0ffff..a9a9913 100644 --- a/lua/config/lazy.lua +++ b/lua/config/lazy.lua @@ -37,5 +37,5 @@ require("lazy").setup({ border = "rounded", }, -- automatically check for plugin updates - checker = { enabled = true }, + checker = { enabled = false }, }) diff --git a/lua/plugins/completion/linter.lua b/lua/plugins/completion/linter.lua index aa285c5..b7e7679 100644 --- a/lua/plugins/completion/linter.lua +++ b/lua/plugins/completion/linter.lua @@ -10,6 +10,26 @@ return { typescript = { "eslint" }, } + -- Only show diagnostics close to the cursor + vim.diagnostic.config({ + virtual_text = { + spacing = 4, + -- You can make prefix dynamic based on severity using a function + prefix = function(diagnostic) + local icons = { + [vim.diagnostic.severity.ERROR] = " ", + [vim.diagnostic.severity.WARN] = " ", + [vim.diagnostic.severity.INFO] = " ", + [vim.diagnostic.severity.HINT] = " ", + } + return icons[diagnostic.severity] or "●" + end, + }, + signs = false, + underline = true, + update_in_insert = false, + }) + -- Auto-run the linter only for the configured filetypes vim.api.nvim_create_autocmd("BufWritePost", { pattern = "!*.lua", diff --git a/lua/plugins/functional/auto-session.lua b/lua/plugins/functional/auto-session.lua new file mode 100644 index 0000000..784a2bb --- /dev/null +++ b/lua/plugins/functional/auto-session.lua @@ -0,0 +1,27 @@ +return { + "rmagatti/auto-session", + lazy = false, + + opts = { + session_lens = { + picker = "telescope", + load_on_setup = true, + picker_opts = { + border = false, + }, + }, + suppressed_dirs = { "~/", "~/Projects", "~/Downloads", "/" }, + git_use_branch_name = true, + git_auto_restore_on_branch_change = true, + purge_after_minutes = 14400, + show_auto_restore_notif = true, + }, + + config = function() + require("auto-session").setup({}) + vim.o.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions" + vim.keymap.set("n", "as", "AutoSession search", { noremap = true }) + vim.keymap.set("n", "an", "AutoSession save", { noremap = true }) + vim.keymap.set("n", "ad", "AutoSession delete", { noremap = true }) + end, +} diff --git a/lua/plugins/functional/mini.lua b/lua/plugins/functional/mini.lua index 5e3eaa3..7402233 100644 --- a/lua/plugins/functional/mini.lua +++ b/lua/plugins/functional/mini.lua @@ -3,8 +3,27 @@ return { version = "", config = function() + local animate = require("mini.animate") require("mini.pairs").setup() -- Bracket pairs and stuff require("mini.ai").setup() -- Around and In extension for visual mode + require("mini.cursorword").setup() -- Underline current word below cursor (makes it easier to c and d) + require("mini.indentscope").setup({ + symbol = "│", + draw = { + delay = 10, + animation = require("mini.indentscope").gen_animation.linear({ + duration = 15, + unit = "step", + easing = "out", + }), + }, + }) -- Indent lines + require("mini.trailspace").setup() -- Shows useless spaces + require("mini.sessions").setup({ + autosread = true, + autowrite = true, + }) + require("mini.notify").setup() -- Better Notifications require("mini.surround").setup() -- Suround selections with characters require("mini.move").setup({ mappings = { @@ -14,5 +33,32 @@ return { }) require("mini.icons").setup() -- Icon provider + require("mini.animate").setup({ + cursor = { + enable = false, + }, + scroll = { + -- Animate for 200 milliseconds with linear easing + timing = animate.gen_timing.linear({ duration = 100, unit = "total" }), + -- Animate equally but with at most 120 steps instead of default 60 + subscroll = animate.gen_subscroll.equal({ max_output_steps = 60 }), + }, + open = { + -- Animate for 400 milliseconds with linear easing + timing = animate.gen_timing.linear({ duration = 100, unit = "total" }), + -- Animate with wiping from nearest edge instead of default static one + winconfig = animate.gen_winconfig.wipe({ direction = "from_edge" }), + -- Make bigger windows more transparent + winblend = animate.gen_winblend.linear({ from = 80, to = 100 }), + }, + close = { + -- Animate for 400 milliseconds with linear easing + timing = animate.gen_timing.linear({ duration = 100, unit = "total" }), + -- Animate with wiping to nearest edge instead of default static one + winconfig = animate.gen_winconfig.wipe({ direction = "to_edge" }), + -- Make bigger windows more transparent + winblend = animate.gen_winblend.linear({ from = 100, to = 80 }), + }, + }) end, } diff --git a/lua/plugins/functional/telescope.lua b/lua/plugins/functional/telescope.lua new file mode 100644 index 0000000..a20758e --- /dev/null +++ b/lua/plugins/functional/telescope.lua @@ -0,0 +1,21 @@ +return { + "nvim-telescope/telescope.nvim", + tag = "0.1.8", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + require("telescope").setup() + local builtin = require("telescope.builtin") + + vim.keymap.set("n", "ff", function() + builtin.find_files({ cwd = vim.fn.expand("%:p:h"), hidden = true }) + end, { desc = "Telescope find files (current file dir)" }) + + vim.keymap.set("n", "fg", function() + builtin.live_grep({ cwd = vim.fn.expand("%:p:h") }) + end, { desc = "Telescope live grep (current file dir)" }) + + vim.keymap.set("n", "fb", function() + builtin.buffers({ cwd = vim.fn.expand("%:p:h") }) -- buffers don’t need cwd, but harmless + end, { desc = "Telescope buffers" }) + end, +} diff --git a/lua/plugins/functional/undotree.lua b/lua/plugins/functional/undotree.lua new file mode 100644 index 0000000..2319ece --- /dev/null +++ b/lua/plugins/functional/undotree.lua @@ -0,0 +1,7 @@ +return { + "mbbill/undotree", + lazy = false, + config = function() + vim.keymap.set("n", "u", "UndotreeToggleUndotreeFocus") + end, +} diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua new file mode 100644 index 0000000..eafbacf --- /dev/null +++ b/lua/plugins/init.lua @@ -0,0 +1 @@ +return { undefined }