diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index fa2e53b..d0a5154 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -1,25 +1,5 @@ --- Bootstrap lazy.nvim -local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" -if not (vim.uv or vim.loop).fs_stat(lazypath) then - local lazyrepo = "https://github.com/folke/lazy.nvim.git" - local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) - if vim.v.shell_error ~= 0 then - vim.api.nvim_echo({ - { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, - { out, "WarningMsg" }, - { "\nPress any key to exit..." }, - }, true, {}) - vim.fn.getchar() - os.exit(1) - end -end -vim.opt.rtp:prepend(lazypath) +vim.g.mapleader = " " +vim.g.maplocalleader = " " -local opts = { - install = { colorscheme = { "catppuccin" } }, - -- automatically check for plugin updates - checker = { enabled = true }, -} - -require("vim-options") -require("lazy").setup("plugins", opts) +require("config") +require("plugins") diff --git a/.config/nvim/lsp/lua_ls.lua b/.config/nvim/lsp/lua_ls.lua new file mode 100644 index 0000000..133645e --- /dev/null +++ b/.config/nvim/lsp/lua_ls.lua @@ -0,0 +1,15 @@ +return { + cmd = { "lua-language-server" }, + filetypes = { "lua" }, + root_markers = { + ".luarc.json", ".luarc.jsonc", ".luacheckrc", + ".stylua.toml", "stylua.toml", "selene.toml", + "selene.yml", ".git" + }, + settings = { + Lua = { + runtime = { version = "LuaJIT" }, -- Neovim uses LuaJIT + diagnostics = { globals = { "vim" } }, -- Recognize 'vim' global + }, + }, +} diff --git a/.config/nvim/lua/config/autocmds.lua b/.config/nvim/lua/config/autocmds.lua new file mode 100644 index 0000000..1b365e0 --- /dev/null +++ b/.config/nvim/lua/config/autocmds.lua @@ -0,0 +1,143 @@ +local function augroup(name) + return vim.api.nvim_create_augroup("user_" .. name, { clear = true }) +end + +-- Check if we need to reload the file when it changed +vim.api.nvim_create_autocmd({ "FocusGained", "TermClose", "TermLeave" }, { + group = augroup("checktime"), + callback = function() + if vim.o.buftype ~= "nofile" then + vim.cmd("checktime") + end + end, +}) + +-- Highlight on yank +vim.api.nvim_create_autocmd("TextYankPost", { + group = augroup("highlight_yank"), + callback = function() + (vim.hl or vim.highlight).on_yank() + end, +}) + +-- resize splits if window got resized +vim.api.nvim_create_autocmd({ "VimResized" }, { + group = augroup("resize_splits"), + callback = function() + local current_tab = vim.fn.tabpagenr() + vim.cmd("tabdo wincmd =") + vim.cmd("tabnext " .. current_tab) + end, +}) + + +-- make it easier to close man-files when opened inline +vim.api.nvim_create_autocmd("FileType", { + group = augroup("man_unlisted"), + pattern = { "man" }, + callback = function(event) + vim.bo[event.buf].buflisted = false + end, +}) + +-- close some filetypes with +vim.api.nvim_create_autocmd("FileType", { + group = augroup("close_with_q"), + pattern = { + "PlenaryTestPopup", + "checkhealth", + "dbout", + "gitsigns-blame", + "grug-far", + "help", + "lspinfo", + "neotest-output", + "neotest-output-panel", + "neotest-summary", + "notify", + "qf", + "spectre_panel", + "startuptime", + "tsplayground", + }, + callback = function(event) + vim.bo[event.buf].buflisted = false + vim.schedule(function() + vim.keymap.set("n", "q", function() + vim.cmd("close") + pcall(vim.api.nvim_buf_delete, event.buf, { force = true }) + end, { + buffer = event.buf, + silent = true, + desc = "Quit buffer", + }) + end) + end, +}) + +-- wrap and check for spell in text filetypes +vim.api.nvim_create_autocmd("FileType", { + group = augroup("wrap_spell"), + pattern = { "text", "plaintex", "typst", "gitcommit", "markdown" }, + callback = function() + vim.opt_local.wrap = true + vim.opt_local.spell = true + end, +}) + +-- Fix conceallevel for json files +vim.api.nvim_create_autocmd({ "FileType" }, { + group = augroup("json_conceal"), + pattern = { "json", "jsonc", "json5" }, + callback = function() + vim.opt_local.conceallevel = 0 + end, +}) + +-- Auto create dir when saving a file, in case some intermediate directory does not exist +vim.api.nvim_create_autocmd({ "BufWritePre" }, { + group = augroup("auto_create_dir"), + callback = function(event) + if event.match:match("^%w%w+:[/][/]") then + return + end + local file = vim.uv.fs_realpath(event.match) or event.match + vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p") + end, +}) + +-- Set filetype for .env and .env.* files +vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { + group = augroup("env_filetype"), + pattern = { "*.env", ".env.*" }, + callback = function() + vim.opt_local.filetype = "sh" + end, +}) + +-- Set filetype for .toml files +vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { + group = augroup("toml_filetype"), + pattern = { "*.tomg-config*" }, + callback = function() + vim.opt_local.filetype = "toml" + end, +}) + +-- Set filetype for .ejs files +vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { + group = augroup("ejs_filetype"), + pattern = { "*.ejs", "*.ejs.t" }, + callback = function() + vim.opt_local.filetype = "embedded_template" + end, +}) + +-- Set filetype for .code-snippets files +vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { + group = augroup("code_snippets_filetype"), + pattern = { "*.code-snippets" }, + callback = function() + vim.opt_local.filetype = "json" + end, +}) diff --git a/.config/nvim/lua/config/diagnostics.lua b/.config/nvim/lua/config/diagnostics.lua new file mode 100644 index 0000000..e4dafa2 --- /dev/null +++ b/.config/nvim/lua/config/diagnostics.lua @@ -0,0 +1,72 @@ +--- diagnostic settings +local map = vim.keymap.set + +local palette = { + err = "#51202A", + warn = "#3B3B1B", + info = "#1F3342", + hint = "#1E2E1E", +} + +vim.api.nvim_set_hl(0, "DiagnosticErrorLine", { bg = palette.err, blend = 20 }) +vim.api.nvim_set_hl(0, "DiagnosticWarnLine", { bg = palette.warn, blend = 15 }) +vim.api.nvim_set_hl(0, "DiagnosticInfoLine", { bg = palette.info, blend = 10 }) +vim.api.nvim_set_hl(0, "DiagnosticHintLine", { bg = palette.hint, blend = 10 }) + +vim.api.nvim_set_hl(0, "DapBreakpointSign", { fg = "#FF0000", bg = nil, bold = true }) +vim.fn.sign_define("DapBreakpoint", { + text = "●", -- a large dot; change as desired + texthl = "DapBreakpointSign", -- the highlight group you just defined + linehl = "", -- no full-line highlight + numhl = "", -- no number-column highlight +}) + +local sev = vim.diagnostic.severity + +vim.diagnostic.config({ + -- keep underline & severity_sort on for quick scanning + underline = true, + severity_sort = true, + update_in_insert = false, -- less flicker + float = { + border = "rounded", + source = true, + }, + -- keep signs & virtual text, but tune them as you like + signs = { + text = { + [sev.ERROR] = " ", + [sev.WARN] = " ", + [sev.INFO] = " ", + [sev.HINT] = "󰌵 ", + }, + }, + virtual_text = { + spacing = 4, + source = "if_many", + prefix = "●", + }, + -- NEW in 0.11 — dim whole line + linehl = { + [sev.ERROR] = "DiagnosticErrorLine", + [sev.WARN] = "DiagnosticWarnLine", + [sev.INFO] = "DiagnosticInfoLine", + [sev.HINT] = "DiagnosticHintLine", + }, +}) + +-- diagnostic keymaps +local diagnostic_goto = function(next, severity) + severity = severity and vim.diagnostic.severity[severity] or nil + return function() + vim.diagnostic.jump({ count = next and 1 or -1, float = true, severity = severity }) + end +end + +map("n", "cd", vim.diagnostic.open_float, { desc = "Line Diagnostics" }) +map("n", "]d", diagnostic_goto(true), { desc = "Next Diagnostic" }) +map("n", "[d", diagnostic_goto(false), { desc = "Prev Diagnostic" }) +map("n", "]e", diagnostic_goto(true, "ERROR"), { desc = "Next Error" }) +map("n", "[e", diagnostic_goto(false, "ERROR"), { desc = "Prev Error" }) +map("n", "]w", diagnostic_goto(true, "WARN"), { desc = "Next Warning" }) +map("n", "[w", diagnostic_goto(false, "WARN"), { desc = "Prev Warning" }) diff --git a/.config/nvim/lua/config/init.lua b/.config/nvim/lua/config/init.lua new file mode 100644 index 0000000..5f6e0af --- /dev/null +++ b/.config/nvim/lua/config/init.lua @@ -0,0 +1,5 @@ +require("config.options") +require("config.keymaps") +require("config.diagnostics") +require("config.autocmds") +require("config.lsp") diff --git a/.config/nvim/lua/config/keymaps.lua b/.config/nvim/lua/config/keymaps.lua new file mode 100644 index 0000000..3b4ba67 --- /dev/null +++ b/.config/nvim/lua/config/keymaps.lua @@ -0,0 +1,222 @@ +local map = vim.keymap.set +local opts = { noremap = true, silent = true } + +-- ═══════════════════════════════════════════════════════════ +-- BUFFER NAVIGATION (think browser tabs) +-- ═══════════════════════════════════════════════════════════ + +-- Tab/Shift-Tab: Like browser tabs, feels natural +map("n", "", ":bnext", { desc = "Next buffer" }) +map("n", "", ":bprevious", { desc = "Previous buffer" }) + +-- Alternative buffer switching (vim-style) +map("n", "bn", ":bnext", { desc = "Next buffer" }) +map("n", "bp", ":bprevious", { desc = "Previous buffer" }) +map("n", "", "bprevious", { desc = "Prev Buffer" }) +map("n", "", "bnext", { desc = "Next Buffer" }) +map("n", "[b", "bprevious", { desc = "Prev Buffer" }) +map("n", "]b", "bnext", { desc = "Next Buffer" }) + +-- Quick switch to last edited file (super useful!) +map("n", "bb", "e #", { desc = "Switch to Other Buffer" }) +map("n", "`", "e #", { desc = "Switch to Other Buffer" }) + +-- ═══════════════════════════════════════════════════════════ +-- WINDOW MANAGEMENT (splitting and navigation) +-- ═══════════════════════════════════════════════════════════ + +-- Move between windows with Ctrl+hjkl (like tmux) +map("n", "", "h", { desc = "Go to Left Window", remap = true }) +map("n", "", "j", { desc = "Go to Lower Window", remap = true }) +map("n", "", "k", { desc = "Go to Upper Window", remap = true }) +map("n", "", "l", { desc = "Go to Right Window", remap = true }) + +-- Resize windows with Ctrl+Shift+arrows (macOS friendly) +map("n", "", "resize +5", opts) +map("n", "", "resize -5", opts) +map("n", "", "vertical resize -5", opts) +map("n", "", "vertical resize +5", opts) + +-- Window splitting +map("n", "ww", "p", { desc = "Other Window", remap = true }) +map("n", "wd", "c", { desc = "Delete Window", remap = true }) +map("n", "w-", "s", { desc = "Split Window Below", remap = true }) +map("n", "sh", "s", { desc = "Split Window Below", remap = true }) +map("n", "w|", "v", { desc = "Split Window Right", remap = true }) +map("n", "|", "v", { desc = "Split Window Right", remap = true }) +map("n", "sv", "v", { desc = "Split Window Right", remap = true }) + +-- ═══════════════════════════════════════════════════════════ +-- SMART LINE MOVEMENT (the VSCode experience) +-- ═══════════════════════════════════════════════════════════ + +-- Smart j/k: moves by visual lines when no count, real lines with count +map({ "n", "x" }, "j", "v:count == 0 ? 'gj' : 'j'", { desc = "Down", expr = true, silent = true }) +map({ "n", "x" }, "", "v:count == 0 ? 'gj' : 'j'", { desc = "Down", expr = true, silent = true }) +map({ "n", "x" }, "k", "v:count == 0 ? 'gk' : 'k'", { desc = "Up", expr = true, silent = true }) +map({ "n", "x" }, "", "v:count == 0 ? 'gk' : 'k'", { desc = "Up", expr = true, silent = true }) + +-- Move lines up/down (Alt+j/k like VSCode) +map("n", "", "execute 'move .+' . v:count1==", { desc = "Move Down" }) +map("n", "", "execute 'move .-' . (v:count1 + 1)==", { desc = "Move Up" }) +map("i", "", "m .+1==gi", { desc = "Move Down" }) +map("i", "", "m .-2==gi", { desc = "Move Up" }) +map("v", "", ":execute \"'<,'>move '>+\" . v:count1gv=gv", { desc = "Move Down" }) +map("v", "", ":execute \"'<,'>move '<-\" . (v:count1 + 1)gv=gv", { desc = "Move Up" }) + +-- Alternative line movement (for terminals that don't support Alt) +map("v", "J", ":move '>+1gv=gv", { desc = "Move Block Down" }) +map("v", "K", ":move '<-2gv=gv", { desc = "Move Block Up" }) +map("n", "", ":m .+1", opts) +map("n", "", ":m .-2", opts) +map("i", "", ":m .+1==gi", opts) +map("i", "", ":m .-2==gi", opts) +map("v", "", ":m '>+1gv=gv", opts) +map("v", "", ":m '<-2gv=gv", opts) + +-- ═══════════════════════════════════════════════════════════ +-- SEARCH & NAVIGATION (ergonomic improvements) +-- ═══════════════════════════════════════════════════════════ + +-- Better line start/end (more comfortable than $ and ^) +map("n", "gl", "$", { desc = "Go to end of line" }) +map("n", "gh", "^", { desc = "Go to start of line" }) +map("n", "", "^", { desc = "Go to start of line", silent = true }) +map("n", "", "$", { desc = "Go to end of line", silent = true }) + +-- Select all content +map("n", "==", "ggG") +map("n", "", "ggVG", { noremap = true, silent = true, desc = "Select all" }) + +-- Clear search highlighting +map({ "i", "n" }, "", "noh", { desc = "Escape and Clear hlsearch" }) +map("n", "ur", "nohlsearchdiffupdatenormal! ", { desc = "Redraw / Clear hlsearch / Diff Update" }) + +-- Smart search navigation (n always goes forward, N always backward) +map("n", "n", "'Nn'[v:searchforward].'zv'", { expr = true, desc = "Next Search Result" }) +map("x", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next Search Result" }) +map("o", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next Search Result" }) +map("n", "N", "'nN'[v:searchforward].'zv'", { expr = true, desc = "Prev Search Result" }) +map("x", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev Search Result" }) +map("o", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev Search Result" }) + +-- ═══════════════════════════════════════════════════════════ +-- SMART TEXT EDITING +-- ═══════════════════════════════════════════════════════════ + +-- Better indenting (stay in visual mode) +map("v", "<", "", ">gv") + +-- Better paste (doesn't replace clipboard with deleted text) +map("v", "p", '"_dP', opts) + +-- Copy whole file to clipboard +map("n", "", ":%y+", opts) + +-- Smart undo break-points (create undo points at logical stops) +map("i", ",", ",u") +map("i", ".", ".u") +map("i", ";", ";u") + +-- Auto-close pairs (simple, no plugin needed) +map("i", "`", "``") +map("i", '"', '""') +map("i", "(", "()") +map("i", "[", "[]") +map("i", "{", "{}") +map("i", "<", "<>") +-- Note: Single quotes commented out to avoid conflicts in some contexts +-- map("i", "'", "''") + +-- ═══════════════════════════════════════════════════════════ +-- FILE OPERATIONS +-- ═══════════════════════════════════════════════════════════ + +-- Save file (works in all modes) +map({ "i", "x", "n", "s" }, "", "w", { desc = "Save File" }) + +-- Create new file +map("n", "fn", "enew", { desc = "New File" }) + +-- Quit operations +map("n", "qq", "qa", { desc = "Quit All" }) + +-- ═══════════════════════════════════════════════════════════ +-- DEVELOPMENT TOOLS +-- ═══════════════════════════════════════════════════════════ + +-- Commenting (add comment above/below current line) +map("n", "gco", "oVcxnormal gccfxa", { desc = "Add Comment Below" }) +map("n", "gcO", "OVcxnormal gccfxa", { desc = "Add Comment Above" }) + +-- Quickfix and location lists +map("n", "xl", function() + local success, err = pcall(vim.fn.getloclist(0, { winid = 0 }).winid ~= 0 and vim.cmd.lclose or vim.cmd.lopen) + if not success and err then + vim.notify(err, vim.log.levels.ERROR) + end +end, { desc = "Location List" }) + +map("n", "xq", function() + local success, err = pcall(vim.fn.getqflist({ winid = 0 }).winid ~= 0 and vim.cmd.cclose or vim.cmd.copen) + if not success and err then + vim.notify(err, vim.log.levels.ERROR) + end +end, { desc = "Quickfix List" }) + +map("n", "[q", vim.cmd.cprev, { desc = "Previous Quickfix" }) +map("n", "]q", vim.cmd.cnext, { desc = "Next Quickfix" }) + +-- Inspection tools (useful for debugging highlights and treesitter) +map("n", "ui", vim.show_pos, { desc = "Inspect Pos" }) +map("n", "uI", "InspectTree", { desc = "Inspect Tree" }) + +-- Keyword program (K for help on word under cursor) +map("n", "K", "norm! K", { desc = "Keywordprg" }) + +-- ═══════════════════════════════════════════════════════════ +-- TERMINAL INTEGRATION +-- ═══════════════════════════════════════════════════════════ + +-- Terminal mode navigation +map("t", "", "", { desc = "Enter Normal Mode" }) +map("t", "", "wincmd h", { desc = "Go to Left Window" }) +map("t", "", "wincmd j", { desc = "Go to Lower Window" }) +map("t", "", "wincmd k", { desc = "Go to Upper Window" }) +map("t", "", "wincmd l", { desc = "Go to Right Window" }) +map("t", "", "close", { desc = "Hide Terminal" }) +map("t", "", "close", { desc = "which_key_ignore" }) + +-- ═══════════════════════════════════════════════════════════ +-- TAB MANAGEMENT (when you need multiple workspaces) +-- ═══════════════════════════════════════════════════════════ + +map("n", "l", "tablast", { desc = "Last Tab" }) +map("n", "o", "tabonly", { desc = "Close Other Tabs" }) +map("n", "f", "tabfirst", { desc = "First Tab" }) +map("n", "", "tabnew", { desc = "New Tab" }) +map("n", "]", "tabnext", { desc = "Next Tab" }) +map("n", "d", "tabclose", { desc = "Close Tab" }) +map("n", "[", "tabprevious", { desc = "Previous Tab" }) + +-- ═══════════════════════════════════════════════════════════ +-- FOLDING NAVIGATION (for code organization) +-- ═══════════════════════════════════════════════════════════ + +-- Close all folds except current one (great for focus) +map("n", "zv", "zMzvzz", { desc = "Close all folds except the current one" }) + +-- Smart fold navigation (closes current, opens next/previous) +map("n", "zj", "zcjzOzz", { desc = "Close current fold when open. Always open next fold." }) +map("n", "zk", "zckzOzz", { desc = "Close current fold when open. Always open previous fold." }) + +-- ═══════════════════════════════════════════════════════════ +-- UTILITY SHORTCUTS +-- ═══════════════════════════════════════════════════════════ + +-- Toggle line wrapping +map("n", "tw", "set wrap!", { desc = "Toggle Wrap", silent = true }) + +-- Fix spelling (picks first suggestion) +map("n", "z0", "1z=", { desc = "Fix word under cursor" }) diff --git a/.config/nvim/lua/config/lsp.lua b/.config/nvim/lua/config/lsp.lua new file mode 100644 index 0000000..aa638c8 --- /dev/null +++ b/.config/nvim/lua/config/lsp.lua @@ -0,0 +1,62 @@ +-- LSP +local function augroup(name) + return vim.api.nvim_create_augroup("user_" .. name, { clear = true }) +end + +local default_keymaps = { + { keys = "ca", func = vim.lsp.buf.code_action, desc = "Code Actions" }, + { keys = "cr", func = vim.lsp.buf.rename, desc = "Code Rename" }, + { keys = "k", func = vim.lsp.buf.hover, desc = "Hover Documentation", has = "hoverProvider" }, + { keys = "K", func = vim.lsp.buf.hover, desc = "Hover (alt)", has = "hoverProvider" }, + { keys = "gd", func = vim.lsp.buf.definition, desc = "Goto Definition", has = "definitionProvider" }, +} + +-- I use blink.cmp for completion, but you can use native completion too +local completion = vim.g.completion_mode or "blink" -- or 'native' for built-in completion +vim.api.nvim_create_autocmd("LspAttach", { + group = augroup("lsp_attach"), + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + local buf = args.buf + if client then + -- Built-in completion + if completion == "native" and client:supports_method("textDocument/completion") then + vim.lsp.completion.enable(true, client.id, args.buf, { autotrigger = true }) + end + + -- Inlay hints + if client:supports_method("textDocument/inlayHints") then + vim.lsp.inlay_hint.enable(true, { bufnr = args.buf }) + end + + if client:supports_method("textDocument/documentColor") then + vim.lsp.document_color.enable(true, args.buf, { + style = "background", -- 'background', 'foreground', or 'virtual' + }) + end + + for _, km in ipairs(default_keymaps) do + -- Only bind if there's no `has` requirement, or the server supports it + if not km.has or client.server_capabilities[km.has] then + vim.keymap.set( + km.mode or "n", + km.keys, + km.func, + { buffer = buf, desc = "LSP: " .. km.desc, nowait = km.nowait } + ) + end + end + end + end, +}) + +-- Enable LSP servers for Neovim 0.11+ +vim.lsp.enable({ + "lua_ls", +}) + +-- Load Lsp on-demand, e.g: eslint is disable by default +-- e.g: We could enable eslint by set vim.g.lsp_on_demands = {"eslint"} +if vim.g.lsp_on_demands then + vim.lsp.enable(vim.g.lsp_on_demands) +end diff --git a/.config/nvim/lua/config/options.lua b/.config/nvim/lua/config/options.lua new file mode 100644 index 0000000..e091464 --- /dev/null +++ b/.config/nvim/lua/config/options.lua @@ -0,0 +1,137 @@ +local opt = vim.opt + +opt.number = true -- Line numbers +opt.relativenumber = true -- Relative line numbers +opt.cursorline = true -- Highlight current line +opt.wrap = false -- Don't wrap lines +opt.scrolloff = 10 -- Keep 10 lines above/below cursor +opt.sidescrolloff = 8 -- Keep 8 columns left/right of cursor + +-- Indentation +opt.tabstop = 2 -- Tab width +opt.shiftwidth = 2 -- Indent width +opt.softtabstop = 2 -- Soft tab stop +opt.expandtab = true -- Use spaces instead of tabs +opt.smartindent = true -- Smart auto-indenting +opt.autoindent = true -- Copy indent from current line + +-- Search settings +opt.ignorecase = true -- Case insensitive search +opt.smartcase = true -- Case sensitive if uppercase in search +opt.hlsearch = false -- Don't highlight search results +opt.incsearch = true -- Show matches as you type + +-- Visual settings +opt.termguicolors = true -- Enable 24-bit colors +opt.signcolumn = "yes" -- Always show sign column +opt.showmatch = true -- Highlight matching brackets +opt.matchtime = 2 -- How long to show matching bracket +opt.cmdheight = 1 -- Command line height +opt.showmode = false -- Don't show mode in command line +opt.pumheight = 10 -- Popup menu height +opt.pumblend = 10 -- Popup menu transparency +opt.winblend = 0 -- Floating window transparency +opt.completeopt = "menu,menuone,noselect" +opt.conceallevel = 2 -- Hide * markup for bold and italic, but not markers with substitutions +opt.confirm = true -- Confirm to save changes before exiting modified buffer +opt.concealcursor = "" -- Don't hide cursor line markup +opt.synmaxcol = 300 -- Syntax highlighting limit +opt.ruler = false -- Disable the default ruler +opt.virtualedit = "block" -- Allow cursor to move where there is no text in visual block mode +opt.winminwidth = 5 -- Minimum window width + +-- File handling +opt.backup = false -- Don't create backup files +opt.writebackup = false -- Don't create backup before writing +opt.swapfile = false -- Don't create swap files +opt.undofile = true -- Persistent undo +opt.undolevels = 10000 +opt.undodir = vim.fn.expand("~/.vim/undodir") -- Undo directory +opt.updatetime = 300 -- Faster completion +opt.timeoutlen = vim.g.vscode and 1000 or 300 -- Lower than default (1000) to quickly trigger which-key +opt.ttimeoutlen = 0 -- Key code timeout +opt.autoread = true -- Auto reload files changed outside vim +opt.autowrite = true -- Auto save + +-- Behavior settings +opt.hidden = true -- Allow hidden buffers +opt.errorbells = false -- No error bells +opt.backspace = "indent,eol,start" -- Better backspace behavior +opt.autochdir = false -- Don't auto change directory +opt.iskeyword:append("-") -- Treat dash as part of word +opt.path:append("**") -- include subdirectories in search +opt.selection = "exclusive" -- Selection behavior +opt.mouse = "a" -- Enable mouse support +opt.clipboard = vim.env.SSH_TTY and "" or "unnamedplus" -- Sync with system clipboard +opt.modifiable = true -- Allow buffer modifications +opt.encoding = "UTF-8" -- Set encoding + +-- Folding settings +opt.smoothscroll = true +vim.wo.foldmethod = "expr" +opt.foldlevel = 99 -- Start with all folds open +opt.formatoptions = "jcroqlnt" -- tcqj +opt.grepformat = "%f:%l:%c:%m" +opt.grepprg = "rg --vimgrep" + +-- Split behavior +opt.splitbelow = true -- Horizontal splits go below +opt.splitright = true -- Vertical splits go right +opt.splitkeep = "screen" + +-- Command-line completion +opt.wildmenu = true +opt.wildmode = "longest:full,full" +opt.wildignore:append({ "*.o", "*.obj", "*.pyc", "*.class", "*.jar" }) + +-- Better diff options +opt.diffopt:append("linematch:60") + +-- Performance improvements +opt.redrawtime = 10000 +opt.maxmempattern = 20000 + +-- Create undo directory if it doesn't exist +local undodir = vim.fn.expand("~/.vim/undodir") +if vim.fn.isdirectory(undodir) == 0 then + vim.fn.mkdir(undodir, "p") +end + +vim.g.autoformat = true +vim.g.trouble_lualine = true + +--[[ +opt.fillchars = { + foldopen = "", + foldclose = "", + fold = " ", + foldsep = " ", + diff = "╱", + eob = " ", +} +]] + +opt.jumpoptions = "view" +opt.laststatus = 3 -- global statusline +opt.list = false +opt.linebreak = true -- Wrap lines at convenient points +opt.list = true -- Show some invisible characters (tabs... +opt.shiftround = true -- Round indent +opt.shiftwidth = 2 -- Size of an indent +opt.shortmess:append({ W = true, I = true, c = true, C = true }) + +vim.g.markdown_recommended_style = 0 + +vim.filetype.add({ + extension = { + env = "dotenv", + }, + filename = { + [".env"] = "dotenv", + ["env"] = "dotenv", + }, + pattern = { + ["[jt]sconfig.*.json"] = "jsonc", + ["%.env%.[%w_.-]+"] = "dotenv", + }, +}) diff --git a/.config/nvim/lua/plugins/catppuccin.lua b/.config/nvim/lua/plugins/catppuccin.lua deleted file mode 100644 index df7244b..0000000 --- a/.config/nvim/lua/plugins/catppuccin.lua +++ /dev/null @@ -1,17 +0,0 @@ -return { - "catppuccin/nvim", - name = "catppuccin", - priority = 1000, - config = function() - local config = require("catppuccin") - config.setup({ - auto_integrations = true, - flavour = "mocha", - background = { - light = "mocha", - dark = "mocha", - }, - }) - vim.cmd.colorscheme "catppuccin-mocha" - end -} diff --git a/.config/nvim/lua/plugins/cmp.lua b/.config/nvim/lua/plugins/cmp.lua deleted file mode 100644 index 8180553..0000000 --- a/.config/nvim/lua/plugins/cmp.lua +++ /dev/null @@ -1,109 +0,0 @@ -return { --- { --- 'milanglacier/minuet-ai.nvim', --- dependencies = { --- 'nvim-lua/plenary.nvim', --- 'Saghen/blink.cmp' --- }, --- config = function() --- require('minuet').setup { --- provider = 'openai_fim_compatible', --- n_completions = 1, -- recommend for local model for resource saving --- -- I recommend beginning with a small context window size and incrementally --- -- expanding it, depending on your local computing power. A context window --- -- of 512, serves as an good starting point to estimate your computing --- -- power. Once you have a reliable estimate of your local computing power, --- -- you should adjust the context window to a larger value. --- context_window = 512, --- provider_options = { --- openai_fim_compatible = { --- -- For Windows users, TERM may not be present in environment variables. --- -- Consider using APPDATA instead. --- api_key = 'TERM', --- name = 'Llama.cpp', --- end_point = 'http://localhost:1234/v1/completions', --- model = 'qwen2.5-coder-7b-instruct', ----- template = { ----- prompt = function(context_before_cursor, context_after_cursor, _) ----- return '<|fim_prefix|>' ----- .. context_before_cursor ----- .. '<|fim_suffix|>' ----- .. context_after_cursor ----- .. '<|fim_middle|>' ----- end, ----- suffix = false, ----- }, --- }, --- }, --- } --- end, --- }, - { - 'saghen/blink.cmp', - -- optional: provides snippets for the snippet source - dependencies = { 'rafamadriz/friendly-snippets' }, - - -- use a release tag to download pre-built binaries - version = '1.*', - -- AND/OR build from source, requires nightly: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust - -- build = 'cargo build --release', - -- If you use nix, you can build from source using latest nightly rust with: - -- build = 'nix run .#build-plugin', - - ---@module 'blink.cmp' - ---@type blink.cmp.Config - opts = { - -- 'default' (recommended) for mappings similar to built-in completions (C-y to accept) - -- 'super-tab' for mappings similar to vscode (tab to accept) - -- 'enter' for enter to accept - -- 'none' for no mappings - -- - -- All presets have the following mappings: - -- C-space: Open menu or open docs if already open - -- C-n/C-p or Up/Down: Select next/previous item - -- C-e: Hide menu - -- C-k: Toggle signature help (if signature.enabled = true) - -- - -- See :h blink-cmp-config-keymap for defining your own keymap - keymap = { preset = 'default' }, - - appearance = { - -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font' - -- Adjusts spacing to ensure icons are aligned - nerd_font_variant = 'mono' - }, - - completion = { trigger = { prefetch_on_insert = false }, documentation = { auto_show = false } }, - - -- Default list of enabled providers defined so that you can extend it - -- elsewhere in your config, without redefining it, due to `opts_extend` - sources = { - default = { 'lsp', 'path', 'snippets', 'buffer' }, - }, - -- (Default) Rust fuzzy matcher for typo resistance and significantly better performance - -- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation, - -- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"` - -- - -- See the fuzzy documentation for more information - fuzzy = { implementation = "prefer_rust_with_warning" } - }, --- config = function() --- require('blink-cmp').setup { --- sources = { --- default = { 'lsp', 'path', 'buffer', 'snippets', 'minuet' }, --- providers = { --- minuet = { --- name = 'minuet', --- module = 'minuet.blink', --- async = true, --- -- Should match minuet.config.request_timeout * 1000, --- -- since minuet.config.request_timeout is in seconds --- timeout_ms = 3000, --- score_offset = 50, -- Gives minuet higher priority among suggestions --- }, --- }, --- }, --- } --- end - } -} diff --git a/.config/nvim/lua/plugins/dap.lua b/.config/nvim/lua/plugins/dap.lua deleted file mode 100644 index cc04d3d..0000000 --- a/.config/nvim/lua/plugins/dap.lua +++ /dev/null @@ -1,41 +0,0 @@ -return { - { - "mfussenegger/nvim-dap", - config = function() - local dap = require('dap') - dap.adapters.codelldb = { - type = "executable", - command = "codelldb" - } - - dap.configurations.cpp = { - { - name = "Launch file", - type = "codelldb", - request = "launch", - program = function() - return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') - end, - cwd = '${workspaceFolder}', - stopOnEntry = false, - }, - } - - dap.configurations.c = dap.configurations.cpp - dap.configurations.rust = dap.configurations.cpp - dap.configurations.zig = dap.configurations.cpp - - vim.keymap.set("n", "dt", ":DapToggleBreakpoint") - vim.keymap.set("n", "dc", ":DapContinue") - vim.keymap.set("n", "dx", ":DapTerminate") - vim.keymap.set("n", "do", ":DapStepOver") - end - }, - { - "rcarriga/nvim-dap-ui", - dependencies = { - "mfussenegger/nvim-dap", - "nvim-neotest/nvim-nio" - } - } -} diff --git a/.config/nvim/lua/plugins/diffview.lua b/.config/nvim/lua/plugins/diffview.lua deleted file mode 100644 index aab3fd3..0000000 --- a/.config/nvim/lua/plugins/diffview.lua +++ /dev/null @@ -1,3 +0,0 @@ -return { - "sindrets/diffview.nvim" -} diff --git a/.config/nvim/lua/plugins/git.lua b/.config/nvim/lua/plugins/git.lua deleted file mode 100644 index 04ca4cb..0000000 --- a/.config/nvim/lua/plugins/git.lua +++ /dev/null @@ -1,8 +0,0 @@ -return { - { - "tpope/vim-fugitive" - }, - { - "lewis6991/gitsigns.nvim" - }, -} diff --git a/.config/nvim/lua/plugins/init.lua b/.config/nvim/lua/plugins/init.lua new file mode 100644 index 0000000..c3c5f7e --- /dev/null +++ b/.config/nvim/lua/plugins/init.lua @@ -0,0 +1,5 @@ +require("plugins.whichkey") +require("plugins.treesitter") +require("plugins.neotree") +require("plugins.telescope") +require("plugins.theme") diff --git a/.config/nvim/lua/plugins/log-highlight.lua b/.config/nvim/lua/plugins/log-highlight.lua deleted file mode 100644 index 228fa84..0000000 --- a/.config/nvim/lua/plugins/log-highlight.lua +++ /dev/null @@ -1,4 +0,0 @@ -return { - "fei6409/log-highlight.nvim", - opts = {}, -} diff --git a/.config/nvim/lua/plugins/lspconfig.lua b/.config/nvim/lua/plugins/lspconfig.lua deleted file mode 100644 index 86c09cb..0000000 --- a/.config/nvim/lua/plugins/lspconfig.lua +++ /dev/null @@ -1,40 +0,0 @@ -return { - { - "neovim/nvim-lspconfig", - lazy = false, - config = function() - vim.keymap.set("n", "K", vim.lsp.buf.hover, {}) - vim.keymap.set("n", "gd", vim.lsp.buf.definition, {}) - vim.keymap.set("n", "gr", vim.lsp.buf.references, {}) - vim.keymap.set("n", "ca", vim.lsp.buf.code_action, {}) - vim.keymap.set("n", 'rn', vim.lsp.buf.rename, {}) - end, - }, - { - "williamboman/mason.nvim", - lazy = false, - config = function() - require("mason").setup({ - registries = { - "github:mason-org/mason-registry", - "github:Crashdummyy/mason-registry", - }, - }) - end - }, - { - "williamboman/mason-lspconfig.nvim", - lazy = false, - opts = { - auto_install = true, - }, - }, - { - "seblyng/roslyn.nvim", - ---@module 'roslyn.config' - ---@type RoslynNvimConfig - opts = { - -- your configuration comes here; leave empty for default settings - }, - } -} diff --git a/.config/nvim/lua/plugins/neo-tree.lua b/.config/nvim/lua/plugins/neo-tree.lua deleted file mode 100644 index ef6ff41..0000000 --- a/.config/nvim/lua/plugins/neo-tree.lua +++ /dev/null @@ -1,12 +0,0 @@ -return { - "nvim-neo-tree/neo-tree.nvim", - branch = "v3.x", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", - "MunifTanjim/nui.nvim", - }, - config = function() - vim.keymap.set('n', '', ':Neotree filesystem reveal float') - end -} diff --git a/.config/nvim/lua/plugins/neotree.lua b/.config/nvim/lua/plugins/neotree.lua new file mode 100644 index 0000000..e0330be --- /dev/null +++ b/.config/nvim/lua/plugins/neotree.lua @@ -0,0 +1,11 @@ +vim.pack.add({ + { + src = 'https://github.com/nvim-neo-tree/neo-tree.nvim', + version = vim.version.range('3') + }, + -- dependencies + "https://github.com/nvim-lua/plenary.nvim", + "https://github.com/MunifTanjim/nui.nvim", + -- optional, but recommended + "https://github.com/nvim-tree/nvim-web-devicons", +}) diff --git a/.config/nvim/lua/plugins/opencode.lua b/.config/nvim/lua/plugins/opencode.lua deleted file mode 100644 index 4414674..0000000 --- a/.config/nvim/lua/plugins/opencode.lua +++ /dev/null @@ -1,19 +0,0 @@ -return { - 'NickvanDyke/opencode.nvim', - dependencies = { 'folke/snacks.nvim', }, - ---@type opencode.Config - opts = { - -- Your configuration, if any - }, - -- stylua: ignore - keys = { - { 'ot', function() require('opencode').toggle() end, desc = 'Toggle embedded opencode', }, - { 'oa', function() require('opencode').ask() end, desc = 'Ask opencode', mode = 'n', }, - { 'oa', function() require('opencode').ask('@selection: ') end, desc = 'Ask opencode about selection', mode = 'v', }, - { 'op', function() require('opencode').select_prompt() end, desc = 'Select prompt', mode = { 'n', 'v', }, }, - { 'on', function() require('opencode').command('session_new') end, desc = 'New session', }, - { 'oy', function() require('opencode').command('messages_copy') end, desc = 'Copy last message', }, - { '', function() require('opencode').command('messages_half_page_up') end, desc = 'Scroll messages up', }, - { '', function() require('opencode').command('messages_half_page_down') end, desc = 'Scroll messages down', }, - }, -} diff --git a/.config/nvim/lua/plugins/scratchpad.lua b/.config/nvim/lua/plugins/scratchpad.lua deleted file mode 100644 index 3ca526c..0000000 --- a/.config/nvim/lua/plugins/scratchpad.lua +++ /dev/null @@ -1,3 +0,0 @@ -return { - "mtth/scratch.vim" -} diff --git a/.config/nvim/lua/plugins/statusbar.lua b/.config/nvim/lua/plugins/statusbar.lua deleted file mode 100644 index 8a7b73a..0000000 --- a/.config/nvim/lua/plugins/statusbar.lua +++ /dev/null @@ -1,60 +0,0 @@ -return { - 'nvim-lualine/lualine.nvim', - dependencies = { 'nvim-tree/nvim-web-devicons' }, - config = function() - require('lualine').setup { - options = { - icons_enabled = true, - theme = 'auto', - component_separators = { left = '', right = ''}, - section_separators = { left = '', right = ''}, - disabled_filetypes = { - statusline = {}, - winbar = {}, - }, - ignore_focus = {}, - always_divide_middle = true, - always_show_tabline = true, - globalstatus = false, - refresh = { - statusline = 1000, - tabline = 1000, - winbar = 1000, - refresh_time = 16, -- ~60fps - events = { - 'WinEnter', - 'BufEnter', - 'BufWritePost', - 'SessionLoadPost', - 'FileChangedShellPost', - 'VimResized', - 'Filetype', - 'CursorMoved', - 'CursorMovedI', - 'ModeChanged', - }, - } - }, - sections = { - lualine_a = {'mode'}, - lualine_b = {'branch', 'diff', 'diagnostics'}, - lualine_c = {'filename'}, - lualine_x = {'encoding', 'fileformat', 'filetype'}, - lualine_y = {'progress'}, - lualine_z = {'location'} - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = {'filename'}, - lualine_x = {'location'}, - lualine_y = {}, - lualine_z = {} - }, - tabline = {}, - winbar = {}, - inactive_winbar = {}, - extensions = {} - } - end -} diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua index fbd46c9..b35514a 100644 --- a/.config/nvim/lua/plugins/telescope.lua +++ b/.config/nvim/lua/plugins/telescope.lua @@ -1,10 +1,13 @@ -return { - "nvim-telescope/telescope.nvim", - tag = "0.1.8", - dependencies = { "nvim-lua/plenary.nvim" }, - config = function() - local builtin = require("telescope.builtin") - vim.keymap.set("n", "", builtin.find_files, {}) - vim.keymap.set("n", "fg", builtin.live_grep, {}) - end -} +vim.pack.add({"https://github.com/nvim-telescope/telescope.nvim", +"https://github.com/nvim-lua/plenary.nvim", +"https://github.com/BurntSushi/ripgrep", +"https://github.com/nvim-telescope/telescope-fzf-native.nvim", +"https://github.com/sharkdp/fd", +"https://github.com/nvim-tree/nvim-web-devicons"} +) + +local builtin = require('telescope.builtin') +vim.keymap.set('n', 'ff', builtin.find_files, { desc = 'Telescope find files' }) +vim.keymap.set('n', 'fg', builtin.live_grep, { desc = 'Telescope live grep' }) +vim.keymap.set('n', 'fb', builtin.buffers, { desc = 'Telescope buffers' }) +vim.keymap.set('n', 'fh', builtin.help_tags, { desc = 'Telescope help tags' }) diff --git a/.config/nvim/lua/plugins/theme.lua b/.config/nvim/lua/plugins/theme.lua new file mode 100644 index 0000000..45c7d33 --- /dev/null +++ b/.config/nvim/lua/plugins/theme.lua @@ -0,0 +1,3 @@ +vim.pack.add({"https://github.com/catppuccin/nvim"}) + +vim.cmd("colorscheme catppuccin") diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua index 24515ad..53e9ff0 100644 --- a/.config/nvim/lua/plugins/treesitter.lua +++ b/.config/nvim/lua/plugins/treesitter.lua @@ -1,7 +1,144 @@ -return { - "nvim-treesitter/nvim-treesitter", - build = ":TSUpdate", - config = function() - require('nvim-treesitter').install({ 'zig', 'c', 'vim', 'rasi', 'cpp', 'javascript', 'markdown', 'markdown_inline', 'lua' }):wait(300000) -- wait max. 5 minutes - end -} +vim.pack.add({ + { + src = "https://github.com/nvim-treesitter/nvim-treesitter", + version = "main", + }, + { + src = "https://github.com/nvim-treesitter/nvim-treesitter-textobjects", + version = "main", + }, +}) + +require("nvim-treesitter").setup({}) +require("nvim-treesitter").install({ + "bash", + "blade", + "c", + "comment", + "css", + "diff", + "dockerfile", + "fish", + "gitcommit", + "gitignore", + "go", + "gomod", + "gosum", + "gowork", + "html", + "ini", + "javascript", + "jsdoc", + "json", + "lua", + "luadoc", + "luap", + "make", + "markdown", + "markdown_inline", + "nginx", + "nix", + "proto", + "python", + "query", + "regex", + "rust", + "scss", + "sql", + "terraform", + "toml", + "tsx", + "typescript", + "vim", + "vimdoc", + "xml", + "yaml", + "zig", +}) + +require("nvim-treesitter-textobjects").setup({ + select = { + enable = true, + lookahead = true, + selection_modes = { + ["@parameter.outer"] = "v", -- charwise + ["@function.outer"] = "V", -- linewise + ["@class.outer"] = "", -- blockwise + }, + include_surrounding_whitespace = false, + }, + move = { + enable = true, + set_jumps = true, + }, +}) + +-- SELECT keymaps +local sel = require("nvim-treesitter-textobjects.select") +for _, map in ipairs({ + { { "x", "o" }, "af", "@function.outer" }, + { { "x", "o" }, "if", "@function.inner" }, + { { "x", "o" }, "ac", "@class.outer" }, + { { "x", "o" }, "ic", "@class.inner" }, + { { "x", "o" }, "aa", "@parameter.outer" }, + { { "x", "o" }, "ia", "@parameter.inner" }, + { { "x", "o" }, "ad", "@comment.outer" }, + { { "x", "o" }, "as", "@statement.outer" }, +}) do +vim.keymap.set(map[1], map[2], function() + sel.select_textobject(map[3], "textobjects") +end, { desc = "Select " .. map[3] }) +end + +-- MOVE keymaps +local mv = require("nvim-treesitter-textobjects.move") +for _, map in ipairs({ + { { "n", "x", "o" }, "]m", mv.goto_next_start, "@function.outer" }, + { { "n", "x", "o" }, "[m", mv.goto_previous_start, "@function.outer" }, + { { "n", "x", "o" }, "]]", mv.goto_next_start, "@class.outer" }, + { { "n", "x", "o" }, "[[", mv.goto_previous_start, "@class.outer" }, + { { "n", "x", "o" }, "]M", mv.goto_next_end, "@function.outer" }, + { { "n", "x", "o" }, "[M", mv.goto_previous_end, "@function.outer" }, + { { "n", "x", "o" }, "]o", mv.goto_next_start, { "@loop.inner", "@loop.outer" } }, + { { "n", "x", "o" }, "[o", mv.goto_previous_start, { "@loop.inner", "@loop.outer" } }, +}) do +local modes, lhs, fn, query = map[1], map[2], map[3], map[4] +-- build a human-readable desc +local qstr = (type(query) == "table") and table.concat(query, ",") or query +vim.keymap.set(modes, lhs, function() + fn(query, "textobjects") +end, { desc = "Move to " .. qstr }) +end + +vim.api.nvim_create_autocmd("PackChanged", { + desc = "Handle nvim-treesitter updates", + group = vim.api.nvim_create_augroup("nvim-treesitter-pack-changed-update-handler", { clear = true }), + callback = function(event) + if event.data.kind == "update" then + local ok = pcall(vim.cmd, "TSUpdate") + if ok then + vim.notify("TSUpdate completed successfully!", vim.log.levels.INFO) + else + vim.notify("TSUpdate command not available yet, skipping", vim.log.levels.WARN) + end + end + end, +}) + +vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()" +vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" + +vim.api.nvim_create_autocmd("FileType", { + pattern = { "*" }, + callback = function() + local filetype = vim.bo.filetype + if filetype and filetype ~= "" then + local success = pcall(function() + vim.treesitter.start() + end) + if not success then + return + end + end + end, +}) diff --git a/.config/nvim/lua/plugins/whichkey.lua b/.config/nvim/lua/plugins/whichkey.lua new file mode 100644 index 0000000..9f2397f --- /dev/null +++ b/.config/nvim/lua/plugins/whichkey.lua @@ -0,0 +1,98 @@ +vim.pack.add({ + "https://github.com/folke/which-key.nvim", +}) + +local wk = require("which-key") +wk.setup({ + preset = "helix", +}) +wk.add({ + { "", group = "tabs" }, + { "c", group = "code" }, + { "d", group = "debug" }, + { "D", group = "Diffview", icon = { icon = "", color = "orange" } }, + { "p", group = "Yanky", icon = { icon = "󰃮 ", color = "yellow" } }, + { "dp", group = "profiler" }, + { "f", group = "file/find" }, + { "g", group = "git" }, + { "gh", group = "hunks" }, + { "q", group = "quit/session" }, + { "s", group = "search" }, + { "u", group = "ui", icon = { icon = "󰙵 ", color = "cyan" } }, + { "x", group = "diagnostics/quickfix", icon = { icon = "󱖫 ", color = "green" } }, + { "[", group = "prev" }, + { "]", group = "next" }, + { "g", group = "goto" }, + { "gs", group = "surround" }, + { "z", group = "fold" }, + { + "b", + group = "buffer", + expand = function() + return require("which-key.extras").expand.buf() + end, + }, + { + "w", + group = "windows", + proxy = "", + expand = function() + return require("which-key.extras").expand.win() + end, + }, + -- better descriptions + { "gx", desc = "Open with system app" }, + { + "fC", + group = "Copy Path", + { + "fCf", + function() + vim.fn.setreg("+", vim.fn.expand("%:p")) -- Copy full file path to clipboard + vim.notify("Copied full file path: " .. vim.fn.expand("%:p")) + end, + desc = "Copy full file path", + }, + { + "fCn", + function() + vim.fn.setreg("+", vim.fn.expand("%:t")) -- Copy file name to clipboard + vim.notify("Copied file name: " .. vim.fn.expand("%:t")) + end, + desc = "Copy file name", + }, + { + "fCr", + function() + local cwd = vim.fn.getcwd() -- Current working directory + local full_path = vim.fn.expand("%:p") -- Full file path + local rel_path = full_path:sub(#cwd + 2) -- Remove cwd prefix and leading slash + vim.fn.setreg("+", rel_path) -- Copy relative file path to clipboard + vim.notify("Copied relative file path: " .. rel_path) + end, + desc = "Copy relative file path", + }, + { + "?", + function() + require("which-key").show({ global = false }) + end, + desc = "Buffer Keymaps (which-key)", + }, + { + "", + function() + require("which-key").show({ keys = "", loop = true }) + end, + desc = "Window Hydra Mode (which-key)", + }, + }, + { + -- Nested mappings are allowed and can be added in any order + -- Most attributes can be inherited or overridden on any level + -- There's no limit to the depth of nesting + mode = { "n", "v" }, -- NORMAL and VISUAL mode + { "q", "q", desc = "Quit" }, -- no need to specify mode since it's inherited + { "w", "w", desc = "Write" }, + }, +}) diff --git a/.config/nvim/lua/vim-options.lua b/.config/nvim/lua/vim-options.lua deleted file mode 100644 index 4500893..0000000 --- a/.config/nvim/lua/vim-options.lua +++ /dev/null @@ -1,14 +0,0 @@ -vim.g.mapleader= " " -vim.o.termguicolors = true -vim.o.number = true -vim.o.relativenumber = true -vim.o.signcolumn = "yes" -vim.o.expandtab = true -vim.o.tabstop = 2 -vim.o.softtabstop = 2 -vim.o.shiftwidth = 2 -vim.o.termguicolors = true -vim.o.winborder = "rounded" -vim.o.cursorline = true -vim.o.list = true -vim.o.scrolloff = 8 diff --git a/.config/nvim/nvim-pack-lock.json b/.config/nvim/nvim-pack-lock.json new file mode 100644 index 0000000..c4e7874 --- /dev/null +++ b/.config/nvim/nvim-pack-lock.json @@ -0,0 +1,55 @@ +{ + "plugins": { + "fd": { + "rev": "5f95a78", + "src": "https://github.com/sharkdp/fd" + }, + "neo-tree.nvim": { + "rev": "f3df514", + "src": "https://github.com/nvim-neo-tree/neo-tree.nvim", + "version": "3.0.0 - 4.0.0" + }, + "nui.nvim": { + "rev": "de74099", + "src": "https://github.com/MunifTanjim/nui.nvim" + }, + "nvim": { + "rev": "6efc53e", + "src": "https://github.com/catppuccin/nvim" + }, + "nvim-treesitter": { + "rev": "b033ab33", + "src": "https://github.com/nvim-treesitter/nvim-treesitter", + "version": "'main'" + }, + "nvim-treesitter-textobjects": { + "rev": "28a3494", + "src": "https://github.com/nvim-treesitter/nvim-treesitter-textobjects", + "version": "'main'" + }, + "nvim-web-devicons": { + "rev": "6788013", + "src": "https://github.com/nvim-tree/nvim-web-devicons" + }, + "plenary.nvim": { + "rev": "b9fd522", + "src": "https://github.com/nvim-lua/plenary.nvim" + }, + "ripgrep": { + "rev": "0a88ccc", + "src": "https://github.com/BurntSushi/ripgrep" + }, + "telescope-fzf-native.nvim": { + "rev": "6fea601", + "src": "https://github.com/nvim-telescope/telescope-fzf-native.nvim" + }, + "telescope.nvim": { + "rev": "3333a52", + "src": "https://github.com/nvim-telescope/telescope.nvim" + }, + "which-key.nvim": { + "rev": "3aab214", + "src": "https://github.com/folke/which-key.nvim" + } + } +} \ No newline at end of file