Giter VIP home page Giter VIP logo

nvim-treesitter / nvim-treesitter Goto Github PK

View Code? Open in Web Editor NEW
9.6K 48.0 812.0 6.59 MB

Nvim Treesitter configurations and abstraction layer

License: Apache License 2.0

Lua 23.14% Scheme 73.00% Shell 0.18% C 0.30% C++ 0.18% Python 0.44% Rust 0.19% TypeScript 0.06% Cuda 0.01% Pascal 0.05% Hack 0.31% JavaScript 0.20% Makefile 0.10% GDScript 0.01% PHP 0.29% R 0.12% Go 0.10% Gleam 0.76% Java 0.06% Solidity 0.49%
neovim tree-sitter nvim-treesitter hacktoberfest

nvim-treesitter's Introduction

nvim-treesitter

Matrix Chat Linting and Style Syntax files

Logo

Treesitter configurations and abstraction layer for Neovim.

Logo by @steelsojka

The goal of nvim-treesitter is both to provide a simple and easy way to use the interface for tree-sitter in Neovim and to provide some basic functionality such as highlighting based on it:

example-cpp

Traditional highlighting (left) vs Treesitter-based highlighting (right). More examples can be found in our gallery.

Warning: Treesitter and nvim-treesitter highlighting are an experimental feature of Neovim. Please consider the experience with this plug-in as experimental until Tree-Sitter support in Neovim is stable! We recommend using the nightly builds of Neovim if possible. You can find the current roadmap here. The roadmap and all features of this plugin are open to change, and any suggestion will be highly appreciated!

Nvim-treesitter is based on three interlocking features: language parsers, queries, and modules, where modules provide features – e.g., highlighting – based on queries for syntax objects extracted from a given buffer by language parsers. Users will generally only need to interact with parsers and modules as explained in the next section. For more detailed information on setting these up, see "Advanced setup".


Table of contents


Quickstart

Requirements

Installation

You can install nvim-treesitter with your favorite package manager (or using the native package feature of vim, see :h packages).

NOTE: This plugin is only guaranteed to work with specific versions of language parsers (as specified in the lockfile.json). When upgrading the plugin, you must make sure that all installed parsers are updated to the latest version via :TSUpdate. It is strongly recommended to automate this; e.g., if you are using vim-plug, put this in your init.vim file:

Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}

For other plugin managers such as packer.nvim, see this Installation page from the wiki (Note that this page is community maintained).

Language parsers

Treesitter uses a different parser for every language, which needs to be generated via tree-sitter-cli from a grammar.js file, then compiled to a .so library that needs to be placed in neovim's runtimepath (typically under parser/{language}.so). To simplify this, nvim-treesitter provides commands to automate this process. If the language is already supported by nvim-treesitter, you can install it with

:TSInstall <language_to_install>

This command supports tab expansion. You can also get a list of all available languages and their installation status with :TSInstallInfo. Parsers not on this list can be added manually by following the steps described under "Adding parsers" below.

