Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabling of highlighting on a particular language prevents text highlights from working #746

Open
jamespinkerton opened this issue Mar 29, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@jamespinkerton
Copy link

Describe the bug
When I disable highlighting in treesitter for a particular language, none of my text movements work.

To Reproduce

Here is my config in lazy nvim:

return {                                                                                                                                                                                                                                               ╭──────────────────────────────────────────────────╮
  { -- Highlight, edit, and navigate code                                                                                                                                                                                                              │  lazy.nvim                             11:40:17 │
    "nvim-treesitter/nvim-treesitter",                                                                                                                                                                                                                 │━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━│
    build = function()                                                                                                                                                                                                                                 │# Config Change Detected. Reloading...            │
      pcall(require("nvim-treesitter.install").update { with_sync = true })                                                                                                                                                                            │                                                  │
    end,                                                                                                                                                                                                                                               │- changed: lua/plugins/nvim_treesitter.lua        │
    dependencies = "nvim-treesitter/nvim-treesitter-textobjects",                                                                                                                                                                                      ╰──────────────────────────────────────────────────╯
    config = function()
      require("nvim-treesitter.configs").setup {
        modules = {},
        sync_install = false,
        auto_install = true,
        ensure_installed = { "python", "c", "cpp", "lua", "rust", "help", "vim" },
        ignore_install = { "help" },
        -- indent = { enable = true },
        indent = { enable = true, disable = { "python" } },
        -- highlight = { enable = true },
        highlight = { enable = true, disable = { "python" } },
        incremental_selection = {
          enable = true,
          keymaps = {
            init_selection = "<c-space>",
            node_incremental = "<c-space>",
            scope_incremental = "<c-s>",
            node_decremental = "<c-backspace>",
          },
        },
        textobjects = {
          select = {
            enable = true,
            lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
            keymaps = {
              -- You can use the capture groups defined in textobjects.scm
              ["aa"] = "@parameter.outer",
              ["ia"] = "@parameter.inner",
              ["af"] = "@function.outer",
              ["if"] = "@function.inner",
              ["ac"] = "@class.outer",
              ["ic"] = "@class.inner",
            },
          },
          move = {
            enable = true,
            set_jumps = true, -- whether to set jumps in the jumplist
            goto_next_start = {
              ["]m"] = "@function.outer",
              ["]]"] = "@class.outer",
            },
            goto_next_end = {
              ["]M"] = "@function.outer",
              ["]["] = "@class.outer",
            },
            goto_previous_start = {
              ["[m"] = "@function.outer",
              ["[["] = "@class.outer",
            },
            goto_previous_end = {
              ["[M"] = "@function.outer",
              ["[]"] = "@class.outer",
            },
          },
          swap = {
            enable = true,
            swap_next = {
              ["<leader>a"] = "@parameter.inner",
            },
            swap_previous = {
              ["<leader>A"] = "@parameter.inner",
            },
          },
        },
      }
    end,
  },
}

Steps to reproduce the behavior:
Open a python file and attempt to select with vif. It wont' work.

Expected behavior
Other actions should work despite highlighting being off.

Output of :checkhealth nvim-treesitter

==============================================================================
nvim-treesitter:                     require("nvim-treesitter.health").check()

Installation
- WARNING tree-sitter executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
- OK node found v22.13.0 (only needed for :TSInstallFromGrammar)
- OK git executable found.
- OK /mnt/disks/condaman/mamba/bin/x86_64-conda-linux-gnu-cc executable found. Selected from { "/mnt/disks/condaman/mamba/bin/x86_64-conda-linux-gnu-cc", "cc", "gcc", "clang", "cl", "zig" }
  Version: x86_64-conda-linux-gnu-cc (conda-forge gcc 14.2.0-2) 14.2.0
- OK Neovim was compiled with tree-sitter runtime ABI version 15 (required >=13). Parsers must be compatible with runtime ABI.

OS Info:
{
  machine = "x86_64",
  release = "6.1.0-32-cloud-amd64",
  sysname = "Linux",
  version = "#1 SMP PREEMPT_DYNAMIC Debian 6.1.129-1 (2025-03-06)"
}

Parser/Features         H L F I J
  - c                   ✓ ✓ ✓ ✓ ✓
  - cpp                 ✓ ✓ ✓ ✓ ✓
  - go                  ✓ ✓ ✓ ✓ ✓
  - lua                 ✓ ✓ ✓ ✓ ✓
  - markdown            ✓ . ✓ ✓ ✓
  - markdown_inline     ✓ . . . ✓
  - python              ✓ ✓ ✓ ✓ ✓
  - query               ✓ ✓ ✓ ✓ ✓
  - rust                ✓ ✓ ✓ ✓ ✓
  - typescript          ✓ ✓ ✓ ✓ ✓
  - vim                 ✓ ✓ ✓ . ✓
  - vimdoc              ✓ . . . ✓

  Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
         +) multiple parsers found, only one will be used
         x) errors found in the query, try to run :TSUpdate {lang}

Output of nvim --version

NVIM v0.11.0
Build type: Release
LuaJIT 2.1.1741730670
Run "nvim -V1 -v" for more info
@jamespinkerton jamespinkerton added the bug Something isn't working label Mar 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant