From 6d3a60c8ddd800803c33636a629af2426e53b0ed Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Fri, 12 Sep 2025 18:26:44 +0545 Subject: [PATCH] feat: enhance editor and language support with new plugins and configurations --- lazy-lock.json | 5 + lua/plugins/editor.lua | 55 +++++++-- lua/plugins/format.lua | 35 +++++- lua/plugins/languages.lua | 229 ++++++++++++++++++++------------------ lua/plugins/lint.lua | 34 ++++-- lua/plugins/utility.lua | 80 ++++++++++--- lua/plugins/whichkey.lua | 28 +++++ 7 files changed, 315 insertions(+), 151 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index b6a97d4..d93e523 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -5,6 +5,7 @@ "better-escape.nvim": { "branch": "master", "commit": "19a38aab94961016430905ebec30d272a01e9742" }, "blink.cmp": { "branch": "main", "commit": "bae4bae0eedd1fa55f34b685862e94a222d5c6f8" }, "conform.nvim": { "branch": "master", "commit": "b4aab989db276993ea5dcb78872be494ce546521" }, + "floaterm": { "branch": "main", "commit": "ae3de018d20dccd9372bbff7137e8a6d6030f69e" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, "gitsigns.nvim": { "branch": "main", "commit": "6e3c66548035e50db7bd8e360a29aec6620c3641" }, "gruvbox.nvim": { "branch": "main", "commit": "5e0a460d8e0f7f669c158dedd5f9ae2bcac31437" }, @@ -27,11 +28,13 @@ "neoscroll.nvim": { "branch": "master", "commit": "f957373912e88579e26fdaea4735450ff2ef5c9c" }, "netrw.nvim": { "branch": "master", "commit": "90501c62b9b816ed3ed1e912ae9db9af5671a1b2" }, "nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" }, + "nvim-genghis": { "branch": "main", "commit": "cdf584d05ffc9d5c1f247079991552249e4f7487" }, "nvim-lint": { "branch": "master", "commit": "f126af5345c7472e9a0cdbe1d1a29209be72c4c4" }, "nvim-lspconfig": { "branch": "master", "commit": "c8b90ae5cbe21d547b342b05c9266dcb8ca0de8f" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, "nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" }, + "project.nvim": { "branch": "main", "commit": "8c6bad7d22eef1b71144b401c9f74ed01526a4fb" }, "smartcolumn.nvim": { "branch": "main", "commit": "b9cdbdf42f7ac5a659204cd5926017c7ff724a19" }, "snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" }, "tiny-code-action.nvim": { "branch": "main", "commit": "2b3fa2fbd25496259eaf50987097982f8ad08d1b" }, @@ -39,7 +42,9 @@ "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, "toggleterm.nvim": { "branch": "main", "commit": "50ea089fc548917cc3cc16b46a8211833b9e3c7c" }, "uv.nvim": { "branch": "main", "commit": "be4a7d47a976249282bb2f71fc773ac2f5325973" }, + "vim-visual-multi": { "branch": "master", "commit": "a6975e7c1ee157615bbc80fc25e4392f71c344d4" }, "vim-wakatime": { "branch": "master", "commit": "d7973b157a632d1edeff01818f18d67e584eeaff" }, + "volt": { "branch": "main", "commit": "7b8c5e790120d9f08c8487dcb80692db6d2087a1" }, "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" }, "windsurf.vim": { "branch": "main", "commit": "a8d47ec54fe82df920b2545559f767003e8a7f8d" } } diff --git a/lua/plugins/editor.lua b/lua/plugins/editor.lua index 3e7edeb..3081ef3 100644 --- a/lua/plugins/editor.lua +++ b/lua/plugins/editor.lua @@ -156,15 +156,48 @@ return { end, }, - -- multiple cursor - -- { - -- "terryma/vim-multiple-cursors", - -- config = function() - -- vim.g.multi_cursor_use_default_mapping = 0 - -- vim.g.multi_cursor_next_key = "" - -- vim.g.multi_cursor_prev_key = "" - -- vim.g.multi_cursor_skip_key = "" - -- vim.g.multi_cursor_quit_key = "mc" - -- end, - -- }, + -- code action + { + "rachartier/tiny-code-action.nvim", + dependencies = { + { + "folke/snacks.nvim", + opts = { + terminal = {}, + }, + }, + }, + event = "LspAttach", + config = function() + local codeaction = require("tiny-code-action") + + codeaction.setup({ + picker = { + "buffer", + opts = { + auto_preview = true, + hotkeys = true, + hotkeys_mode = "sequential", + }, + }, + }) + + vim.keymap.set("n", ".", codeaction.code_action) + end, + }, + + -- 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, + }, } diff --git a/lua/plugins/format.lua b/lua/plugins/format.lua index 506c3bb..40ec981 100644 --- a/lua/plugins/format.lua +++ b/lua/plugins/format.lua @@ -6,11 +6,38 @@ return { 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" }, - python = { "black" }, + ["lua"] = { "stylua" }, + ["python"] = { "ruff_fix", "ruff_format", "ruff_organize_imports" }, + ["javascript"] = { "prettier" }, + ["typescript"] = { "prettier" }, + ["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 { @@ -27,9 +54,11 @@ return { end) require("mason-conform").setup({ ensure_installed = { - "black", + "ruff", "stylua", "prettier", + "markdown-toc", + "markdownlint-cli2", }, automatic_installation = true, }) diff --git a/lua/plugins/languages.lua b/lua/plugins/languages.lua index 41c4a50..e03ddce 100644 --- a/lua/plugins/languages.lua +++ b/lua/plugins/languages.lua @@ -1,116 +1,129 @@ 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", - "ts_ls", - "gitignore", - "go", - "rust", - "html", - "css", - "scss", - "markdown_inline", - }, - auto_install = true, - highlight = { - enable = true, - additional_vim_regex_highlighting = true, - }, - indent = { - enable = true, - }, - }) - end, - }, + -- 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", + "ts_ls", + "gitignore", + "go", + "rust", + "html", + "css", + "scss", + "markdown_inline", + }, + auto_install = true, + highlight = { + enable = true, + additional_vim_regex_highlighting = true, + }, + indent = { + enable = true, + }, + }) + end, + }, - -- rendering for html, latex, md - { - "OXY2DEV/markview.nvim", - lazy = false, - -- to load before treesitter - priority = 45, - config = function() - require("markview").setup({ - markdown = { - code_blocks = { sign = false }, - }, - }) - end, - }, + -- rendering for html, latex, md + { + "OXY2DEV/markview.nvim", + lazy = false, + -- to load before treesitter + priority = 45, + config = function() + require("markview").setup({ + markdown = { + code_blocks = { sign = false }, + }, + }) + end, + }, - -- markdown preview - { - "iamcco/markdown-preview.nvim", - build = "cd app && yarn install", - init = function() - vim.g.mkdp_filetypes = { "markdown" } - end, - ft = "markdown", - cmd = { "MarkdownPreviewToggle", "MarkdownPreview" }, - }, + -- markdown preview + { + "iamcco/markdown-preview.nvim", + build = "cd app && yarn install", + init = function() + vim.g.mkdp_filetypes = { "markdown" } + end, + ft = "markdown", + cmd = { "MarkdownPreviewToggle", "MarkdownPreview" }, + }, - { - "danymat/neogen", - dependencies = { "nvim-treesitter/nvim-treesitter" }, - opts = { - snippet_engine = "luasnip", - languages = { - python = { - template = { - annotation_convention = "google_docstrings", - }, - }, - }, - }, - }, + { + "danymat/neogen", + dependencies = { "nvim-treesitter/nvim-treesitter" }, + opts = { + snippet_engine = "luasnip", + languages = { + python = { + template = { + annotation_convention = "google_docstrings", + }, + }, + }, + }, + }, - -- auto pairs - { - "windwp/nvim-autopairs", - event = "InsertEnter", - config = function() - require("nvim-autopairs").setup() + -- auto pairs + { + "windwp/nvim-autopairs", + event = "InsertEnter", + config = function() + require("nvim-autopairs").setup() - -- add new rules - local pairs = require("nvim-autopairs") - local rule = require("nvim-autopairs.rule") - local cond = require("nvim-autopairs.conds") - pairs.add_rules({ - rule("$", "$", { "tex", "latex", "plaintex" }) - -- do not move right when repeat character - :with_move(cond.none()), - }) - end, - }, + -- add new rules + local pairs = require("nvim-autopairs") + local rule = require("nvim-autopairs.rule") + local cond = require("nvim-autopairs.conds") + pairs.add_rules({ + rule("$", "$", { "tex", "latex", "plaintex" }) + -- do not move right when repeat character + :with_move(cond.none()), + }) + end, + }, - { - "windwp/nvim-ts-autotag", - event = "InsertEnter", - lazy = true, - opts = { - enable_close = true, - enable_rename = true, - enable_close_on_slash = true, - }, - }, + { + "windwp/nvim-ts-autotag", + ft = { + "html", + "xml", + "javascript", + "typescript", + "javascriptreact", + "typescriptreact", + "jsx", + "tsx", + "vue", + "svelte", + "markdown", + }, + event = "InsertEnter", + lazy = true, + opts = { + enable_close = true, + enable_rename = true, + enable_close_on_slash = true, + }, + }, } diff --git a/lua/plugins/lint.lua b/lua/plugins/lint.lua index 692e169..8af7bd0 100644 --- a/lua/plugins/lint.lua +++ b/lua/plugins/lint.lua @@ -2,18 +2,29 @@ return { "mfussenegger/nvim-lint", dependencies = { "rshkarin/mason-nvim-lint" }, event = { "BufReadPost", "BufNewFile" }, + keys = { + { + "L", + mode = { "n" }, + function() + require("lint").try_lint() + end, + desc = "Trigger linting for current file", + }, + }, config = function() require("lint").linters_by_ft = { - javascript = { "eslint_d" }, - typescript = { "eslint_d" }, - javascriptreact = { "eslint_d" }, - typescriptreact = { "eslint_d" }, - dockerfile = { "hadolint" }, - markdown = { "write_good", "markdownlint" }, - text = { "write_good" }, - sh = { "shellcheck" }, - yaml = { "actionlint" }, - python = { "ruff" }, + ["*"] = { "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 = { @@ -25,7 +36,8 @@ return { "actionlint", "djlint", "ruff", - "pylint", + "codespell", + "cspell", }, automatic_installation = true, }) diff --git a/lua/plugins/utility.lua b/lua/plugins/utility.lua index 92ebacb..7eb5bc8 100644 --- a/lua/plugins/utility.lua +++ b/lua/plugins/utility.lua @@ -80,7 +80,7 @@ return { { "akinsho/toggleterm.nvim", cmd = { "ToggleTerm" }, - version = "v2.*", + version = "*", config = function() require("toggleterm").setup({ size = 10, @@ -107,6 +107,20 @@ return { }) end, }, + { + "nvzone/floaterm", + dependencies = "nvzone/volt", + opts = { + mappings = { + term = function(buf) + vim.keymap.set({ "n", "t" }, "", function() + require("floaterm.api").cycle_term_bufs("prev") + end, { buffer = buf }) + end, + }, + }, + cmd = "FloatermToggle", + }, -- smooth scrolling { @@ -120,23 +134,6 @@ return { -- event = "VeryLazy", -- }, - { - "rachartier/tiny-code-action.nvim", - dependencies = { - { - "folke/snacks.nvim", - opts = { - terminal = {}, - }, - }, - }, - event = "LspAttach", - opts = {}, - vim.keymap.set({ "n", "x" }, "ca", function() - require("tiny-code-action").code_action() - end, { noremap = true, silent = true }), - }, - -- uv { "benomahony/uv.nvim", @@ -160,10 +157,57 @@ return { }, }, + -- Project management + { + "ahmedkhalf/project.nvim", + config = function() + require("project_nvim").setup({ + detection_methods = { "lsp", "pattern" }, + patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json" }, + }) + end, + }, + { "wakatime/vim-wakatime", event = "VimEnter", lazy = false }, + -- { -- "m4xshen/hardtime.nvim", -- lazy = false, -- opts = {}, -- }, + + -- file operations + { + "chrisgrieser/nvim-genghis", + keys = { + { + "fp", + 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", + }, + }, + }, } diff --git a/lua/plugins/whichkey.lua b/lua/plugins/whichkey.lua index 5ec4cde..5bacc94 100644 --- a/lua/plugins/whichkey.lua +++ b/lua/plugins/whichkey.lua @@ -79,6 +79,20 @@ return { { "fx", ":%bd|e#|bd#", desc = "Close except current" }, { "ff", ":lua require('snacks').picker.files()", desc = "Find Files" }, { "fg", ":lua require('snacks').picker.live_grep()", desc = "Live Grep" }, + { + "fp", + function() + Snacks.picker.projects() + end, + desc = "Projects", + }, + { + "ft", + function() + Snacks.picker.todo_comments() + end, + desc = "Search Todos", + }, { "g", group = " Git" }, { "gA", ":Gitsigns stage_buffer", desc = "Stage Buffer" }, @@ -91,7 +105,21 @@ return { { "gi", ":Gitsigns preview_hunk", desc = "Hunk Info" }, { "gj", ":Gitsigns next_hunk", desc = "Next Hunk" }, { "gk", ":Gitsigns prev_hunk", desc = "Prev Hunk" }, + { + "gl", + function() + Snacks.picker.git_log() + end, + desc = "Checkout commit", + }, { "gr", ":Gitsigns reset_hunk", desc = "Reset Hunk" }, + { + "gs", + function() + Snacks.picker.git_status() + end, + 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" },