diff options
| author | Steven Sojka <Steven.Sojka@tdameritrade.com> | 2020-08-21 07:49:06 -0500 |
|---|---|---|
| committer | Steven Sojka <steelsojka@gmail.com> | 2020-08-22 06:07:21 -0500 |
| commit | 3fe8bbcf9c238c70ffd7a01982d98981b346984e (patch) | |
| tree | c880c69babac5f45870bc06685d3df14b72760c7 /lua/nvim-treesitter/textobjects | |
| parent | f3a515b3506f7ad6bd2ce88f0e150e32b93cb2dd (diff) | |
fix(modules): do not reattach if already attached
Diffstat (limited to 'lua/nvim-treesitter/textobjects')
| -rw-r--r-- | lua/nvim-treesitter/textobjects/attach.lua | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/lua/nvim-treesitter/textobjects/attach.lua b/lua/nvim-treesitter/textobjects/attach.lua index 22d6b650..c7f44375 100644 --- a/lua/nvim-treesitter/textobjects/attach.lua +++ b/lua/nvim-treesitter/textobjects/attach.lua @@ -6,9 +6,8 @@ local M = {} function M.make_attach(normal_mode_functions, submodule) return function(bufnr, lang) - local buf = bufnr or api.nvim_get_current_buf() local config = configs.get_module("textobjects."..submodule) - local lang = lang or parsers.get_buf_lang(buf) + local lang = lang or parsers.get_buf_lang(bufnr) for _, function_call in pairs(normal_mode_functions) do for mapping, query in pairs(config[function_call] or {}) do @@ -19,7 +18,7 @@ function M.make_attach(normal_mode_functions, submodule) end if query then local cmd = ":lua require'nvim-treesitter.textobjects."..submodule.."'."..function_call.."('"..query.."')<CR>" - api.nvim_buf_set_keymap(buf, "n", mapping, cmd, {silent = true, noremap = true }) + api.nvim_buf_set_keymap(bufnr, "n", mapping, cmd, {silent = true, noremap = true }) end end end @@ -28,7 +27,6 @@ end function M.make_detach(normal_mode_functions, submodule) return function(bufnr) - local buf = bufnr or api.nvim_get_current_buf() local config = configs.get_module("textobjects."..submodule) local lang = parsers.get_buf_lang(bufnr) @@ -39,8 +37,8 @@ function M.make_detach(normal_mode_functions, submodule) query = nil end if query then - api.nvim_buf_del_keymap(buf, "o", mapping) - api.nvim_buf_del_keymap(buf, "v", mapping) + api.nvim_buf_del_keymap(bufnr, "o", mapping) + api.nvim_buf_del_keymap(bufnr, "v", mapping) end end for _, function_call in pairs(normal_mode_functions) do @@ -51,7 +49,7 @@ function M.make_detach(normal_mode_functions, submodule) query = nil end if query then - api.nvim_buf_del_keymap(buf, "n", mapping) + api.nvim_buf_del_keymap(bufnr, "n", mapping) end end end |