To make sure a parser is at the latest compatible version (as specified in nvim-treesitter's lockfile.json), use :TSUpdate {language}. To update all parsers unconditionally, use :TSUpdate all or just :TSUpdate.

Modules

Each module provides a distinct tree-sitter-based feature such as highlighting, indentation, or folding; see :h nvim-treesitter-modules or "Available modules" below for a list of modules and their options.

Following examples assume that you are configuring neovim with lua. If you are using vimscript, see :h lua-heredoc. All modules are disabled by default and need to be activated explicitly in your init.lua, e.g., via

require'nvim-treesitter.configs'.setup {
  -- A list of parser names, or "all" (the five listed parsers should always be installed)
  ensure_installed = { "c", "lua", "vim", "vimdoc", "query" },

  -- Install parsers synchronously (only applied to `ensure_installed`)
  sync_install = false,

  -- Automatically install missing parsers when entering buffer
  -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
  auto_install = true,

  -- List of parsers to ignore installing (or "all")
  ignore_install = { "javascript" },

  ---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
  -- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!

  highlight = {
    enable = true,

    -- NOTE: these are the names of the parsers and not the filetype. (for example if you want to
    -- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is
    -- the name of the parser)
    -- list of language that will be disabled
    disable = { "c", "rust" },
    -- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files
    disable = function(lang, buf)
        local max_filesize = 100 * 1024 -- 100 KB
        local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
        if ok and stats and stats.size > max_filesize then
            return true
        end
    end,

    -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
    -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
    -- Using this option may slow down your editor, and you may see some duplicate highlights.
    -- Instead of true it can also be a list of languages
    additional_vim_regex_highlighting = false,
  },
}

Each module can also be enabled or disabled interactively through the following commands:

:TSBufEnable {module} " enable module on current buffer
:TSBufDisable {module} " disable module on current buffer
:TSEnable {module} [{ft}] " enable module on every buffer. If filetype is specified, enable only for this filetype.
:TSDisable {module} [{ft}] " disable module on every buffer. If filetype is specified, disable only for this filetype.
:TSModuleInfo [{module}] " list information about modules state for each filetype

Check :h nvim-treesitter-commands for a list of all available commands. It may be necessary to reload the buffer (e.g., via :e) after enabling a module interactively.

Supported languages

For nvim-treesitter to support a specific feature for a specific language requires both a parser for that language and an appropriate language-specific query file for that feature.

The following is a list of languages for which a parser can be installed through :TSInstall; a checked box means that nvim-treesitter also contains queries at least for the highlight module.

Experimental parsers are parsers that have a maintainer but are not stable enough for daily use yet.

We are looking for maintainers to add more parsers and to write query files for their languages. Check our tracking issue for open language requests.

  • ada (maintained by @briot)
  • agda (maintained by @Decodetalkers)
  • angular (experimental, maintained by @dlvandenberg)
  • apex (maintained by @aheber)
  • arduino (maintained by @ObserverOfTime)
  • asm (maintained by @RubixDev)
  • astro (maintained by @virchau13)
  • authzed (maintained by @mattpolzin)
  • awk
  • bash (maintained by @TravonteD)
  • bass (maintained by @amaanq)
  • beancount (maintained by @polarmutex)
  • bibtex (maintained by @theHamsta, @clason)
  • bicep (maintained by @amaanq)
  • bitbake (maintained by @amaanq)
  • blueprint (experimental, maintained by @gabmus)
  • c (maintained by @amaanq)
  • c_sharp (maintained by @Luxed)
  • cairo (maintained by @amaanq)
  • capnp (maintained by @amaanq)
  • chatito (maintained by @ObserverOfTime)
  • clojure (maintained by @NoahTheDuke)
  • cmake (maintained by @uyha)
  • comment (maintained by @stsewd)
  • commonlisp (maintained by @theHamsta)
  • cooklang (maintained by @addcninblue)
  • corn (maintained by @jakestanger)
  • cpon (maintained by @amaanq)
  • cpp (maintained by @theHamsta)
  • css (maintained by @TravonteD)
  • csv (maintained by @amaanq)
  • cuda (maintained by @theHamsta)
  • cue (maintained by @amaanq)
  • d (maintained by @amaanq)
  • dart (maintained by @akinsho)
  • devicetree (maintained by @jedrzejboczar)
  • dhall (maintained by @amaanq)
  • diff (maintained by @gbprod)
  • disassembly (maintained by @ColinKennedy)
  • djot (maintained by @NoahTheDuke)
  • dockerfile (maintained by @camdencheek)
  • dot (maintained by @rydesun)
  • doxygen (maintained by @amaanq)
  • dtd (maintained by @ObserverOfTime)
  • earthfile (maintained by @glehmann)
  • ebnf (experimental, maintained by @RubixDev)
  • eds (maintained by @uyha)
  • eex (maintained by @connorlay)
  • elixir (maintained by @connorlay)
  • elm (maintained by @zweimach)
  • elsa (maintained by @glapa-grossklag, @amaanq)
  • elvish (maintained by @elves)
  • embedded_template
  • erlang (maintained by @filmor)
  • facility (maintained by @bryankenote)
  • faust (maintained by @khiner)
  • fennel (maintained by @alexmozaidze)
  • fidl (maintained by @chaopeng)
  • firrtl (maintained by @amaanq)
  • fish (maintained by @ram02z)
  • foam (experimental, maintained by @FoamScience)
  • forth (maintained by @amaanq)
  • fortran (maintained by @amaanq)
  • fsh (maintained by @mgramigna)
  • func (maintained by @amaanq)
  • fusion (maintained by @jirgn)
  • Godot (gdscript) (maintained by @PrestonKnopp)
  • gdshader (maintained by @godofavacyn)
  • git_config (maintained by @amaanq)
  • git_rebase (maintained by @gbprod)
  • gitattributes (maintained by @ObserverOfTime)
  • gitcommit (maintained by @gbprod)
  • gitignore (maintained by @theHamsta)
  • gleam (maintained by @amaanq)
  • Glimmer and Ember (maintained by @NullVoxPopuli)
  • glsl (maintained by @theHamsta)
  • GN (Generate Ninja) (maintained by @amaanq)
  • gnuplot (maintained by @dpezto)
  • go (maintained by @theHamsta, @WinWisely268)
  • Godot Resources (gdresource) (maintained by @pierpo)
  • gomod (maintained by @camdencheek)
  • gosum (maintained by @amaanq)
  • gotmpl (maintained by @qvalentin)
  • gowork (maintained by @omertuc)
  • gpg (maintained by @ObserverOfTime)
  • graphql (maintained by @bkegley)
  • groovy (maintained by @murtaza64)
  • gstlaunch (maintained by @theHamsta)
  • hack
  • hare (maintained by @amaanq)
  • haskell (maintained by @mrcjkb)
  • haskell_persistent (maintained by @lykahb)
  • hcl (maintained by @MichaHoffmann)
  • heex (maintained by @connorlay)
  • helm (maintained by @qvalentin)
  • hjson (maintained by @winston0410)
  • hlsl (maintained by @theHamsta)
  • hlsplaylist (maintained by @Freed-Wu)
  • hocon (maintained by @antosha417)
  • hoon (experimental, maintained by @urbit-pilled)
  • html (maintained by @TravonteD)
  • htmldjango (experimental, maintained by @ObserverOfTime)
  • http (maintained by @amaanq, @NTBBloodbath)
  • hurl (maintained by @pfeiferj)
  • hyprlang (maintained by @luckasRanarison)
  • idl (maintained by @cathaysa)
  • ini (experimental, maintained by @theHamsta)
  • inko (maintained by @yorickpeterse)
  • ispc (maintained by @fab4100)
  • janet_simple (maintained by @sogaiu)
  • java (maintained by @p00f)
  • javascript (maintained by @steelsojka)
  • jq (maintained by @ObserverOfTime)
  • jsdoc (maintained by @steelsojka)
  • json (maintained by @steelsojka)
  • json5 (maintained by @Joakker)
  • JSON with comments (maintained by @WhyNotHugo)
  • jsonnet (maintained by @nawordar)
  • julia (maintained by @theHamsta)
  • just (maintained by @Hubro)
  • kconfig (maintained by @amaanq)
  • kdl (maintained by @amaanq)
  • kotlin (maintained by @SalBakraa)
  • koto (maintained by @irh)
  • kusto (maintained by @Willem-J-an)
  • lalrpop (maintained by @traxys)
  • latex (maintained by @theHamsta, @clason)
  • ledger (maintained by @cbarrete)
  • leo (maintained by @r001)
  • linkerscript (maintained by @amaanq)
  • liquid (maintained by @hankthetank27)
  • liquidsoap (maintained by @toots)
  • llvm (maintained by @benwilliamgraham)
  • lua (maintained by @muniftanjim)
  • luadoc (maintained by @amaanq)
  • lua patterns (maintained by @amaanq)
  • luau (maintained by @amaanq)
  • m68k (maintained by @grahambates)
  • make (maintained by @lewis6991)
  • markdown (basic highlighting) (experimental, maintained by @MDeiml)
  • markdown_inline (needed for full highlighting) (experimental, maintained by @MDeiml)
  • matlab (maintained by @acristoffers)
  • menhir (maintained by @Kerl13)
  • mermaid (experimental)
  • meson (maintained by @Decodetalkers)
  • mlir (experimental, maintained by @artagnon)
  • muttrc (maintained by @Freed-Wu)
  • nasm (maintained by @ObserverOfTime)
  • nickel
  • nim (maintained by @aMOPel)
  • nim_format_string (maintained by @aMOPel)
  • ninja (maintained by @alemuller)
  • nix (maintained by @leo60228)
  • norg (maintained by @JoeyGrajciar, @vhyrro)
  • nqc (maintained by @amaanq)
  • objc (maintained by @amaanq)
  • objdump (maintained by @ColinKennedy)
  • ocaml (maintained by @undu)
  • ocaml_interface (maintained by @undu)
  • ocamllex (maintained by @undu)
  • odin (maintained by @amaanq)
  • org
  • pascal (maintained by @Isopod)
  • passwd (maintained by @amaanq)
  • pem (maintained by @ObserverOfTime)
  • perl (maintained by @RabbiVeesh, @LeoNerd)
  • php (maintained by @tk-shirasaka)
  • php_only (maintained by @tk-shirasaka)
  • phpdoc (experimental, maintained by @mikehaertl)
  • pioasm (maintained by @leo60228)
  • po (maintained by @amaanq)
  • pod (maintained by @RabbiVeesh, @LeoNerd)
  • Path of Exile item filter (experimental, maintained by @ObserverOfTime)
  • pony (maintained by @amaanq, @mfelsche)
  • printf (maintained by @ObserverOfTime)
  • prisma (maintained by @elianiva)
  • promql (maintained by @MichaHoffmann)
  • properties (maintained by @ObserverOfTime)
  • proto (maintained by @treywood)
  • prql (maintained by @matthias-Q)
  • psv (maintained by @amaanq)
  • pug (experimental, maintained by @zealot128)
  • puppet (maintained by @amaanq)
  • purescript (maintained by @postsolar)
  • PyPA manifest (maintained by @ObserverOfTime)
  • python (maintained by @stsewd, @theHamsta)
  • ql (maintained by @pwntester)
  • qmldir (maintained by @amaanq)
  • qmljs (maintained by @Decodetalkers)
  • Tree-Sitter query language (maintained by @steelsojka)
  • r (maintained by @echasnovski)
  • racket
  • rasi (maintained by @Fymyte)
  • rbs (maintained by @joker1007)
  • re2c (maintained by @amaanq)
  • readline (maintained by @ribru17)
  • regex (maintained by @theHamsta)
  • rego (maintained by @FallenAngel97)
  • pip requirements (maintained by @ObserverOfTime)
  • rnoweb (maintained by @bamonroe)
  • robot (maintained by @Hubro)
  • roc (maintained by @nat-418)
  • ron (maintained by @amaanq)
  • rst (maintained by @stsewd)
  • ruby (maintained by @TravonteD)
  • rust (maintained by @amaanq)
  • scala (maintained by @stevanmilic)
  • scfg (maintained by @WhyNotHugo)
  • scheme
  • scss (maintained by @elianiva)
  • slang (experimental, maintained by @theHamsta)
  • slint (maintained by @hunger)
  • smali (maintained by @amaanq)
  • smithy (maintained by @amaanq, @keynmol)
  • snakemake (experimental)
  • solidity (maintained by @amaanq)
  • soql (maintained by @aheber)
  • sosl (maintained by @aheber)
  • sourcepawn (maintained by @Sarrus1)
  • sparql (maintained by @BonaBeavis)
  • sql (maintained by @derekstride)
  • squirrel (maintained by @amaanq)
  • ssh_config (maintained by @ObserverOfTime)
  • starlark (maintained by @amaanq)
  • strace (maintained by @amaanq)
  • styled (maintained by @mskelton)
  • supercollider (maintained by @madskjeldgaard)
  • surface (maintained by @connorlay)
  • svelte (maintained by @amaanq)
  • swift (maintained by @alex-pinkus)
  • sxhkdrc (maintained by @RaafatTurki)
  • systemtap (maintained by @ok-ryoko)
  • t32 (maintained by @xasc)
  • tablegen (maintained by @amaanq)
  • tact (maintained by @novusnota)
  • tcl (maintained by @lewis6991)
  • teal (maintained by @euclidianAce)
  • templ (maintained by @vrischmann)
  • terraform (maintained by @MichaHoffmann)
  • textproto (maintained by @Porter)
  • thrift (maintained by @amaanq, @duskmoon314)
  • tiger (maintained by @ambroisie)
  • tlaplus (maintained by @ahelwer, @susliko)
  • tmux (maintained by @Freed-Wu)
  • todotxt (experimental, maintained by @arnarg)
  • toml (maintained by @tk-shirasaka)
  • tsv (maintained by @amaanq)
  • tsx (maintained by @steelsojka)
  • turtle (maintained by @BonaBeavis)
  • twig (maintained by @gbprod)
  • typescript (maintained by @steelsojka)
  • typoscript (maintained by @Teddytrombone)
  • typst (maintained by @uben0, @RaafatTurki)
  • udev (maintained by @ObserverOfTime)
  • ungrammar (maintained by @Philipp-M, @amaanq)
  • unison (maintained by @tapegram)
  • usd (maintained by @ColinKennedy)
  • uxn tal (maintained by @amaanq)
  • v (maintained by @kkharji, @amaanq)
  • vala (maintained by @Prince781)
  • vento (maintained by @wrapperup, @oscarotero)
  • verilog (maintained by @zegervdv)
  • vhs (maintained by @caarlos0)
  • vim (maintained by @clason)
  • vimdoc (maintained by @clason)
  • vue (maintained by @WhyNotHugo, @lucario387)
  • wgsl (maintained by @szebniok)
  • wgsl_bevy (maintained by @theHamsta)
  • wing (maintained by @gshpychka, @MarkMcCulloh)
  • wit (maintained by @liamwh)
  • xcompose (maintained by @ObserverOfTime)
  • xml (maintained by @ObserverOfTime)
  • yaml (maintained by @amaanq)
  • yang (maintained by @Hubro)
  • yuck (maintained by @Philipp-M, @amaanq)
  • zathurarc (maintained by @Freed-Wu)
  • zig (maintained by @maxxnino)

For related information on the supported languages, including related plugins, see this wiki page.

Available modules

Modules provide the top-level features of nvim-treesitter. The following is a list of modules included in nvim-treesitter and their configuration via init.lua (where multiple modules can be combined in a single call to setup). Note that not all modules work for all languages (depending on the queries available for them). Additional modules can be provided as external plugins.

Highlight

Consistent syntax highlighting.

require'nvim-treesitter.configs'.setup {
  highlight = {
    enable = true,
    -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
    -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
    -- Using this option may slow down your editor, and you may see some duplicate highlights.
    -- Instead of true it can also be a list of languages
    additional_vim_regex_highlighting = false,
  },
}

To customize the syntax highlighting of a capture, simply define or link a highlight group of the same name:

-- Highlight the @foo.bar capture group with the "Identifier" highlight group
vim.api.nvim_set_hl(0, "@foo.bar", { link = "Identifier" })

For a language-specific highlight, append the name of the language:

-- Highlight @foo.bar as "Identifier" only in Lua files
vim.api.nvim_set_hl(0, "@foo.bar.lua", { link = "Identifier" })

See :h treesitter-highlight-groups for details.

Incremental selection

Incremental selection based on the named nodes from the grammar.

require'nvim-treesitter.configs'.setup {
  incremental_selection = {
    enable = true,
    keymaps = {
      init_selection = "gnn", -- set to `false` to disable one of the mappings
      node_incremental = "grn",
      scope_incremental = "grc",
      node_decremental = "grm",
    },
  },
}

Indentation

Indentation based on treesitter for the = operator. NOTE: This is an experimental feature.

require'nvim-treesitter.configs'.setup {
  indent = {
    enable = true
  }
}

Folding

Tree-sitter based folding. (Technically not a module because it's per windows and not per buffer.)

set foldmethod=expr
set foldexpr=nvim_treesitter#foldexpr()
set nofoldenable                     " Disable folding at startup.

This will respect your foldminlines and foldnestmax settings.

Advanced setup

Changing the parser install directory

If you want to install the parsers to a custom directory you can specify this directory with parser_install_dir option in that is passed to setup. nvim-treesitter will then install the parser files into this directory.

This directory must be writeable and must be explicitly added to the runtimepath. For example:

  vim.opt.runtimepath:append("/some/path/to/store/parsers")

  require'nvim-treesitter.configs'.setup {
    parser_install_dir = "/some/path/to/store/parsers",

    ...

  }

If this option is not included in the setup options, or is explicitly set to nil then the default install directories will be used. If this value is set the default directories will be ignored.

Bear in mind that any parser installed into a parser folder on the runtime path will still be considered installed. (For example if "~/.local/share/nvim/site/parser/c.so" exists then the "c" parser will be considered installed, even though it is not in parser_install_dir)

The default paths are:

  1. first the package folder. Where nvim-treesitter is installed.
  2. second the site directory. This is the "site" subdirectory of stdpath("data").

Adding parsers

If you have a parser that is not on the list of supported languages (either as a repository on Github or in a local directory), you can add it manually for use by nvim-treesitter as follows:

  1. Clone the repository or create a new project in, say, ~/projects/tree-sitter-zimbu. Make sure that the tree-sitter-cli executable is installed and in your path; see https://tree-sitter.github.io/tree-sitter/creating-parsers#installation for installation instructions.
  2. Run tree-sitter generate in this directory (followed by tree-sitter test for good measure).
  3. Add the following snippet to your init.lua:
local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
parser_config.zimbu = {
  install_info = {
    url = "~/projects/tree-sitter-zimbu", -- local path or git repo
    files = {"src/parser.c"}, -- note that some parsers also require src/scanner.c or src/scanner.cc
    -- optional entries:
    branch = "main", -- default branch in case of git repo if different from master
    generate_requires_npm = false, -- if stand-alone parser without npm dependencies
    requires_generate_from_grammar = false, -- if folder contains pre-generated src/parser.c
  },
  filetype = "zu", -- if filetype does not match the parser name
}

If you wish to set a specific parser for a filetype, you should use vim.treesitter.language.register():

vim.treesitter.language.register('python', 'someft')  -- the someft filetype will use the python parser and queries.

Note this requires Nvim v0.9.

  1. Start nvim and :TSInstall zimbu.

You can also skip step 2 and use :TSInstallFromGrammar zimbu to install directly from a grammar.js in the top-level directory specified by url. Once the parser is installed, you can update it (from the latest revision of the main branch if url is a Github repository) with :TSUpdate zimbu.

Note that neither :TSInstall nor :TSInstallFromGrammar copy query files from the grammar repository. If you want your installed grammar to be useful, you must manually add query files to your local nvim-treesitter installation. Note also that module functionality is only triggered if your language's filetype is correctly identified. If Neovim does not detect your language's filetype by default, you can use Neovim's vim.filetype.add() to add a custom detection rule.

If you use a git repository for your parser and want to use a specific version, you can set the revision key in the install_info table for you parser config.

Adding queries

Queries are what nvim-treesitter uses to extract information from the syntax tree; they are located in the queries/{language}/* runtime directories (see :h rtp), like the queries folder of this plugin, e.g. queries/{language}/{locals,highlights,textobjects}.scm. Other modules may require additional queries such as folding.scm. You can find a list of all supported capture names in CONTRIBUTING.md.

All queries found in the runtime directories will be combined. By convention, if you want to write a query, use the queries/ directory, but if you want to extend a query use the after/queries/ directory.

If you want to completely override a query, you can use :h set_query(). For example, to override the injections queries from c with your own:

require("vim.treesitter.query").set_query("c", "injections", "(comment) @comment")

Note: when using set_query, all queries in the runtime directories will be ignored.

Adding modules

If you wish you write your own module, you need to support

  • tree-sitter language detection support;
  • attaching and detaching to buffers;
  • all nvim-treesitter commands.

At the top level, you can use the define_modules function to define one or more modules or module groups:

require'nvim-treesitter'.define_modules {
  my_cool_plugin = {
    attach = function(bufnr, lang)
      -- Do cool stuff here
    end,
    detach = function(bufnr)
      -- Undo cool stuff here
    end,
    is_supported = function(lang)
      -- Check if the language is supported
    end
  }
}

with the following properties:

  • module_path specifies a require path (string) that exports a module with an attach and detach function. This is not required if the functions are on this definition.
  • enable determines if the module is enabled by default. This is usually overridden by the user.
  • disable takes a list of languages that this module is disabled for. This is usually overridden by the user.
  • is_supported takes a function that takes a language and determines if this module supports that language.
  • attach takes a function that attaches to a buffer. This is required if module_path is not provided.
  • detach takes a function that detaches from a buffer. This is required if module_path is not provided.

Extra features

Statusline indicator

echo nvim_treesitter#statusline(90)  " 90 can be any length
module->expression_statement->call->identifier

Utilities

You can get some utility functions with

local ts_utils = require 'nvim-treesitter.ts_utils'

Check :h nvim-treesitter-utils for more information.

Troubleshooting

Before doing anything, make sure you have the latest version of this plugin and run :checkhealth nvim-treesitter. It can also help to update the parsers via :TSUpdate.

Feature X does not work for {language}...

First, check the health#nvim_treesitter#check and the health#treesitter#check sections of :checkhealth for any warning. If there is one, it's highly likely that this is the cause of the problem.

Next check the ## Parser/Features subsection of the health#nvim_treesitter#check section of :checkhealth to ensure the desired module is enabled for your language. If not, you might be missing query files; see Adding queries.

Finally, ensure Neovim is correctly identifying your language's filetype using the :echo &filetype command while one of your language's files is open in Neovim. If not, add a short Vimscript file to nvim-treesitter's ftdetect runtime directory following Neovim's documentation on filetype detection. You can also quickly & temporarily set the filetype for a single buffer with the :set filetype=langname command to test whether it fixes the problem.

If everything is okay, then it might be an actual error. In that case, feel free to open an issue here.

I get module 'vim.treesitter.query' not found

Make sure you have the latest version of Neovim.

I get Error detected while processing .../plugin/nvim-treesitter.vim every time I open Neovim

This is probably due to a change in a parser's grammar or its queries. Try updating the parser that you suspect has changed (:TSUpdate {language}) or all of them (:TSUpdate). If the error persists after updating all parsers, please open an issue.

I get query error: invalid node type at position

This could be due a query file outside this plugin using outdated nodes, or due to an outdated parser.

  • Make sure you have the parsers up to date with :TSUpdate
  • Make sure you don't have more than one parser runtime directory. You can execute this command :echo nvim_get_runtime_file('parser', v:true) to find all runtime directories. If you get more than one path, remove the ones that are outside this plugin (nvim-treesitter directory), so the correct version of the parser is used.

I experience weird highlighting issues similar to #78

This is a well known issue, which arises when the tree and the buffer have gotten out of sync. As this is an upstream issue, we don't have any definite fix. To get around this, you can force reparsing the buffer with

:write | edit | TSBufEnable highlight

This will save, restore and enable highlighting for the current buffer.

I experience bugs when using nvim-treesitter's foldexpr similar to #194

This might happen, and is known to happen, with vim-clap. To avoid these kind of errors, please use setlocal instead of set for the respective filetypes.

I run into errors like module 'nvim-treesitter.configs' not found at startup

This is because of rtp management in nvim, adding packadd nvim-treesitter should fix the issue.

I want to use Git instead of curl for downloading the parsers

In your Lua config:

require("nvim-treesitter.install").prefer_git = true

I want to use a HTTP proxy for downloading the parsers

You can either configure curl to use additional CLI arguments in your Lua config:

require("nvim-treesitter.install").command_extra_args = {
    curl = { "--proxy", "<proxy url>" },
}

or you can configure git via .gitconfig and use git instead of curl

require("nvim-treesitter.install").prefer_git = true

I want to use a mirror instead of "https://github.com/"

In your Lua config:

for _, config in pairs(require("nvim-treesitter.parsers").get_parser_configs()) do
  config.install_info.url = config.install_info.url:gsub("https://github.com/", "something else")
end

require'nvim-treesitter.configs'.setup {
    --
    --
}

Using an existing parser for another filetype

For example, to use the bash tree-sitter to highlight file with filetype=apkbuild, use:

vim.treesitter.language.register("bash", "apkbuild")

The bash tree-sitter must be installed following the usual procedure as described above.

nvim-treesitter's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nvim-treesitter's Issues

Compiling *.cc with C compiler gives shared object no personality

Hello! Thanks for this awesome plugin.

I have some problem install those parsers who use C++ files (*.cc, e.g. tree-sitter-python). Apparently, linking with a C compiler to libstdc++ is not sufficient.

I get the following error when compiling with the C compiler GCC 9.3 or Clang 11.0:
image

__gxx_personality_v0 is missing 😢

The problem is solved when I compile the C++ files with g++ instead of gcc or clang++ instead of clang (e.g. by setting up a small CMake project).

No locals.scm query found for c, cpp and rust

health#nvim_treesitter#check
========================================================================
## Installation
  - OK: `git` executable found.
  - OK: `cc` executable found.

## c parser healthcheck
  - OK: c parser found.
  - WARNING: No `locals.scm` query found for c
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `highlights.scm` query found for c
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## cpp parser healthcheck
  - OK: cpp parser found.
  - WARNING: No `locals.scm` query found for cpp
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `highlights.scm` query found for cpp
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## lua parser healthcheck
  - OK: lua parser found.
  - OK: `locals.scm` found.
  - OK: `highlights.scm` found.

## rust parser healthcheck
  - OK: rust parser found.
  - WARNING: No `locals.scm` query found for rust
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `highlights.scm` query found for rust
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## Missing parsers
  - WARNING: Some parsers are not installed:
    csharp
    html
    typescript
    swift
    java
    python
    nix
    yaml
    elm
    vue
    ruby
    ocaml
    go
    scala
    haskell
    json
    toml
    javascript
    css
    julia
    markdown
    php
    bash
    tsx
    - ADVICE:
      - Install them using `:TSInstall language

NVIM v0.5.0-504-g55b62a937
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: /Library/Developer/CommandLineTools/usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/Users/yashladha/nvim/build/config -I/Users/yashladha/nvim/src -I/Users/yashladha/nvim/.deps/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include -I/usr/local/opt/gettext/include -I/Users/yashladha/nvim/build/src/nvim/auto -I/Users/yashladha/nvim/build/include
Compiled by [email protected]

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/share/nvim"

Run :checkhealth for more info

Python's async keyword not highlighted as a keyword

Open any python file with the async keyword in it => notice that it's not highlighted (whilst await is btw).

**Output of :checkhealth nvim_treesitter *** ( I took the liberty of snipping it at the python entry)

 84 health#nvim_treesitter#check
 83 ========================================================================
 82 ## Installation
 81   - OK: git executable found.
 80   - OK: cc executable found.
 79
 78 ## html parser healthcheck
 77   - OK: html parser found.
 76   - WARNING: No locals.scm query found for html
 75     - ADVICE:
 74     ¦ - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
 73   - OK: highlights.scm found.
 72
 71 ## typescript parser healthcheck
 70   - OK: typescript parser found.
 69   - OK: locals.scm found.
 68   - OK: highlights.scm found.
 67
 66 ## regex parser healthcheck
 65   - OK: regex parser found.
 64   - WARNING: No locals.scm query found for regex
 63     - ADVICE:
 62     ¦ - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
 61   - OK: highlights.scm found.
 60
 59 ## c parser healthcheck
 58   - OK: c parser found.
 57   - OK: locals.scm found.
 56   - OK: highlights.scm found.
 55
 54 ## nix parser healthcheck
 53   - OK: nix parser found.
 52   - WARNING: No locals.scm query found for nix
 51     - ADVICE:
 50     ¦ - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
 49   - WARNING: No highlights.scm query found for nix
 48     - ADVICE:
 47     ¦ - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
 46
 45 ## swift parser healthcheck
 44   - OK: swift parser found.
 43   - WARNING: No locals.scm query found for swift
 42     - ADVICE:
 41     ¦ - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
 40   - WARNING: No highlights.scm query found for swift
 39     - ADVICE:
 38     ¦ - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
 37
 36 ## java parser healthcheck
 35   - OK: java parser found.
 34   - OK: locals.scm found.
 33   - OK: highlights.scm found.
 32
 31 ## python parser healthcheck
 30   - OK: python parser found.
 29   - OK: locals.scm found.
 28   - OK: highlights.scm found.

Output of nvim --version

NVIM v0.5.0-577-g48ac77a14
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-5 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/travis/build/neovim/bot-ci/build/neovim/build/config -I/home/travis/build/neovim/bot-ci/build/neovim/src -I/home/travis/build/neovim/bot-ci/build/neovim/.deps/usr/include -I/usr/include -I/home/travis/build/neovim/bot-ci/build/neovim/build/src/nvim/auto -I/home/travis/build/neovim/bot-ci/build/neovim/build/include
Compiled by travis@travis-job-926e4ea1-1710-4627-a936-0e46d2a8c227

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/home/travis/build/neovim/bot-ci/build/neovim/build/nvim.AppDir/usr/share/nvim
"

2020-06-30-085550_grim

Error detected while processing CursorMoved Autocommands for "<buffer=1>": attempt to index field 'highlight' (a nil value)

Describe the bug
When moving the cursor, this mesage appears:

Error detected while processing CursorMoved Autocommands for "<buffer=1>":
E5108: Error executing lua ...plugged/nvim-treesitter/lua/nvim-treesitter/ts_utils.lua:129: attempt to index field 'highlight' (a nil value)

Output of :checkhealth nvim_treesitter

java parser healthcheck

Output of nvim --version

NVIM v0.5.0-552-g980b12edb
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-5 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/travis/build/neovim/bot-ci/build/neovim/build/config -I/home/travis/build/neovim/bot-ci/build/neovim/src -I/home/travis/build/neovim/bot-ci/build/neovim/.deps/usr/include -I/usr/include -I/home/travis/build/neovim/bot-ci/build/neovim/build/src/nvim/auto -I/home/travis/build/neovim/bot-ci/build/neovim/build/include
Compiled by travis@travis-job-f7d211e6-a956-4241-bc4b-14b1292347f8

To Reproduce

  • Create minimal config init.vim with:
set runtimepath^=~/.local/share/nvim/plugged/nvim-treesitter
filetype plugin indent on
syntax on
set hidden
set termguicolors

I've also added the setup given in the readme with:

ensure_installed = "java"
  • Create Main.java file with:
public class Main {
    public static void main(String[] args) {
        String element = "Hello World";
    }
}
  • Run with nvim -u init.vim Main.java.

  • Press j or k and see the error message.

Expected behavior

Highlight the occurrences of variables, especially highlighting the difference between method's variables and local variables.

Add position to the jumplist when calling to `goto_definition`

Currently, goto_definition doesn't add the position to the jumplist, so you can't use <C-o> to go back to the original position.

Looks like this can be done, from :h jumplist:

You can explicitly add a jump by setting the ' mark with "m'". Note that calling setpos() does not do this.

Lua error with tsx `attempt to index a nil value`

Describe the bug
When I open a tsx file, I keep getting this error (everytime I ignore it, it comes back the second after).

Error detected while processing CursorHold Autocommands for "<buffer=1>":
E5108: Error executing lua ...lugged/nvim-treesitter//lua/nvim-treesitter/ts_utils.lua:213: attempt to index a nil value

local root = parsers.get_parser().tree:root()

To Reproduce
Steps to reproduce the behavior:

  1. I installed the tsx parser, and added the provided default configuration from nvim-treesitter README.
  2. I opened a random tsx file
  3. I see the error all the time

Expected behavior
No error 😉

Output of :checkhealth nvim_treesitter

health#nvim_treesitter#check

Installation

  • OK: git executable found.
  • OK: cc executable found.

typescript parser healthcheck

  • OK: typescript parser found.
  • OK: locals.scm found.
  • OK: highlights.scm found.

c parser healthcheck

  • OK: c parser found.
  • OK: locals.scm found.
  • OK: highlights.scm found.

tsx parser healthcheck

  • OK: tsx parser found.
  • OK: locals.scm found.
  • OK: highlights.scm found.

Missing parsers

  • WARNING: Some parsers are not installed:
    html
    regex
    nix
    swift
    java
    python
    yaml
    elm
    vue
    cpp
    toml
    lua
    ruby
    ocaml
    go
    scala
    haskell
    rust
    json
    markdown
    javascript
    css
    julia
    php
    c_sharp
    bash
    • ADVICE:
      • Install them using `:TSInstall language

Output of nvim --version

NVIM v0.5.0-593-g1ca67a73c
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/pierpo/projects/neovim/build/config -I/home/pierpo/projects/neovim/src -I/home/pierpo/projects/neovim/.deps/usr/include -I/usr/include -I/home/pierpo/projects/neovim/build/src/nvim/auto -I/home/pierpo/projects/neovim/build/include
Compiled by pierpo@pierpo-zotac

Thank you for all your work, this is truly awesome. Neovim will be fantastic thanks to this!

The highlight disappears after selecting delete and undo

Describe the bug
The highlight disappears after selecting delete and undo

To Reproduce
Steps to reproduce the behavior:
NOTE: example_config.vim ref to README

  1. nvim -u example_config.vim
  2. :e example.cpp
  3. vi{ to select and d to delet and u to undo
  4. See highlight disappears after undo

Expected behavior
The highlight should not disappears.

Output of nvim --version

NVIM v0.5.0-607-g459800db4

Support defining forward and backward movements

This would allow users to make use of ]], [[, ]m, [m, [M`, and friends.

Right now plugins implement this using a search with regular expressions.

Maybe we can re-use the textobjects.scm file for these queries, or have a movements.scm file. The queries will define something like

@function
@function.start
@function.end

If only function is given the start would be taken from the beginning of the first node, and the end would be taken from the end of the last node inside that.

This will need to search the node matching the query from the cursor position to the end of the file for forward movements and from the cursor position till the start of the file for backward movements.

Find a way to handle typescript installation

Typescript has two separates folder with parsers: one for typescript and one for tsx.
The folder structure is:

  • repo / typescript / src / ...
  • repo / tsx / src / ...
    The installer should be ran two times, and one more command should be specified.

Issues found with syntax hightlighting

I have been using the highlight feature for a couple of weeks now (python mainly).

There are three issues I have found so far:

  • While typing some syntax may be invalid, and everything goes red (fixed with highlight link TSError Normal)

red3
red2

  • Sometimes there is an error (not sure how to replicate), and the text gets replaced with an error from lua. This is fixed by reloading the text with :e. Fixed, haven't experienced this anymore.

luaerrro

  • When the using folds, some parts of the code doesn't get highlighted. This happens when I open a file where the text is folded (syntax is highlighted as normal), then go to the last line with G (syntax isn't highlighted, the whole text is white). This is fixed by forcing a redraw with <C-L>.

Getting error when trying to use textobjects: `attempt to concatenate local 'query' (a boolean value)`

Describe the bug

When trying to configure textobjects, I'm getting the following error whenever I open a Python file (or C/C++):

Error executing vim.schedule lua callback: ...plug/nvim-treesitter/lua/nvim-treesitter/textobjects.lua:70: attempt to concatenate local 'query' (a boolean value)

Here's the config I tried:

  local configs = require('nvim-treesitter.configs')
  configs.setup({
    highlight = {enable = false};
    incremental_selection = {
      enable = true;
      keymaps = {
        init_selection = 'gnn';
        node_incremental = '<tab>';
        scope_incremental = 'grc';
        node_decremental = '<s-tab>';
      };
    };
    refactor = {
      smart_rename = {enable = true; keymaps = {smart_rename = 'grr'}};
      navigation = {enable = true; keymaps = {goto_definition = 'gnd'; list_defitinions = 'gnD'}};
    };
    textobjects = {
      enable = true;
      keymaps = {
        af = '@function.outer';
        ['if'] = '@function.inner';
        aC = '@class.outer';
        iC = '@class.inner';
        al = '@block.outer';
        il = '@block.inner';
      };
    };
    ensure_installed = 'all';
}

I assume I'm doing something wrong, but I can't really figure out what.

To Reproduce
Steps to reproduce the behavior:

  1. Add textobjects to your treesitter config
  2. Open a file that has textobjects query (builtin: Python, C & C++)

Output of :checkhealth nvim_treesitter

health#nvim_treesitter#check

Installation

  • OK: git executable found.
  • OK: cc executable found.

html parser healthcheck

typescript parser healthcheck

  • OK: typescript parser found.
  • OK: locals.scm found.
  • OK: highlights.scm found.

regex parser healthcheck

c parser healthcheck

  • OK: c parser found.
  • OK: locals.scm found.
  • OK: highlights.scm found.

nix parser healthcheck

swift parser healthcheck

java parser healthcheck

  • OK: java parser found.
  • OK: locals.scm found.
  • OK: highlights.scm found.

python parser healthcheck

  • OK: python parser found.
  • OK: locals.scm found.
  • OK: highlights.scm found.

yaml parser healthcheck

elm parser healthcheck

vue parser healthcheck

cpp parser healthcheck

  • OK: cpp parser found.
  • OK: locals.scm found.
  • OK: highlights.scm found.

toml parser healthcheck

lua parser healthcheck

  • OK: lua parser found.
  • OK: locals.scm found.
  • OK: highlights.scm found.

ruby parser healthcheck

  • OK: ruby parser found.
  • OK: locals.scm found.
  • OK: highlights.scm found.

ocaml parser healthcheck

go parser healthcheck

  • OK: go parser found.
  • OK: locals.scm found.
  • OK: highlights.scm found.

scala parser healthcheck

haskell parser healthcheck

rust parser healthcheck

  • OK: rust parser found.
  • OK: locals.scm found.
  • OK: highlights.scm found.

json parser healthcheck

markdown parser healthcheck

javascript parser healthcheck

  • OK: javascript parser found.
  • OK: locals.scm found.
  • OK: highlights.scm found.

css parser healthcheck

php parser healthcheck

c_sharp parser healthcheck

bash parser healthcheck

tsx parser healthcheck

  • OK: tsx parser found.
  • OK: locals.scm found.
  • OK: highlights.scm found.

Missing parsers

  • WARNING: Some parsers are not installed:
    julia
    • ADVICE:
      • Install them using `:TSInstall language

Output of nvim --version

% nvim --version
NVIM v0.5.0-593-g1ca67a73c
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/Users/fsouza/Projects/os/3/neovim/build/config -I/Users/fsouza/Projects/os/3/neovim/src -I/Users/fsouza/Projects/os/3/neovim/.deps/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include -I/usr/local/opt/gettext/include -I/Users/fsouza/Projects/os/3/neovim/build/src/nvim/auto -I/Users/fsouza/Projects/os/3/neovim/build/include
Compiled by fsouza@fsouza-mbp152

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/Users/fsouza/opt/neovim/share/nvim"

Run :checkhealth for more info

How to disable highlighting of syntax errors?

Describe the bug
The treesitter highlighting is fast and awesome.But when syntax error occurs , the highlight groups will take effect, which is a hassle.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

**Output of :checkhealth nvim_treesitter ***


health#nvim_treesitter#check
========================================================================
## Installation
  - OK: `git` executable found.
  - OK: `cc` executable found.

## html parser healthcheck
  - OK: html parser found.
  - WARNING: No `locals.scm` query found for html
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - OK: `highlights.scm` found.

## c parser healthcheck
  - OK: c parser found.
  - OK: `locals.scm` found.
  - OK: `highlights.scm` found.

## java parser healthcheck
  - OK: java parser found.
  - OK: `locals.scm` found.
  - OK: `highlights.scm` found.

## python parser healthcheck
  - OK: python parser found.
  - OK: `locals.scm` found.
  - OK: `highlights.scm` found.

## cpp parser healthcheck
  - OK: cpp parser found.
  - OK: `locals.scm` found.
  - OK: `highlights.scm` found.

## go parser healthcheck
  - OK: go parser found.
  - OK: `locals.scm` found.
  - OK: `highlights.scm` found.

## javascript parser healthcheck
  - OK: javascript parser found.
  - OK: `locals.scm` found.
  - OK: `highlights.scm` found.

## css parser healthcheck
  - OK: css parser found.
  - WARNING: No `locals.scm` query found for css
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - OK: `highlights.scm` found.

## Missing parsers
  - WARNING: Some parsers are not installed:
    typescript
    regex
    nix
    swift
    yaml
    elm
    vue
    toml
    lua
    ruby
    ocaml
    scala
    haskell
    rust
    json
    markdown
    julia
    php
    c_sharp
    bash
    tsx
    - ADVICE:
      - Install them using `:TSInstall language


Output of nvim --version

NVIM v0.5.0-576-g7efb302d2

Additional context
Add any other context about the problem here.

Custom Capture Groups

Is your feature request related to a problem? Please describe.
Hello! I've been meaning to contribute to the tsx/jsx queries for nvim-treesitter, throughout me learning the ins and outs of this plugin I thought this feature might be beneficial in supporting various languages, and might a degree of customisation to users of this plugin.

I am not sure if this would be viable, but I think it would be useful for the handling of some language specific highlighting or allowing customisation of highlighting just based on preference.

Describe the solution you'd like
Using typescript as an example

capturegroups.scm

capturegroups = { -- custom capture groups
    typescriptreact = {
        "tsx.tag" = TSConstant -- mapping to an existing syntax group
        "tsx.tag" = TSHTMLTag -- mapping to a custom user defined syntax group, which can be picked up by the theme
        "tsx.tag" = DraculaOrange -- mapping to theme syntax group, this could allow for user customisable syntax highlighting
    }
}
(jsx_attribute (property_identifier) @tsx.tag)

I am unsure if you can call highlight default link programmatically, since this would essentially rely on that...I believe.

Describe alternatives you've considered
I've looked into achieving highlighting using the groups available, however to me, it seems pretty misleading (for maintainers) and incorrect (as the user) to define a query to classify a piece of syntax as something it is not.
Taking the above example for a tsx tag, being highlighted as a function just for a certain colour.

(jsx_attribute (property_identifier) @function)

Additional context
I am still learning so please excuse me if I failed to consider a case.

Highlight definition can be slow and blocks cursor movement

Describe the bug
highlight_definitions can be really slow if it does not find the definition in current scope but in one of the parent levels.
This can be annoying since it blocks cursor movement while it is running.

To Reproduce
Open a big Python or C++ file with a lot of variable definitions (like this one https://i10git.cs.fau.de/pycodegen/pystencils/-/raw/master/pystencils/field.py)

Try to move over the individual letters of @staticmethod. It will not find a definition but quite a few usages. Cursor movement is blocked during the search of the definitions.

Expected behavior
Cursor movement is smooth. Search for definitions is non-blocking

** Output of :checkhealth nvim_treesitter **

```

health#nvim_treesitter#check

Installation

  • OK: git executable found.
  • OK: cc executable found.

html parser healthcheck

typescript parser healthcheck

  • OK: typescript parser found.
  • OK: locals.scm found.
  • OK: highlights.scm found.

clojure parser healthcheck

lisp parser healthcheck

regex parser healthcheck

c parser healthcheck

  • OK: c parser found.
  • OK: locals.scm found.
  • OK: highlights.scm found.

nix parser healthcheck

swift parser healthcheck

java parser healthcheck

  • OK: java parser found.
  • OK: locals.scm found.
  • OK: highlights.scm found.

python parser healthcheck

  • OK: python parser found.
  • OK: locals.scm found.
  • OK: highlights.scm found.

yaml parser healthcheck

elm parser healthcheck

vue parser healthcheck

cpp parser healthcheck

  • OK: cpp parser found.
  • OK: locals.scm found.
  • OK: highlights.scm found.

toml parser healthcheck

lua parser healthcheck

  • OK: lua parser found.
  • OK: locals.scm found.
  • OK: highlights.scm found.

ruby parser healthcheck

  • OK: ruby parser found.
  • OK: locals.scm found.
  • OK: highlights.scm found.

ocaml parser healthcheck

go parser healthcheck

  • OK: go parser found.
  • OK: locals.scm found.
  • OK: highlights.scm found.

scala parser healthcheck

haskell parser healthcheck

rust parser healthcheck

json parser healthcheck

markdown parser healthcheck

javascript parser healthcheck

  • OK: javascript parser found.
  • OK: locals.scm found.
  • OK: highlights.scm found.

css parser healthcheck

julia parser healthcheck

php parser healthcheck

c_sharp parser healthcheck

bash parser healthcheck

tsx parser healthcheck

  • OK: tsx parser found.
  • OK: locals.scm found.
  • OK: highlights.scm found.

Output of nvim --version

➜ nvim --version
NVIM v0.5.0-bd5f0e969
Build type: Release
LuaJIT 2.0.5
Compilation: /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/shims/linux/super/gcc-10 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/tmp/neovim-20200704-130349-1xlbcrp/build/config -I/tmp/neovim-20200704-130349-1xlbcrp/src -I/home/linuxbrew/.linuxbrew/include -I/tmp/neovim-20200704-130349-1xlbcrp/deps-build/include -I/usr/include -I/tmp/neovim-20200704-130349-1xlbcrp/build/src/nvim/auto -I/tmp/neovim-20200704-130349-1xlbcrp/build/include
Compiled by stephan@stephan-Z87-DS3H

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/home/linuxbrew/.linuxbrew/Cellar/neovim/HEAD-bd5f0e9_1/share/nvim"

Run :checkhealth for more info

Additional context
Add any other context about the problem here.

ensure_installed has no effect on latest master

Describe the bug

When doing a fresh install, ensure_installed has no effect on latest master. Here's how I'm configuring nvim-treesitter: https://github.com/fsouza/vimfiles/blob/2f9e248a7566bd45fd1aa9fe32d86093a0e3c11a/lua/plugin/ts.lua#L34-L51 (let me know if I'm doing this the wrong way).

I bisected the code and it seems that it stops working after this commit: c42c38a.

Other custom module configs are also ignored (for example, doesn't expand selection). See #178 for issue with textobjects.

To Reproduce

Using the latest master, follow instructions from the README to add ensure_installed. Open nvim and nothing really happens.

Expected behavior

The desired parsers should get installed.

Output of :checkhealth nvim_treesitter

health#nvim_treesitter#check
2 ========================================================================
3 ## Installation
4 - OK: git executable found.
5 - OK: cc executable found.
6
7 ## c parser healthcheck
8 - OK: c parser found.
9 - OK: locals.scm found.
10 - OK: highlights.scm found.
11
12 ## Missing parsers
13 - WARNING: Some parsers are not installed:
14 html
15 typescript
16 regex
17 nix
18 swift
19 java
20 python
21 yaml
22 elm
23 vue
24 cpp
25 toml
26 lua
27 ruby
28 ocaml
29 go
30 scala
31 haskell
32 rust
33 json
34 markdown
35 javascript
36 css
37 julia
38 php
39 c_sharp
40 bash
41 tsx
42 - ADVICE:
43 - Install them using `:TSInstall language

Output of nvim --version

 nvim --version
NVIM v0.5.0-593-g1ca67a73c
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/Users/fsouza/Projects/os/3/neovim/build/config -I/Users/fsouza/Projects/os/3/neovim/src -I/Users/fsouza/Projects/os/3/neovim/.deps/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include -I/usr/local/opt/gettext/include -I/Users/fsouza/Projects/os/3/neovim/build/src/nvim/auto -I/Users/fsouza/Projects/os/3/neovim/build/include
Compiled by fsouza@fsouza-mbp152

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/Users/fsouza/opt/neovim/share/nvim"

Run :checkhealth for more info

Add sync option to TSInstall

TSInstall runs asynchronous backend, but in headless install mode, it needs a way to exit when all installations are done.
nvim --headless ' +TSInstall -sync all' +qa
with -sync option or any other symbal to represent "synchronous" meaning, the +qa command will excute after +TSInstall all done

smart_rename fails for multiple replacements in the same line

Describe the bug
smart_rename does not work correctly when replacing the same variable multiple times in the same row, iff the desired variable name is of different length than the original variable name.

To Reproduce
Consider this code:

template <class Functor>
auto inspect(Functor& f, value& ec) {
  return f(ec.a, ec.b);
}

Use smart_rename to rename ec to x.

This is the result:

template <class Functor>
auto inspect(Functor& f, value& x) {
  return f(x.a, exb);
}

Expected behavior

template <class Functor>
auto inspect(Functor& f, value& x) {
  return f(x.a, x.b);
}

Output of :checkhealth nvim_treesitter

health#nvim_treesitter#check

Installation

  • OK: git executable found.
  • OK: cc executable found.

html parser healthcheck

typescript parser healthcheck

markdown parser healthcheck

regex parser healthcheck

c parser healthcheck

  • OK: c parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: textobjects.scm found.

nix parser healthcheck

swift parser healthcheck

java parser healthcheck

python parser healthcheck

  • OK: python parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: textobjects.scm found.

yaml parser healthcheck

elm parser healthcheck

vue parser healthcheck

cpp parser healthcheck

  • OK: cpp parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: textobjects.scm found.

toml parser healthcheck

lua parser healthcheck

ruby parser healthcheck

ocaml parser healthcheck

go parser healthcheck

  • OK: go parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: textobjects.scm found.

scala parser healthcheck

haskell parser healthcheck

rust parser healthcheck

  • OK: rust parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: textobjects.scm found.

json parser healthcheck

jsdoc parser healthcheck

javascript parser healthcheck

css parser healthcheck

julia parser healthcheck

php parser healthcheck

c_sharp parser healthcheck

bash parser healthcheck

tsx parser healthcheck

Output of nvim --version

❯ nvim --version
NVIM v0.5.0-nightly-217-g950ca6abc
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/tmp/neovim-20200720-14610-1xe0vle/build/config -I/tmp/neovim-20200720-14610-1xe0vle/src -I/usr/local/include -I/tmp/neovim-20200720-14610-1xe0vle/deps-build/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.16.sdk/usr/include -I/usr/local/opt/gettext/include -I/tmp/neovim-20200720-14610-1xe0vle/build/src/nvim/auto -I/tmp/neovim-20200720-14610-1xe0vle/build/include
Compiled by dominiklohmann@amethyst

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/HEAD-950ca6a/share/nvim"

Run :checkhealth for more info

Setting foldmethod causes vim-clap to crash

Hey guys,

First of all, great plugin, I really like what you have created here. Keep up the great work.

Describe the bug
I got a bug with the plugin vim-clap.
After a while vim-clap providers will result in an error message and resulting in a floating window without content. I'm not sure if this is a bug on your, vim-clap or neovim core side.
When i tried to create a minimal vimrc i noticed that this bug only appears when foldmethod=expr foldexpr=nvim_treesitter#foldexpr() is set.

To Reproduce
Steps to reproduce the behavior:

  1. Minimal vimrc
let mapleader = ','

call plug#begin('~/.config/nvim/plugged')
	Plug 'nvim-treesitter/nvim-treesitter'
	Plug 'liuchengxu/vim-clap'
call plug#end()

nnoremap <leader>q :Clap files<CR>

lua << EOF
require'nvim-treesitter.configs'.setup {
	highlight = {
		enable = true,                    -- false will disable the whole extension
	},
	ensure_installed = { -- one of 'all', 'language' or a list of languages
		'c',
	}
}
EOF

set foldmethod=expr foldexpr=nvim_treesitter#foldexpr()
  1. Go for example to neovim repo
  2. Open random c file. Example: nvim -u ~/minimalrc.vim src/nvim/ui.c
  3. Open another file with :Clap files or <leader>q. e.g. src/tree_sitter/parser.c
  4. Try opening vim-clap again triggers error message:
Error detected while processing function clap#[41]..clap#for[39]..clap#floating_win#open[17]..clap#_init[3]..48[4]..47[7]..clap#job#regular#forerunner#start[1]..<SNR>52_run_maple_command[3]..clap#spinner#refresh[1]..<SNR>47_set_spinner[2]..clap#spinner#set:
line    2:
Error executing lua callback: /usr/share/nvim/runtime/lua/vim/treesitter.lua:215: invalid start

Pressing enter opens vim-claps floating window without content.
6. If message is not triggered, try opening more files with vim-clap or move around in the file. It is not entirely deterministic when it fails.

Expected behavior
vim-clap opens normally without triggering a error message and being able to open a new file.

Output of :checkhealth nvim_treesitter

health#nvim_treesitter#check

Installation

  • OK: git executable found.
  • OK: cc executable found.

html parser healthcheck

typescript parser healthcheck

markdown parser healthcheck

regex parser healthcheck

c parser healthcheck

  • OK: c parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: textobjects.scm found.

java parser healthcheck

python parser healthcheck

  • OK: python parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: textobjects.scm found.

yaml parser healthcheck

cpp parser healthcheck

  • OK: cpp parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: textobjects.scm found.

toml parser healthcheck

lua parser healthcheck

ruby parser healthcheck

go parser healthcheck

  • OK: go parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: textobjects.scm found.

scala parser healthcheck

rust parser healthcheck

json parser healthcheck

javascript parser healthcheck

css parser healthcheck

c_sharp parser healthcheck

bash parser healthcheck

Missing parsers

  • WARNING: Some parsers are not installed:
    nix
    swift
    elm
    vue
    ocaml
    haskell
    jsdoc
    julia
    php
    tsx
    • ADVICE:
      • Install them using `:TSInstall language

Output of nvim --version

NVIM v0.5.0-593-g1ca67a73c
Build type: RelWithDebInfo
LuaJIT 2.0.5
Compilation: /usr/lib/ccache/bin/cc -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/conni/.cache/yay/neovim-git/src/build/config -I/home/conni/.cache/yay/neovim-git/src/neovim-git/src -I/usr/include -I/home/conni/.cache/yay/neovim-git/src/build/src/nvim/auto -I/home/conni/.cache/yay/neovim-git/src/build/include
Compiled by conni@home

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

Additional context
Installing vim-claps binaries does not fix this bug so I left this one out.

Invalid query syntax error on MacOS

Describe the bug
When trying to add highlighting to a buffer using treesitter on my mac I encounter a syntax error and highlighting
fails to load. The exact same command works without issues on Linux. Other functionality works correctly like incremental selection etc. only highlighting fails. I've tried this highlighting disabled and manually highlighting each buffer. I'm not sure if this might be due to different compilers being used between mac and linux (I don't have any visibility on which is used on mac)

To Reproduce
Steps to reproduce the behavior:

  1. Open a file in a supported language on MacOS (Catalina)
  2. Run :TSBufEnable highlight
  3. See error
E5108: Error executing lua ...m/HEAD-91e41c8/share/nvim/runtime/lua/vim/treesitter.lua:127: query: invalid syntax at position 536  

Expected behavior
The buffer should be syntax highlighted correctly like on linux.

Output of :checkhealth nvim_treesitter

health#nvim_treesitter#check

  • ERROR: Failed to run healthcheck for "nvim_treesitter" plugin. Exception:
    function health#check[21]..health#nvim_treesitter#check, line 1
    Vim(lua):E5108: Error executing lua ...m/HEAD-91e41c8/share/nvim/runtime/lua/vim/treesitter.lua:127: query: invalid syntax at position 190

Output of nvim --version

NVIM v0.5.0-nightly
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/tmp/neovim-20200602-82373-1pwmboa/build/config -I/tmp/neovim-20200602-82373-1pwmboa/src -I/usr/local/include -I/tmp/neovim-20200602-82373-1pwmboa/deps-build/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include -I/usr/local/opt/gettext/include -I/tmp/neovim-20200602-82373-1pwmboa/build/src/nvim/auto -I/tmp/neovim-20200602-82373-1pwmboa/build/include
Compiled by akinsowemimo@Akins-MacBook-Pro

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/HEAD-91e41c8/share/nvim"

Run :checkhealth for more info

Highlight FIXME: and TODO: comments

Is your feature request related to a problem? Please describe.

Many colorschemes highlight FIXME: and TODO: style comments differently. With nvim-treesitter, this is not currently possible.

Describe the solution you'd like

Highlight common prefixes like FIXME or TODO within comments.

Additional context

Some screenshots w/ gruvbox colorscheme.

With nvim-treesitter:
image

Without nvim-treesitter:
image

Incremental selection skips one parent on some grammars

On grammars where there isn't a char that "ends" the node, like indentation base languages (python, rst),
when the incremental selection is started in the last line of the node, calling to next node will skip one node.

To Reproduce

Open this file

def foo(a, b):
    # foo
    return a + b

def foo(a, b):
    return a + b

Start incremental selection on any of the returns and advance one node, the whole document gets selected instead of selecting the function first.

If you start in a node that doesn't "touch" the last line (the foo comment in the first function) it works as expected. It selects the function first and then the whole document

[RFC]: How to handle scope of @definition.function

Things like goto_definition are based that on the assumption that all @definitions have a surrounding scope in which they are valid. But there is a problem: Most locals.scm define functions as separate scopes which makes sense since all the arguments of a function are only valid in this function. However, the name of the function is defined for the surrounding scope not the scope defined by the function itself.

How can we tackle that problem?

Get error when starting nvim: query: invalid node type at position 1707

Describe the bug
After 8021a76, every time when I start nvim, I got the following error message from nvim-treesitter.

Error detected while processing /home/voldikss/.cache/nvim/plugged/nvim-treesitter/plugin/nvim-treesitter.vim:
line   20:
E5108: Error executing lua /usr/local/share/nvim/runtime/lua/vim/treesitter.lua:151: query: invalid node type at position 1707

To Reproduce
Steps to reproduce the behavior:

  1. Use the lastest build nvim

  2. Use the simplest config file

set rtp+=~/.cache/nvim/plugged/nvim-treesitter

lua <<EOF
require'nvim-treesitter.configs'.setup {
    highlight = {
      enable = true,                    -- false will disable the whole extension
      disable = { "c", "rust" },        -- list of language that will be disabled
      custom_captures = {               -- mapping of user defined captures to highlight groups
        -- ["foo.bar"] = "Identifier"   -- highlight own capture @foo.bar with highlight group "Identifier", see :h nvim-treesitter-query-extensions
      },
    }
}
EOF
  1. start nvim using nvim -u mini_vimrc

  2. See error, as described above.

Output of :checkhealth nvim_treesitter

health#nvim_treesitter#check

  • ERROR: Failed to run healthcheck for "nvim_treesitter" plugin. Exception:
    function health#check[21]..health#nvim_treesitter#check, line 1
    Vim(lua):E5108: Error executing lua /usr/local/share/nvim/runtime/lua/vim/treesitter.lua:151: query: invalid node type at position 1707

Output of nvim --version

NVIM v0.5.0-615-g5f5bd576e
Build type: Debug
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=1 -I/mnt/repo/neovim/build/config -I/mnt/repo/neovim/src -I/mnt/repo/neovim/.deps/usr/include -I/usr/include -I/mnt/repo/neovim/build/src/nvim/auto -I/mnt/repo/neovim/build/include
Compiled by root@legion

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/share/nvim"

Run :checkhealth for more info

Also, /usr/local/share/nvim/runtime/lua/vim/treesitter.lua is the identical with neovim official repo.

Additional context
Screenshot
image

Startup Time

TLDR: Maybe lazy-load utils.setup_command functions?

I did some --startuptime analysis on my configuration today and noticed, that
nvim-treesitter does add a fair amount delay to the startup.

I'm using a rather slow system:

  • Windows 10 1909 and nvim inside WSL

After playing around a bit, I noticed that the utils.setup_command function
have a great effect on startup.

Commenting out these lines:

utils.setup_commands('install', install.commands)
utils.setup_commands('info', info.commands)

saves ~250ms from ~500ms before.

To Reproduce

Steps to reproduce my very rough measurements:

  1. nvim file-with-no-treesitter-support.rst --startuptime time.txt
  2. Looking at the relevant part of time.txt:
1604.056  555.734  555.734: sourcing /home/viol/.local/share/nvim/plugged/nvim-treesitter/plugin/nvim-treesitter.vim
  1. Commenting out the mentioned lines from above
  2. Repeating step 1
  3. Readout new times from time.txt
1191.265  260.503  260.503: sourcing /home/viol/.local/share/nvim/plugged/nvim-treesitter/plugin/nvim-treesitter.vim

Expected behavior

I may have been not really careful and other parts could have also played a part
of the reduced startup time. I just wanted to bring attention to the startup
time in general. Maybe there are ways to optimize it in the future?
If I understand in correctly the utils.setup_command functions are not really
needed for the overall functionality and could also be loaded lazily?

Output of :checkhealth nvim_treesitter

health#nvim_treesitter#check

Installation

  • OK: git executable found.
  • OK: cc executable found.

html parser healthcheck

typescript parser healthcheck

markdown parser healthcheck

regex parser healthcheck

c parser healthcheck

  • OK: c parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: textobjects.scm found.

nix parser healthcheck

swift parser healthcheck

java parser healthcheck

python parser healthcheck

  • OK: python parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: textobjects.scm found.

yaml parser healthcheck

elm parser healthcheck

vue parser healthcheck

cpp parser healthcheck

  • OK: cpp parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: textobjects.scm found.

toml parser healthcheck

lua parser healthcheck

ruby parser healthcheck

ocaml parser healthcheck

go parser healthcheck

  • OK: go parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: textobjects.scm found.

scala parser healthcheck

haskell parser healthcheck

rust parser healthcheck

  • OK: rust parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: textobjects.scm found.

json parser healthcheck

jsdoc parser healthcheck

javascript parser healthcheck

css parser healthcheck

julia parser healthcheck

php parser healthcheck

c_sharp parser healthcheck

bash parser healthcheck

tsx parser healthcheck

Output of nvim --version


NVIM v0.5.0-610-g326b87feb
Build type: RelWithDebInfo
LuaJIT 2.0.5
Compilation: /usr/sbin/cc -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/viol/.cache/yay/neovim-git/src/build/config -I/home/viol/.cache/yay/neovim-git/src/neovim-git/src -I/usr/include -I/home/viol/.cache/yay/neovim-git/src/build/src/nvim/auto -I/home/viol/.cache/yay/neovim-git/src/build/include
Compiled by viol@DE2WXL-520036

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

Can it add support to a synchronized cooperative work with luochen1990/rainbow ?

Is your feature request related to a problem? Please describe.
When i installed rainbow and nvim-treesitter, i found that the parentheses don't show different levels of parentheses in different colors.

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Support lua 5.1

Describe the bug
the plugin fails to load with the following error

Error detected while processing $HOME/.local/share/nvim/plugged/nvim-treesitter/plugin/nvim-treesitter.vim:
line   20:
E5108: Error executing lua error loading module 'nvim-treesitter.install' from file '$HOME/.local/share/nvim/plugged/nvim-treesitter/lua/nvim-treesitter/install.lua':
        ...local/share/nvim/plugged/nvim-treesitter/lua/nvim-treesitter/install.lua:110: '=' expected near 'continue'

git bisect reveals 0ed1fbf to be the first bad commit
lua -v : Lua 5.1.5
To Reproduce
install nvim-treesitter (using vim-plug in my case)

Expected behavior
neovim should start without errors

**Output of :checkhealth nvim_treesitter **

health#nvim_treesitter#check
========================================================================
## Installation
  - OK: `git` executable found.
  - OK: `cc` executable found.

## c parser healthcheck
  - OK: c parser found.
  - OK: `locals.scm` found.
  - OK: `highlights.scm` found.

## Missing parsers
  - WARNING: Some parsers are not installed:
    typescript
    haskell
    json
    ocaml
    regex
    ruby
    rust
    yaml
    swift
    html
    java
    cpp
    scala
    vue
    lua
    nix
    php
    markdown
    julia
    css
    elm
    tsx
    python
    c_sharp
    javascript
    toml
    bash
    go
    - ADVICE:
      - Install them using `:TSInstall language

Output of nvim --version

NVIM v0.5.0-dev
Build type: RelWithDebInfo
Lua 5.1
Compilation: /usr/bin/cc -g -O2 -fdebug-prefix-map=/build/neovim-_aWOCt/neovim-0.5.0+ubuntu1+git202006281322-48ac77a-00e710e=. -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_M -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/build/neovim-_aWOCt/neovim-0.5.0+ubuntu1+git202006281322-48ac77a-00e710e/build/config -I/build/neovim-_aWOCt/neovim-0.5.0+ubuntu1+git202006281322-48ac77a-00e710e/src -I/build/neovim-_aWOCt/neovim02006281322-48ac77a-00e710e/.deps/usr/include -I/usr/include -I/build/neovim-_aWOCt/neovim-0.5.0+ubuntu1+git202006281322-48ac77a-00e710e/build/src/nvim/auto -I/build/neovim-_aWOCt/neovim-0.5.0+ubuntu1+git202006281322-48ac77a-00e710e/build/inc
Compiled by buildd@lgw01-amd64-017

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

Is it possible to achieve different colors for arguments and local variables? Java parser

Regarding to config, I've pasted what is defined in the readme's setup.

java parser healthcheck

colorscheme sublimemonokai

  • TSBufEnable highlight

image

  • TSBufDisable highlight

image

The differences are:

  1. Class name Main from non-italic to italic.
  2. Return type void from non-italic to italic.
  3. Type variable String from non-italic to italic.
  4. Highlight of function name main.
  5. Highlight of brackets.

colorscheme default

  • TSBufEnable highlight

image

  • TSBufDisable highlight

image

The differences are:

  1. Highlight of class name Main.
  2. Highlight of keyword static.
  3. Highlight of return type void.
  4. Highlight of function name main.
  5. Highlight of type variable String[].
  6. Highlight of argument args.
  7. Highlights of local type variable String and variable name element.
  8. Highlight of brackets.

Track latest commit from parsers

This will avoid having to update all parsers with :TSUpdate, and only update the ones that have changed. We can make use of git ls-remote <repo> HEAD to query the latest commit, and compare that with the one saved from when the parser was installed.

How to highlight JSX elements?

Describe the bug
I'm trying to add a custom highlighting color to JSX elements, but am failing to do so. I have the following query in after/queries/javascript/highlights.scm:

(jsx_text) @function

But when I open Neovim, then I get this error:

Error detected while processing <home dir>/.local/share/nvim/plugged/nvim-treesitter/plugin/nvim-treesitter.vim:
line   20:
E5108: Error executing lua ...m/HEAD-a0a84fc/share/nvim/runtime/lua/vim/treesitter.lua:127: query: invalid node type at position 3054

I saw that the tree-sitter-javascript parser includes the JSX queries in highlights-jsx.scm not highlights.scm. Could that be the reason why it's failing for me? I tried to move this query to highlights-jsx.scm but it doesn't look like that file is read.

To Reproduce
Here is a minimal case to reproduce the problem:

init.vim:

call plug#begin(stdpath('data') . '/plugged')
Plug 'nvim-treesitter/nvim-treesitter'
call plug#end()

syntax off

lua <<EOF
require'nvim-treesitter.configs'.setup {
    highlight = {
        enable = true,
    },
    incremental_selection = {
        enable = false,
    },
    ensure_installed = {'javascript'}
}
EOF

after/queries/javascript/highlights.scm:

(jsx_text) @function

An example JSX file (MyComponent.js):

import React from 'react';

const MyComponent = () => (
  <div>Hello World</div>
);

export const MyComponent;

Expected behavior
I would expect there to not be an error and the JSX text element should be highlighted with the highlight group I specified.

Output of :checkhealth nvim_treesitter

health#nvim_treesitter#check
========================================================================
  - ERROR: Failed to run healthcheck for "nvim_treesitter" plugin. Exception:
    function health#check[21]..health#nvim_treesitter#check, line 1
    Vim(lua):E5108: Error executing lua ...m/HEAD-a0a84fc/share/nvim/runtime/lua/vim/treesitter.lua:127: query: invalid node type at position 3054

Here is the health check results if I remove the query:

health#nvim_treesitter#check
========================================================================
## Installation
  - OK: `git` executable found.
  - OK: `cc` executable found.

## typescript parser healthcheck
  - OK: typescript parser found.
  - OK: `locals.scm` found.
  - OK: `highlights.scm` found.

## javascript parser healthcheck
  - OK: javascript parser found.
  - OK: `locals.scm` found.
  - OK: `highlights.scm` found.

## tsx parser healthcheck
  - OK: tsx parser found.
  - OK: `locals.scm` found.
  - OK: `highlights.scm` found.

## Missing parsers
  - WARNING: Some parsers are not installed:
    csharp
    html
    c
    regex
    swift
    java
    python
    nix
    yaml
    elm
    cpp
    vue
    lua
    ruby
    ocaml
    go
    scala
    haskell
    rust
    json
    toml
    css
    julia
    markdown
    php
    bash
    - ADVICE:
      - Install them using `:TSInstall language

Output of nvim --version

NVIM v0.5.0-a0a84fc9e
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/tmp/neovim-20200614-7434-2psdhv/build/config -I/tmp/neovim-20200614-7434-2psdhv/src -I/usr/local/include -I/tmp/neovim-20200614-7434-2psdhv/deps-build/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include -I/usr/local/opt/gettext/include -I/tmp/neovim-20200614-7434-2psdhv/build/src/nvim/auto -I/tmp/neovim-20200614-7434-2psdhv/build/include
Compiled by [email protected]

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/HEAD-a0a84fc/share/nvim"

Run :checkhealth for more info

Additional context

I tried a bunch of other JSX related queries as well and none of them seemed to work. For example:

(jsx_opening_element (identifier) @tag)

Stop asking to reinstall parsers on startup

Describe the bug
The plugin keeps asking to reinstall parsers on startup.

To Reproduce
With this config:

require'nvim-treesitter.configs'.setup {
	highlight = {
		disable = { 'lua' }
	},
	ensure_installed = { 'c', 'rust', 'java', 'lua' }
}

Just launch nvim, and it will ask to reinstall the parsers every time.

Expected behavior
Just stop asking

**Output of :checkhealth nvim_treesitter ***


health#nvim_treesitter#check
========================================================================
## Installation
  - OK: `git` executable found.
  - OK: `cc` executable found.

## regex parser healthcheck
  - OK: regex parser found.
  - WARNING: No `locals.scm` query found for regex
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - OK: `highlights.scm` found.

## c parser healthcheck
  - OK: c parser found.
  - OK: `locals.scm` found.
  - OK: `highlights.scm` found.

## java parser healthcheck
  - OK: java parser found.
  - OK: `locals.scm` found.
  - OK: `highlights.scm` found.

## python parser healthcheck
  - OK: python parser found.
  - OK: `locals.scm` found.
  - OK: `highlights.scm` found.

## lua parser healthcheck
  - OK: lua parser found.
  - OK: `locals.scm` found.
  - OK: `highlights.scm` found.

## rust parser healthcheck
  - OK: rust parser found.
  - WARNING: No `locals.scm` query found for rust
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `highlights.scm` query found for rust
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## markdown parser healthcheck
  - OK: markdown parser found.
  - WARNING: No `locals.scm` query found for markdown
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter
  - WARNING: No `highlights.scm` query found for markdown
    - ADVICE:
      - Open an issue at https://github.com/nvim-treesitter/nvim-treesitter

## javascript parser healthcheck
  - OK: javascript parser found.
  - OK: `locals.scm` found.
  - OK: `highlights.scm` found.

## Missing parsers
  - WARNING: Some parsers are not installed:
    html
    typescript
    nix
    swift
    yaml
    elm
    vue
    cpp
    toml
    ruby
    ocaml
    go
    scala
    haskell
    json
    css
    julia
    php
    c_sharp
    bash
    tsx
    - ADVICE:
      - Install them using `:TSInstall language

Output of nvim --version

NVIM v0.5.0-583-gec7a15f2f-dirty
Build type: Debug
LuaJIT 2.1.0-beta3
Compilation: /bin/cc -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -
fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=1 -I/home/thomas/src/neovim/build/config -I/home/thomas/src/neovim/sr
c -I/home/thomas/src/neovim/.deps/usr/include -I/usr/include -I/home/thomas/src/neovim/build/src/nvim/auto -I/home/thomas/src/neovim/build/include
Compilé par thomas@fixe-thomas

Features: +acl +iconv +tui
See ":help feature-compile"

         fichier vimrc système : "$VIM/sysinit.vim"
               $VIM par défaut : "/usr/local/share/nvim"

Run :checkhealth for more info

Incorrect definition highlighting in for different scopes

Describe the bug
Definition is incorrect when the focused symbol is the definition.

To Reproduce
Given this javascript file

nvim-ts-error-1

When the cursor is on the variable a (not the function parameter), the function parameter a is highlighted as the definition.
If the parenthesis are removed from the arguments the variable definition is flagged as the definition of the argument.'

nvim-ts-error-2

Expected behavior
Neither one should be highlighted since they are in different scopes and are definitions them self. This may just be an issue with the queries for javascript or the algorithm used for finding definitions.

**Output of :checkhealth nvim_treesitter ***

Paste the output here

Output of nvim --version

Paste your output here

Additional context
Add any other context about the problem here.

Have to use augroup to customize highlight groups

Is your feature request related to a problem? Please describe.

Commit 282e18e added support for custom highlight groups, I'm trying to make my color scheme support this plugin.

However, I have to use augroup to get it work, see this commit.

I think using augroup is not a good solution, the custom hi groups should be placed in colors/colorscheme.vim. My color scheme supports some other enhanced syntax highlighting plugins such as chromatica, vim-lsp-cxx-highlight and semshi, they don't need an augroup and just work if I place the code in colors/colorscheme.vim.

Describe the solution you'd like

The code for custom highlight groups should work when I place them in colors/colorscheme.vim without an augroup.

Describe alternatives you've considered

Additional context

To reproduce it, edit the color scheme you are using in your init.vim. Restart nvim, and the custom hi groups won't be applied.

Make installer cross compatible

the installer currently only works on *nix systems with gcc as a compiler. We need to make this command work on macos and windows. Windows support will be harder to implement as we also need to handle path resolution differently.

TSBufToggle

When i work in some files, i sometime want to enable a plugin that uses the default neovim syntax (like styled-components stuff in js files).
Mapping TSBufDisable and TSBufEnable would work but it's a hassle and it would be easier to just map TSBufToggle highlight.

Highlight for `function.builtin` does not work

In highlight.lua: hlmap["function.builtin"] = "Special" has not effect. All queries will be highlighted as function.

The query itself works, changing it to @type will use the Type highlighting. Also inventing a new name without . will work.

((call
  function: (identifier) @function.builtin)
 (match?
   @function.builtin
   "^(abs|all|any|ascii|bin|bool|breakpoint|bytearray|bytes|callable|chr|classmethod|compile|complex|delattr|dict|dir|divmod|enumerate|eval|exec|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|isinstance|issubclass|iter|len|list|locals|map|max|memoryview|min|next|object|oct|open|ord|pow|print|property|range|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|vars|zip|__import__)$"))

hl_map['method'] ignores color

Describe the bug
When defining a highlight scheme for the method the hlmap["method"] group ignores the color being set and seems to revert to the global default.

tree-sitter_issue
On the left-hand side, I have set the color bold_red for hlmap["method"]. However, as seen for torch.arange on the right-hand side only the bold font is being applied. I played a lot with the highlighting groups (still have not found how I quite like it perfectly :) and everything else seemed to have worked fine.

To Reproduce
Steps to reproduce the behavior:
Set hlmap["method"] to anything else but the standard highlighting group. For instance, see "[4.8] nvim-treesitter in my init.vim. I define highlighting groups for my colorscheme gruvbox further below manually to have more control and hopefully facilitates to reproduce the issue.

Expected behavior
Color highlighting for method group as set in config.

Output of :checkhealth nvim_treesitter
health -- nvim_treesitter -- check
-- Installation

  • OK: git executable found.
  • OK: cc executable found.

-- python parser

  • OK: python parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: textobjects.scm found.

Output of nvim --version
NVIM v0.5.0-594-ga02a267f8
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-5 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/travis/build/neovim/bot-ci/build/neovim/build/config -I/home/travis/build/neovim/bot-ci/build/neovim/src -I/home/travis/build/neovim/bot-ci/build/neovim/.deps/usr/include -I/usr/include -I/home/travis/build/neovim/bot-ci/build/neovim/build/src/nvim/auto -I/home/travis/build/neovim/bot-ci/build/neovim/build/include
Compiled by travis@travis-job-8f879c1d-28ee-4300-8b89-6a5ac11fd666

Features: +acl +iconv +tui
See ":help feature-compile"

system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/share/nvim"

Additional context
Thank you for your great work on the plugin! Great progress and I've been playing with the past few days quite a lot :)

"Plugin runtime path not found" when installed via dein.vim

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Install nvim-treesitter via dein.vim. (add a line call dein#add('nvim-treesitter/nvim-treesitter') in the init.vim file)
  2. Run :call dein#install().
  3. Restart NeoVim.
  4. Run :TSInstall lua.
  5. See error

Expected behavior
Should install lua parser properly.

Output of :checkhealth nvim_treesitter

health#nvim_treesitter#check

Installation

  • OK: git executable found.
  • OK: cc executable found.

c parser healthcheck

  • OK: c parser found.
  • OK: locals.scm found.
  • OK: highlights.scm found.

Missing parsers

  • WARNING: Some parsers are not installed:
    html
    typescript
    regex
    nix
    swift
    java
    python
    yaml
    elm
    vue
    cpp
    toml
    lua
    ruby
    ocaml
    go
    scala
    haskell
    rust
    json
    markdown
    javascript
    css
    julia
    php
    c_sharp
    bash
    tsx
    • ADVICE:
      • Install them using `:TSInstall language

Output of nvim --version

NVIM v0.5.0-593-g1ca67a73c
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/share/nvim"

Run :checkhealth for more info

Impossible to add a custom parser

Describe the bug
When building and installing manually a custom parser, nvim-treesitter does not let you use it easily.

To Reproduce
Build a custom parser or get tree-sitter-viml without installing it.

Try to use it with the playground.

Nothing happens and the buffer is not attached to.

Expected behavior
It should be possible to add your own parser / queries and use nvim-treesitter like with any other parser.

Additional context
I think the problem comes from how the module system handles languages.

Support `locals` for highlighting

Is your feature request related to a problem? Please describe.
Semshi provides semantic highlighting. In particular

  • Highlighting of imported names
  • Highlighting of definition of symbol under cursor
  • Highlighting of other usages of symbol under cursor

We could implement this feature in a language-agnostic way.

Describe the solution you'd like

  • We could include queries for imported names rather than count them as definition. @include in locals.scm
  • We could write a function to get definition of a symbol (@definition or @include)
  • We could write a function to get usages of a definition or include (@references)

Aren't those function aleady defined somewhere in completion-treesitter? (to lazy to look up)

Describe alternatives you've considered
N/A

Additional context
Semshi looks good and the differentiation of local symbols vs imported ones is super helpful.

Would be fast to implement but I am too lazy for that today.

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.