From c4e88698204643019be74951dc8c32071f74eaed Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 29 Aug 2023 15:24:30 +0300 Subject: [PATCH] Mini.surround and mini.files --- dotfiles/neovim/lazy-lock.json | 5 ++- dotfiles/neovim/lua/my/plugins/files.lua | 29 +++++++++++++++ dotfiles/neovim/lua/my/plugins/flash.lua | 9 ++++- dotfiles/neovim/lua/my/plugins/init.lua | 5 ++- dotfiles/neovim/lua/my/plugins/surround.lua | 39 ++++++++++++++++++-- dotfiles/neovim/lua/my/plugins/telescope.lua | 6 +-- 6 files changed, 79 insertions(+), 14 deletions(-) create mode 100644 dotfiles/neovim/lua/my/plugins/files.lua diff --git a/dotfiles/neovim/lazy-lock.json b/dotfiles/neovim/lazy-lock.json index b078cbd..de0d124 100644 --- a/dotfiles/neovim/lazy-lock.json +++ b/dotfiles/neovim/lazy-lock.json @@ -2,6 +2,7 @@ "LuaSnip": { "branch": "master", "commit": "409535b8fc54c650eb845b0c35e0cc7f08810284" }, "abbreinder.nvim": { "branch": "main", "commit": "5b2b5ff08a9ada42238d733aeebc6d3d96314d77" }, "abbremand.nvim": { "branch": "main", "commit": "d633341f632b0b2666dfc6dfe6b9842ba1610a1d" }, + "catppuccin": { "branch": "main", "commit": "490078b1593c6609e6a50ad5001e7902ea601824" }, "clipboard-image.nvim": { "branch": "main", "commit": "af8fdaad7e6fed0741e18dbf2f57bdc7494adaee" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" }, @@ -34,6 +35,8 @@ "lualine.nvim": { "branch": "master", "commit": "45e27ca739c7be6c49e5496d14fcf45a303c3a63" }, "magma-nvim": { "branch": "main", "commit": "ff3deba8a879806a51c005e50782130246143d06" }, "mind.nvim": { "branch": "master", "commit": "002137dd7cf97865ebd01b6a260209d2daf2da66" }, + "mini.files": { "branch": "main", "commit": "dea80a8147aa4e3025c34d2e2aaa6f2aeb7b21dd" }, + "mini.surround": { "branch": "main", "commit": "9d1956b576d7051da3a483b251dfc778121c60db" }, "neoconf.nvim": { "branch": "main", "commit": "08f146d53e075055500dca35e93281faff95716b" }, "neodev.nvim": { "branch": "main", "commit": "9a5c0f0de5c15fba52d4fb83d425d3f4fa7abfa1" }, "neogit": { "branch": "master", "commit": "e4c428239928425829cb5247e430f26d25d5788e" }, @@ -65,9 +68,7 @@ "typst.vim": { "branch": "main", "commit": "6a99324a138c2da69589a8ab2e49375774e43d77" }, "undotree": { "branch": "master", "commit": "0e11ba7325efbbb3f3bebe06213afa3e7ec75131" }, "venn.nvim": { "branch": "main", "commit": "c114563960b8fb1197695d42798d1f3e7190b798" }, - "vim-abolish": { "branch": "master", "commit": "cb3dcb220262777082f63972298d57ef9e9455ec" }, "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, - "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, "vim-teal": { "branch": "master", "commit": "d2aa107b257879e774680792a2aebaf9cd5742e0" }, "vim-tmux-navigator": { "branch": "master", "commit": "cdd66d6a37d991bba7997d593586fc51a5b37aa8" }, "vim-wakatime": { "branch": "master", "commit": "018fa9a80c27ccf2a8967b9e27890372e5c2fb4f" }, diff --git a/dotfiles/neovim/lua/my/plugins/files.lua b/dotfiles/neovim/lua/my/plugins/files.lua new file mode 100644 index 0000000..07eb46b --- /dev/null +++ b/dotfiles/neovim/lua/my/plugins/files.lua @@ -0,0 +1,29 @@ +local K = require("my.keymaps") + +local M = { + "echasnovski/mini.files", + version = "main", + keys = { "" }, +} + +function M.config() + local files = require("mini.files") + + files.setup({ + windows = { + preview = true, + }, + mappings = { + reveal_cwd = "R", + }, + }) + + K.nmap("", function() + if not files.close() then + files.open(vim.api.nvim_buf_get_name(0)) + files.reveal_cwd() + end + end, "[S]earch [F]iles") +end + +return M diff --git a/dotfiles/neovim/lua/my/plugins/flash.lua b/dotfiles/neovim/lua/my/plugins/flash.lua index e2b027a..2462a75 100644 --- a/dotfiles/neovim/lua/my/plugins/flash.lua +++ b/dotfiles/neovim/lua/my/plugins/flash.lua @@ -15,8 +15,15 @@ end local M = { "folke/flash.nvim", + event = "VeryLazy", ---@type Flash.Config - opts = {}, + opts = { + modes = { + char = { + enabled = false, + }, + }, + }, keys = { keybind("s", "jump", "Flash"), keybind("S", "treesitter", "Flash Treesitter"), diff --git a/dotfiles/neovim/lua/my/plugins/init.lua b/dotfiles/neovim/lua/my/plugins/init.lua index 4c979ab..d96e412 100644 --- a/dotfiles/neovim/lua/my/plugins/init.lua +++ b/dotfiles/neovim/lua/my/plugins/init.lua @@ -118,8 +118,8 @@ return { "christoomey/vim-tmux-navigator", keys = { "", "", "", "" }, cond = env.vscode.not_active() - and env.neovide.not_active() - and env.firenvim.not_active(), + and env.neovide.not_active() + and env.firenvim.not_active(), }, { @@ -159,6 +159,7 @@ return { -- case switching + the subvert command "tpope/vim-abolish", event = "VeryLazy", + enabled = false, }, { diff --git a/dotfiles/neovim/lua/my/plugins/surround.lua b/dotfiles/neovim/lua/my/plugins/surround.lua index b32b42d..83d38b7 100644 --- a/dotfiles/neovim/lua/my/plugins/surround.lua +++ b/dotfiles/neovim/lua/my/plugins/surround.lua @@ -1,12 +1,43 @@ local M = { - -- work with brackets, quotes, tags, etc - "tpope/vim-surround", + "echasnovski/mini.surround", + version = "main", event = "VeryLazy", } function M.config() - vim.g.surround_113 = '"\r"' - vim.g.surround_97 = "'\r'" + require("mini.surround").setup({ + mappings = { + add = "s", -- Add surrounding in Normal and Visul modes + delete = "d", -- Delete surrounding + find = "f", -- Find surrounding (to the right) + find_left = "F", -- Find surrounding (to the left) + highlight = "h", -- Highlight surrounding + replace = "r", -- Replace surrounding + update_n_lines = "", -- Update `n_lines` + }, + custom_surroundings = { + ["b"] = { + input = { "%b()", "^.%s*().-()%s*.$" }, + output = { left = "(", right = ")" }, + }, + ["B"] = { + input = { "%b{}", "^.%s*().-()%s*.$" }, + output = { left = "{", right = "}" }, + }, + ["r"] = { + input = { "%b[]", "^.%s*().-()%s*.$" }, + output = { left = "[", right = "]" }, + }, + ["q"] = { + input = { '".-"', "^.().*().$" }, + output = { left = '"', right = '"' }, + }, + ["a"] = { + input = { "'.-'", "^.().*().$" }, + output = { left = "'", right = "'" }, + }, + }, + }) end return M diff --git a/dotfiles/neovim/lua/my/plugins/telescope.lua b/dotfiles/neovim/lua/my/plugins/telescope.lua index 458ef51..8defe70 100644 --- a/dotfiles/neovim/lua/my/plugins/telescope.lua +++ b/dotfiles/neovim/lua/my/plugins/telescope.lua @@ -5,8 +5,7 @@ local telescope = { cmd = "Telescope", dependencies = { { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, - "nvim-telescope/telescope-file-browser.nvim", - "nvim-lua/plenary.nvim" + "nvim-lua/plenary.nvim", }, version = "0.1.x", cond = env.vscode.not_active(), @@ -36,7 +35,6 @@ local keybinds = { }, { "d", "diagnostics", "[D]iagnostics" }, { "", "live_grep", "[F]ind in project" }, - { "", "file_browser", "[F]ile browser" }, { "t", "builtin", "[T]elescope pickers" }, } @@ -63,7 +61,6 @@ function telescope.config() defaults = { mappings = { i = { [""] = "which_key" } } }, pickers = { find_files = { hidden = true } }, extensions = { - file_browser = { path = "%:p:h" }, fzf = { fuzzy = true, override_generic_sorter = true, @@ -74,7 +71,6 @@ function telescope.config() require("telescope").setup(settings) require("telescope").load_extension("fzf") - require("telescope").load_extension("file_browser") end return M