From f295b60bf39886d9a6607a22262780383b10a2e0 Mon Sep 17 00:00:00 2001 From: Tovi Jaeschke-Rogers Date: Tue, 9 Jan 2024 15:17:43 +1030 Subject: [PATCH] Update nvim config --- .config/nvim/lazy-lock.json | 74 +++++++------ .config/nvim/lua/tovi/core/commands.lua | 15 +++ .config/nvim/lua/tovi/core/init.lua | 1 + .config/nvim/lua/tovi/plugins/formatting.lua | 1 + .config/nvim/lua/tovi/plugins/harpoon.lua | 30 ++++-- .config/nvim/lua/tovi/plugins/laravel.lua | 75 +++++++++++++ .config/nvim/lua/tovi/plugins/linting.lua | 4 + .../nvim/lua/tovi/plugins/lsp/lspconfig.lua | 13 +++ .config/nvim/lua/tovi/plugins/lsp/mason.lua | 2 +- .../plugins/nvim-treesitter-textobjects.lua | 100 ++++++++++++++++++ .../nvim/lua/tovi/plugins/nvim-treesitter.lua | 100 +++++++++++++++++- 11 files changed, 364 insertions(+), 51 deletions(-) create mode 100644 .config/nvim/lua/tovi/core/commands.lua create mode 100644 .config/nvim/lua/tovi/plugins/laravel.lua create mode 100644 .config/nvim/lua/tovi/plugins/nvim-treesitter-textobjects.lua diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index bd101cd..430d9ab 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,49 +1,53 @@ { "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, - "LuaSnip": { "branch": "master", "commit": "46c91e814732c1630b8a8b50d04acbf54b8320fa" }, + "LuaSnip": { "branch": "master", "commit": "82108e7e31cc6fc223cc5df5cae6d89f70bb199f" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, - "conform.nvim": { "branch": "master", "commit": "ca3dfba94600aa62bfc88ae37cbd4f17eaea2553" }, - "copilot.vim": { "branch": "release", "commit": "309b3c803d1862d5e84c7c9c5749ae04010123b8" }, + "conform.nvim": { "branch": "master", "commit": "47ceff644e9d00872f410be374cc973eefa20ba9" }, + "copilot.vim": { "branch": "release", "commit": "5b19fb001d7f31c4c7c5556d7a97b243bd29f45f" }, "dart-vim-plugin": { "branch": "master", "commit": "928302ec931caf0dcf21835cca284ccd2b192f7b" }, - "dressing.nvim": { "branch": "master", "commit": "fe3071330a0720ce3695ac915820c8134b22d1b0" }, - "friendly-snippets": { "branch": "main", "commit": "43727c2ff84240e55d4069ec3e6158d74cb534b6" }, + "dressing.nvim": { "branch": "master", "commit": "94b0d24483d56f3777ee0c8dc51675f21709318c" }, + "friendly-snippets": { "branch": "main", "commit": "69a2c1675b66e002799f5eef803b87a12f593049" }, "fugitive-gitlab.vim": { "branch": "master", "commit": "55fed481c0309b3405dd3d72921d687bf36873a8" }, - "gitsigns.nvim": { "branch": "main", "commit": "af0f583cd35286dd6f0e3ed52622728703237e50" }, - "go.nvim": { "branch": "master", "commit": "38f6402fa5362f2c31a31439294d9e24eda46b13" }, - "guihua.lua": { "branch": "master", "commit": "cd68996069abedffcd677ca7eee3a660b79e5b32" }, - "harpoon": { "branch": "master", "commit": "c1aebbad9e3d13f20bedb8f2ce8b3a94e39e424a" }, + "gitsigns.nvim": { "branch": "main", "commit": "3e6e91b09f0468c32d3b96dcacf4b947f037ce25" }, + "go.nvim": { "branch": "master", "commit": "24d2fa373d55d9900cd4b502a88214dc17e6fab6" }, + "guihua.lua": { "branch": "master", "commit": "9fb6795474918b492d9ab01b1ebaf85e8bf6fe0b" }, + "harpoon": { "branch": "harpoon2", "commit": "2cd4e03372f7ee5692c8caa220f479ea07970f17" }, + "laravel.nvim": { "branch": "main", "commit": "a4d6f85f2be05aca0b4dd1feb8f28cb8b4e68420" }, "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, - "lazygit.nvim": { "branch": "main", "commit": "de35012036d43bca03628d40d083f7c02a4cda3f" }, - "leap.nvim": { "branch": "main", "commit": "b6ae80f8fc9993638608fc1a51c6ab0eeb12618c" }, - "lspkind.nvim": { "branch": "master", "commit": "57610d5ab560c073c465d6faf0c19f200cb67e6e" }, - "lualine.nvim": { "branch": "master", "commit": "2248ef254d0a1488a72041cfb45ca9caada6d994" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "6eb8cae80f2e4322ec82cd9f8fa423f6d1eb02c3" }, - "mason-tool-installer.nvim": { "branch": "main", "commit": "e4f34741daa9cf95de68a603d3e7a6844a69fdf0" }, - "mason.nvim": { "branch": "main", "commit": "41e75af1f578e55ba050c863587cffde3556ffa6" }, - "minintro.nvim": { "branch": "master", "commit": "6bbb922a5628f5bc746fa2e13dbf5f9b6049c6b1" }, - "neotest": { "branch": "master", "commit": "901891484db3d46ce43d56871273dc7d40621356" }, - "neotest-go": { "branch": "main", "commit": "1a15e1136db43775214a3e7a598f8930c29c94b7" }, + "lazygit.nvim": { "branch": "main", "commit": "1e08e3f5ac1152339690140e61a4a32b3bdc7de5" }, + "leap.nvim": { "branch": "main", "commit": "b63f14d7474002573710d10f02f1af33a4910490" }, + "lspkind.nvim": { "branch": "master", "commit": "7f26cf5e27e2bd910ce0ea00c514da2bf97423b8" }, + "lualine.nvim": { "branch": "master", "commit": "566b7036f717f3d676362742630518a47f132fff" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "0989bdf4fdf7b5aa4c74131d7ffccc3f399ac788" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "8b70e7f1e0a4119c1234c3bde4a01c241cabcc74" }, + "mason.nvim": { "branch": "main", "commit": "e110bc3be1a7309617cecd77bfe4bf86ba1b8134" }, + "minintro.nvim": { "branch": "master", "commit": "b7fa58cc549e8d2b362a217a7620d9aedc47d47e" }, + "neotest": { "branch": "master", "commit": "1ee3fcc150207f33dba8c9b3f478e5a0148d661d" }, + "neotest-go": { "branch": "main", "commit": "d29d20d912aca81a07c50022d880cc66f0d26542" }, "neotest-phpunit": { "branch": "main", "commit": "e2dfa3280d2a33495a3f710bc364d2cfd1f40c83" }, - "nightfly": { "branch": "master", "commit": "06ad2689ebd251a71c6caeb9fb47e231773c9b47" }, - "nvim-cmp": { "branch": "main", "commit": "0b751f6beef40fd47375eaf53d3057e0bfa317e4" }, - "nvim-colorizer.lua": { "branch": "master", "commit": "dde3084106a70b9a79d48f426f6d6fec6fd203f7" }, - "nvim-lint": { "branch": "master", "commit": "775ae0e5a451dd6c5d15de7a828ea72d2c54e8cf" }, - "nvim-lsp-file-operations": { "branch": "master", "commit": "1e0ffa0acc92f88f9f2b68df47ccbe1917653a42" }, - "nvim-lspconfig": { "branch": "master", "commit": "90a28fd7637b66e055af62387ecee06f7cbd3173" }, - "nvim-tree.lua": { "branch": "master", "commit": "874ae6e9445a5eb5ba430e5fd10212450a261ad7" }, - "nvim-treesitter": { "branch": "master", "commit": "075a64addc33390028ea124a1046a43497f05cd1" }, - "nvim-ts-autotag": { "branch": "main", "commit": "6be1192965df35f94b8ea6d323354f7dc7a557e4" }, - "nvim-web-devicons": { "branch": "master", "commit": "3fafeea5f339223e888fd15eb4032260849cb038" }, - "oil.nvim": { "branch": "master", "commit": "3727410e4875ad8ba339c585859a9391d643b9ed" }, - "plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" }, + "nightfly": { "branch": "master", "commit": "0c6e2e88bf15634af94a91fcc2e20e28a09dfecd" }, + "nui.nvim": { "branch": "main", "commit": "35da9ca1de0fc4dda96c2e214d93d363c145f418" }, + "nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "85855b38011114929f4058efc97af1059ab3e41d" }, + "nvim-lint": { "branch": "master", "commit": "8df53b5dde8ea80f0a039775777eae6648a10229" }, + "nvim-lsp-file-operations": { "branch": "master", "commit": "8e7223e138590c1bd9d86d3de810e65939d8b12f" }, + "nvim-lspconfig": { "branch": "master", "commit": "796394fd19fb878e8dbc4fd1e9c9c186ed07a5f4" }, + "nvim-tree.lua": { "branch": "master", "commit": "b8c3a23e76f861d5f0ff3f6714b9b56388984d0b" }, + "nvim-treesitter": { "branch": "master", "commit": "8cd2b230174efbf7b5d9f49fe2f90bda6b5eb16e" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "85b9d0cbd4ff901abcda862b50dbb34e0901848b" }, + "nvim-ts-autotag": { "branch": "main", "commit": "8515e48a277a2f4947d91004d9aa92c29fdc5e18" }, + "nvim-web-devicons": { "branch": "master", "commit": "db0c864375c198cacc171ff373e76bfce2a85045" }, + "oil.nvim": { "branch": "master", "commit": "c4cc8240f1c71defcb67c45da96e44b968d29e5f" }, + "plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, - "telescope-undo.nvim": { "branch": "main", "commit": "a3dcb6e32a3a59a5570a7cda33171eeef9753345" }, - "telescope.nvim": { "branch": "0.1.x", "commit": "7011eaae0ac1afe036e30c95cf80200b8dc3f21a" }, + "telescope-undo.nvim": { "branch": "main", "commit": "d3afc1c105535a90caec092ce27a113f77ba7b84" }, + "telescope.nvim": { "branch": "0.1.x", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, "undotree": { "branch": "master", "commit": "36ff7abb6b60980338344982ad4cdf03f7961ecd" }, - "vim-fugitive": { "branch": "master", "commit": "46eaf8918b347906789df296143117774e827616" }, + "vim-dotenv": { "branch": "master", "commit": "5c51cfcf8d87280d6414e03cd6b253eb70ecb800" }, + "vim-fugitive": { "branch": "master", "commit": "59659093581aad2afacedc81f009ed6a4bfad275" }, "vim-repeat": { "branch": "master", "commit": "24afe922e6a05891756ecf331f39a1f6743d3d5a" } } \ No newline at end of file diff --git a/.config/nvim/lua/tovi/core/commands.lua b/.config/nvim/lua/tovi/core/commands.lua new file mode 100644 index 0000000..385032b --- /dev/null +++ b/.config/nvim/lua/tovi/core/commands.lua @@ -0,0 +1,15 @@ + +local function ToggleTabs() + local options = {"tabstop", "softtabstop", "shiftwidth"} + + for _, option in ipairs(options) do + local current_value = vim.opt[option]:get() + vim.opt[option] = (current_value == 4) and 2 or 4 + end +end + +vim.api.nvim_create_user_command( + 'ToggleTabs', + ToggleTabs, + { nargs = 0 } +) diff --git a/.config/nvim/lua/tovi/core/init.lua b/.config/nvim/lua/tovi/core/init.lua index 3534db7..f0cdd4b 100644 --- a/.config/nvim/lua/tovi/core/init.lua +++ b/.config/nvim/lua/tovi/core/init.lua @@ -1,4 +1,5 @@ require('tovi.core.options') require('tovi.core.remaps') require('tovi.core.autocmd') +require('tovi.core.commands') diff --git a/.config/nvim/lua/tovi/plugins/formatting.lua b/.config/nvim/lua/tovi/plugins/formatting.lua index 78bb100..f8a0dec 100644 --- a/.config/nvim/lua/tovi/plugins/formatting.lua +++ b/.config/nvim/lua/tovi/plugins/formatting.lua @@ -18,6 +18,7 @@ return { rust = { "rustfmt" }, shell = { "shfmt", "shellcheck" }, python = { "isort", "black" }, + php = { "phpcbf" } }, -- format_on_save = { -- lsp_fallback = true, diff --git a/.config/nvim/lua/tovi/plugins/harpoon.lua b/.config/nvim/lua/tovi/plugins/harpoon.lua index 6b1a7bf..cde9bbd 100644 --- a/.config/nvim/lua/tovi/plugins/harpoon.lua +++ b/.config/nvim/lua/tovi/plugins/harpoon.lua @@ -1,41 +1,49 @@ return { "ThePrimeagen/harpoon", + branch = "harpoon2", dependencies = { "nvim-lua/plenary.nvim", }, config = function() - local mark = require("harpoon.mark") - local ui = require("harpoon.ui") + local harpoon = require("harpoon") + + -- REQUIRED + harpoon:setup() + -- REQUIRED -- set keymaps local keymap = vim.keymap -- for conciseness - keymap.set("n", "a", mark.add_file, { desc = "Mark file with harpoon" }) - keymap.set("n", "th", mark.toggle_file, { desc = "Toggle file with harpoon" }) - keymap.set("n", "", ui.toggle_quick_menu, { desc = "Toggle quick menu for harpoon" }) + keymap.set("n", "a", function () + harpoon:list():append() + end, { desc = "Mark file with harpoon" }) + + keymap.set("n", "", function () + harpoon.ui:toggle_quick_menu() + end, { desc = "Toggle quick menu for harpoon" }) keymap.set("n", "", function() - ui.nav_prev() + harpoon:list():prev() end, { desc = "Go to previous harpoon mark" }) keymap.set("n", "", function() - ui.nav_next() + harpoon:list():next() end, { desc = "Go to next harpoon mark" }) keymap.set("n", "", function() - ui.nav_file(1) + harpoon:list():select(1) end, { desc = "Go to first harpoon file" }) keymap.set("n", "", function() - ui.nav_file(2) + harpoon:list():select(2) end, { desc = "Go to second harpoon file" }) keymap.set("n", "", function() - ui.nav_file(3) + harpoon:list():select(3) end, { desc = "Go to third harpoon file" }) keymap.set("n", "", function() - ui.nav_file(4) + harpoon:list():select(4) end, { desc = "Go to fourth harpoon file" }) end, } diff --git a/.config/nvim/lua/tovi/plugins/laravel.lua b/.config/nvim/lua/tovi/plugins/laravel.lua new file mode 100644 index 0000000..01b445c --- /dev/null +++ b/.config/nvim/lua/tovi/plugins/laravel.lua @@ -0,0 +1,75 @@ +return { + "tovijaeschke/laravel.nvim", + dependencies = { + "nvim-telescope/telescope.nvim", + "tpope/vim-dotenv", + "MunifTanjim/nui.nvim", + -- "nvimtools/none-ls.nvim", + }, + cmd = { "Sail", "Artisan", "Composer", "Npm", "Yarn", "Laravel" }, + keys = { + { "la", ":Laravel artisan" }, + { "lr", ":Laravel routes" }, + { "lm", ":Laravel related" }, + }, + event = { "VeryLazy" }, + config = function () + local laravel = require("laravel") + + laravel.setup({ + lsp_server = "intelephense", + features = { + null_ls = { + enable = false, + }, + }, + environments = { + env_variable = "NVIM_LARAVEL_ENV", + auto_dicover = false, + default = "docker-compose", + definitions = { + { + name = "sail", + condition = { + file_exists = { "vendor/bin/sail", "docker-compose.yml" }, + }, + commands = { + sail = { "vendor/bin/sail" }, + { + commands = { "php", "composer", "npm", "yarn" }, + prefix = { "vendor/bin/sail" }, + }, + }, + }, + { + name = "docker-compose", + condition = { + file_exists = { "docker-compose.yml" }, + executable = { "docker" }, + }, + commands = { + compose = { "docker", "compose" }, + { + commands = { "php", "composer", "npm" }, + docker = { + container = { + env = "APP_SERVICE", + default = "fpm", + }, + exec = { "docker", "compose", "exec", "-it" }, + run = { "docker", "compose", "run" }, + }, + }, + }, + }, + { + name = "local", + condition = { + executable = { "php" }, + }, + }, + } + } + }) + end, +} diff --git a/.config/nvim/lua/tovi/plugins/linting.lua b/.config/nvim/lua/tovi/plugins/linting.lua index 0d3842a..987d05b 100644 --- a/.config/nvim/lua/tovi/plugins/linting.lua +++ b/.config/nvim/lua/tovi/plugins/linting.lua @@ -4,6 +4,10 @@ return { config = function() local lint = require("lint") + lint.linters.ecs = { + cmd = "ecs", + } + lint.linters_by_ft = { javascript = { "eslint_d" }, typescript = { "eslint_d" }, diff --git a/.config/nvim/lua/tovi/plugins/lsp/lspconfig.lua b/.config/nvim/lua/tovi/plugins/lsp/lspconfig.lua index 5a22755..b3443b7 100644 --- a/.config/nvim/lua/tovi/plugins/lsp/lspconfig.lua +++ b/.config/nvim/lua/tovi/plugins/lsp/lspconfig.lua @@ -8,6 +8,7 @@ return { config = function() -- import lspconfig plugin local lspconfig = require("lspconfig") + local util = require("lspconfig.util") -- import cmp-nvim-lsp plugin local cmp_nvim_lsp = require("cmp_nvim_lsp") @@ -114,8 +115,20 @@ return { -- configure php server lspconfig["intelephense"].setup({ + root_dir = function(pattern) + local cwd = vim.loop.cwd() + local root = util.root_pattern('composer.json')(pattern) + + -- prefer cwd if root is a descendant + return util.path.is_descendant(cwd, root) and cwd or root + end, capabilities = capabilities, on_attach = on_attach, + init_options = { + licenceKey = "/home/tovi/.local/share/nvim/intelephense-licence.txt" + }, + settings = { + } }) -- configure python server diff --git a/.config/nvim/lua/tovi/plugins/lsp/mason.lua b/.config/nvim/lua/tovi/plugins/lsp/mason.lua index cf10105..12ed065 100644 --- a/.config/nvim/lua/tovi/plugins/lsp/mason.lua +++ b/.config/nvim/lua/tovi/plugins/lsp/mason.lua @@ -47,7 +47,7 @@ return { "eslint_d", "jsonlint", "markdownlint", - "phpcs", + "tlint", "gospel", "golangci-lint", "pylint", diff --git a/.config/nvim/lua/tovi/plugins/nvim-treesitter-textobjects.lua b/.config/nvim/lua/tovi/plugins/nvim-treesitter-textobjects.lua new file mode 100644 index 0000000..33be932 --- /dev/null +++ b/.config/nvim/lua/tovi/plugins/nvim-treesitter-textobjects.lua @@ -0,0 +1,100 @@ +return { + lazy = false, + enabled = true, + dependencies = { "nvim-treesitter/nvim-treesitter" }, + config = function() + require("nvim-treesitter.configs").setup({ + incremental_selection = { + enable = true, + keymaps = { + -- mappings for incremental selection (visual mappings) + init_selection = "gnn", -- maps in normal mode to init the node/scope selection + node_incremental = "grn", -- increment to the upper named parent + scope_incremental = "grc", -- increment to the upper scope (as defined in locals.scm) + node_decremental = "grm", -- decrement to the previous node + }, + }, + + textobjects = { + -- syntax-aware textobjects + enable = true, + lsp_interop = { + enable = true, + peek_definition_code = { + ["af"] = "@function.outer", + ["if"] = "@class.outer", + }, + }, + keymaps = { + ["iL"] = { + -- you can define your own textobjects directly here + go = "(function_definition) @function", + }, + -- or you use the queries from supported languages with textobjects.scm + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["aC"] = "@class.outer", + ["iC"] = "@class.inner", + ["ac"] = "@conditional.outer", + ["ic"] = "@conditional.inner", + ["ae"] = "@block.outer", + ["ie"] = "@block.inner", + ["al"] = "@loop.outer", + ["il"] = "@loop.inner", + ["is"] = "@statement.inner", + ["as"] = "@statement.outer", + ["ad"] = "@comment.outer", + ["am"] = "@call.outer", + ["im"] = "@call.inner", + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + ["]m"] = "@function.outer", + ["]]"] = "@class.outer", + }, + goto_next_end = { + ["]M"] = "@function.outer", + ["]["] = "@class.outer", + }, + goto_previous_start = { + ["[m"] = "@function.outer", + ["[["] = "@class.outer", + }, + goto_previous_end = { + ["[M"] = "@function.outer", + ["[]"] = "@class.outer", + }, + }, + select = { + enable = true, + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ac"] = "@class.outer", + ["ic"] = "@class.inner", + -- Or you can define your own textobjects like this + ["iF"] = { + python = "(function_definition) @function", + cpp = "(function_definition) @function", + c = "(function_definition) @function", + java = "(method_declaration) @function", + go = "(method_declaration) @function", + }, + }, + }, + swap = { + enable = true, + swap_next = { + ["a"] = "@parameter.inner", + }, + swap_previous = { + ["A"] = "@parameter.inner", + }, + }, + }, + }) + end, +} diff --git a/.config/nvim/lua/tovi/plugins/nvim-treesitter.lua b/.config/nvim/lua/tovi/plugins/nvim-treesitter.lua index 762f932..7eb4f94 100644 --- a/.config/nvim/lua/tovi/plugins/nvim-treesitter.lua +++ b/.config/nvim/lua/tovi/plugins/nvim-treesitter.lua @@ -5,13 +5,15 @@ return { build = ":TSUpdate", dependencies = { "windwp/nvim-ts-autotag", + "nvim-treesitter/nvim-treesitter-textobjects", }, config = function() -- import nvim-treesitter plugin local treesitter = require("nvim-treesitter.configs") -- configure treesitter - treesitter.setup({ -- enable syntax highlighting + treesitter.setup({ + -- enable syntax highlighting highlight = { enable = true, }, @@ -47,7 +49,97 @@ return { }, -- auto install above language parsers auto_install = true, - }) - end, - }, + + textobjects = { + select = { + enable = true, + + -- Automatically jump forward to textobj, similar to targets.vim + lookahead = true, + + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ["aa"] = "@parameter.outer", + ["ia"] = "@parameter.inner", + + ["af"] = "@function.outer", + ["if"] = "@function.inner", + + ["ac"] = "@class.outer", + ["ic"] = "@class.inner", + + ["ab"] = "@block.outer", + ["ib"] = "@block.inner", + + ["al"] = "@loop.outer", + ["il"] = "@loop.inner", + + ["am"] = "@call.outer", + ["im"] = "@call.inner", + + ["ai"] = "@conditional.outer", + ["ii"] = "@conditional.inner", + }, + selection_modes = { + ['@parameter.outer'] = 'v', -- charwise + ['@function.outer'] = 'V', -- linewise + ['@class.outer'] = '', -- blockwise + }, + include_surrounding_whitespace = true, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + ["]m"] = "@function.outer", + ["]]"] = "@class.outer", + }, + goto_next_end = { + ["]M"] = "@function.outer", + ["]["] = "@class.outer", + }, + goto_previous_start = { + ["[m"] = "@function.outer", + ["[["] = "@class.outer", + }, + goto_previous_end = { + ["[M"] = "@function.outer", + ["[]"] = "@class.outer", + }, + goto_next = { + ["]i"] = "@conditional.outer", + ["]l"] = "@loop.outer", + }, + goto_previous = { + ["[i"] = "@conditional.outer", + ["[l"] = "@loop.outer", + } + }, + swap = { + enable = true, + swap_next = { + ["s"] = "@parameter.inner", + }, + swap_previous = { + ["S"] = "@parameter.inner", + }, + }, + }, + }) + + local ts_repeat_move = require("nvim-treesitter.textobjects.repeatable_move") + + local keymap = vim.keymap + + -- vim way: ; goes to the direction you were moving. + keymap.set({ "n", "x", "o" }, ";", ts_repeat_move.repeat_last_move) + keymap.set({ "n", "x", "o" }, ",", ts_repeat_move.repeat_last_move_opposite) + + -- Optionally, make builtin f, F, t, T also repeatable with ; and , + keymap.set({ "n", "x", "o" }, "f", ts_repeat_move.builtin_f) + keymap.set({ "n", "x", "o" }, "F", ts_repeat_move.builtin_F) + keymap.set({ "n", "x", "o" }, "t", ts_repeat_move.builtin_t) + keymap.set({ "n", "x", "o" }, "T", ts_repeat_move.builtin_T) + end, + }, }