From aa62e1f27b0cb3d712d6f2b13071cca0f09379be Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Thu, 11 Sep 2025 16:38:11 +0100 Subject: Add a lot of changes --- home/.config/nvim/lua/custom/plugins/ts.lua | 292 ++++++++++++++-------------- 1 file changed, 146 insertions(+), 146 deletions(-) (limited to 'home/.config/nvim/lua/custom/plugins/ts.lua') diff --git a/home/.config/nvim/lua/custom/plugins/ts.lua b/home/.config/nvim/lua/custom/plugins/ts.lua index c2741e5..40b1209 100644 --- a/home/.config/nvim/lua/custom/plugins/ts.lua +++ b/home/.config/nvim/lua/custom/plugins/ts.lua @@ -1,155 +1,155 @@ return { { - 'nvim-treesitter/nvim-treesitter', + "aaronik/treewalker.nvim", + keys = { + { + "", + "Treewalker Up", + { "n", "v" }, + silent = true, + desc = "Moves up to the previous neighbor node", + }, + { + "", + "Treewalker Down", + { "n", "v" }, + silent = true, + desc = "Moves up to the next neighbor node", + }, + { + "", + "Treewalker Left", + { "n", "v" }, + silent = true, + desc = "Moves to the first ancestor node that's on a different line from the current node", + }, + { + "", + "Treewalker Right", + { "n", "v" }, + silent = true, + desc = "Moves to the next node down that's indented further than the current node", + }, + { + "Treewalker SwapUp", + "", + silent = true, + desc = "Swaps the highest node on the line upwards in the document", + }, + { + "", + "Treewalker SwapDown", + silent = true, + desc = "Swaps the biggest node on the line downward in the document", + }, + { + "", + "Treewalker SwapLeft", + silent = true, + desc = "Swap the node under the cursor with its previous neighbor", + }, + { + "", + "Treewalker SwapRight", + silent = true, + desc = "Swap the node under the cursor with its next neighbor", + }, + }, + opts = {}, + }, + { + "nvim-treesitter/nvim-treesitter", + branch = "main", + lazy = false, dependencies = { - 'nvim-treesitter/nvim-treesitter-textobjects', - "nvim-treesitter/nvim-treesitter-refactor", - "theHamsta/crazy-node-movement", - "theHamsta/nvim-treesitter-pairs", - "RRethy/nvim-treesitter-endwise", + -- "theHamsta/nvim-treesitter-pairs", -- Reneable once main branch is supported + { + "LiadOz/nvim-dap-repl-highlights", + opts = {}, + }, }, build = ":TSUpdate", config = function() - require("nvim-treesitter.configs").setup({ - ensure_installed = { - "bash", - "c", - "cmake", - "comment", - "cpp", - "css", - "diff", - "dockerfile", - "doxygen", - "fortran", - "git_config", - "git_rebase", - "gitattributes", - "gitcommit", - "gitignore", - "gpg", - "html", - "http", - "ini", - "javascript", - "jsdoc", - "json", - "jsonc", - "llvm", - "lua", - "luadoc", - "luap", - "make", - "markdown", - "markdown_inline", - "python", - "regex", - "rust", - "sql", - "tablegen", - "todotxt", - "toml", - "typescript", - "vim", - "vimdoc", - "xml", - "yaml", - }, - highlight = { - enable = true, - additional_vim_regex_highlighting = false, - }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = "gnn", - node_incremental = "grn", - scope_incremental = "grc", - node_decremental = "grm", - }, - }, - indent = { enable = true }, - refactor = { - highlight_definitions = { enable = true }, - highlight_current_scope = { enable = true }, - }, - 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 - ["af"] = "@function.outer", - ["if"] = "@function.inner", - ["ac"] = "@class.outer", - ["ic"] = "@class.inner", - }, - }, - swap = { - enable = true, - swap_next = { ["a"] = "@parameter.inner" }, - swap_previous = { ["A"] = "@parameter.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", - }, - }, - lsp_interop = { - enable = true, - peek_definition_code = { - ["df"] = "@function.outer", - ["dF"] = "@class.outer", - }, - }, - }, - matchup = { - enable = true, - }, - pairs = { - enable = true, - goto_right_end = false, - keymaps = { goto_partner = "%" }, - }, - node_movement = { - enable = true, - keymaps = { - move_up = "", - move_down = "", - move_left = "", - move_right = "", - swap_left = "", -- will only swap when one of "swappable_textobjects" is selected - swap_right = "", - select_current_node = "", - }, - swappable_textobjects = { '@function.outer', '@parameter.inner', '@statement.outer' }, - allow_switch_parents = true, -- more craziness by switching parents while staying on the same level, false prevents you from accidentally jumping out of a function - allow_next_parent = true, -- more craziness by going up one level if next node does not have children - }, - tree_docs = { - enable = true, - }, - endwise = { - enable = true, - }, + require("nvim-treesitter").install({ + "awk", + "bash", + "c", + "cmake", + "comment", + "cpp", + "css", + "csv", + "diff", + "dockerfile", + "dap_repl", + "doxygen", + "editorconfig", + "fortran", + "git_config", + "git_rebase", + "gitattributes", + "gitcommit", + "gitignore", + "groovy", + "gpg", + "hlsplaylist", + "html", + "http", + "ini", + "javascript", + "jq", + "jsdoc", + "json", + "jsonc", + "just", + "llvm", + "lua", + "luadoc", + "luap", + "make", + "markdown", + "markdown_inline", + "query", + "passwd", + "printf", + "python", + "regex", + "readline", + "requirements", + "rust", + "sql", + "ssh_config", + "strace", + "sxhkdrc", + "tablegen", + "tmux", + "todotxt", + "toml", + "typescript", + "vim", + "vimdoc", + "xcompose", + "xml", + "xresources", + "yaml", + }) + end, + }, + "RRethy/nvim-treesitter-endwise", + { "nvim-treesitter/nvim-treesitter-context", opts = {} }, + { + "JoosepAlviste/nvim-ts-context-commentstring", + config = function() + require("ts_context_commentstring").setup({ + enable_autocmd = false, }) - end + local get_option = vim.filetype.get_option + + vim.filetype.get_option = function(filetype, option) + return option == "commentstring" + and require("ts_context_commentstring.internal").calculate_commentstring() + or get_option(filetype, option) + end + end, }, - "nvim-treesitter/nvim-treesitter-context", } -- cgit v1.2.3-70-g09d2