diff --git a/lua/keymap.lua b/lua/keymap.lua index 8d1886d..91f361d 100644 --- a/lua/keymap.lua +++ b/lua/keymap.lua @@ -258,6 +258,7 @@ vim.keymap.set('n', ']', 'cnext', { desc = 'Next item in quickf vim.keymap.set('n', '[', 'cprevious', { desc = 'Previous item in quickfix list' }) vim.keymap.set('n', 'gd', 'Telescope lsp_definitions', { desc = 'Go to definition' }) + local function open_test() require('neotest').summary.open() require('neotest').output_panel.open() diff --git a/lua/plugins/todo-comments.lua b/lua/plugins/todo-comments.lua index eea12c8..51f02bc 100644 --- a/lua/plugins/todo-comments.lua +++ b/lua/plugins/todo-comments.lua @@ -1,7 +1,7 @@ -- Highlight todo, notes, etc in comments return { - "folke/todo-comments.nvim", - event = "VimEnter", - dependencies = { "nvim-lua/plenary.nvim" }, - opts = { signs = false }, + 'folke/todo-comments.nvim', + event = 'VimEnter', + dependencies = { 'nvim-lua/plenary.nvim' }, + opts = { signs = false }, } diff --git a/lua/plugins/treesitter-textobjects.lua b/lua/plugins/treesitter-textobjects.lua new file mode 100644 index 0000000..6e58f32 --- /dev/null +++ b/lua/plugins/treesitter-textobjects.lua @@ -0,0 +1,86 @@ +return { + 'nvim-treesitter/nvim-treesitter-textobjects', + dependencies = { + 'nvim-treesitter/nvim-treesitter', + }, + lazy = false, + enabled = true, + 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, + 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', + ['ay'] = '@conditional.outer', + ['iy'] = '@conditional.inner', + ['aj'] = '@loop.outer', + ['ij'] = '@loop.inner', + ['is'] = '@statement.inner', + ['as'] = '@statement.outer', + ['ac'] = '@comment.outer', + ['ic'] = '@comment.inner', + ['ap'] = '@comment.parameter', + ['ip'] = '@comment.parameter', + }, + 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', + }, + }, + }, + }, + } + end, +}