Skip to content

Commit 0d7c800

Browse files
authored
docs: vim.g.no_plugin_maps to avoid conflicts (#838)
1. `vim.g.no_python_maps` or `vim.g.no_plugin_maps` to avoid conflicts. This actually got me because it seems totally working but actually is broken (like repeatable move etc. won't work) - A better way is to overwrite the buffer mappings, but it will be too difficult to explain in the main docs unless we actually provide a convenience function that helps mapping. 2. `nvim-next` doesn't support main branch of this plugin, thus removed. 3. I think it's unintuitive that "move function" uses `]m` and "select function" uses `af`, `if`. The standard seems to be using `am` and `im` for selecting function as per https://github.com/neovim/neovim/blob/master/runtime/ftplugin/ruby.vim . I know this is just an example, but keeping the main doc following the common convention helps a lot.
1 parent af51903 commit 0d7c800

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

README.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,26 @@ You can install nvim-treesitter-textobjects with your favorite package manager,
1212

1313
### Using a package manager
1414

15-
If you are using [vim-plug](https://github.com/junegunn/vim-plug), put this in your `init.vim` file:
16-
17-
```vim
18-
Plug 'nvim-treesitter/nvim-treesitter-textobjects'
19-
```
20-
2115
If you are using [lazy.nvim](https://github.com/folke/lazy.nvim), add this to your `init.lua` or `plugins.lua`.
2216

2317
```lua
2418
{
2519
"nvim-treesitter/nvim-treesitter-textobjects",
20+
branch = "main",
21+
init = function()
22+
-- Disable entire built-in ftplugin mappings to avoid conflicts.
23+
-- See https://github.com/neovim/neovim/tree/master/runtime/ftplugin for built-in ftplugins.
24+
vim.g.no_plugin_maps = true
25+
26+
-- Or, disable per filetype (add as you like)
27+
-- vim.g.no_python_maps = true
28+
-- vim.g.no_ruby_maps = true
29+
-- vim.g.no_rust_maps = true
30+
-- vim.g.no_go_maps = true
31+
end,
32+
config = function()
33+
-- put your config here
34+
end,
2635
}
2736
```
2837

@@ -64,10 +73,10 @@ require("nvim-treesitter-textobjects").setup {
6473

6574
-- keymaps
6675
-- You can use the capture groups defined in `textobjects.scm`
67-
vim.keymap.set({ "x", "o" }, "af", function()
76+
vim.keymap.set({ "x", "o" }, "am", function()
6877
require "nvim-treesitter-textobjects.select".select_textobject("@function.outer", "textobjects")
6978
end)
70-
vim.keymap.set({ "x", "o" }, "if", function()
79+
vim.keymap.set({ "x", "o" }, "im", function()
7180
require "nvim-treesitter-textobjects.select".select_textobject("@function.inner", "textobjects")
7281
end)
7382
vim.keymap.set({ "x", "o" }, "ac", function()
@@ -198,8 +207,6 @@ vim.keymap.set({ "n", "x", "o" }, "<end>", function()
198207
end)
199208
```
200209

201-
For a similar way of making arbitrary movements repeatable, see [nvim-next](https://github.com/ghostbuster91/nvim-next).
202-
203210
# Overriding or extending textobjects
204211

205212
Textobjects are defined in the `textobjects.scm` files.

0 commit comments

Comments
 (0)