Code Monkey home page Code Monkey logo

Comments (5)

theHamsta avatar theHamsta commented on September 15, 2024 1

Probably it will not work for buffer number 0. Can you try to get the current buffer number with nvim_get_current_buf or you use nil for buf. When the command works then the function should work too

from nvim-treesitter-textobjects.

stsewd avatar stsewd commented on September 15, 2024 1

Can you share your config? This works for me

require'nvim-treesitter.configs'.setup {
  ensure_installed = "all",
  textobjects = {
    select = {
      enable = true,
      keymaps = {
        ["af"] = "@function.outer",
        ["if"] = "@function.inner",
        ["ac"] = "@class.outer",
        ["ic"] = "@class.inner",
        ["ib"] = "@block.inner",
        ["ab"] = "@block.outer",
      },
    },
  },
}

Also, you can check :map if

from nvim-treesitter-textobjects.

muarifer avatar muarifer commented on September 15, 2024 1

Can you share your config? This works for me

require'nvim-treesitter.configs'.setup {
  ensure_installed = "all",
  textobjects = {
    select = {
      enable = true,
      keymaps = {
        ["af"] = "@function.outer",
        ["if"] = "@function.inner",
        ["ac"] = "@class.outer",
        ["ic"] = "@class.inner",
        ["ib"] = "@block.inner",
        ["ab"] = "@block.outer",
      },
    },
  },
}

Also, you can check :map if

With this config, :map if says "No mapping found"
but Highlight, fold, indent and refactor works.

Here my sample config:

lua <<EOF
require'nvim-treesitter.configs'.setup {
	ensure_installed = "maintained",
	highlight= {
		enable = true,
	},
	indent = {
		enable = true,
	},
	refactor = {
		highlight_definitions = { enable = true },
		navigation = {
			enable = true,
			keymaps = {
				goto_definiton = "gnd",
				list_definitions = "gnD",
				list_definitions_toc = "gO",
				goto_next_usage = "<a-*>",
				goto_previous_usage = "<a-#>",
			},
		},
	},
	textobjects = {
    select = {
      enable = true,
      keymaps = {
        ["af"] = "@function.outer",
        ["if"] = "@function.inner",
        ["ac"] = "@class.outer",
        ["ic"] = "@class.inner",
        ["ib"] = "@block.inner",
        ["ab"] = "@block.outer",
      },
    },
  },
}
EOF

Edit:
It works.
:map shows only in supported filetype.
Also, after change keymaps, restart nvim and it'll works.

from nvim-treesitter-textobjects.

vpeopleonatank avatar vpeopleonatank commented on September 15, 2024

Can you share your config? This works for me

require'nvim-treesitter.configs'.setup {
  ensure_installed = "all",
  textobjects = {
    select = {
      enable = true,
      keymaps = {
        ["af"] = "@function.outer",
        ["if"] = "@function.inner",
        ["ac"] = "@class.outer",
        ["ic"] = "@class.inner",
        ["ib"] = "@block.inner",
        ["ab"] = "@block.outer",
      },
    },
  },
}

Also, you can check :map if

With this config, :map if says "No mapping found"
but Highlight, fold, indent and refactor works.

Here my sample config:

lua <<EOF
require'nvim-treesitter.configs'.setup {
	ensure_installed = "maintained",
	highlight= {
		enable = true,
	},
	indent = {
		enable = true,
	},
	refactor = {
		highlight_definitions = { enable = true },
		navigation = {
			enable = true,
			keymaps = {
				goto_definiton = "gnd",
				list_definitions = "gnD",
				list_definitions_toc = "gO",
				goto_next_usage = "<a-*>",
				goto_previous_usage = "<a-#>",
			},
		},
	},
	textobjects = {
    select = {
      enable = true,
      keymaps = {
        ["af"] = "@function.outer",
        ["if"] = "@function.inner",
        ["ac"] = "@class.outer",
        ["ic"] = "@class.inner",
        ["ib"] = "@block.inner",
        ["ab"] = "@block.outer",
      },
    },
  },
}
EOF

Edit:
It works.
:map shows only in supported filetype.
Also, after change keymaps, restart nvim and it'll works.

Probably I 'm in your case. How do you change keymaps? My :map if return no mapping found. How do you remap

from nvim-treesitter-textobjects.

vpeopleonatank avatar vpeopleonatank commented on September 15, 2024

After remove duplicated line of code, my issue is solved.

from nvim-treesitter-textobjects.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.