mirror of
https://github.com/chenasraf/nvim-treesitter.git
synced 2026-05-18 01:39:00 +00:00
modules: move textobj to incremental_selection
As suggested in #37, rename the textobj module to incremental_selection. Also adds a utility function to get the config of a module.
This commit is contained in:
@@ -214,7 +214,7 @@ local config = {
|
||||
return queries.get_query(ft, 'highlights') ~= nil
|
||||
end
|
||||
},
|
||||
textobj = {
|
||||
incremental_selection = {
|
||||
enable = false,
|
||||
disable = {},
|
||||
keymaps = {
|
||||
@@ -403,4 +403,8 @@ function M.available_modules()
|
||||
return vim.tbl_keys(config.modules)
|
||||
end
|
||||
|
||||
function M.get_module(mod)
|
||||
return config.modules[mod]
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@@ -56,10 +56,10 @@ end)
|
||||
function M.attach(bufnr)
|
||||
local buf = bufnr or api.nvim_get_current_buf()
|
||||
|
||||
local config = require'nvim-treesitter.configs'.get_config().textobj
|
||||
local config = require'nvim-treesitter.configs'.get_module('incremental_selection')
|
||||
for funcname, mapping in pairs(config.keymaps) do
|
||||
api.nvim_buf_set_keymap(buf, 'v', mapping,
|
||||
string.format(":lua require'nvim-treesitter.textobj'.%s()<CR>", funcname), { silent = true })
|
||||
string.format(":lua require'nvim-treesitter.incremental_selection'.%s()<CR>", funcname), { silent = true })
|
||||
api.nvim_buf_set_keymap(buf, 'o', mapping,
|
||||
string.format(":normal v%s<CR>", mapping), { silent = true })
|
||||
end
|
||||
@@ -68,7 +68,7 @@ end
|
||||
function M.detach(bufnr)
|
||||
local buf = bufnr or api.nvim_get_current_buf()
|
||||
|
||||
local config = require'nvim-treesitter.configs'.get_config().textobj
|
||||
local config = require'nvim-treesitter.configs'.get_module('incremental_selection')
|
||||
for _, mapping in pairs(config.keymaps) do
|
||||
api.nvim_buf_del_keymap(buf, 'v', mapping)
|
||||
api.nvim_buf_del_keymap(buf, 'o', mapping)
|
||||
Reference in New Issue
Block a user