diff --git a/.config/nvim/lua/plugin/cmp.lua b/.config/nvim/lua/plugin/cmp.lua index e53c879..c87d9b5 100644 --- a/.config/nvim/lua/plugin/cmp.lua +++ b/.config/nvim/lua/plugin/cmp.lua @@ -18,33 +18,7 @@ end cmp.event:on( 'confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } })) -- Custom item icons -local icons = { - Class = "", - Color = "", - Constant = "µ", - Constructor = "", - Enum = "", - EnumMember = "", - Event = "", - Field = "", - File = "", - Folder = "", - Function = "", - Keyword = "", - Interface = "", - Method = "", - Module = "", - Operator = "", - Property = "", - Reference = "", - Snippet = "", - Struct = "", - Text = "", - TypeParameter = "", - Unit = "", - Value = "", - Variable = "", -} +local icons = { } cmp.setup { completion = { @@ -62,8 +36,6 @@ cmp.setup { }, formatting = { format = function(entry, vim_item) - vim_item.kind = string.format("%s %s", icons[vim_item.kind], - vim_item.kind) vim_item.menu = ({ nvim_lsp = "[lsp]", nvim_lua = "[nvim]", diff --git a/.config/nvim/lua/plugin/packer.lua b/.config/nvim/lua/plugin/packer.lua index 8c53feb..781d35e 100644 --- a/.config/nvim/lua/plugin/packer.lua +++ b/.config/nvim/lua/plugin/packer.lua @@ -54,6 +54,11 @@ return require("packer").startup(function() config = function() require("plugin.treesitter") end } + use { -- Additional text objects via treesitter + 'nvim-treesitter/nvim-treesitter-textobjects', + after = 'nvim-treesitter', + } + -- telescope use { "nvim-telescope/telescope.nvim", diff --git a/.config/nvim/lua/plugin/treesitter.lua b/.config/nvim/lua/plugin/treesitter.lua index 2b7f3a3..314c6f8 100644 --- a/.config/nvim/lua/plugin/treesitter.lua +++ b/.config/nvim/lua/plugin/treesitter.lua @@ -4,12 +4,112 @@ -- Description : treesitter config file require("nvim-treesitter.configs").setup { - ensure_installed = { "c", "lua", "python", "rust", "bash" }, - ignore_install = { "javascript" }, + ensure_installed = { "c", "lua", "rust", "bash", "vim" }, highlight = { enable = true, }, indent = { enable = true, }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", + node_incremental = "", + scope_incremental = "", + node_decremental = "", + }, + }, + textobjects = { + select = { + enable = true, + lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim + keymaps = { + -- use the capture groups defined in textobjects.scm + ["ap"] = { + query = "@parameter.outer", + desc = "Select parameter region" + }, + ["ip"] = { + query = "@parameter.inner", + desc = "Select inner part of a parameter region" + }, + ["af"] = { + query = "@function.outer", + desc = "Select a function block" + }, + ["if"] = { + query = "@function.inner", + desc = "Select inner part of a function" + }, + ["ac"] = { + query = "@class.outer", + desc = "Select a class block" + }, + ["ic"] = { + query = "@class.inner", + desc = "Select inner part of a class" + }, + }, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + ["]m"] = { + query = "@function.outer", + desc = "Jump to next function", + }, + ["])"] = { + query = "@class.outer", + desc = "Jump to next class", + }, + }, + goto_next_end = { + ["]M"] = { + query = "@function.outer", + desc = "Jump after next function", + }, + ["]]"] = { + query = "@class.outer", + desc = "Jump after next class", + }, + }, + goto_previous_start = { + ["[m"] = { + query = "@function.outer", + desc = "Jump to previous function", + }, + ["[)"] = { + query = "@class.outer", + desc = "Jump to previous class", + }, + }, + goto_previous_end = { + ["[M"] = { + query = "@function.outer", + desc = "Jump after previous function", + }, + ["[]"] = { + query = "@class.outer", + desc = "Jump after previous class", + }, + }, + }, + swap = { + enable = true, + swap_next = { + ["a"] = { + query = "@parameter.inner", + desc = "Swap with next parameter", + }, + }, + swap_previous = { + ["A"] = { + query = "@parameter.inner", + desc = "Swap with previous parameter", + }, + }, + }, + }, }