From d3592bd80abf6dc8eb60acf5ac1992022032b25c Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Fri, 17 Oct 2025 15:33:11 +0545 Subject: [PATCH] refactor: restructure core modules into config directory for better organization --- init.lua | 11 +- lazy-lock.json | 4 +- lua/config/autocmd.lua | 187 ++++++++++++ lua/config/extensions.lua | 66 +++++ lua/config/keys.lua | 140 +++++++++ lua/{core => config}/lazy.lua | 20 +- lua/config/lsp.lua | 100 +++++++ lua/config/options.lua | 67 +++++ lua/core/autocmd.lua | 187 ------------ lua/core/functions.lua | 68 ----- lua/core/keys.lua | 140 --------- lua/core/lsp.lua | 135 --------- lua/core/options.lua | 67 ----- lua/plugins/coding.lua | 178 +++++++++-- lua/plugins/completion.lua | 81 ----- lua/plugins/editor.lua | 204 ++++++++++--- lua/plugins/format.lua | 72 ----- lua/plugins/formatting.lua | 64 ++++ lua/plugins/git.lua | 102 ------- lua/plugins/lint.lua | 45 --- lua/plugins/linting.lua | 34 +++ lua/plugins/lsp.lua | 82 +++-- lua/plugins/mini.lua | 126 ++++---- lua/plugins/picker.lua | 362 ----------------------- lua/plugins/snacks.lua | 340 +++++++++++++++++++++ lua/plugins/treesitter.lua | 45 --- lua/plugins/ui.lua | 81 ----- lua/plugins/util.lua | 125 +++----- lua/plugins/whichkey.lua | 542 +++++++++++++++++----------------- 29 files changed, 1751 insertions(+), 1924 deletions(-) create mode 100644 lua/config/autocmd.lua create mode 100644 lua/config/extensions.lua create mode 100644 lua/config/keys.lua rename lua/{core => config}/lazy.lua (54%) create mode 100644 lua/config/lsp.lua create mode 100644 lua/config/options.lua delete mode 100644 lua/core/autocmd.lua delete mode 100644 lua/core/functions.lua delete mode 100644 lua/core/keys.lua delete mode 100644 lua/core/lsp.lua delete mode 100644 lua/core/options.lua delete mode 100644 lua/plugins/completion.lua delete mode 100644 lua/plugins/format.lua create mode 100644 lua/plugins/formatting.lua delete mode 100644 lua/plugins/git.lua delete mode 100644 lua/plugins/lint.lua create mode 100644 lua/plugins/linting.lua delete mode 100644 lua/plugins/picker.lua create mode 100644 lua/plugins/snacks.lua delete mode 100644 lua/plugins/treesitter.lua delete mode 100644 lua/plugins/ui.lua mode change 100755 => 100644 lua/plugins/util.lua diff --git a/init.lua b/init.lua index 61ed86b..ea06955 100644 --- a/init.lua +++ b/init.lua @@ -1,7 +1,6 @@ -- load config -require('core.options') -require('core.functions') -require('core.keys') -require('core.autocmd') -require('core.lsp') -require('core.lazy') +require("config.options") +require("config.keys") +require("config.autocmd") +require("config.lazy") +require("config.lsp") diff --git a/lazy-lock.json b/lazy-lock.json index 5c4b1dd..2085baf 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -10,8 +10,7 @@ "gitsigns.nvim": { "branch": "main", "commit": "1ee5c1fd068c81f9dd06483e639c2aa4587dc197" }, "gruvbox.nvim": { "branch": "main", "commit": "5e0a460d8e0f7f669c158dedd5f9ae2bcac31437" }, "hardtime.nvim": { "branch": "main", "commit": "b4e431934af1fe224a3a801f632c008278cb7628" }, - "lazy.nvim": { "branch": "main", "commit": "1ea3c4085785f460fb0e46d2fe1ee895f5f9e7c1" }, - "lazygit.nvim": { "branch": "main", "commit": "2305deed25bc61b866d5d39189e9105a45cf1cfb" }, + "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lspsaga.nvim": { "branch": "main", "commit": "8efe00d6aed9db6449969f889170f1a7e43101a1" }, "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, "markview.nvim": { "branch": "main", "commit": "c93ea99d96b4bfda5b7c7d0dfca9c26edf6e78f0" }, @@ -20,7 +19,6 @@ "mason-nvim-lint": { "branch": "main", "commit": "767b8ccdddaa977bec8987fd7507b9865a279235" }, "mason.nvim": { "branch": "main", "commit": "ad7146aa61dcaeb54fa900144d768f040090bff0" }, "mdx.nvim": { "branch": "main", "commit": "464a74be368dce212cff02f6305845dc7f209ab3" }, - "messenger.nvim": { "branch": "main", "commit": "309fec2ddd3de55eba2781b676931b37ce8190af" }, "mini.nvim": { "branch": "main", "commit": "8a7cf7eee8d89bd1b83f6d72f7f3b5598e7ae2cb" }, "neogen": { "branch": "main", "commit": "d7f9461727751fb07f82011051338a9aba07581d" }, "neoscroll.nvim": { "branch": "master", "commit": "f957373912e88579e26fdaea4735450ff2ef5c9c" }, diff --git a/lua/config/autocmd.lua b/lua/config/autocmd.lua new file mode 100644 index 0000000..06a7833 --- /dev/null +++ b/lua/config/autocmd.lua @@ -0,0 +1,187 @@ +local function augroup(name) + return vim.api.nvim_create_augroup("nvim" .. name, { clear = true }) +end + +-- Strip trailing spaces before write +vim.api.nvim_create_autocmd({ "BufWritePre" }, { + group = augroup("strip_space"), + pattern = { "*" }, + callback = function() + vim.cmd([[ %s/\s\+$//e ]]) + end, +}) + +-- Check if we need to reload the file when it changed +vim.api.nvim_create_autocmd({ "FocusGained", "TermClose", "TermLeave" }, { + group = augroup("checktime"), + command = "checktime", +}) + +-- Highlight on yank +vim.api.nvim_create_autocmd("TextYankPost", { + group = augroup("highlight_yank"), + callback = function() + vim.highlight.on_yank() + end, +}) + +-- resize splits if window got resized +vim.api.nvim_create_autocmd({ "VimResized" }, { + group = augroup("resize_splits"), + callback = function() + vim.cmd("tabdo wincmd =") + end, +}) + +-- go to last loc when opening a buffer +vim.api.nvim_create_autocmd("BufReadPost", { + group = augroup("last_loc"), + callback = function() + local mark = vim.api.nvim_buf_get_mark(0, '"') + local lcount = vim.api.nvim_buf_line_count(0) + if mark[1] > 0 and mark[1] <= lcount then + pcall(vim.api.nvim_win_set_cursor, 0, mark) + end + end, +}) + +-- close some filetypes with +vim.api.nvim_create_autocmd("FileType", { + group = augroup("close_with_q"), + pattern = { + "Jaq", + "PlenaryTestPopup", + "Avante", + "AvanteInput", + "AvanteSelectedFiles", + "fugitive", + "git", + "help", + "lir", + "lspinfo", + "man", + "netrw", + "notify", + "qf", + "spectre_panel", + "startuptime", + "tsplayground", + }, + callback = function(event) + vim.bo[event.buf].buflisted = false + vim.keymap.set("n", "q", "close", { buffer = event.buf, silent = true }) + end, +}) + +-- wrap and check for spell in text filetypes +vim.api.nvim_create_autocmd("FileType", { + group = augroup("wrap_spell"), + pattern = { "gitcommit", "markdown" }, + callback = function() + vim.opt_local.wrap = true + vim.opt_local.spell = true + 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) + local file = vim.loop.fs_realpath(event.match) or event.match + vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p") + end, +}) + +-- Set arb filetype +vim.api.nvim_create_autocmd({ "BufEnter" }, { + group = augroup("set_file_type"), + pattern = { "*.arb" }, + command = "setfiletype arb", +}) + +-- Disable format options +vim.api.nvim_create_autocmd("FileType", { + group = augroup("disable_formatoptions"), + pattern = "*", + callback = function() + vim.opt_local.formatoptions:remove({ "c", "r", "o" }) + end, +}) + +local function enable_autoformat() + vim.api.nvim_create_autocmd({ "BufWritePre" }, { + group = augroup("autoformat"), + pattern = { "*" }, + callback = function() + vim.lsp.buf.format() + end, + }) +end + +enable_autoformat() + +vim.api.nvim_create_user_command("WriteNoFormat", function() + -- Temporarily disable the autoformat autocmd + vim.api.nvim_del_augroup_by_name("keycodex_autoformat") + vim.cmd("write") + -- Re-enable the autoformat autocmd + enable_autoformat() +end, {}) + +-- Macro recording notifications +vim.api.nvim_create_autocmd("RecordingEnter", { + callback = function() + vim.notify("Macro recording started", vim.log.levels.INFO, { + title = "Macro", + timeout = 2000, + }) + -- Print to command line for debugging + vim.cmd("echo 'Recording macro...'") + end, +}) + +vim.api.nvim_create_autocmd("RecordingLeave", { + callback = function() + vim.notify("Macro recording stopped", vim.log.levels.INFO, { + title = "Macro", + timeout = 2000, + }) + -- Print to command line for debugging + vim.cmd("echo 'Macro recording stopped'") + end, +}) + +-- Function to show macro replay notification +local function show_macro_replay(count) + local message = count > 1 and string.format("Replaying macro %d times", count) or "Replaying macro" + vim.notify(message, vim.log.levels.INFO, { + title = "Macro", + timeout = 2000, + }) +end + +-- Function to clear all macros +local function clear_all_macros() + -- Clear all registers from a to z + for i = 97, 122 do -- ASCII values for 'a' to 'z' + vim.fn.setreg(string.char(i), "") + end + -- Clear all registers from 0 to 9 + for i = 48, 57 do -- ASCII values for '0' to '9' + vim.fn.setreg(string.char(i), "") + end + vim.notify("All macros cleared", vim.log.levels.INFO, { + title = "Macro", + timeout = 2000, + }) +end + +-- Create keymaps for macro replay with notifications +vim.keymap.set("n", "@", function() + local count = vim.v.count1 + show_macro_replay(count) + return "@" +end, { expr = true }) + +-- Add keybinding to clear all macros +vim.keymap.set("n", "mc", clear_all_macros, { desc = "Clear all macros" }) diff --git a/lua/config/extensions.lua b/lua/config/extensions.lua new file mode 100644 index 0000000..abb815d --- /dev/null +++ b/lua/config/extensions.lua @@ -0,0 +1,66 @@ +local treesitter_parsers = { + "c", + "markdown", + "python", + "java", + "cpp", + "bash", + "lua", + "make", + "json", + "jsonc", + "sql", + "yaml", + "toml", + "javascript", + "typescript", + "gitignore", + "go", + "rust", + "html", + "css", + "scss", + "markdown_inline", +} + +local lsp_server = { + "ts_ls", + "html", + "cssls", + "tailwindcss", + "lua_ls", + "basedpyright", + "bashls", + "clangd", + "rust_analyzer", +} + +local formatter = { + "clang_format", + "ruff", + "stylua", + "prettier", + "markdown-toc", + "markdownlint-cli2", + "biome", +} + +local linter = { + "eslint_d", + "hadolint", + "write_good", + "markdownlint", + "shellcheck", + "actionlint", + "djlint", + "ruff", + "codespell", + "cspell", +} + +return { + ts_parsers = treesitter_parsers, + lsp_server = lsp_server, + formatter = formatter, + linter = linter, +} diff --git a/lua/config/keys.lua b/lua/config/keys.lua new file mode 100644 index 0000000..2922f18 --- /dev/null +++ b/lua/config/keys.lua @@ -0,0 +1,140 @@ +local function map(mode, lhs, rhs, opts) + opts = opts or {} + opts.silent = opts.silent ~= false + vim.keymap.set(mode, lhs, rhs, opts) +end +local opts = { noremap = true, silent = true } + +-- Space as leader +map("n", "", "", opts) +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +-- Modes +-- normal_mode = "n", insert_mode = "i", visual_mode = "v", +-- visual_block_mode = "x", term_mode = "t", command_mode = "c", + +-- Terminal Mappings +map("t", "jk", "") +map("t", "kj", "") +map("t", "", "") + +-- Clear search, diff update and redraw +map({ "i", "n" }, "", "noh", { desc = "Escape and clear hlsearch" }) + +map({ "i", "c" }, "", "") +map({ "i", "c" }, "", "") + +map("n", "rL", vim.lsp.buf.rename, { desc = "Rename Lsp Symbol" }) +map("n", "`", "'", { noremap = true }) -- better marks + +map({ "n", "v" }, "H", "^", { desc = "Move to the beginning of the line" }) +map({ "n", "v" }, "L", "$", { desc = "Move to the end of the line" }) + +-- Visual overwrite paste +map({ "v", "x" }, "p", '"_dP', opts) + +-- Do not copy on x +map({ "v", "x" }, "x", '"_x', opts) +map("n", "X", '"_D', opts) +map("n", "dd", '"_dd', opts) +map({ "v", "x" }, "X", '"_d', opts) + +-- Select all +map("n", "", "ggVG", { desc = "Select all" }) +map("i", "", "ggVG", { desc = "Select all" }) + +-- Move text up and down +map({ "v", "x" }, "K", ":move '<-2gv-gv", opts) +map({ "v", "x" }, "J", ":move '>+1gv-gv", opts) + +-- Line operations +map("n", "", ":m .-2==", { desc = "Move line up" }) +map("n", "", ":m .+1==", { desc = "Move line down" }) +map("i", "", ":m .-2==gi", { desc = "Move line up" }) +map("i", "", ":m .+1==gi", { desc = "Move line down" }) +map("v", "", ":m '<-2gv=gv", { desc = "Move selection up" }) +map("v", "", ":m '>+1gv=gv", { desc = "Move selection down" }) + +-- Line manipulation +map("n", "", ">>", { desc = "Indent line" }) +map("n", "", "<<", { desc = "Unindent line" }) +map("i", "", ">>", { desc = "Indent line" }) +map("i", "", "<<", { desc = "Unindent line" }) + +-- Quick word operations +map("n", "", "db", { desc = "Delete word backward" }) +map("i", "", "", { desc = "Delete word backward" }) +map("n", "", "dw", { desc = "Delete word forward" }) +map("i", "", "dw", { desc = "Delete word forward" }) + +map("n", "d", '"_d', { desc = "Delete without replacing clipboard" }) +map("n", "x", '"_x', { desc = "Cut without replacing clipboard" }) +map("n", "c", '"_c', { desc = "Change without replacing clipboard" }) +map("v", "p", '"_dP', { desc = "Paste without replacing clipboard" }) + +--insert the following characters around the visual selection +map("v", "(", "s()Pll", { desc = "wrap selection with parens" }) +map("v", "[", "s[]Pll", { desc = "wrap selection with square braces" }) +map("v", "{", "s{}Pll", { desc = "wrap selection with curly braces" }) +map("v", "'", "s''Pll", { desc = "wrap selection with single quotes" }) +map("v", '"', 's""Pll', { desc = "wrap selection with double quotes" }) + +-- Insert mode cursor movement with Ctrl+hjkl +map({ "i", "c" }, "", "", { noremap = true, silent = true }) +map({ "i", "c" }, "", "", { noremap = true, silent = true }) +map({ "i", "c" }, "", "", { noremap = true, silent = true }) +map({ "i", "c" }, "", "", { noremap = true, silent = true }) + +map("n", "re", ":%s//", { desc = "Shortcut to replace current word under cursor" }) + +-- toggle inlay hints +vim.keymap.set("n", "th", function() + vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) +end) + +-- No arrow navigation +local modes = { "n", "v", "i" } +local arrows = { "", "", "", "" } + +for _, mode in ipairs(modes) do + for _, key in ipairs(arrows) do + vim.api.nvim_set_keymap(mode, key, "", opts) + end +end + +-- Go to Beginning or End of line +map({ "n", "v" }, "H", "_^", { desc = "Move to the beginning of the line" }) +map({ "n", "v" }, "L", "$", { desc = "Move to the end of the line" }) + +-- Search inside visually highlighted text. +map("x", "g/", "/\\%V", { silent = false, desc = "Search inside visual selection" }) + +-- Search & replace in current file/line +map("v", "rw", '"9y:%s@9@9@g', { desc = "Search & replace selection", silent = false }) +map("n", "rw", 'viw"9y:%s@9@9@g', { desc = "Search & replace word", silent = false }) +map( + "v", + "rl", + '"9y:s@9@9@g', + { desc = "Search & replace in current line", silent = false } +) +map( + "n", + "rl", + 'viw"9y:s@9@9@g', + { desc = "Search & replace word in current line", silent = false } +) + +-- Folds +map("n", "<", function() + if not vim.opt.foldmethod then + vim.opt.foldmethod = "indent" + end + vim.cmd("normal! zM") +end, { desc = "Fold all" }) + +map("n", ">", function() + vim.opt.foldenable = false + vim.cmd("normal! zR") +end, { desc = "Open all folds" }) diff --git a/lua/core/lazy.lua b/lua/config/lazy.lua similarity index 54% rename from lua/core/lazy.lua rename to lua/config/lazy.lua index 92ffa3f..cb5c563 100644 --- a/lua/core/lazy.lua +++ b/lua/config/lazy.lua @@ -1,15 +1,15 @@ -------------------------------------------------------------------------------- -- Bootstrap lazy plugin manager -------------------------------------------------------------------------------- -local lazypath = vim.fn.stdpath('data') .. '/lazy/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 }) + 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...' }, + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, }, true, {}) vim.fn.getchar() os.exit(1) @@ -18,20 +18,20 @@ end vim.opt.rtp:prepend(lazypath) -- lazy config -require('lazy').setup({ +require("lazy").setup({ spec = { - { import = 'plugins' }, + { import = "plugins" }, }, install = { missing = true, - colorscheme = { 'gruvbox' }, + colorscheme = { "gruvbox" }, }, change_detection = { enable = true, notify = false, }, ui = { - border = 'rounded', + border = "rounded", backdrop = 100, }, }) diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua new file mode 100644 index 0000000..31cac1b --- /dev/null +++ b/lua/config/lsp.lua @@ -0,0 +1,100 @@ +-------------------------------------------------------------------------------- +-- LSP +-------------------------------------------------------------------------------- + +-- ts_ls +vim.lsp.config("ts_ls", { + settings = { + typescript = { + inlayHints = { + includeInlayParameterNameHints = "all", + includeInlayParameterNameHintsWhenArgumentMatchesName = false, + includeInlayFunctionParameterTypeHints = true, + includeInlayVariableTypeHints = true, + includeInlayPropertyDeclarationTypeHints = true, + includeInlayFunctionLikeReturnTypeHints = true, + includeInlayEnumMemberValueHints = true, + }, + }, + }, +}) +vim.lsp.enable("ts_ls") + +vim.lsp.enable("html") +vim.lsp.enable("cssls") +vim.lsp.enable("tailwindcss") + +-- rust +vim.lsp.config("rust_analyzer", { + settings = { + ["rust-analyzer"] = { + diagnostics = { + enable = true, + experimental = { enable = true }, + }, + }, + }, +}) +vim.lsp.enable("rust_analyzer") + +-- lua +vim.lsp.config("lua_ls", { + settings = { + Lua = { + diagnostics = { + disable = { + "missing-fields", + "undefined-global", + }, + }, + }, + }, +}) +vim.lsp.enable("lua_ls") + +-- python +vim.lsp.config("basedpyright", { + settings = { + basedpyright = { + inlayHints = true, + analysis = { + diagnosticSeverityOverrides = { + reportUnusedImport = "none", + reportUnusedVariable = "none", + reportAttributeAccessIssue = "none", + reportUnusedClass = "none", + reportUnusedFunction = "none", + reportDuplicateImport = "none", + reportArgumentType = "error", + }, + typeCheckingMode = "standard", + }, + }, + }, +}) +vim.lsp.enable("basedpyright") + + + +-- bash +vim.lsp.config("bashls", { + settings = { + bashIde = { + shellcheckArguments = { + "--exclude=SC1090,SC1091,SC2076,SC2164", + }, + }, + }, +}) +vim.lsp.enable("bashls") + +-- cpp +vim.lsp.config("clangd", { + cmd = { + "clangd", + "--fallback-style=llvm", + "--header-insertion=iwyu", + "-j=4", + }, +}) +vim.lsp.enable("clangd") diff --git a/lua/config/options.lua b/lua/config/options.lua new file mode 100644 index 0000000..3290630 --- /dev/null +++ b/lua/config/options.lua @@ -0,0 +1,67 @@ +local options = { + ai = true, + clipboard = "unnamedplus", -- use system clipboard + number = true, + relativenumber = true, + undofile = true, -- save state of file on write + undodir = vim.fn.stdpath("cache") .. "/undo", + undolevels = 10000, + autoread = true, -- autoread changes from other sources + signcolumn = "yes", + cursorline = true, + cursorlineopt = "number", + wrap = false, + scrolloff = 3, + ruler = false, -- removes cursor position from lastline + pumheight = 10, -- size of completion window + showmode = false, -- do not show mode under statusline + swapfile = false, -- creates a swapfile + backup = false, -- creates a backup file + writebackup = false, -- do not edit backups + winminwidth = 5, -- Minimum window width + termguicolors = true, -- set term gui colors (most terminals support this) + showtabline = 0, -- always show tabs + showcmd = false, + mouse = "a", -- allow the mouse to be used in neovim + confirm = true, -- Confirm to save changes before exiting modified buffer + + -- tabs + smarttab = true, + tabstop = 4, -- 1 tab represented as 4 spaces + expandtab = true, -- key will create " " instead of "\t" + shiftwidth = 4, -- indent change after backspace and >> << + softtabstop = 4, -- number of spaces instead of tab + autoindent = true, -- auto indent + smartindent = true, -- make indenting smarter again + list = true, + -- listchars = { trail = "", tab = "", nbsp = "_", extends = ">", precedes = "<" }, -- highlight + showbreak = string.rep(" ", 3), + + -- Search + ignorecase = true, + smartcase = true, + hlsearch = true, + wildmenu = true, + wildmode = "longest:full,full", + wildoptions = "pum", + + -- Window + splitright = true, + splitbelow = true, + title = true, +} + +for k, v in pairs(options) do + vim.opt[k] = v +end + +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 + +vim.opt.path:append({ "**" }) +vim.opt.shortmess:append({ W = true, I = true, c = true }) -- disable greeting + +-- Fix markdown indentation settings +vim.g.markdown_recommended_style = 0 + +vim.cmd([[set fillchars+=eob:\ ]]) diff --git a/lua/core/autocmd.lua b/lua/core/autocmd.lua deleted file mode 100644 index 426d448..0000000 --- a/lua/core/autocmd.lua +++ /dev/null @@ -1,187 +0,0 @@ -local function augroup(name) - return vim.api.nvim_create_augroup('nvim' .. name, { clear = true }) -end - --- Strip trailing spaces before write -vim.api.nvim_create_autocmd({ 'BufWritePre' }, { - group = augroup('strip_space'), - pattern = { '*' }, - callback = function() - vim.cmd([[ %s/\s\+$//e ]]) - end, -}) - --- Check if we need to reload the file when it changed -vim.api.nvim_create_autocmd({ 'FocusGained', 'TermClose', 'TermLeave' }, { - group = augroup('checktime'), - command = 'checktime', -}) - --- Highlight on yank -vim.api.nvim_create_autocmd('TextYankPost', { - group = augroup('highlight_yank'), - callback = function() - vim.highlight.on_yank() - end, -}) - --- resize splits if window got resized -vim.api.nvim_create_autocmd({ 'VimResized' }, { - group = augroup('resize_splits'), - callback = function() - vim.cmd('tabdo wincmd =') - end, -}) - --- go to last loc when opening a buffer -vim.api.nvim_create_autocmd('BufReadPost', { - group = augroup('last_loc'), - callback = function() - local mark = vim.api.nvim_buf_get_mark(0, '"') - local lcount = vim.api.nvim_buf_line_count(0) - if mark[1] > 0 and mark[1] <= lcount then - pcall(vim.api.nvim_win_set_cursor, 0, mark) - end - end, -}) - --- close some filetypes with -vim.api.nvim_create_autocmd('FileType', { - group = augroup('close_with_q'), - pattern = { - 'Jaq', - 'PlenaryTestPopup', - 'Avante', - 'AvanteInput', - 'AvanteSelectedFiles', - 'fugitive', - 'git', - 'help', - 'lir', - 'lspinfo', - 'man', - 'netrw', - 'notify', - 'qf', - 'spectre_panel', - 'startuptime', - 'tsplayground', - }, - callback = function(event) - vim.bo[event.buf].buflisted = false - vim.keymap.set('n', 'q', 'close', { buffer = event.buf, silent = true }) - end, -}) - --- wrap and check for spell in text filetypes -vim.api.nvim_create_autocmd('FileType', { - group = augroup('wrap_spell'), - pattern = { 'gitcommit', 'markdown' }, - callback = function() - vim.opt_local.wrap = true - vim.opt_local.spell = true - 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) - local file = vim.loop.fs_realpath(event.match) or event.match - vim.fn.mkdir(vim.fn.fnamemodify(file, ':p:h'), 'p') - end, -}) - --- Set arb filetype -vim.api.nvim_create_autocmd({ 'BufEnter' }, { - group = augroup('set_file_type'), - pattern = { '*.arb' }, - command = 'setfiletype arb', -}) - --- Disable format options -vim.api.nvim_create_autocmd('FileType', { - group = augroup('disable_formatoptions'), - pattern = '*', - callback = function() - vim.opt_local.formatoptions:remove({ 'c', 'r', 'o' }) - end, -}) - -local function enable_autoformat() - vim.api.nvim_create_autocmd({ 'BufWritePre' }, { - group = augroup('autoformat'), - pattern = { '*' }, - callback = function() - vim.lsp.buf.format() - end, - }) -end - -enable_autoformat() - -vim.api.nvim_create_user_command('WriteNoFormat', function() - -- Temporarily disable the autoformat autocmd - vim.api.nvim_del_augroup_by_name('keycodex_autoformat') - vim.cmd('write') - -- Re-enable the autoformat autocmd - enable_autoformat() -end, {}) - --- Macro recording notifications -vim.api.nvim_create_autocmd('RecordingEnter', { - callback = function() - vim.notify('Macro recording started', vim.log.levels.INFO, { - title = 'Macro', - timeout = 2000, - }) - -- Print to command line for debugging - vim.cmd("echo 'Recording macro...'") - end, -}) - -vim.api.nvim_create_autocmd('RecordingLeave', { - callback = function() - vim.notify('Macro recording stopped', vim.log.levels.INFO, { - title = 'Macro', - timeout = 2000, - }) - -- Print to command line for debugging - vim.cmd("echo 'Macro recording stopped'") - end, -}) - --- Function to show macro replay notification -local function show_macro_replay(count) - local message = count > 1 and string.format('Replaying macro %d times', count) or 'Replaying macro' - vim.notify(message, vim.log.levels.INFO, { - title = 'Macro', - timeout = 2000, - }) -end - --- Function to clear all macros -local function clear_all_macros() - -- Clear all registers from a to z - for i = 97, 122 do -- ASCII values for 'a' to 'z' - vim.fn.setreg(string.char(i), '') - end - -- Clear all registers from 0 to 9 - for i = 48, 57 do -- ASCII values for '0' to '9' - vim.fn.setreg(string.char(i), '') - end - vim.notify('All macros cleared', vim.log.levels.INFO, { - title = 'Macro', - timeout = 2000, - }) -end - --- Create keymaps for macro replay with notifications -vim.keymap.set('n', '@', function() - local count = vim.v.count1 - show_macro_replay(count) - return '@' -end, { expr = true }) - --- Add keybinding to clear all macros -vim.keymap.set('n', 'mc', clear_all_macros, { desc = 'Clear all macros' }) diff --git a/lua/core/functions.lua b/lua/core/functions.lua deleted file mode 100644 index a92c3cb..0000000 --- a/lua/core/functions.lua +++ /dev/null @@ -1,68 +0,0 @@ --- Reload neovim config -vim.api.nvim_create_user_command('ReloadConfig', function() - for name, _ in pairs(package.loaded) do - if name:match('^plugins') then - package.loaded[name] = nil - end - end - - dofile(vim.env.MYVIMRC) - vim.notify('Nvim configuration reloaded!', vim.log.levels.INFO) -end, {}) - -local function copy_to_clipboard(content, message) - vim.fn.setreg('+', content) - vim.notify('Copied "' .. content .. '" to the clipboard!', vim.log.levels.INFO) -end - -vim.api.nvim_create_user_command('CopyRelativePath', function() - local path = vim.fn.expand('%') - copy_to_clipboard(path, 'Copied "' .. path .. '" to the clipboard!') -end, {}) - -vim.api.nvim_create_user_command('CopyAbsolutePath', function() - local path = vim.fn.expand('%:p') - copy_to_clipboard(path, 'Copied "' .. path .. '" to the clipboard!') -end, {}) - -vim.api.nvim_create_user_command('CopyRelativePathWithLine', function() - local path = vim.fn.expand('%') - local line = vim.fn.line('.') - local result = path .. ':' .. line - copy_to_clipboard(result, 'Copied "' .. result .. '" to the clipboard!') -end, {}) - -vim.api.nvim_create_user_command('CopyAbsolutePathWithLine', function() - local path = vim.fn.expand('%:p') - local line = vim.fn.line('.') - local result = path .. ':' .. line - copy_to_clipboard(result, 'Copied "' .. result .. '" to the clipboard!') -end, {}) - -vim.api.nvim_create_user_command('CopyFileName', function() - local path = vim.fn.expand('%:t') - copy_to_clipboard(path, 'Copied "' .. path .. '" to the clipboard!') -end, {}) - --- Switch to git root or file parent dir -vim.api.nvim_create_user_command('RootDir', function() - local bufname = vim.fn.expand('%:p') - if vim.fn.filereadable(bufname) == 0 then - return - end - - local parent = vim.fn.fnamemodify(bufname, ':h') - local git_root = vim.fn.systemlist('git -C ' .. vim.fn.fnameescape(parent) .. ' rev-parse --show-toplevel') - local root = '' - if #git_root > 0 and git_root[1] ~= '' then - root = git_root[1] - else - root = parent - end - - if root ~= '' then - vim.cmd('lcd ' .. vim.fn.fnameescape(root)) - vim.notify('Changed directory to ' .. root, vim.log.levels.INFO) - end -end, {}) - diff --git a/lua/core/keys.lua b/lua/core/keys.lua deleted file mode 100644 index 61d4555..0000000 --- a/lua/core/keys.lua +++ /dev/null @@ -1,140 +0,0 @@ -local function map(mode, lhs, rhs, opts) - opts = opts or {} - opts.silent = opts.silent ~= false - vim.keymap.set(mode, lhs, rhs, opts) -end -local opts = { noremap = true, silent = true } - --- Space as leader -map('n', '', '', opts) -vim.g.mapleader = ' ' -vim.g.maplocalleader = ' ' - --- Modes --- normal_mode = "n", insert_mode = "i", visual_mode = "v", --- visual_block_mode = "x", term_mode = "t", command_mode = "c", - --- Terminal Mappings -map('t', 'jk', '') -map('t', 'kj', '') -map('t', '', '') - --- Clear search, diff update and redraw -map({ 'i', 'n' }, '', 'noh', { desc = 'Escape and clear hlsearch' }) - -map({ 'i', 'c' }, '', '') -map({ 'i', 'c' }, '', '') - -map('n', 'rL', vim.lsp.buf.rename, { desc = 'Rename Lsp Symbol' }) -map('n', '`', "'", { noremap = true }) -- better marks - -map({ 'n', 'v' }, 'H', '^', { desc = 'Move to the beginning of the line' }) -map({ 'n', 'v' }, 'L', '$', { desc = 'Move to the end of the line' }) - --- Visual overwrite paste -map({ 'v', 'x' }, 'p', '"_dP', opts) - --- Do not copy on x -map({ 'v', 'x' }, 'x', '"_x', opts) -map('n', 'X', '"_D', opts) -map('n', 'dd', '"_dd', opts) -map({ 'v', 'x' }, 'X', '"_d', opts) - --- Select all -map('n', '', 'ggVG', { desc = 'Select all' }) -map('i', '', 'ggVG', { desc = 'Select all' }) - --- Move text up and down -map({ 'v', 'x' }, 'K', ":move '<-2gv-gv", opts) -map({ 'v', 'x' }, 'J', ":move '>+1gv-gv", opts) - --- Line operations -map('n', '', ':m .-2==', { desc = 'Move line up' }) -map('n', '', ':m .+1==', { desc = 'Move line down' }) -map('i', '', ':m .-2==gi', { desc = 'Move line up' }) -map('i', '', ':m .+1==gi', { desc = 'Move line down' }) -map('v', '', ":m '<-2gv=gv", { desc = 'Move selection up' }) -map('v', '', ":m '>+1gv=gv", { desc = 'Move selection down' }) - --- Line manipulation -map('n', '', '>>', { desc = 'Indent line' }) -map('n', '', '<<', { desc = 'Unindent line' }) -map('i', '', '>>', { desc = 'Indent line' }) -map('i', '', '<<', { desc = 'Unindent line' }) - --- Quick word operations -map('n', '', 'db', { desc = 'Delete word backward' }) -map('i', '', '', { desc = 'Delete word backward' }) -map('n', '', 'dw', { desc = 'Delete word forward' }) -map('i', '', 'dw', { desc = 'Delete word forward' }) - -map('n', 'd', '"_d', { desc = 'Delete without replacing clipboard' }) -map('n', 'x', '"_x', { desc = 'Cut without replacing clipboard' }) -map('n', 'c', '"_c', { desc = 'Change without replacing clipboard' }) -map('v', 'p', '"_dP', { desc = 'Paste without replacing clipboard' }) - ---insert the following characters around the visual selection -map('v', '(', 's()Pll', { desc = 'wrap selection with parens' }) -map('v', '[', 's[]Pll', { desc = 'wrap selection with square braces' }) -map('v', '{', 's{}Pll', { desc = 'wrap selection with curly braces' }) -map('v', "'", "s''Pll", { desc = 'wrap selection with single quotes' }) -map('v', '"', 's""Pll', { desc = 'wrap selection with double quotes' }) - --- Insert mode cursor movement with Ctrl+hjkl -map({ 'i', 'c' }, '', '', { noremap = true, silent = true }) -map({ 'i', 'c' }, '', '', { noremap = true, silent = true }) -map({ 'i', 'c' }, '', '', { noremap = true, silent = true }) -map({ 'i', 'c' }, '', '', { noremap = true, silent = true }) - -map('n', 're', ':%s//', { desc = 'Shortcut to replace current word under cursor' }) - --- toggle inlay hints -vim.keymap.set('n', 'th', function() - vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) -end) - --- No arrow navigation -local modes = { 'n', 'v', 'i' } -local arrows = { '', '', '', '' } - -for _, mode in ipairs(modes) do - for _, key in ipairs(arrows) do - vim.api.nvim_set_keymap(mode, key, '', opts) - end -end - --- Go to Beginning or End of line -map({ 'n', 'v' }, 'H', '_^', { desc = 'Move to the beginning of the line' }) -map({ 'n', 'v' }, 'L', '$', { desc = 'Move to the end of the line' }) - --- Search inside visually highlighted text. -map('x', 'g/', '/\\%V', { silent = false, desc = 'Search inside visual selection' }) - --- Search & replace in current file/line -map('v', 'rw', '"9y:%s@9@9@g', { desc = 'Search & replace selection', silent = false }) -map('n', 'rw', 'viw"9y:%s@9@9@g', { desc = 'Search & replace word', silent = false }) -map( - 'v', - 'rl', - '"9y:s@9@9@g', - { desc = 'Search & replace in current line', silent = false } -) -map( - 'n', - 'rl', - 'viw"9y:s@9@9@g', - { desc = 'Search & replace word in current line', silent = false } -) - --- Folds -map('n', '<', function() - if not vim.opt.foldmethod then - vim.opt.foldmethod = 'indent' - end - vim.cmd('normal! zM') -end, { desc = 'Fold all' }) - -map('n', '>', function() - vim.opt.foldenable = false - vim.cmd('normal! zR') -end, { desc = 'Open all folds' }) diff --git a/lua/core/lsp.lua b/lua/core/lsp.lua deleted file mode 100644 index 227611f..0000000 --- a/lua/core/lsp.lua +++ /dev/null @@ -1,135 +0,0 @@ --------------------------------------------------------------------------------- --- LSP --------------------------------------------------------------------------------- - --- ts_ls -vim.lsp.config('ts_ls', { - settings = { - typescript = { - inlayHints = { - includeInlayParameterNameHints = 'all', - includeInlayParameterNameHintsWhenArgumentMatchesName = false, - includeInlayFunctionParameterTypeHints = true, - includeInlayVariableTypeHints = true, - includeInlayPropertyDeclarationTypeHints = true, - includeInlayFunctionLikeReturnTypeHints = true, - includeInlayEnumMemberValueHints = true, - }, - }, - }, -}) -vim.lsp.enable('ts_ls') - --- rust -vim.lsp.config('rust_analyzer', { - settings = { - ['rust-analyzer'] = { - diagnostics = { - enable = true, - experimental = { enable = true }, - }, - }, - }, -}) -vim.lsp.enable('rust_analyzer') - --- lua -vim.lsp.config('lua_ls', { - settings = { - Lua = { - diagnostics = { - disable = { - 'missing-fields', - 'undefined-global', - }, - }, - }, - }, -}) -vim.lsp.enable('lua_ls') - --- python -vim.lsp.config('basedpyright', { - settings = { - basedpyright = { - inlayHints = true, - disableDiagnostics = true, - disableOrganizeImports = true, - analysis = { - -- Ignore all files for analysis to exclusively use Ruff for linting - -- Enable diagnostics - -- ignore = { "*" }, - diagnosticSeverityOverrides = { - reportUnusedImport = 'none', - reportUnusedVariable = 'none', - reportAttributeAccessIssue = 'none', - reportUnusedClass = 'none', - reportUnusedFunction = 'none', - reportDuplicateImport = 'none', - reportArgumentType = 'error', - }, - typeCheckingMode = 'standard', - }, - }, - }, -}) -vim.lsp.enable('basedpyright') - --- vim.lsp.config('pylsp', { --- settings = { --- pylsp = { --- plugins = { --- -- use black as default formatter --- yapf = { enabled = false }, --- autopep8 = { enabled = false }, --- black = { enabled = true }, --- pycodestyle = { --- enabled = true, --- ignore = { 'E203', 'E701', 'W503' }, --- maxLineLength = 88, --- }, --- }, --- }, --- }, --- }) - --- latex -vim.lsp.config('texlab', { - settings = { - texlab = { - build = { - executable = 'latexmk', - args = { - '-lualatex', - '-interaction=nonstopmode', - '-outdir=build', - }, - onSave = true, - }, - }, - }, -}) -vim.lsp.enable('texlab') - --- bash -vim.lsp.config('bashls', { - settings = { - bashIde = { - shellcheckArguments = { - '--exclude=SC1090,SC1091,SC2076,SC2164', - }, - }, - }, -}) -vim.lsp.enable('bashls') - --- cpp -vim.lsp.config('clangd', { - cmd = { - 'clangd', - '--fallback-style=llvm', - '--header-insertion=iwyu', - '-j=4', - }, -}) -vim.lsp.enable('clangd') diff --git a/lua/core/options.lua b/lua/core/options.lua deleted file mode 100644 index 63067e9..0000000 --- a/lua/core/options.lua +++ /dev/null @@ -1,67 +0,0 @@ -local options = { - ai = true, - clipboard = 'unnamedplus', -- use system clipboard - number = true, - relativenumber = true, - undofile = true, -- save state of file on write - undodir = vim.fn.stdpath('cache') .. '/undo', - undolevels = 10000, - autoread = true, -- autoread changes from other sources - signcolumn = 'yes', - cursorline = true, - cursorlineopt = 'number', - wrap = false, - scrolloff = 3, - ruler = false, -- removes cursor position from lastline - pumheight = 10, -- size of completion window - showmode = false, -- do not show mode under statusline - swapfile = false, -- creates a swapfile - backup = false, -- creates a backup file - writebackup = false, -- do not edit backups - winminwidth = 5, -- Minimum window width - termguicolors = true, -- set term gui colors (most terminals support this) - showtabline = 0, -- always show tabs - showcmd = false, - mouse = 'a', -- allow the mouse to be used in neovim - confirm = true, -- Confirm to save changes before exiting modified buffer - - -- tabs - smarttab = true, - tabstop = 4, -- 1 tab represented as 4 spaces - expandtab = true, -- key will create " " instead of "\t" - shiftwidth = 4, -- indent change after backspace and >> << - softtabstop = 4, -- number of spaces instead of tab - autoindent = true, -- auto indent - smartindent = true, -- make indenting smarter again - list = true, - -- listchars = { trail = "", tab = "", nbsp = "_", extends = ">", precedes = "<" }, -- highlight - showbreak = string.rep(' ', 3), - - -- Search - ignorecase = true, - smartcase = true, - hlsearch = true, - wildmenu = true, - wildmode = 'longest:full,full', - wildoptions = 'pum', - - -- Window - splitright = true, - splitbelow = true, - title = true, -} - -for k, v in pairs(options) do - vim.opt[k] = v -end - -vim.g.loaded_netrw = 1 -vim.g.loaded_netrwPlugin = 1 - -vim.opt.path:append({ '**' }) -vim.opt.shortmess:append({ W = true, I = true, c = true }) -- disable greeting - --- Fix markdown indentation settings -vim.g.markdown_recommended_style = 0 - -vim.cmd([[set fillchars+=eob:\ ]]) diff --git a/lua/plugins/coding.lua b/lua/plugins/coding.lua index 8036279..5bfea27 100644 --- a/lua/plugins/coding.lua +++ b/lua/plugins/coding.lua @@ -1,52 +1,178 @@ return { + + -- completion + { + "saghen/blink.cmp", + version = "*", + config = function() + require("blink.cmp").setup({ + completion = { + list = { + selection = { + preselect = false, + auto_insert = true, + }, + }, + documentation = { + window = { border = "rounded" }, + auto_show = true, + auto_show_delay_ms = 50, + }, + menu = { + border = "rounded", + draw = { + components = { + kind_icon = { + text = function(ctx) + local kind_icon, _, _ = require("mini.icons").get("lsp", ctx.kind) + return kind_icon + end, + highlight = function(ctx) + local _, hl, _ = require("mini.icons").get("lsp", ctx.kind) + return hl + end, + }, + kind = { + highlight = function(ctx) + local _, hl, _ = require("mini.icons").get("lsp", ctx.kind) + return hl + end, + }, + }, + }, + }, + }, + signature = { + window = { border = "rounded" }, + }, + snippets = { preset = "luasnip" }, + sources = { + default = { "lsp", "path", "snippets", "buffer" }, + providers = {}, + }, + keymap = { + preset = "none", + [""] = { "select_prev", "snippet_backward", "fallback" }, + [""] = { "select_next", "snippet_forward", "fallback" }, + [""] = { "accept", "fallback" }, + [""] = { "hide", "show" }, + [""] = { "show", "show_documentation", "hide_documentation" }, + [""] = { "scroll_documentation_up", "fallback" }, + [""] = { "scroll_documentation_down", "fallback" }, + }, + }) + end, + }, + + -- snippets + { + "L3MON4D3/LuaSnip", + version = "*", + dependencies = { "rafamadriz/friendly-snippets" }, + config = function() + local luasnip = require("luasnip") + require("luasnip.loaders.from_vscode").lazy_load() + require("luasnip.loaders.from_vscode").lazy_load({ + paths = { vim.fn.stdpath("config") .. "/snippets" }, + }) + + luasnip.filetype_extend("mdx", { "markdown" }) + end, + }, + -- auto pairs { - 'windwp/nvim-autopairs', - event = 'InsertEnter', + "windwp/nvim-autopairs", + event = "InsertEnter", config = function() - local npairs = require('nvim-autopairs') - local Rule = require('nvim-autopairs.rule') - local conds = require('nvim-autopairs.conds') + local npairs = require("nvim-autopairs") + local Rule = require("nvim-autopairs.rule") + local conds = require("nvim-autopairs.conds") npairs.setup() -- Autoclosing angle-brackets. - npairs.add_rule(Rule('<', '>', { + npairs.add_rule(Rule("<", ">", { -- Avoid conflicts with nvim-ts-autotag. - '-html', - '-javascriptreact', - '-typescriptreact', - }):with_pair(conds.before_regex('%a+:?:?$', 3)):with_move(function(opts) - return opts.char == '>' + "-html", + "-javascriptreact", + "-typescriptreact", + }):with_pair(conds.before_regex("%a+:?:?$", 3)):with_move(function(opts) + return opts.char == ">" end)) end, }, -- auto tag { - 'windwp/nvim-ts-autotag', + "windwp/nvim-ts-autotag", ft = { - 'html', - 'xml', - 'javascript', - 'typescript', - 'javascriptreact', - 'typescriptreact', - 'jsx', - 'tsx', - 'vue', - 'svelte', - 'markdown', - 'htmldjango', + "html", + "xml", + "javascript", + "typescript", + "javascriptreact", + "typescriptreact", + "jsx", + "tsx", + "vue", + "svelte", + "markdown", + "htmldjango", }, - event = 'InsertEnter', + event = "InsertEnter", lazy = true, config = function() - require('nvim-ts-autotag').setup({ + require("nvim-ts-autotag").setup({ enable_close = true, enable_rename = true, enable_close_on_slash = true, }) end, }, + + -- comment + { + "numToStr/Comment.nvim", + dependencies = { + "JoosepAlviste/nvim-ts-context-commentstring", + }, + config = function() + require("Comment").setup({ + pre_hook = require("ts_context_commentstring.integrations.comment_nvim").create_pre_hook(), + mappings = { + basic = true, + extra = true, + }, + }) + end, + keys = { + { "gcc", mode = "n", desc = "Toggle comment line" }, + { "gc", mode = { "n", "o" }, desc = "Toggle comment linewise" }, + { "gc", mode = "x", desc = "Toggle comment linewise (visual)" }, + { "gbc", mode = "n", desc = "Toggle comment block" }, + { "gb", mode = { "n", "o" }, desc = "Toggle comment blockwise" }, + { "gb", mode = "x", desc = "Toggle comment blockwise (visual)" }, + }, + }, + + -- treesitter + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + event = { "BufReadPost", "BufNewFile" }, + config = function() + require("nvim-treesitter.configs").setup({ + ensure_installed = require("config.extensions").ts_parsers, + auto_install = true, + highlight = { + enable = true, + additional_vim_regex_highlighting = true, + }, + indent = { + enable = true, + }, + }) + end, + }, } diff --git a/lua/plugins/completion.lua b/lua/plugins/completion.lua deleted file mode 100644 index 88a17a2..0000000 --- a/lua/plugins/completion.lua +++ /dev/null @@ -1,81 +0,0 @@ -return { - -- snippets - { - 'L3MON4D3/LuaSnip', - version = '*', - dependencies = { 'rafamadriz/friendly-snippets' }, - config = function() - local luasnip = require('luasnip') - require('luasnip.loaders.from_vscode').lazy_load() - require('luasnip.loaders.from_vscode').lazy_load({ - paths = { vim.fn.stdpath('config') .. '/snippets' }, - }) - - luasnip.filetype_extend('mdx', { 'markdown' }) - end, - }, - - -- completion - { - 'saghen/blink.cmp', - version = '*', - config = function() - require('blink.cmp').setup({ - completion = { - list = { - selection = { - preselect = false, - auto_insert = true, - }, - }, - documentation = { - window = { border = 'rounded' }, - auto_show = true, - auto_show_delay_ms = 50, - }, - menu = { - border = 'rounded', - draw = { - components = { - kind_icon = { - text = function(ctx) - local kind_icon, _, _ = require('mini.icons').get('lsp', ctx.kind) - return kind_icon - end, - highlight = function(ctx) - local _, hl, _ = require('mini.icons').get('lsp', ctx.kind) - return hl - end, - }, - kind = { - highlight = function(ctx) - local _, hl, _ = require('mini.icons').get('lsp', ctx.kind) - return hl - end, - }, - }, - }, - }, - }, - signature = { - window = { border = 'rounded' }, - }, - snippets = { preset = 'luasnip' }, - sources = { - default = { 'lsp', 'path', 'snippets', 'buffer' }, - providers = {}, - }, - keymap = { - preset = 'none', - [''] = { 'select_prev', 'snippet_backward', 'fallback' }, - [''] = { 'select_next', 'snippet_forward', 'fallback' }, - [''] = { 'accept', 'fallback' }, - [''] = { 'hide', 'show' }, - [''] = { 'show', 'show_documentation', 'hide_documentation' }, - [''] = { 'scroll_documentation_up', 'fallback' }, - [''] = { 'scroll_documentation_down', 'fallback' }, - }, - }) - end, - }, -} diff --git a/lua/plugins/editor.lua b/lua/plugins/editor.lua index e928182..fd0ac57 100644 --- a/lua/plugins/editor.lua +++ b/lua/plugins/editor.lua @@ -1,11 +1,75 @@ return { - + -- gitignore generator { - 'zbirenbaum/neodim', + "wintermute-cell/gitignore.nvim", + cmd = { "Gitignore" }, + opts = {}, + }, + + -- git signs + { + "lewis6991/gitsigns.nvim", + events = { "BufReadPost", "BufNewFile" }, + opts = { + signcolumn = true, + current_line_blame = true, + attach_to_untracked = false, + watch_gitdir = { + follow_files = true, + }, + signs = { + add = { text = " " }, + change = { text = "󱗜 " }, + delete = { text = "󰍵 " }, + topdelete = { text = "󱥨 " }, + changedelete = { text = "󰾟 " }, + untracked = { text = "󰰧 " }, + }, + }, + }, + + -- Todo Comments + { + "folke/todo-comments.nvim", + event = "BufRead", + opts = {}, + }, + + -- Working with file permissions + { + "lambdalisue/vim-suda", + cmd = { "SudaRead", "SudaWrite" }, + }, + + -- Undo tree + { + "mbbill/undotree", + cmd = "UndotreeToggle", + keys = { { "u", "UndotreeToggle", desc = "Undo Tree" } }, + }, + + -- visual multi + { + "mg979/vim-visual-multi", + event = "VeryLazy", + init = function() + vim.g.VM_maps = { + ["Find Under"] = "", + ["Find Subword Under"] = "", + ["Select All"] = "", + ["Add Cursor Down"] = "", + ["Add Cursor Up"] = "", + } + end, + }, + + -- dimming the highlights of unused functions, variables, parameters, and more + { + "zbirenbaum/neodim", enabled = false, - event = 'LspAttach', + event = "LspAttach", config = function() - require('neodim').setup({ + require("neodim").setup({ alpha = 0.5, blend_color = nil, hide = { @@ -14,9 +78,9 @@ return { signs = true, }, regex = { - '[uU]nused', - '[nN]ever [rR]ead', - '[nN]ot [rR]ead', + "[uU]nused", + "[nN]ever [rR]ead", + "[nN]ot [rR]ead", }, priority = 128, disable = {}, @@ -24,50 +88,110 @@ return { end, }, - -- comment + -- file operations { - 'numToStr/Comment.nvim', - dependencies = { - 'JoosepAlviste/nvim-ts-context-commentstring', + "chrisgrieser/nvim-genghis", + keys = { + { + "fn", + function() + require("genghis").createNewFile() + end, + desc = "New File", + }, + { + "fd", + function() + require("genghis").duplicateFile() + end, + desc = "Duplicate File", + }, + { + "fr", + function() + require("genghis").renameFile() + end, + desc = "Rename File", + }, + { + "fx", + function() + require("genghis").chmodx() + end, + desc = "Make Executable", + }, + }, + }, + + -- Better folding + { + "kevinhwang91/nvim-ufo", + dependencies = "kevinhwang91/promise-async", + event = "BufReadPost", + keys = { + { + "zR", + function() + require("ufo").openAllFolds() + end, + }, + { + "zM", + function() + require("ufo").closeAllFolds() + end, + }, + { + "zr", + function() + require("ufo").openFoldsExceptKinds() + end, + }, + { + "zm", + function() + require("ufo").closeFoldsWith() + end, + }, }, config = function() - require('Comment').setup({ - pre_hook = require('ts_context_commentstring.integrations.comment_nvim').create_pre_hook(), - mappings = { - basic = true, - extra = true, - }, + vim.o.foldcolumn = "1" + vim.o.foldlevel = 99 + vim.o.foldlevelstart = 99 + vim.o.foldenable = true + + require("ufo").setup({ + provider_selector = function() + return { "treesitter", "indent" } + end, }) end, + }, + + -- rendering for html and markdown + { + "OXY2DEV/markview.nvim", + lazy = false, + -- to load before treesitter + priority = 45, + opts = { + preview = { + enable = false, + }, + }, keys = { - { 'gcc', mode = 'n', desc = 'Toggle comment line' }, - { 'gc', mode = { 'n', 'o' }, desc = 'Toggle comment linewise' }, - { 'gc', mode = 'x', desc = 'Toggle comment linewise (visual)' }, - { 'gbc', mode = 'n', desc = 'Toggle comment block' }, - { 'gb', mode = { 'n', 'o' }, desc = 'Toggle comment blockwise' }, - { 'gb', mode = 'x', desc = 'Toggle comment blockwise (visual)' }, + { "cv", "Markview toggle", desc = "Toggle markdown preview", mode = "n" }, }, }, - -- Todo Comments + -- markdown preview { - 'folke/todo-comments.nvim', - event = 'BufRead', - opts = {}, - }, - - -- visual multi - { - 'mg979/vim-visual-multi', - event = 'VeryLazy', + "iamcco/markdown-preview.nvim", + build = "cd app && yarn install", init = function() - vim.g.VM_maps = { - ['Find Under'] = '', - ['Find Subword Under'] = '', - ['Select All'] = '', - ['Add Cursor Down'] = '', - ['Add Cursor Up'] = '', - } + vim.g.mkdp_filetypes = { "markdown" } end, + ft = "markdown", + cmd = { "MarkdownPreviewToggle", "MarkdownPreview" }, }, } diff --git a/lua/plugins/format.lua b/lua/plugins/format.lua deleted file mode 100644 index 8c1d11b..0000000 --- a/lua/plugins/format.lua +++ /dev/null @@ -1,72 +0,0 @@ -return { - 'stevearc/conform.nvim', - dependencies = { 'zapling/mason-conform.nvim' }, - event = 'BufWritePre', - cmd = 'ConformInfo', - keys = { 'tf' }, - config = function() - require('conform').setup({ - formatters = { - ['markdown-toc'] = { - condition = function(_, ctx) - for _, line in ipairs(vim.api.nvim_buf_get_lines(ctx.buf, 0, -1, false)) do - if line:find('') then - return true - end - end - end, - }, - ['markdownlint-cli2'] = { - condition = function(_, ctx) - local diag = vim.tbl_filter(function(d) - return d.source == 'markdownlint' - end, vim.diagnostic.get(ctx.buf)) - return #diag > 0 - end, - }, - }, - formatters_by_ft = { - ['lua'] = { 'stylua' }, - ['c'] = { 'clang_format' }, - ['cpp'] = { 'clang_format' }, - ['h'] = { 'clang_format' }, - ['python'] = { 'ruff_fix', 'ruff_format', 'ruff_organize_imports' }, - ['javascript'] = { 'biome' }, - ['typescript'] = { 'biome' }, - ['typescriptreact'] = { 'biome' }, - ['markdown'] = { 'prettier', 'markdownlint-cli2', 'markdown-toc' }, - ['markdown.mdx'] = { 'prettier', 'markdownlint-cli2', 'markdown-toc' }, - ['mdx'] = { 'prettier' }, - ['_'] = { 'trim_whitespace' }, - }, - options = { - stop_after_first = true, - }, - format_after_save = function(bufnr) - if not vim.b[bufnr].conform_disable then - return { - lsp_format = 'fallback', - } - end - end, - }) - - vim.keymap.set('n', 'tf', function() - vim.b.conform_disable = not vim.b.conform_disable - local status = vim.b.conform_disable and 'disabled' or 'enabled' - vim.notify('Autoformat ' .. status, vim.log.levels.INFO) - end, { desc = 'Toggle autoformat' }) - require('mason-conform').setup({ - ensure_installed = { - 'clang_format', - 'ruff', - 'stylua', - 'prettier', - 'markdown-toc', - 'markdownlint-cli2', - 'biome', - }, - automatic_installation = true, - }) - end, -} diff --git a/lua/plugins/formatting.lua b/lua/plugins/formatting.lua new file mode 100644 index 0000000..9716fb3 --- /dev/null +++ b/lua/plugins/formatting.lua @@ -0,0 +1,64 @@ +return { + "stevearc/conform.nvim", + dependencies = { "zapling/mason-conform.nvim" }, + event = "BufWritePre", + cmd = "ConformInfo", + keys = { "tf" }, + config = function() + require("conform").setup({ + formatters = { + ["markdown-toc"] = { + condition = function(_, ctx) + for _, line in ipairs(vim.api.nvim_buf_get_lines(ctx.buf, 0, -1, false)) do + if line:find("") then + return true + end + end + end, + }, + ["markdownlint-cli2"] = { + condition = function(_, ctx) + local diag = vim.tbl_filter(function(d) + return d.source == "markdownlint" + end, vim.diagnostic.get(ctx.buf)) + return #diag > 0 + end, + }, + }, + formatters_by_ft = { + ["lua"] = { "stylua" }, + ["c"] = { "clang_format" }, + ["cpp"] = { "clang_format" }, + ["h"] = { "clang_format" }, + ["python"] = { "ruff_fix", "ruff_format", "ruff_organize_imports" }, + ["javascript"] = { "biome" }, + ["typescript"] = { "biome" }, + ["typescriptreact"] = { "biome" }, + ["markdown"] = { "prettier", "markdownlint-cli2", "markdown-toc" }, + ["markdown.mdx"] = { "prettier", "markdownlint-cli2", "markdown-toc" }, + ["mdx"] = { "prettier" }, + ["_"] = { "trim_whitespace" }, + }, + options = { + stop_after_first = true, + }, + format_after_save = function(bufnr) + if not vim.b[bufnr].conform_disable then + return { + lsp_format = "fallback", + } + end + end, + }) + + vim.keymap.set("n", "tf", function() + vim.b.conform_disable = not vim.b.conform_disable + local status = vim.b.conform_disable and "disabled" or "enabled" + vim.notify("Autoformat " .. status, vim.log.levels.INFO) + end, { desc = "Toggle autoformat" }) + require("mason-conform").setup({ + ensure_installed = require("config.extensions").formatter, + automatic_installation = true, + }) + end, +} diff --git a/lua/plugins/git.lua b/lua/plugins/git.lua deleted file mode 100644 index 216f0fc..0000000 --- a/lua/plugins/git.lua +++ /dev/null @@ -1,102 +0,0 @@ -return { - { - 'wintermute-cell/gitignore.nvim', - opts = {}, - }, - -- FLOATING COMMIT WINDOW - { - 'lsig/messenger.nvim', - enabled = false, - opts = { - border = 'rounded', - }, - keys = { - { - 'gc', - 'MessengerShow', - desc = 'show commit in floating window', - mode = 'n', - noremap = true, - silent = true, - }, - }, - }, - -- git signs - { - 'lewis6991/gitsigns.nvim', - config = function() - require('gitsigns').setup({ - signs = { - add = { text = ' ' }, - change = { text = '󱗜 ' }, - delete = { text = '󰍵 ' }, - topdelete = { text = '󱥨 ' }, - changedelete = { text = '󰾟 ' }, - untracked = { text = '󰰧 ' }, - }, - signs_staged = { - add = { text = ' ' }, - change = { text = '󱗜 ' }, - delete = { text = '󰍵 ' }, - topdelete = { text = '󱥨 ' }, - changedelete = { text = '󰾟 ' }, - untracked = { text = '󰰧 ' }, - }, - signs_staged_enable = true, - signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` - numhl = false, -- Toggle with `:Gitsigns toggle_numhl` - linehl = false, -- Toggle with `:Gitsigns toggle_linehl` - word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` - watch_gitdir = { - follow_files = true, - }, - auto_attach = true, - attach_to_untracked = false, - current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` - current_line_blame_opts = { - virt_text = true, - virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align' - delay = 1000, - ignore_whitespace = false, - virt_text_priority = 100, - use_focus = true, - }, - current_line_blame_formatter = ', - ', - sign_priority = 6, - update_debounce = 100, - status_formatter = nil, -- Use default - max_file_length = 40000, -- Disable if file is longer than this (in lines) - preview_config = { - -- Options passed to nvim_open_win - border = 'single', - style = 'minimal', - relative = 'cursor', - row = 0, - col = 1, - }, - }) - end, - }, - - -- lazygit integration - { - 'kdheepak/lazygit.nvim', - lazy = true, - enabled = true, - cmd = { - 'LazyGit', - 'LazyGitConfig', - 'LazyGitCurrentFile', - 'LazyGitFilter', - 'LazyGitFilterCurrentFile', - }, - keys = { - { 'lg', 'LazyGit', desc = 'LazyGit' }, - }, - config = function() - vim.g.lazygit_floating_window_winblend = 0 - vim.g.lazygit_floating_window_scaling_factor = 0.9 - vim.g.lazygit_floating_window_border_chars = { '╭', '─', '╮', '│', '╯', '─', '╰', '│' } - end, - }, -} diff --git a/lua/plugins/lint.lua b/lua/plugins/lint.lua deleted file mode 100644 index 289f319..0000000 --- a/lua/plugins/lint.lua +++ /dev/null @@ -1,45 +0,0 @@ -return { - 'mfussenegger/nvim-lint', - dependencies = { 'rshkarin/mason-nvim-lint' }, - event = { 'BufReadPost', 'BufNewFile' }, - keys = { - { - 'cL', - mode = { 'n' }, - function() - require('lint').try_lint() - end, - desc = 'Trigger linting for current file', - }, - }, - config = function() - require('lint').linters_by_ft = { - ['*'] = { 'codespell' }, - ['javascript'] = { 'eslint_d', 'cspell' }, - ['typescript'] = { 'eslint_d', 'cspell' }, - ['javascriptreact'] = { 'eslint_d', 'cspell' }, - ['typescriptreact'] = { 'eslint_d', 'cspell' }, - ['dockerfile'] = { 'hadolint' }, - ['markdown'] = { 'write_good', 'markdownlint' }, - ['text'] = { 'write_good' }, - ['sh'] = { 'shellcheck' }, - ['yaml'] = { 'actionlint' }, - ['python'] = { 'ruff' }, - } - require('mason-nvim-lint').setup({ - ensure_installed = { - 'eslint_d', - 'hadolint', - 'write_good', - 'markdownlint', - 'shellcheck', - 'actionlint', - 'djlint', - 'ruff', - 'codespell', - 'cspell', - }, - automatic_installation = false, - }) - end, -} diff --git a/lua/plugins/linting.lua b/lua/plugins/linting.lua new file mode 100644 index 0000000..3836822 --- /dev/null +++ b/lua/plugins/linting.lua @@ -0,0 +1,34 @@ +return { + "mfussenegger/nvim-lint", + dependencies = { "rshkarin/mason-nvim-lint" }, + event = { "BufReadPost", "BufNewFile" }, + keys = { + { + "cL", + mode = { "n" }, + function() + require("lint").try_lint() + end, + desc = "Trigger linting for current file", + }, + }, + config = function() + require("lint").linters_by_ft = { + ["*"] = { "codespell" }, + ["javascript"] = { "eslint_d", "cspell" }, + ["typescript"] = { "eslint_d", "cspell" }, + ["javascriptreact"] = { "eslint_d", "cspell" }, + ["typescriptreact"] = { "eslint_d", "cspell" }, + ["dockerfile"] = { "hadolint" }, + ["markdown"] = { "write_good", "markdownlint" }, + ["text"] = { "write_good" }, + ["sh"] = { "shellcheck" }, + ["yaml"] = { "actionlint" }, + ["python"] = { "ruff" }, + } + require("mason-nvim-lint").setup({ + ensure_installed = require("config.extensions").linter, + automatic_installation = false, + }) + end, +} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 388c863..b41a0b3 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,67 +1,57 @@ return { -- default lsp configs { - 'neovim/nvim-lspconfig', + "neovim/nvim-lspconfig", config = function() end, }, -- lsp installer { - 'williamboman/mason.nvim', + "williamboman/mason.nvim", dependencies = { - 'williamboman/mason-lspconfig.nvim', + "williamboman/mason-lspconfig.nvim", }, - cmd = 'Mason', + cmd = "Mason", config = function() -- mason - require('mason').setup({ + require("mason").setup({ ui = { icons = { - package_installed = '✓', - package_pending = '➜', - package_uninstalled = '✗', + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗", }, - border = 'rounded', + border = "rounded", backdrop = 100, }, }) - require('mason-lspconfig').setup({ - -- list of servers for mason to install - ensure_installed = { - 'ts_ls', - 'html', - 'cssls', - 'tailwindcss', - 'lua_ls', - 'basedpyright', - 'bashls', - 'clangd', - -- "pylsp", - 'rust_analyzer', - }, + require("mason-lspconfig").setup({ + ensure_installed = require("config.extensions").lsp_server, automatic_installation = false, -- Don't auto-install or auto-configure }) end, }, + + -- improve neovim lsp experience { - 'nvimdev/lspsaga.nvim', - event = 'LspAttach', + "nvimdev/lspsaga.nvim", + event = "LspAttach", config = function() - require('lspsaga').setup({ + require("lspsaga").setup({ ui = { - theme = 'round', - border = 'rounded', + theme = "round", + border = "rounded", devicon = true, title = true, winblend = 1, - expand = ' ', - collapse = ' ', - preview = '', - code_action = '󰠠 ', - diagnostic = ' ', - incoming = ' ', - outgoing = ' ', - hover = ' ', + expand = " ", + collapse = " ", + preview = "", + code_action = "󰠠 ", + diagnostic = " ", + incoming = " ", + outgoing = " ", + hover = " ", }, }) end, @@ -69,42 +59,42 @@ return { -- inline diagnostic { - 'rachartier/tiny-inline-diagnostic.nvim', - event = 'VeryLazy', + "rachartier/tiny-inline-diagnostic.nvim", + event = "VeryLazy", priority = 1000, config = function() - require('tiny-inline-diagnostic').setup() + require("tiny-inline-diagnostic").setup() vim.diagnostic.config({ virtual_text = false }) -- Disable default virtual text end, }, -- code action { - 'rachartier/tiny-code-action.nvim', + "rachartier/tiny-code-action.nvim", dependencies = { { - 'folke/snacks.nvim', + "folke/snacks.nvim", opts = { terminal = {}, }, }, }, - event = 'LspAttach', + event = "LspAttach", config = function() - local codeaction = require('tiny-code-action') + local codeaction = require("tiny-code-action") codeaction.setup({ picker = { - 'buffer', + "buffer", opts = { auto_preview = true, hotkeys = true, - hotkeys_mode = 'sequential', + hotkeys_mode = "sequential", }, }, }) - vim.keymap.set('n', '.', codeaction.code_action) + vim.keymap.set("n", ".", codeaction.code_action) end, }, } diff --git a/lua/plugins/mini.lua b/lua/plugins/mini.lua index fb09227..20b389a 100644 --- a/lua/plugins/mini.lua +++ b/lua/plugins/mini.lua @@ -1,62 +1,80 @@ return { - 'echasnovski/mini.nvim', + "echasnovski/mini.nvim", config = function() - require('mini.ai').setup() -- Extend and create a/i textobjects - require('mini.pairs').setup() -- Autopairs - require('mini.icons').setup() -- Icons - require('mini.bracketed').setup() -- Go forward/backward with square brackets - require('mini.tabline').setup() -- Tabline - require('mini.files').setup() -- Files + require("mini.ai").setup() -- Extend and create a/i textobjects + require("mini.pairs").setup() -- Autopairs + require("mini.icons").setup() -- Icons + require("mini.bracketed").setup() -- Go forward/backward with square brackets + require("mini.tabline").setup() -- Tabline - require('mini.misc').setup({ + -- File explorer + require("mini.files").setup({ + mappings = { + close = "q", + go_in = "L", + go_in_plus = "l", + go_out = "h", + go_out_plus = "H", + mark_goto = "'", + mark_set = "m", + reset = "", + reveal_cwd = "@", + show_help = "g?", + synchronize = "", + trim_left = "<", + trim_right = ">", + }, + }) + + require("mini.misc").setup({ -- restore cursor position on file reopen - require('mini.misc').setup_restore_cursor(), + require("mini.misc").setup_restore_cursor(), -- automated change of current directory - require('mini.misc').setup_auto_root(), + require("mini.misc").setup_auto_root(), }) -- splitjoin - require('mini.splitjoin').setup({ + require("mini.splitjoin").setup({ mappings = { - toggle = 'tj', - split = '', - join = '', + toggle = "tj", + split = "", + join = "", }, }) -- surround action - require('mini.surround').setup({ + require("mini.surround").setup({ mappings = { - add = 'msa', - delete = 'msd', - find = 'msf', - find_left = 'msF', - highlight = 'msh', - replace = 'msr', - update_n_lines = 'msn', + add = "msa", + delete = "msd", + find = "msf", + find_left = "msF", + highlight = "msh", + replace = "msr", + update_n_lines = "msn", - suffix_last = 'l', - suffix_next = 'n', + suffix_last = "l", + suffix_next = "n", }, }) -- indents - require('mini.indentscope').setup({ - draw = { animation = require('mini.indentscope').gen_animation.linear({ ease = 'out', duration = 15 }) }, - options = { border = 'top', try_as_border = true, indent_at_cursor = false }, + require("mini.indentscope").setup({ + draw = { animation = require("mini.indentscope").gen_animation.linear({ ease = "out", duration = 15 }) }, + options = { border = "top", try_as_border = true, indent_at_cursor = false }, }) - vim.api.nvim_create_autocmd('BufEnter', { - pattern = '*', + vim.api.nvim_create_autocmd("BufEnter", { + pattern = "*", callback = function(args) - if vim.bo[args.buf].buftype ~= '' then + if vim.bo[args.buf].buftype ~= "" then vim.b[args.buf].miniindentscope_disable = true end end, }) -- statusline - require('mini.statusline').setup({ + require("mini.statusline").setup({ use_icons = true, content = { active = function() @@ -70,51 +88,51 @@ return { local function section_filetype(args) if MiniStatusline.is_truncated(args.trunc_width) - or vim.bo.filetype == '' - or vim.bo.buftype ~= '' + or vim.bo.filetype == "" + or vim.bo.buftype ~= "" then - return '' + return "" end - local ok, icons = pcall(require, 'mini.icons') - local icon = ok and select(1, icons.get('filetype', vim.bo.filetype)) or '' - return string.format('%s %s│', icon, vim.bo.filetype) + local ok, icons = pcall(require, "mini.icons") + local icon = ok and select(1, icons.get("filetype", vim.bo.filetype)) or "" + return string.format("%s %s│", icon, vim.bo.filetype) end local function section_lsp_clients(args) if MiniStatusline.is_truncated(args.trunc_width) then - return '' + return "" end local clients = vim.lsp.get_clients({ bufnr = 0 }) if not clients or #clients == 0 then - return '' + return "" end local names = vim.tbl_map(function(c) return c.name end, clients) - return string.format(' %s', table.concat(names, ', ')) + return string.format(" %s", table.concat(names, ", ")) end local function section_searchcount(args) if vim.v.hlsearch == 0 then - return '' + return "" end local ok, s = pcall(vim.fn.searchcount, { recompute = true }) if not ok or s.current == nil or s.total == 0 then - return '' + return "" end - local icon = MiniStatusline.is_truncated(args.trunc_width) and '' or ' ' + local icon = MiniStatusline.is_truncated(args.trunc_width) and "" or " " if s.incomplete == 1 then - return icon .. '?/?│' + return icon .. "?/?│" end - local fmt = '>%d' + local fmt = ">%d" local cur = s.current > s.maxcount and fmt:format(s.maxcount) or s.current local tot = s.total > s.maxcount and fmt:format(s.maxcount) or s.total - return ('%s%s/%s│'):format(icon, cur, tot) + return ("%s%s/%s│"):format(icon, cur, tot) end local function section_location(args) - return MiniStatusline.is_truncated(args.trunc_width) and '%-2l│%-2v' - or '󰉸 %-2l│󱥖 %-2v' + return MiniStatusline.is_truncated(args.trunc_width) and "%-2l│%-2v" + or "󰉸 %-2l│󱥖 %-2v" end local filetype = section_filetype({ trunc_width = 70 }) @@ -124,18 +142,18 @@ return { return MiniStatusline.combine_groups({ { hl = mode_hl, strings = { mode:upper() } }, - { hl = 'MiniStatuslineDevinfo', strings = { git, diff, diagnostics, lsp } }, - '%<', - { hl = 'MiniStatuslineFilename', strings = { filename } }, - '%=', - { hl = 'MiniStatuslineDevinfo', strings = { lsp_clients } }, + { hl = "MiniStatuslineDevinfo", strings = { git, diff, diagnostics, lsp } }, + "%<", + { hl = "MiniStatuslineFilename", strings = { filename } }, + "%=", + { hl = "MiniStatuslineDevinfo", strings = { lsp_clients } }, { hl = mode_hl, strings = { filetype, searchcount, loc } }, }) end, inactive = function() return MiniStatusline.combine_groups({ - { hl = 'MiniStatuslineInactive', strings = { vim.fn.expand('%:t') } }, + { hl = "MiniStatuslineInactive", strings = { vim.fn.expand("%:t") } }, }) end, }, diff --git a/lua/plugins/picker.lua b/lua/plugins/picker.lua deleted file mode 100644 index 9141b2d..0000000 --- a/lua/plugins/picker.lua +++ /dev/null @@ -1,362 +0,0 @@ -return { - 'folke/snacks.nvim', - priority = 1000, - lazy = false, - -- opts = { - -- bigfile = { enabled = true }, - -- dashboard = { enabled = true }, - -- explorer = { enabled = true }, - -- indent = { enabled = true }, - -- input = { enabled = true }, - -- notifier = { - -- enabled = true, - -- timeout = 3000, - -- }, - -- picker = { enabled = true }, - -- quickfile = { enabled = true }, - -- scope = { enabled = true }, - -- scroll = { enabled = true }, - -- statuscolumn = { enabled = true }, - -- words = { enabled = true }, - -- styles = { - -- notification = { - -- -- wo = { wrap = true } -- Wrap notifications - -- }, - -- }, - -- }, - config = function() - local function files_layout(preview_width, height, width) - preview_width = preview_width or 0.6 - height = height or 0.8 - width = width or 0.9 - return { - layout = { - box = 'horizontal', - width = width, - min_width = 120, - height = height, - { - box = 'vertical', - border = 'rounded', - title = '{title} {live} {flags}', - { win = 'input', height = 1, border = 'bottom' }, - { win = 'list', border = 'none' }, - }, - { win = 'preview', title = '{preview}', border = 'rounded', width = preview_width }, - }, - } - end - - local function palette_layout(height, width) - height = height or 0.4 - width = width or 0.6 - return { - preview = false, - layout = { - backdrop = false, - row = 1, - width = width, - min_width = 80, - height = height, - border = 'rounded', - box = 'vertical', - { - win = 'input', - height = 1, - border = 'rounded', - title = '{title} {live} {flags}', - title_pos = 'center', - }, - { win = 'list', border = 'hpad' }, - { win = 'preview', title = '{preview}', border = 'rounded' }, - }, - } - end - - local Snacks = require('snacks') - Snacks.setup({ - animate = { - enabled = true, - duration = 20, -- ms per step - easing = 'linear', - fps = 60, - }, - bigfile = { - enabled = true, - notify = true, - size = 1000 * 1024, -- 1 MB instead of 100 KB - }, - bufdelete = { enabled = true }, - dashboard = { - enabled = true, - sections = { - { section = 'header' }, - { - icon = ' ', - title = 'Keymaps', - section = 'keys', - indent = 2, - padding = 1, - }, - { - icon = ' ', - title = 'Recent Files', - section = 'recent_files', - indent = 2, - padding = 1, - }, - { - icon = ' ', - title = 'Projects', - section = 'projects', - indent = 2, - padding = 1, - }, - { section = 'startup' }, - }, - }, - debug = { enabled = true }, - dim = { - enabled = true, - scope = { - min_size = 5, - max_size = 20, - siblings = true, - }, - }, - explorer = { enabled = false }, - git = { enabled = true }, - gitbrowse = { enabled = true }, - image = { enabled = true }, - indent = { - enabled = true, - priority = 1, - char = '▍', - only_scope = false, - only_current = false, - hl = { - 'SnacksIndent1', - 'SnacksIndent2', - 'SnacksIndent3', - 'SnacksIndent4', - 'SnacksIndent5', - 'SnacksIndent6', - 'SnacksIndent7', - 'SnacksIndent8', - }, - }, - input = { - enabled = true, - icon = ' ', - icon_hl = 'SnacksInputIcon', - icon_pos = 'left', - prompt_pos = 'title', - win = { style = 'input' }, - expand = true, - }, - layout = { enabled = true }, - lazygit = { enabled = true }, - notifier = { - enabled = true, - timeout = 2000, - width = { min = 40, max = 0.4 }, - height = { min = 1, max = 0.6 }, - margin = { top = 0, right = 1, bottom = 0 }, - padding = true, - sort = { 'level', 'added' }, - level = vim.log.levels.TRACE, - icons = { - debug = ' ', - error = ' ', - info = ' ', - trace = ' ', - warn = ' ', - }, - style = 'compact', - top_down = true, - date_format = '%R', - more_format = ' ↓ %d lines ', - refresh = 50, - }, - notify = { enabled = true }, - picker = { - enabled = true, - icon = ' ', - icon_hl = 'SnacksPickerIcon', - icon_pos = 'left', - prompt_pos = 'title', - win = { style = 'picker' }, - expand = true, - matchers = { - frecency = true, - cwd_bonus = false, - }, - sources = { - -- layout options: dropdown, horizontal, vertical, vscode, ivy, ivy_split, telescope, top, left, right, bottom, sidebar - buffers = { layout = files_layout() }, - commands = { layout = palette_layout() }, - command_history = { layout = palette_layout() }, - files = { - hidden = true, - layout = files_layout(), - }, - icons = { - icon_sources = { 'nerd_fonts', 'emoji' }, - layout = palette_layout(), - }, - git_files = { layout = files_layout() }, - git_branches = { layout = { preset = 'vertical' } }, - git_status = { layout = files_layout() }, - help = { layout = { preset = 'ivy_split' } }, - man = { layout = { preset = 'ivy_split' } }, - notifications = { layout = palette_layout() }, - projects = { layout = files_layout(0.8) }, - recent = { layout = files_layout() }, - search_history = { layout = palette_layout() }, - smart = { layout = files_layout() }, - undo = { layout = { preset = 'ivy' } }, - zoxide = { layout = files_layout(0.7) }, - }, - }, - profiler = { enabled = true }, - quickfile = { enabled = true }, - rename = { enabled = true }, - scope = { - enabled = true, - keys = { - textobject = { - ii = { - min_size = 2, -- minimum size of the scope - edge = false, -- inner scope - cursor = false, - treesitter = { blocks = { enabled = false } }, - desc = 'inner scope', - }, - ai = { - cursor = false, - min_size = 2, -- minimum size of the scope - treesitter = { blocks = { enabled = false } }, - desc = 'full scope', - }, - }, - jump = { - ['[a'] = { - min_size = 1, -- allow single line scopes - bottom = false, - cursor = false, - edge = true, - treesitter = { blocks = { enabled = false } }, - desc = 'jump to top edge of scope', - }, - [']a'] = { - min_size = 1, -- allow single line scopes - bottom = true, - cursor = false, - edge = true, - treesitter = { blocks = { enabled = false } }, - desc = 'jump to bottom edge of scope', - }, - }, - }, - }, - scratch = { - enabled = true, - name = 'SCRATCH', - ft = function() - if vim.bo.buftype == '' and vim.bo.filetype ~= '' then - return vim.bo.filetype - end - return 'markdown' - end, - icon = nil, - root = vim.fn.stdpath('data') .. '/scratch', - autowrite = true, - filekey = { - cwd = true, - branch = true, - count = true, - }, - win = { - width = 120, - height = 40, - bo = { buftype = '', buflisted = false, bufhidden = 'hide', swapfile = false }, - minimal = false, - noautocmd = false, - zindex = 20, - wo = { winhighlight = 'NormalFloat:Normal' }, - border = 'rounded', - title_pos = 'center', - footer_pos = 'center', - - keys = { - ['execute'] = { - '', - function(_) - vim.cmd('%SnipRun') - end, - desc = 'Execute buffer', - mode = { 'n', 'x' }, - }, - }, - }, - win_by_ft = { - lua = { - keys = { - ['source'] = { - 'cr', - function(self) - local name = 'scratch.' - .. vim.fn.fnamemodify(vim.api.nvim_buf_get_name(self.buf), ':e') - Snacks.debug.run({ buf = self.buf, name = name }) - end, - desc = 'Source buffer', - mode = { 'n', 'x' }, - }, - }, - }, - }, - }, - scroll = { enabled = false }, - statuscolumn = { - enabled = false, -- Change this to false - left = { 'mark', 'sign' }, - right = { 'fold', 'git' }, - folds = { - open = false, - git_hl = false, - }, - git = { - patterns = { 'GitSign', 'MiniDiffSign' }, - }, - refresh = 50, - }, - terminal = { enabled = false }, - toggle = { enabled = false }, - win = { enabled = true }, - words = { enabled = false }, - zen = { - enabled = true, - toggles = { - dim = true, - git_signs = false, - mini_diff_signs = false, - -- diagnostics = false, - -- inlay_hints = false, - }, - show = { - statusline = false, - tabline = false, - }, - win = { style = 'zen' }, - zoom = { - toggles = {}, - show = { statusline = true, tabline = true }, - win = { - backdrop = false, - width = 0, - }, - }, - }, - }) - end, -} diff --git a/lua/plugins/snacks.lua b/lua/plugins/snacks.lua new file mode 100644 index 0000000..5a6d76c --- /dev/null +++ b/lua/plugins/snacks.lua @@ -0,0 +1,340 @@ +return { + "folke/snacks.nvim", + priority = 1000, + lazy = false, + config = function() + local function files_layout(preview_width, height, width) + preview_width = preview_width or 0.6 + height = height or 0.8 + width = width or 0.9 + return { + layout = { + box = "horizontal", + width = width, + min_width = 120, + height = height, + { + box = "vertical", + border = "rounded", + title = "{title} {live} {flags}", + { win = "input", height = 1, border = "bottom" }, + { win = "list", border = "none" }, + }, + { win = "preview", title = "{preview}", border = "rounded", width = preview_width }, + }, + } + end + + local function palette_layout(height, width) + height = height or 0.4 + width = width or 0.6 + return { + preview = false, + layout = { + backdrop = false, + row = 1, + width = width, + min_width = 80, + height = height, + border = "rounded", + box = "vertical", + { + win = "input", + height = 1, + border = "rounded", + title = "{title} {live} {flags}", + title_pos = "center", + }, + { win = "list", border = "hpad" }, + { win = "preview", title = "{preview}", border = "rounded" }, + }, + } + end + + local Snacks = require("snacks") + Snacks.setup({ + animate = { + enabled = true, + duration = 20, -- ms per step + easing = "linear", + fps = 60, + }, + bigfile = { + enabled = true, + notify = true, + size = 1000 * 1024, -- 1 MB instead of 100 KB + }, + bufdelete = { enabled = true }, + dashboard = { + enabled = true, + sections = { + { section = "header" }, + { + icon = " ", + title = "Keymaps", + section = "keys", + indent = 2, + padding = 1, + }, + { + icon = " ", + title = "Recent Files", + section = "recent_files", + indent = 2, + padding = 1, + }, + { + icon = " ", + title = "Projects", + section = "projects", + indent = 2, + padding = 1, + }, + { section = "startup" }, + }, + }, + debug = { enabled = true }, + dim = { + enabled = true, + scope = { + min_size = 5, + max_size = 20, + siblings = true, + }, + }, + explorer = { enabled = false }, + git = { enabled = true }, + gitbrowse = { enabled = true }, + image = { enabled = true }, + indent = { + enabled = true, + priority = 1, + char = "▍", + only_scope = false, + only_current = false, + hl = { + "SnacksIndent1", + "SnacksIndent2", + "SnacksIndent3", + "SnacksIndent4", + "SnacksIndent5", + "SnacksIndent6", + "SnacksIndent7", + "SnacksIndent8", + }, + }, + input = { + enabled = true, + icon = " ", + icon_hl = "SnacksInputIcon", + icon_pos = "left", + prompt_pos = "title", + win = { style = "input" }, + expand = true, + }, + layout = { enabled = true }, + lazygit = { enabled = true }, + notifier = { + enabled = true, + timeout = 2000, + width = { min = 40, max = 0.4 }, + height = { min = 1, max = 0.6 }, + margin = { top = 0, right = 1, bottom = 0 }, + padding = true, + sort = { "level", "added" }, + level = vim.log.levels.TRACE, + icons = { + debug = " ", + error = " ", + info = " ", + trace = " ", + warn = " ", + }, + style = "compact", + top_down = true, + date_format = "%R", + more_format = " ↓ %d lines ", + refresh = 50, + }, + notify = { enabled = true }, + picker = { + enabled = true, + icon = " ", + icon_hl = "SnacksPickerIcon", + icon_pos = "left", + prompt_pos = "title", + win = { style = "picker" }, + expand = true, + matchers = { + frecency = true, + cwd_bonus = false, + }, + sources = { + -- layout options: dropdown, horizontal, vertical, vscode, ivy, ivy_split, telescope, top, left, right, bottom, sidebar + buffers = { layout = files_layout() }, + commands = { layout = palette_layout() }, + command_history = { layout = palette_layout() }, + files = { + hidden = true, + layout = files_layout(), + }, + icons = { + icon_sources = { "nerd_fonts", "emoji" }, + layout = palette_layout(), + }, + git_files = { layout = files_layout() }, + git_branches = { layout = { preset = "vertical" } }, + git_status = { layout = files_layout() }, + help = { layout = { preset = "ivy_split" } }, + man = { layout = { preset = "ivy_split" } }, + notifications = { layout = palette_layout() }, + projects = { layout = files_layout(0.8) }, + recent = { layout = files_layout() }, + search_history = { layout = palette_layout() }, + smart = { layout = files_layout() }, + undo = { layout = { preset = "ivy" } }, + zoxide = { layout = files_layout(0.7) }, + }, + }, + profiler = { enabled = true }, + quickfile = { enabled = true }, + rename = { enabled = true }, + scope = { + enabled = true, + keys = { + textobject = { + ii = { + min_size = 2, -- minimum size of the scope + edge = false, -- inner scope + cursor = false, + treesitter = { blocks = { enabled = false } }, + desc = "inner scope", + }, + ai = { + cursor = false, + min_size = 2, -- minimum size of the scope + treesitter = { blocks = { enabled = false } }, + desc = "full scope", + }, + }, + jump = { + ["[a"] = { + min_size = 1, -- allow single line scopes + bottom = false, + cursor = false, + edge = true, + treesitter = { blocks = { enabled = false } }, + desc = "jump to top edge of scope", + }, + ["]a"] = { + min_size = 1, -- allow single line scopes + bottom = true, + cursor = false, + edge = true, + treesitter = { blocks = { enabled = false } }, + desc = "jump to bottom edge of scope", + }, + }, + }, + }, + scratch = { + enabled = true, + name = "SCRATCH", + ft = function() + if vim.bo.buftype == "" and vim.bo.filetype ~= "" then + return vim.bo.filetype + end + return "markdown" + end, + icon = nil, + root = vim.fn.stdpath("data") .. "/scratch", + autowrite = true, + filekey = { + cwd = true, + branch = true, + count = true, + }, + win = { + width = 120, + height = 40, + bo = { buftype = "", buflisted = false, bufhidden = "hide", swapfile = false }, + minimal = false, + noautocmd = false, + zindex = 20, + wo = { winhighlight = "NormalFloat:Normal" }, + border = "rounded", + title_pos = "center", + footer_pos = "center", + + keys = { + ["execute"] = { + "", + function(_) + vim.cmd("%SnipRun") + end, + desc = "Execute buffer", + mode = { "n", "x" }, + }, + }, + }, + win_by_ft = { + lua = { + keys = { + ["source"] = { + "cr", + function(self) + local name = "scratch." + .. vim.fn.fnamemodify(vim.api.nvim_buf_get_name(self.buf), ":e") + Snacks.debug.run({ buf = self.buf, name = name }) + end, + desc = "Source buffer", + mode = { "n", "x" }, + }, + }, + }, + }, + }, + scroll = { enabled = false }, + statuscolumn = { + enabled = false, -- Change this to false + left = { "mark", "sign" }, + right = { "fold", "git" }, + folds = { + open = false, + git_hl = false, + }, + git = { + patterns = { "GitSign", "MiniDiffSign" }, + }, + refresh = 50, + }, + terminal = { enabled = false }, + toggle = { enabled = false }, + win = { enabled = true }, + words = { enabled = false }, + zen = { + enabled = true, + toggles = { + dim = true, + git_signs = false, + mini_diff_signs = false, + -- diagnostics = false, + -- inlay_hints = false, + }, + show = { + statusline = false, + tabline = false, + }, + win = { style = "zen" }, + zoom = { + toggles = {}, + show = { statusline = true, tabline = true }, + win = { + backdrop = false, + width = 0, + }, + }, + }, + }) + end, +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua deleted file mode 100644 index 8152a1b..0000000 --- a/lua/plugins/treesitter.lua +++ /dev/null @@ -1,45 +0,0 @@ -return { - -- treesitter - { - 'nvim-treesitter/nvim-treesitter', - build = ':TSUpdate', - event = { 'BufReadPost', 'BufNewFile' }, - config = function() - require('nvim-treesitter').setup({ - ensure_installed = { - 'c', - 'markdown', - 'python', - 'java', - 'cpp', - 'bash', - 'lua', - 'make', - 'latex', - 'json', - 'jsonc', - 'sql', - 'yaml', - 'toml', - 'javascript', - 'typescript', - 'gitignore', - 'go', - 'rust', - 'html', - 'css', - 'scss', - 'markdown_inline', - }, - auto_install = true, - highlight = { - enable = true, - additional_vim_regex_highlighting = true, - }, - indent = { - enable = true, - }, - }) - end, - }, -} diff --git a/lua/plugins/ui.lua b/lua/plugins/ui.lua deleted file mode 100644 index 7e5e2bc..0000000 --- a/lua/plugins/ui.lua +++ /dev/null @@ -1,81 +0,0 @@ -return { - - -- rendering for html, latex, md - { - 'OXY2DEV/markview.nvim', - lazy = false, - -- to load before treesitter - priority = 45, - opts = { - preview = { - enable = false, - }, - }, - keys = { - { 'cv', 'Markview toggle', desc = 'Toggle markdown preview', mode = 'n' }, - }, - }, - - -- markdown preview - { - 'iamcco/markdown-preview.nvim', - build = 'cd app && yarn install', - init = function() - vim.g.mkdp_filetypes = { 'markdown' } - end, - ft = 'markdown', - cmd = { 'MarkdownPreviewToggle', 'MarkdownPreview' }, - }, - - -- Better folding - { - 'kevinhwang91/nvim-ufo', - dependencies = 'kevinhwang91/promise-async', - event = 'BufReadPost', - keys = { - { - 'zR', - function() - require('ufo').openAllFolds() - end, - }, - { - 'zM', - function() - require('ufo').closeAllFolds() - end, - }, - { - 'zr', - function() - require('ufo').openFoldsExceptKinds() - end, - }, - { - 'zm', - function() - require('ufo').closeFoldsWith() - end, - }, - }, - config = function() - vim.o.foldcolumn = '1' - vim.o.foldlevel = 99 - vim.o.foldlevelstart = 99 - vim.o.foldenable = true - - require('ufo').setup({ - provider_selector = function() - return { 'treesitter', 'indent' } - end, - }) - end, - }, - - -- Undo tree - { - 'mbbill/undotree', - cmd = 'UndotreeToggle', - keys = { { 'u', 'UndotreeToggle', desc = 'Undo Tree' } }, - }, -} diff --git a/lua/plugins/util.lua b/lua/plugins/util.lua old mode 100755 new mode 100644 index 0f9e012..4112941 --- a/lua/plugins/util.lua +++ b/lua/plugins/util.lua @@ -1,14 +1,14 @@ return { { - 'danymat/neogen', - dependencies = { 'nvim-treesitter/nvim-treesitter' }, + "danymat/neogen", + dependencies = { "nvim-treesitter/nvim-treesitter" }, opts = { - snippet_engine = 'luasnip', + snippet_engine = "luasnip", languages = { python = { template = { - annotation_convention = 'google_docstrings', + annotation_convention = "google_docstrings", }, }, }, @@ -16,27 +16,27 @@ return { }, { - 'davidmh/mdx.nvim', + "davidmh/mdx.nvim", config = true, - dependencies = { 'nvim-treesitter/nvim-treesitter' }, + dependencies = { "nvim-treesitter/nvim-treesitter" }, }, -- better escape { - 'max397574/better-escape.nvim', + "max397574/better-escape.nvim", config = function() - require('better_escape').setup({ + require("better_escape").setup({ mappings = { -- i for insert, other modes are the first letter too i = { -- map kj to exit insert mode k = { - j = '', + j = "", }, -- map jk and jj to exit insert mode j = { - k = '', - j = '', + k = "", + j = "", }, -- disable jj j = { @@ -50,43 +50,43 @@ return { -- Navigator { - 'numToStr/Navigator.nvim', - event = 'VeryLazy', + "numToStr/Navigator.nvim", + event = "VeryLazy", config = function() - require('Navigator').setup({ - auto_save = 'current', + require("Navigator").setup({ + auto_save = "current", disable_on_zoom = false, - mux = 'auto', + mux = "auto", }) end, }, -- float terminal { - 'akinsho/toggleterm.nvim', - cmd = { 'ToggleTerm' }, - version = '*', + "akinsho/toggleterm.nvim", + cmd = { "ToggleTerm" }, + version = "*", config = function() - require('toggleterm').setup({ + require("toggleterm").setup({ size = 10, open_mapping = [[]], hide_numbers = true, shade_filetypes = {}, shade_terminals = true, - shading_factor = '2', + shading_factor = "2", start_in_insert = true, insert_mappings = true, terminal_mappings = true, persist_size = true, - direction = 'float', -- 'vertical' | 'horizontal' | 'tab' | 'float' + direction = "float", -- 'vertical' | 'horizontal' | 'tab' | 'float' close_on_exit = true, shell = vim.o.shell, float_opts = { - border = 'curved', -- 'single', 'double', 'shadow', etc. - winblend = 0, -- Set to 0 for full transparency + border = "curved", -- 'single', 'double', 'shadow', etc. + winblend = 0, -- Set to 0 for full transparency highlights = { - border = 'Normal', - background = 'Normal', + border = "Normal", + background = "Normal", }, }, }) @@ -95,7 +95,7 @@ return { -- smooth scrolling { - 'karb94/neoscroll.nvim', + "karb94/neoscroll.nvim", opts = {}, }, @@ -107,75 +107,34 @@ return { -- uv { - 'benomahony/uv.nvim', - ft = 'python', - event = 'BufReadPre', + "benomahony/uv.nvim", + ft = "python", + event = "BufReadPre", opts = { picker_integration = true, keymaps = { - prefix = 'u', -- Main prefix for uv commands - commands = true, -- Show uv commands menu (x) - run_file = true, -- Run current file (xr) + prefix = "u", -- Main prefix for uv commands + commands = true, -- Show uv commands menu (x) + run_file = true, -- Run current file (xr) run_selection = true, -- Run selected code (xs) - run_function = true, -- Run function (xf) - venv = true, -- Environment management (xe) - init = true, -- Initialize uv project (xi) - add = true, -- Add a package (xa) - remove = true, -- Remove a package (xd) - sync = true, -- Sync packages (xc) - sync_all = true, -- Sync all packages, extras and groups (xC) + run_function = true, -- Run function (xf) + venv = true, -- Environment management (xe) + init = true, -- Initialize uv project (xi) + add = true, -- Add a package (xa) + remove = true, -- Remove a package (xd) + sync = true, -- Sync packages (xc) + sync_all = true, -- Sync all packages, extras and groups (xC) }, }, }, -- wakatime - { 'wakatime/vim-wakatime', event = 'VimEnter', lazy = false }, + { "wakatime/vim-wakatime", event = "VimEnter", lazy = false }, -- workflow { - 'm4xshen/hardtime.nvim', + "m4xshen/hardtime.nvim", lazy = false, opts = {}, }, - - -- file operations - { - 'chrisgrieser/nvim-genghis', - keys = { - { - 'fn', - function() - require('genghis').createNewFile() - end, - desc = 'New File', - }, - { - 'fd', - function() - require('genghis').duplicateFile() - end, - desc = 'Duplicate File', - }, - { - 'fr', - function() - require('genghis').renameFile() - end, - desc = 'Rename File', - }, - { - 'fx', - function() - require('genghis').chmodx() - end, - desc = 'Make Executable', - }, - }, - }, - - -- Working with file permissions - { - 'lambdalisue/vim-suda', - cmd = { 'SudaRead', 'SudaWrite' }, - }, } diff --git a/lua/plugins/whichkey.lua b/lua/plugins/whichkey.lua index 092c457..b6d89ba 100644 --- a/lua/plugins/whichkey.lua +++ b/lua/plugins/whichkey.lua @@ -1,305 +1,305 @@ return { - 'folke/which-key.nvim', - event = 'VeryLazy', - config = function() - local wk = require('which-key') - wk.setup({ - preset = 'helix', - plugins = { - marks = true, - registers = true, - spelling = { - enabled = true, - suggestions = 30, - }, - }, - presets = { - operators = true, - motions = true, - text_objects = true, - windows = true, - nav = true, - z = true, - g = true, - }, - icons = { - breadcrumb = ' ', - separator = ' ', - group = '', - keys = { - Space = ' ', - }, - rules = false, -- enable auto icon rules - }, - show_help = false, - show_keys = true, - triggers = { - { '', mode = 'nvisoct' }, - { '', mode = { 'n', 'v' } }, - }, - }) + "folke/which-key.nvim", + event = "VeryLazy", + config = function() + local wk = require("which-key") + wk.setup({ + preset = "helix", + plugins = { + marks = true, + registers = true, + spelling = { + enabled = true, + suggestions = 30, + }, + }, + presets = { + operators = true, + motions = true, + text_objects = true, + windows = true, + nav = true, + z = true, + g = true, + }, + icons = { + breadcrumb = " ", + separator = " ", + group = "", + keys = { + Space = " ", + }, + rules = false, -- enable auto icon rules + }, + show_help = false, + show_keys = true, + triggers = { + { "", mode = "nvisoct" }, + { "", mode = { "n", "v" } }, + }, + }) - local normal_mappings = { - mode = 'n', - { 'x', ':x', desc = ' Save and Quit' }, + local normal_mappings = { + mode = "n", + { "x", ":x", desc = " Save and Quit" }, - -- { "a", group = " AI" }, + -- { "a", group = " AI" }, - { 'b', group = ' Buffer' }, + { "b", group = " Buffer" }, - { 'c', group = ' Code' }, - { 'cF', ':retab', desc = 'Fix Tabs' }, - { 'cd', ':RootDir', desc = 'Root Directory' }, - { 'cf', ':lua vim.lsp.buf.format({async = true})', desc = 'Format File' }, - { 'cg', ':Neogen', desc = 'Generate Docstring' }, - { 'cl', '::g/^\\s*$/d', desc = 'Clean Empty Lines' }, - { 'cm', ':MarkdownPreviewToggle', desc = 'Markdown Preview' }, - { 'cq', ':lua Snacks.picker.qflist()', desc = 'Quickfix List' }, + { "c", group = " Code" }, + { "cF", ":retab", desc = "Fix Tabs" }, + { "cd", ":RootDir", desc = "Root Directory" }, + { "cf", ":lua vim.lsp.buf.format({async = true})", desc = "Format File" }, + { "cg", ":Neogen", desc = "Generate Docstring" }, + { "cl", "::g/^\\s*$/d", desc = "Clean Empty Lines" }, + { "cm", ":MarkdownPreviewToggle", desc = "Markdown Preview" }, + { "cq", ":lua Snacks.picker.qflist()", desc = "Quickfix List" }, - { 'e', group = ' Edit' }, - { 'ea', ':b#', desc = 'Alternate File' }, - { 'eC', group = 'Edit Configs' }, - { - 'ee', - function() - local minifiles = require('mini.files') - minifiles.open(vim.api.nvim_buf_get_name(0), true) - minifiles.reveal_cwd() - end, - desc = 'Explore Tree', - }, - { 'eE', ':lua Snacks.explorer()', desc = 'File Explorer' }, - { 'ef', 'gf', desc = 'File Under Cursor' }, - { 'em', ':e README.md', desc = 'Readme' }, - { 'en', ':enew', desc = 'New File' }, - { 'er', ":lua require('snacks').rename.rename_file()", desc = 'Rename Current File' }, + { "e", group = " Edit" }, + { "ea", ":b#", desc = "Alternate File" }, + { "eC", group = "Edit Configs" }, + { + "ee", + function() + local minifiles = require("mini.files") + minifiles.open(vim.api.nvim_buf_get_name(0), true) + minifiles.reveal_cwd() + end, + desc = "Explore Tree", + }, + { "eE", ":lua Snacks.explorer()", desc = "File Explorer" }, + { "ef", "gf", desc = "File Under Cursor" }, + { "em", ":e README.md", desc = "Readme" }, + { "en", ":enew", desc = "New File" }, + { "er", ":lua require('snacks').rename.rename_file()", desc = "Rename Current File" }, - { 'f', group = ' Find' }, - { 'fx', ':%bd|e#|bd#', desc = 'Close except current' }, - { 'ff', ':lua Snacks.picker.files()', desc = 'Find Files' }, - { 'fg', ':lua Snacks.picker.grep()', desc = 'Live Grep' }, - { 'fp', ':lua Snacks.picker.projects()', desc = 'Projects' }, - { - 'ct', - function() - local curr_path = vim.fn.expand('%:p') - Snacks.picker.todo_comments({ - transform = function(item) - local item_path = vim.fn.fnamemodify(item.cwd .. '/' .. item.file, ':p') - return item_path == curr_path - end, - }) - end, - desc = 'Search Todos in Current File', - }, - { 'fT', ':lua Snacks.picker.todo_comments()', desc = 'Search Todos' }, - { 'fu', ':lua Snacks.picker.undo()', desc = 'Undotree' }, + { "f", group = " Find" }, + { "fx", ":%bd|e#|bd#", desc = "Close except current" }, + { "ff", ":lua Snacks.picker.files()", desc = "Find Files" }, + { "fg", ":lua Snacks.picker.grep()", desc = "Live Grep" }, + { "fp", ":lua Snacks.picker.projects()", desc = "Projects" }, + { + "ct", + function() + local curr_path = vim.fn.expand("%:p") + Snacks.picker.todo_comments({ + transform = function(item) + local item_path = vim.fn.fnamemodify(item.cwd .. "/" .. item.file, ":p") + return item_path == curr_path + end, + }) + end, + desc = "Search Todos in Current File", + }, + { "fT", ":lua Snacks.picker.todo_comments()", desc = "Search Todos" }, + { "fu", ":lua Snacks.picker.undo()", desc = "Undotree" }, - { 'g', group = ' Git' }, - { 'gA', ':Gitsigns stage_buffer', desc = 'Stage Buffer' }, - { 'gR', ':Gitsigns reset_buffer', desc = 'Reset Buffer' }, - { 'ga', ':Gitsigns stage_hunk', desc = 'Stage Hunk' }, - { 'gb', ":lua require('gitsigns').blame_line({full = true})", desc = 'Blame' }, - { 'gB', ":lua require('snacks').git.blame_line()", desc = 'Detailed Blame' }, - { 'gc', ':Gitignore', desc = 'Generate .gitignore' }, - { 'gd', ':Gitsigns diffthis HEAD', desc = 'Git Diff' }, - { 'gF', ':Git', desc = 'Fugitive Panel' }, - { 'gi', ':Gitsigns preview_hunk', desc = 'Hunk Info' }, - { 'gj', ':Gitsigns next_hunk', desc = 'Next Hunk' }, - { 'gk', ':Gitsigns prev_hunk', desc = 'Prev Hunk' }, - { 'gl', ':lua Snacks.picker.git_log()', desc = 'Checkout commit' }, - { 'gr', ':Gitsigns reset_hunk', desc = 'Reset Hunk' }, - { 'gs', ':lua Snacks.picker.git_status()', desc = 'Open changed file' }, - { 'gu', ':Gitsigns undo_stage_hunk', desc = 'Undo Stage Hunk' }, - { 'gv', ':Gitsigns select_hunk', desc = 'Select Hunk' }, - { 'gw', ':lua require("snacks").gitbrowse()', desc = 'Git Browse' }, - { 'gp', ':lua Snacks.picker.git_branches()', desc = 'Pick and Switch Git Branches' }, + { "g", group = " Git" }, + { "gA", ":Gitsigns stage_buffer", desc = "Stage Buffer" }, + { "gR", ":Gitsigns reset_buffer", desc = "Reset Buffer" }, + { "ga", ":Gitsigns stage_hunk", desc = "Stage Hunk" }, + { "gb", ":lua require('gitsigns').blame_line({full = true})", desc = "Blame" }, + { "gB", ":lua require('snacks').git.blame_line()", desc = "Detailed Blame" }, + { "gc", ":Gitignore", desc = "Generate .gitignore" }, + { "gd", ":Gitsigns diffthis HEAD", desc = "Git Diff" }, + { "gF", ":Git", desc = "Fugitive Panel" }, + { "gi", ":Gitsigns preview_hunk", desc = "Hunk Info" }, + { "gj", ":Gitsigns next_hunk", desc = "Next Hunk" }, + { "gk", ":Gitsigns prev_hunk", desc = "Prev Hunk" }, + { "gl", ":lua Snacks.picker.git_log()", desc = "Checkout commit" }, + { "gr", ":Gitsigns reset_hunk", desc = "Reset Hunk" }, + { "gs", ":lua Snacks.picker.git_status()", desc = "Open changed file" }, + { "gu", ":Gitsigns undo_stage_hunk", desc = "Undo Stage Hunk" }, + { "gv", ":Gitsigns select_hunk", desc = "Select Hunk" }, + { "gw", ':lua require("snacks").gitbrowse()', desc = "Git Browse" }, + { "gp", ":lua Snacks.picker.git_branches()", desc = "Pick and Switch Git Branches" }, - { 'gt', group = 'Toggle' }, - { 'gtb', ':Gitsigns toggle_current_line_blame', desc = 'Blame' }, - { 'gtd', ':Gitsigns toggle_deleted', desc = 'Deleted' }, - { 'gtl', ':Gitsigns toggle_linehl', desc = 'Line HL' }, - { 'gtn', ':Gitsigns toggle_numhl', desc = 'Number HL' }, - { 'gts', ':Gitsigns toggle_signs', desc = 'Signs' }, - { 'gtw', ':Gitsigns toggle_word_diff', desc = 'Word Diff' }, + { "gt", group = "Toggle" }, + { "gtb", ":Gitsigns toggle_current_line_blame", desc = "Blame" }, + { "gtd", ":Gitsigns toggle_deleted", desc = "Deleted" }, + { "gtl", ":Gitsigns toggle_linehl", desc = "Line HL" }, + { "gtn", ":Gitsigns toggle_numhl", desc = "Number HL" }, + { "gts", ":Gitsigns toggle_signs", desc = "Signs" }, + { "gtw", ":Gitsigns toggle_word_diff", desc = "Word Diff" }, - { 'i', group = ' Insert' }, - { 'id', ":put =strftime('## %a, %d %b, %Y, %r')", desc = 'Date' }, - { 'if', ":put =expand('%:t')", desc = 'File Name' }, - { 'ip', ':put %', desc = 'Relative Path' }, - { 'iP', ':put %:p', desc = 'Absolute Path' }, - { 'it', ":put =strftime('## %r')", desc = 'Time' }, + { "i", group = " Insert" }, + { "id", ":put =strftime('## %a, %d %b, %Y, %r')", desc = "Date" }, + { "if", ":put =expand('%:t')", desc = "File Name" }, + { "ip", ":put %", desc = "Relative Path" }, + { "iP", ":put %:p", desc = "Absolute Path" }, + { "it", ":put =strftime('## %r')", desc = "Time" }, - { 'l', group = ' LSP' }, - { 'la', ':Lspsaga code_action', desc = 'Code Action' }, - { 'ld', ':Lspsaga goto_definition', desc = 'Goto Definition' }, - { 'lf', ':Lspsaga finder', desc = 'Finder' }, - { 'lh', ':Lspsaga hover_doc', desc = 'Hover' }, - { 'lI', ':LspInfo', desc = 'LSP Info' }, - { 'lj', ':Lspsaga diagnostic_jump_next', desc = 'Next Diagnostic' }, - { 'lk', ':Lspsaga diagnostic_jump_prev', desc = 'Prev Diagnostic' }, - { 'lo', ':Lspsaga outline', desc = 'Outline' }, - { 'lp', ':Lspsaga peek_definition', desc = 'Peek Definition' }, - { 'lq', ':LspStop', desc = 'Stop LSP' }, - { 'lQ', ':LspRestart', desc = 'Restart LSP' }, - { 'lr', ':Lspsaga rename', desc = 'Rename' }, - { 'lR', ':Lspsaga project_replace', desc = 'Replace' }, - { 'lt', ':Lspsaga goto_type_definition', desc = 'Goto Type Definition' }, - { 'lT', ':Lspsaga peek_type_definition', desc = 'Peek Type Definition' }, + { "l", group = " LSP" }, + { "la", ":Lspsaga code_action", desc = "Code Action" }, + { "ld", ":Lspsaga goto_definition", desc = "Goto Definition" }, + { "lf", ":Lspsaga finder", desc = "Finder" }, + { "lh", ":Lspsaga hover_doc", desc = "Hover" }, + { "lI", ":LspInfo", desc = "LSP Info" }, + { "lj", ":Lspsaga diagnostic_jump_next", desc = "Next Diagnostic" }, + { "lk", ":Lspsaga diagnostic_jump_prev", desc = "Prev Diagnostic" }, + { "lo", ":Lspsaga outline", desc = "Outline" }, + { "lp", ":Lspsaga peek_definition", desc = "Peek Definition" }, + { "lq", ":LspStop", desc = "Stop LSP" }, + { "lQ", ":LspRestart", desc = "Restart LSP" }, + { "lr", ":Lspsaga rename", desc = "Rename" }, + { "lR", ":Lspsaga project_replace", desc = "Replace" }, + { "lt", ":Lspsaga goto_type_definition", desc = "Goto Type Definition" }, + { "lT", ":Lspsaga peek_type_definition", desc = "Peek Type Definition" }, - { 'o', group = ' Options' }, - { 'oi', 'vim.show_pos', desc = 'Inspect Position' }, - { 'oN', ':lua Snacks.notifier.show_history()', desc = 'Notification History' }, - { 'or', ':set relativenumber!', desc = 'Relative Numbers' }, + { "o", group = " Options" }, + { "oi", "vim.show_pos", desc = "Inspect Position" }, + { "oN", ":lua Snacks.notifier.show_history()", desc = "Notification History" }, + { "or", ":set relativenumber!", desc = "Relative Numbers" }, - { 'p', group = ' Packages' }, - { 'pc', ':Lazy check', desc = 'Check' }, - { 'pd', ':Lazy debug', desc = 'Debug' }, - { 'pe', ':lua require("snacks").profiler.scratch()', desc = 'Profiler Scratch' }, - { 'pf', ':lua require("snacks").profiler.pick()', desc = 'Profiler Pick' }, - { 'pi', ':Lazy install', desc = 'Install' }, - { 'pl', ':Lazy log', desc = 'Log' }, - { 'pm', ':Mason', desc = 'Mason' }, - { 'pp', ':Lazy', desc = 'Plugins' }, - { 'pP', ':Lazy profile', desc = 'Profile' }, - { 'pr', ':Lazy restore', desc = 'Restore' }, - { 'ps', ':Lazy sync', desc = 'Sync' }, - { 'pt', ':lua require("snacks").profiler.toggle()', desc = 'Profiler Toggle' }, - { 'pu', ':Lazy update', desc = 'Update' }, - { 'px', ':Lazy clean', desc = 'Clean' }, + { "p", group = " Packages" }, + { "pc", ":Lazy check", desc = "Check" }, + { "pd", ":Lazy debug", desc = "Debug" }, + { "pe", ':lua require("snacks").profiler.scratch()', desc = "Profiler Scratch" }, + { "pf", ':lua require("snacks").profiler.pick()', desc = "Profiler Pick" }, + { "pi", ":Lazy install", desc = "Install" }, + { "pl", ":Lazy log", desc = "Log" }, + { "pm", ":Mason", desc = "Mason" }, + { "pp", ":Lazy", desc = "Plugins" }, + { "pP", ":Lazy profile", desc = "Profile" }, + { "pr", ":Lazy restore", desc = "Restore" }, + { "ps", ":Lazy sync", desc = "Sync" }, + { "pt", ':lua require("snacks").profiler.toggle()', desc = "Profiler Toggle" }, + { "pu", ":Lazy update", desc = "Update" }, + { "px", ":Lazy clean", desc = "Clean" }, - { 'q', group = ' Quit' }, - { 'qa', ':qall', desc = 'Quit All' }, - { 'qb', ':bw', desc = 'Close Buffer' }, - { 'qd', ':lua require("snacks").bufdelete()', desc = 'Delete Buffer' }, - { 'qf', ':qall!', desc = 'Force Quit' }, - { 'qo', ':%bdelete|b#|bdelete#', desc = 'Close Others' }, - { 'qq', ':q', desc = 'Quit' }, - { 'qs', 'c', desc = 'Close Split' }, - { 'qw', ':wq', desc = 'Write and Quit' }, + { "q", group = " Quit" }, + { "qa", ":qall", desc = "Quit All" }, + { "qb", ":bw", desc = "Close Buffer" }, + { "qd", ':lua require("snacks").bufdelete()', desc = "Delete Buffer" }, + { "qf", ":qall!", desc = "Force Quit" }, + { "qo", ":%bdelete|b#|bdelete#", desc = "Close Others" }, + { "qq", ":q", desc = "Quit" }, + { "qs", "c", desc = "Close Split" }, + { "qw", ":wq", desc = "Write and Quit" }, - { 'r', group = ' Refactor' }, - { 'rd', '', desc = 'Go To Definition' }, -- treesitter navigation - { 'rD', '', desc = 'List Definition' }, - { 'rh', '', desc = 'List Definition Head' }, - { 'rj', '', desc = 'Next Usage' }, - { 'rk', '', desc = 'Previous Usage' }, - { 'rn', '', desc = 'Swap Next' }, - { 'rp', '', desc = 'Swap Previous' }, - { 'rr', '', desc = 'Smart Rename' }, - { 'rs', ':%s/\\<\\>//gI', desc = 'Replace Word Buffer' }, + { "r", group = " Refactor" }, + { "rd", "", desc = "Go To Definition" }, -- treesitter navigation + { "rD", "", desc = "List Definition" }, + { "rh", "", desc = "List Definition Head" }, + { "rj", "", desc = "Next Usage" }, + { "rk", "", desc = "Previous Usage" }, + { "rn", "", desc = "Swap Next" }, + { "rp", "", desc = "Swap Previous" }, + { "rr", "", desc = "Smart Rename" }, + { "rs", ":%s/\\<\\>//gI", desc = "Replace Word Buffer" }, - { 's', group = ' Split' }, - { 's+', ':resize +10', desc = 'Increase window height' }, - { 's-', ':vertical resize -20', desc = 'Decrease window width' }, - { 's/', 's', desc = 'Split Below' }, - { 's=', ':vertical resize +20', desc = 'Increase window width' }, - { 'sH', ':vertical resize -10', desc = 'Decrease window width' }, - { 'sJ', ':resize -5', desc = 'Decrease window height' }, - { 'sK', ':resize +5', desc = 'Increase window height' }, - { 'sL', ':vertical resize +10', desc = 'Increase window width' }, - { 's\\', 'v', desc = 'Split Right' }, - { 's_', ':resize -10', desc = 'Decrease window height' }, - { 's`', 'p', desc = 'Previous Window' }, - { 'sa', ':split', desc = 'Horizontal Split' }, - { 'sc', ':tabclose', desc = 'Close Tab' }, - { 'sf', ':tabfirst', desc = 'First Tab' }, - { 'sh', 'h', desc = 'Move Left' }, - { 'sj', 'j', desc = 'Move Down' }, - { 'sk', 'k', desc = 'Move Up' }, - { 'sl', 'l', desc = 'Move Right' }, - { 'sp', ':NavigatorPrevious', desc = 'Previous Pane' }, - { 'sq', 'c', desc = 'Close Split' }, - { 'ss', ':vsplit', desc = 'Vertical Split' }, + { "s", group = " Split" }, + { "s+", ":resize +10", desc = "Increase window height" }, + { "s-", ":vertical resize -20", desc = "Decrease window width" }, + { "s/", "s", desc = "Split Below" }, + { "s=", ":vertical resize +20", desc = "Increase window width" }, + { "sH", ":vertical resize -10", desc = "Decrease window width" }, + { "sJ", ":resize -5", desc = "Decrease window height" }, + { "sK", ":resize +5", desc = "Increase window height" }, + { "sL", ":vertical resize +10", desc = "Increase window width" }, + { "s\\", "v", desc = "Split Right" }, + { "s_", ":resize -10", desc = "Decrease window height" }, + { "s`", "p", desc = "Previous Window" }, + { "sa", ":split", desc = "Horizontal Split" }, + { "sc", ":tabclose", desc = "Close Tab" }, + { "sf", ":tabfirst", desc = "First Tab" }, + { "sh", "h", desc = "Move Left" }, + { "sj", "j", desc = "Move Down" }, + { "sk", "k", desc = "Move Up" }, + { "sl", "l", desc = "Move Right" }, + { "sp", ":NavigatorPrevious", desc = "Previous Pane" }, + { "sq", "c", desc = "Close Split" }, + { "ss", ":vsplit", desc = "Vertical Split" }, - { 't', group = ' Terminal' }, - { 't1', '1ToggleTerm', desc = 'Toggle Terminal' }, - { 't2', '2ToggleTerm', desc = 'Toggle Terminal' }, - { 'tc', 'close', desc = 'Hide Terminal' }, + { "t", group = " Terminal" }, + { "t1", "1ToggleTerm", desc = "Toggle Terminal" }, + { "t2", "2ToggleTerm", desc = "Toggle Terminal" }, + { "tc", "close", desc = "Hide Terminal" }, - { 'th', group = 'Inlay Hints' }, + { "th", group = "Inlay Hints" }, - { 'w', group = ' Writing' }, - { 'wc', ':set spell!', desc = 'Spellcheck' }, - { 'wd', ':lua require("snacks").dim.enable()', desc = 'Dim On' }, - { 'wD', ':lua require("snacks").dim.disable()', desc = 'Dim Off' }, - { 'wf', ":lua require'utils'.sudo_write()", desc = 'Force Write' }, - { 'wj', ']s', desc = 'Next Misspell' }, - { 'wk', '[s', desc = 'Prev Misspell' }, - { 'wn', ':WriteNoFormat', desc = 'Write Without Formatting' }, - { 'wq', ':wq', desc = 'Write and Quit' }, - { 'ww', ':w', desc = 'Write' }, - { 'wz', ':lua require("snacks").zen.zen()', desc = 'Zen' }, - { 'wZ', ':lua require("snacks").zen.zoom()', desc = 'Zoom' }, + { "w", group = " Writing" }, + { "wc", ":set spell!", desc = "Spellcheck" }, + { "wd", ':lua require("snacks").dim.enable()', desc = "Dim On" }, + { "wD", ':lua require("snacks").dim.disable()', desc = "Dim Off" }, + { "wf", ":lua require'utils'.sudo_write()", desc = "Force Write" }, + { "wj", "]s", desc = "Next Misspell" }, + { "wk", "[s", desc = "Prev Misspell" }, + { "wn", ":WriteNoFormat", desc = "Write Without Formatting" }, + { "wq", ":wq", desc = "Write and Quit" }, + { "ww", ":w", desc = "Write" }, + { "wz", ':lua require("snacks").zen.zen()', desc = "Zen" }, + { "wZ", ':lua require("snacks").zen.zoom()', desc = "Zoom" }, - { 'y', group = ' Yank' }, - { 'yL', ':CopyAbsolutePathWithLine', desc = 'Absolute Path with Line' }, - { 'yP', ':CopyAbsolutePath', desc = 'Absolute Path' }, - { 'ya', ':%y+', desc = 'Copy Whole File' }, - { 'yf', ':CopyFileName', desc = 'File Name' }, - { 'yg', ':lua require"gitlinker".get_buf_range_url()', desc = 'Copy Git URL' }, - { 'yl', ':CopyRelativePathWithLine', desc = 'Relative Path with Line' }, - { 'yp', ':CopyRelativePath', desc = 'Relative Path' }, - } + { "y", group = " Yank" }, + { "yL", ":CopyAbsolutePathWithLine", desc = "Absolute Path with Line" }, + { "yP", ":CopyAbsolutePath", desc = "Absolute Path" }, + { "ya", ":%y+", desc = "Copy Whole File" }, + { "yf", ":CopyFileName", desc = "File Name" }, + { "yg", ':lua require"gitlinker".get_buf_range_url()', desc = "Copy Git URL" }, + { "yl", ":CopyRelativePathWithLine", desc = "Relative Path with Line" }, + { "yp", ":CopyRelativePath", desc = "Relative Path" }, + } - local visual_mappings = { - mode = 'v', - -- { "a", group = " AI" }, + local visual_mappings = { + mode = "v", + -- { "a", group = " AI" }, - { 'c', group = ' Code' }, - { 'cS', ':sort!', desc = 'Sort Desc' }, - { 'ci', ':sort i', desc = 'Sort Case Insensitive' }, - { 'cs', ':sort', desc = 'Sort Asc' }, - { 'cu', ':!uniq', desc = 'Unique' }, - { 'cx', ':lua', desc = 'Execute Lua' }, + { "c", group = " Code" }, + { "cS", ":sort!", desc = "Sort Desc" }, + { "ci", ":sort i", desc = "Sort Case Insensitive" }, + { "cs", ":sort", desc = "Sort Asc" }, + { "cu", ":!uniq", desc = "Unique" }, + { "cx", ":lua", desc = "Execute Lua" }, - { 'g', group = ' Git' }, - { 'ga', ":'<,'>Gitsigns stage_hunk", desc = 'Stage Hunk' }, - { 'gr', ":'<,'>Gitsigns reset_hunk", desc = 'Reset Hunk' }, - { 'gu', ":'<,'>Gitsigns undo_stage_hunk", desc = 'Undo Stage Hunk' }, + { "g", group = " Git" }, + { "ga", ":'<,'>Gitsigns stage_hunk", desc = "Stage Hunk" }, + { "gr", ":'<,'>Gitsigns reset_hunk", desc = "Reset Hunk" }, + { "gu", ":'<,'>Gitsigns undo_stage_hunk", desc = "Undo Stage Hunk" }, - { 'l', group = ' LSP' }, - { 'la', ':Lspsaga range_code_action', desc = 'Code Action' }, + { "l", group = " LSP" }, + { "la", ":Lspsaga range_code_action", desc = "Code Action" }, - { 'y', group = ' Yank' }, - { 'yg', ':lua require"gitlinker".get_buf_range_url("v")', desc = 'Copy Git URL' }, - } + { "y", group = " Yank" }, + { "yg", ':lua require"gitlinker".get_buf_range_url("v")', desc = "Copy Git URL" }, + } - local no_leader_mappings = { - mode = 'n', - { '', ':resize -10', desc = 'Decrease window height' }, - { '', ':vertical resize -10', desc = 'Decrease window width' }, - { '', ':vertical resize +10', desc = 'Increase window width' }, - { '', ':resize +10', desc = 'Increase window height' }, + local no_leader_mappings = { + mode = "n", + { "", ":resize -10", desc = "Decrease window height" }, + { "", ":vertical resize -10", desc = "Decrease window width" }, + { "", ":vertical resize +10", desc = "Increase window width" }, + { "", ":resize +10", desc = "Increase window height" }, - { '', ':NavigatorLeft', desc = 'Move Left' }, - { '', ':NavigatorDown', desc = 'Move Down' }, - { '', ':NavigatorUp', desc = 'Move Up' }, - { '', ':NavigatorRight', desc = 'Move Right' }, - { '', ':NavigatorPrevious', desc = 'Previous Pane' }, + { "", ":NavigatorLeft", desc = "Move Left" }, + { "", ":NavigatorDown", desc = "Move Down" }, + { "", ":NavigatorUp", desc = "Move Up" }, + { "", ":NavigatorRight", desc = "Move Right" }, + { "", ":NavigatorPrevious", desc = "Previous Pane" }, - -- { '', ':bprevious', desc = 'Previous Buffer' }, - -- { '', ':bnext', desc = 'Next Buffer' }, - { '', ':bnext', desc = 'Next Buffer' }, - { '', ':bprevious', desc = 'Previous Buffer' }, + -- { '', ':bprevious', desc = 'Previous Buffer' }, + -- { '', ':bnext', desc = 'Next Buffer' }, + { "", ":bnext", desc = "Next Buffer" }, + { "", ":bprevious", desc = "Previous Buffer" }, - { 'K', ':Lspsaga hover_doc', desc = 'LSP Hover' }, - { 'Q', ':qall!', desc = 'Force Quit!' }, - { 'U', ':redo', desc = 'Redo' }, + { "K", ":Lspsaga hover_doc", desc = "LSP Hover" }, + { "Q", ":qall!", desc = "Force Quit!" }, + { "U", ":redo", desc = "Redo" }, - { '[', group = ' Previous' }, - { '[g', ':Gitsigns prev_hunk', desc = 'Git Hunk' }, - { '[o', group = 'Textobjects' }, + { "[", group = " Previous" }, + { "[g", ":Gitsigns prev_hunk", desc = "Git Hunk" }, + { "[o", group = "Textobjects" }, - { ']', group = ' Next' }, - { ']g', ':Gitsigns next_hunk', desc = 'Git Hunk' }, - { ']o', group = 'Textobjects' }, + { "]", group = " Next" }, + { "]g", ":Gitsigns next_hunk", desc = "Git Hunk" }, + { "]o", group = "Textobjects" }, - { 'gd', ':Lspsaga goto_definition', desc = 'Goto Definition' }, - } + { "gd", ":Lspsaga goto_definition", desc = "Goto Definition" }, + } - wk.add(normal_mappings) - wk.add(visual_mappings) - wk.add(no_leader_mappings) - end, + wk.add(normal_mappings) + wk.add(visual_mappings) + wk.add(no_leader_mappings) + end, }