From 6f3b7152abc0d29aad02e55d1d4d7b7b1740e653 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Mon, 27 Feb 2023 16:41:19 +0900 Subject: [PATCH] Vim cleanups --- modules/home/nvim/lazy-lock.json | 2 +- modules/home/nvim/lua/plugins/lsp.lua | 23 +++++++++--------- modules/home/nvim/lua/plugins/motions.lua | 26 ++++++++++----------- modules/home/nvim/lua/plugins/tree.lua | 18 ++++++++++++++ modules/home/nvim/lua/plugins/treesiter.lua | 13 ++++++++++- modules/home/nvim/lua/plugins/ui.lua | 14 ----------- modules/home/nvim/lua/settings.lua | 3 ++- 7 files changed, 57 insertions(+), 42 deletions(-) diff --git a/modules/home/nvim/lazy-lock.json b/modules/home/nvim/lazy-lock.json index 6e3405a..0d57228 100644 --- a/modules/home/nvim/lazy-lock.json +++ b/modules/home/nvim/lazy-lock.json @@ -32,6 +32,7 @@ "nvim-lspconfig": { "branch": "master", "commit": "62856b20751b748841b0f3ec5a10b1e2f6a6dbc9" }, "nvim-navic": { "branch": "master", "commit": "7e9d2b2b601149fecdccd11b516acb721e571fe6" }, "nvim-scrollbar": { "branch": "main", "commit": "75210c554e935740448cfb532d8a671ae544bb1b" }, + "nvim-surround": { "branch": "main", "commit": "a06dea11e7fdcf338776fa51fa5277163ffb048d" }, "nvim-treesitter": { "branch": "master", "commit": "50709361378fa37d455b21fb716169416888314f" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "4b30081d2736e09f90c890a8a7adfe4df36f5b36" }, "nvim-ts-autotag": { "branch": "main", "commit": "fdefe46c6807441460f11f11a167a2baf8e4534b" }, @@ -45,7 +46,6 @@ "unimpaired-which-key.nvim": { "branch": "main", "commit": "321a247ecbbb31a59a8580350eec044b88d82e81" }, "vim-repeat": { "branch": "master", "commit": "24afe922e6a05891756ecf331f39a1f6743d3d5a" }, "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, - "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, "vim-unimpaired": { "branch": "master", "commit": "6d44a6dc2ec34607c41ec78acf81657248580bf1" }, "vim-wordmotion": { "branch": "master", "commit": "81d9bd298376ab0dc465c85d55afa4cb8d5f47a1" }, "virt-column.nvim": { "branch": "master", "commit": "93b40ea038f676f5a72d7d1f2336fe7b051fc0ce" }, diff --git a/modules/home/nvim/lua/plugins/lsp.lua b/modules/home/nvim/lua/plugins/lsp.lua index 6047ecd..145f19f 100644 --- a/modules/home/nvim/lua/plugins/lsp.lua +++ b/modules/home/nvim/lua/plugins/lsp.lua @@ -212,17 +212,18 @@ return { history = true, delete_check_events = "TextChanged", }, - keys = { - { - "", - function() - return require("luasnip").jumpable(1) and "luasnip-jump-next" or "" - end, - expr = true, silent = true, mode = "i", - }, - { "", function() require("luasnip").jump(1) end, mode = "s" }, - { "", function() require("luasnip").jump(-1) end, mode = { "i", "s" } }, - }, + -- I'm never using snippets and it only bother me so for now I am disabling it. + -- keys = { + -- { + -- "", + -- function() + -- return require("luasnip").jumpable(1) and "luasnip-jump-next" or "" + -- end, + -- expr = true, silent = true, mode = "i", + -- }, + -- { "", function() require("luasnip").jump(1) end, mode = "s" }, + -- { "", function() require("luasnip").jump(-1) end, mode = { "i", "s" } }, + -- }, }, { diff --git a/modules/home/nvim/lua/plugins/motions.lua b/modules/home/nvim/lua/plugins/motions.lua index 9d68e6a..b7e75ef 100644 --- a/modules/home/nvim/lua/plugins/motions.lua +++ b/modules/home/nvim/lua/plugins/motions.lua @@ -2,19 +2,11 @@ return { { "ggandor/leap.nvim", keys = { - { "s", mode = { "n", "x", "o" }, desc = "Leap forward to" }, - { "S", mode = { "n", "x", "o" }, desc = "Leap backward to" }, - { "gs", mode = { "n", "x", "o" }, desc = "Leap from windows" }, + { "s", "(leap-forward-to)", mode = { "n", "x", }, desc = "Leap forward to" }, + { "S", "(leap-backward-to)", mode = { "n", "x", }, desc = "Leap backward to" }, + { "z", "(leap-forward-to)", mode = "o", desc = "Leap forward to" }, + { "Z", "(leap-backward-to)", mode = "o", desc = "Leap backward to" }, }, - config = function(_, opts) - local leap = require("leap") - for k, v in pairs(opts) do - leap.opts[k] = v - end - leap.add_default_mappings(true) - vim.keymap.del({ "x", "o" }, "x") - vim.keymap.del({ "x", "o" }, "X") - end, }, { "tpope/vim-repeat", event = "VeryLazy" }, @@ -33,7 +25,7 @@ return { { "", 'lua require("harpoon.ui").nav_file(1)', desc = "Navigate to harpoon 1" }, { "", 'lua require("harpoon.ui").nav_file(2)', desc = "Navigate to harpoon 2" }, { "", 'lua require("harpoon.ui").nav_file(3)', desc = "Navigate to harpoon 3" }, - { "", 'lua require("harpoon.ui").nav_file(4)', desc = "Navigate to harpoon 4" }, + -- is already taken but since I use harpoon less on querty no worry }, opts = { mark_branch = true, @@ -44,9 +36,15 @@ return { }, "tpope/vim-unimpaired", - "tpope/vim-surround", "tpope/vim-sleuth", + { + "kylechui/nvim-surround", + version = "*", + event = "VeryLazy", + config = true, + }, + { "nishigori/increment-activator", keys = { diff --git a/modules/home/nvim/lua/plugins/tree.lua b/modules/home/nvim/lua/plugins/tree.lua index 88585c6..abaa20f 100644 --- a/modules/home/nvim/lua/plugins/tree.lua +++ b/modules/home/nvim/lua/plugins/tree.lua @@ -48,6 +48,24 @@ return { window = { mappings = { [""] = "none", + ["h"] = function(state) + local node = state.tree:get_node() + if node.type == 'directory' and node:is_expanded() then + require'neo-tree.sources.filesystem'.toggle_directory(state, node) + else + require'neo-tree.ui.renderer'.focus_node(state, node:get_parent_id()) + end + end, + ["l"] = function(state) + local node = state.tree:get_node() + if node.type == 'directory' then + if not node:is_expanded() then + require'neo-tree.sources.filesystem'.toggle_directory(state, node) + elseif node:has_children() then + require'neo-tree.ui.renderer'.focus_node(state, node:get_child_ids()[1]) + end + end + end, }, }, filesystem = { diff --git a/modules/home/nvim/lua/plugins/treesiter.lua b/modules/home/nvim/lua/plugins/treesiter.lua index 073f3bd..4df5f6d 100644 --- a/modules/home/nvim/lua/plugins/treesiter.lua +++ b/modules/home/nvim/lua/plugins/treesiter.lua @@ -60,6 +60,17 @@ return { { "echasnovski/mini.pairs", version = '*', - config = function () require('mini.pairs').setup() end, + opts = { + mappings = { + -- Disable pairs if the next char is not a whitespace + ['('] = { action = 'open', pair = '()', neigh_pattern = '[^\\][%s]' }, + ['['] = { action = 'open', pair = '[]', neigh_pattern = '[^\\][%s]' }, + ['{'] = { action = 'open', pair = '{}', neigh_pattern = '[^\\][%s]' }, + ['"'] = { action = 'closeopen', pair = '""', neigh_pattern = '[^\\][%s]', register = { cr = false } }, + ["'"] = { action = 'closeopen', pair = "''", neigh_pattern = '[^%a\\][%s]', register = { cr = false } }, + ['`'] = { action = 'closeopen', pair = '``', neigh_pattern = '[^\\][%s]', register = { cr = false } }, + }, + }, + config = function(_, opts) require('mini.pairs').setup(opts) end, }, } diff --git a/modules/home/nvim/lua/plugins/ui.lua b/modules/home/nvim/lua/plugins/ui.lua index 48be003..6914d0b 100644 --- a/modules/home/nvim/lua/plugins/ui.lua +++ b/modules/home/nvim/lua/plugins/ui.lua @@ -80,20 +80,6 @@ return { local wk = require("which-key") wk.setup(opts) - wk.register({ - gc = { - name = "Comment", - }, - ys = { name = "Add Surroundings" }, - ds = { name = "Delete Surroundings" }, - cs = { name = "Change Surroundings" }, - yS = { name = "Add Surroundings" }, - dS = { name = "Delete Surroundings" }, - cS = { name = "Change Surroundings" }, - }, { - noremap = false, - }) - wk.register({ mode = { "n", "v" }, ["g"] = { name = "+goto" }, diff --git a/modules/home/nvim/lua/settings.lua b/modules/home/nvim/lua/settings.lua index c1ad14f..3b41388 100644 --- a/modules/home/nvim/lua/settings.lua +++ b/modules/home/nvim/lua/settings.lua @@ -77,7 +77,8 @@ keymap({"n", "x"}, "Y", '"+y$', "Yank line to system clipboard") keymap({"n", "x"}, "p", '"+p', "Past from system clipboard") keymap({"n", "x"}, "P", '"+P', "Past line from system clipboard") -keymap("t", "", "") +keymap("t", "", "", "+windows") +keymap("t", "", "", "Normal mode") vim.cmd("autocmd FileType qf setl nolist") vim.cmd("syntax on")