diff --git a/home/base/desktop/neovim/README.md b/home/base/desktop/neovim/README.md index a1639ad0..e6975361 100644 --- a/home/base/desktop/neovim/README.md +++ b/home/base/desktop/neovim/README.md @@ -57,11 +57,11 @@ Provided by [flash.nvim](https://github.com/folke/flash.nvim), it's a intelligen 1. It enhaces the default search and jump behavior of neovim.(search with prefix `/`) -| Action | Shortcut | -| ----------------- | -------------------------------------------------------------------------------------- | -| Search | `/`(normal search), `s`(disable all code highlight, only highlight matches) | -| Treesitter Search | `yR`,`dR`, `cR`, `vR`, `ctrl+v+R`(arround your matches, all the surrounding Treesitter nodes will be labeled) | -| Remote Flash | `yr`, `dr`, `cr`, (arround your matches, all the surrounding Treesitter nodes will be labeled) | +| Action | Shortcut | +| ----------------- | ------------------------------------------------------------------------------------------------------------- | +| Search | `/`(normal search), `s`(disable all code highlight, only highlight matches) | +| Treesitter Search | `yR`,`dR`, `cR`, `vR`, `ctrl+v+R`(arround your matches, all the surrounding Treesitter nodes will be labeled) | +| Remote Flash | `yr`, `dr`, `cr`, (arround your matches, all the surrounding Treesitter nodes will be labeled) | ## Text Manipulation @@ -183,11 +183,16 @@ The postfix(flags) in the above commands: ## Surrounding Characters -| Action | Shortcut | Description | -| ----------------------------- | -------- | ---------------------------------------------- | -| Add surrounding characters | `ysiw'` | Add `'` around the word under cursor | -| Delete surrounding characters | `ds'` | Delete `'` around the word under cursor | -| Change surrounding characters | `cs'"` | Change `'` to `"` around the word under cursor | +Provided by mini.surround plugin. + +- Prefix `gz` + +| Action | Shortcut | Description | +| ------------------------------ | -------- | ----------------------------------------------- | +| Add surrounding characters | `gzaiw'` | Add `'` around the word under cursor | +| Delete surrounding characters | `gzd'` | Delete `'` around the word under cursor | +| Replace surrounding characters | `gzr'"` | Replace `'` by `"` around the word under cursor | +| Highlight surrounding | `gzh'` | Highlight `'` around the word under cursor | ## Text Manipulation diff --git a/home/base/desktop/neovim/astronvim_user/init.lua b/home/base/desktop/neovim/astronvim_user/init.lua index b0d7ca8d..a98950b8 100644 --- a/home/base/desktop/neovim/astronvim_user/init.lua +++ b/home/base/desktop/neovim/astronvim_user/init.lua @@ -26,6 +26,8 @@ return { { import = "astrocommunity.scrolling.nvim-scrollbar" }, { import = "astrocommunity.editing-support.auto-save-nvim" }, { import = "astrocommunity.editing-support.todo-comments-nvim" }, + -- clipboard history manager + { import = "astrocommunity.editing-support.yanky-nvim" }, -- Language Support ---- Frontend & NodeJS { import = "astrocommunity.pack.typescript-all-in-one" }, @@ -52,6 +54,14 @@ return { { import = "astrocommunity.pack.cmake" }, { import = "astrocommunity.pack.cpp" }, { import = "astrocommunity.pack.docker" }, + -- Motion + { import = "astrocommunity.motion.mini-surround" }, + -- https://github.com/echasnovski/mini.ai + { import = "astrocommunity.motion.mini-ai" }, + { import = "astrocommunity.motion.flash-nvim" }, + { "folke/flash.nvim", vscode = false }, + -- Lua implementation of CamelCaseMotion, with extra consideration of punctuation. + { import = "astrocommunity.motion.nvim-spider" }, -- AI Assistant { import = "astrocommunity.completion.copilot-lua-cmp" }, -- Custom copilot-lua to enable filtypes: markdown @@ -78,6 +88,44 @@ return { end, }, + -- clipboard manager + { + "gbprod/yanky.nvim", + opts = function() + local mapping = require "yanky.telescope.mapping" + local mappings = mapping.get_defaults() + mappings.i[""] = nil + return { + highlight = { timer = 200 }, + picker = { + telescope = { + use_default_mappings = false, + mappings = mappings, + }, + }, + } + end, + keys = { + { "y", "(YankyYank)", mode = { "n", "x" }, desc = "Yank text" }, + { "p", "(YankyPutAfter)", mode = { "n", "x" }, desc = "Put yanked text after cursor" }, + { "P", "(YankyPutBefore)", mode = { "n", "x" }, desc = "Put yanked text before cursor" }, + { "gp", "(YankyGPutAfter)", mode = { "n", "x" }, desc = "Put yanked text after selection" }, + { "gP", "(YankyGPutBefore)", mode = { "n", "x" }, desc = "Put yanked text before selection" }, + { "[y", "(YankyCycleForward)", desc = "Cycle forward through yank history" }, + { "]y", "(YankyCycleBackward)", desc = "Cycle backward through yank history" }, + { "]p", "(YankyPutIndentAfterLinewise)", desc = "Put indented after cursor (linewise)" }, + { "[p", "(YankyPutIndentBeforeLinewise)", desc = "Put indented before cursor (linewise)" }, + { "]P", "(YankyPutIndentAfterLinewise)", desc = "Put indented after cursor (linewise)" }, + { "[P", "(YankyPutIndentBeforeLinewise)", desc = "Put indented before cursor (linewise)" }, + { ">p", "(YankyPutIndentAfterShiftRight)", desc = "Put and indent right" }, + { "(YankyPutIndentAfterShiftLeft)", desc = "Put and indent left" }, + { ">P", "(YankyPutIndentBeforeShiftRight)", desc = "Put before and indent right" }, + { "(YankyPutIndentBeforeShiftLeft)", desc = "Put before and indent left" }, + { "=p", "(YankyPutAfterFilter)", desc = "Put after applying a filter" }, + { "=P", "(YankyPutBeforeFilter)", desc = "Put before applying a filter" }, + }, + }, + -- Enhanced matchparen.vim plugin for Neovim to highlight the outer pair. { "utilyre/sentiment.nvim", @@ -102,18 +150,6 @@ return { end, }, - -- clipboard history manager - { - "gbprod/yanky.nvim", - config = function() - require("yanky").setup({ - -- your configuration comes here - -- or leave it empty to use the default settings - -- refer to the configuration section below - }) - end, - }, - -- File explorer(Custom configs) { "nvim-neo-tree/neo-tree.nvim", @@ -188,9 +224,6 @@ return { -- Undo tree { "debugloop/telescope-undo.nvim", }, - -- Lua implementation of CamelCaseMotion, with extra consideration of punctuation. - { "chrisgrieser/nvim-spider", lazy = true }, - -- Install lsp, formmatter and others via home manager instead of Mason.nvim -- LSP installations { @@ -272,40 +305,6 @@ return { end, }, - -- Fast and feature-rich surround actions - { - "kylechui/nvim-surround", - version = "*", -- Use for stability; omit to use `main` branch for the latest features - event = "VeryLazy", - config = function() - require("nvim-surround").setup({ - -- Configuration here, or leave empty to use defaults - }) - end - }, - - -- Flash enhances the built-in search/jump functionality. - { - "folke/flash.nvim", - event = "VeryLazy", - vscode = true, - ---@type Flash.Config - opts = {}, - -- stylua: ignore - keys = { - -- Normal, Visual, or Operator-pending modes - { "s", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" }, - -- confict with nvim-surround's keys - { "S", mode = { "n", "o", "x" }, function() require("flash").treesitter() end, desc = "Flash Treesitter" }, - -- command: yr - { "r", mode = "o", function() require("flash").remote() end, desc = "Remote Flash" }, - -- command: yR - { "R", mode = { "o", "x" }, function() require("flash").treesitter_search() end, desc = "Treesitter Search" }, - -- , Command-line mode(prefix: `:`) - { "", mode = { "c" }, function() require("flash").toggle() end, desc = "Toggle Flash Search" }, - }, - }, - { 'nvim-telescope/telescope.nvim', branch = '0.1.x', dependencies = { 'nvim-lua/plenary.nvim' }, diff --git a/home/base/desktop/neovim/astronvim_user/mappings.lua b/home/base/desktop/neovim/astronvim_user/mappings.lua index 8f6b9816..83807c97 100644 --- a/home/base/desktop/neovim/astronvim_user/mappings.lua +++ b/home/base/desktop/neovim/astronvim_user/mappings.lua @@ -35,8 +35,6 @@ return { -- yank_history ["yh"] = { function() require("telescope").extensions.yank_history.yank_history() end, desc = "Preview Yank History" }, - ["p"] = {"(YankyPutAfter)", desc="YankyPutAfter" }, - ["P"] = {"(YankyPutBefore)", desc="YankyPutBefore" }, -- undo history ["uh"] = {"Telescope undo", desc="Telescope undo" }, @@ -61,9 +59,5 @@ return { ["rf"] = { function() require('refactoring').refactor('Extract Function To File') end, desc = "Extract Function To File" }, ["rv"] = { function() require('refactoring').refactor('Extract Variable') end, desc = "Extracts occurrences of a selected expression to its own variable" }, ["rr"] = { function() require('telescope').extensions.refactoring.refactors() end, desc = "Prompt for a refactor to apply" }, - - -- yank_history - ["p"] = {"(YankyPutAfter)", desc="YankyPutAfter" }, - ["P"] = {"(YankyPutBefore)", desc="YankyPutBefore" }, }, }