Skip to main content

install(languages, opts)

Download, compile, and install the specified treesitter parsers and copy the corresponding queries to a directory on runtimepath, enabling their use in Neovim.
This operation is performed asynchronously by default. For synchronous operation (e.g., in a bootstrapping script), you need to wait() for it.

Parameters

languages
string|string[]
required
Language(s) to install. Can be:
  • A single language name (e.g., "rust")
  • An array of language names (e.g., { "rust", "javascript", "python" })
  • A tier name: "stable", "unstable", "unmaintained", or "all" (not recommended)
The special value "all" installs all available parsers.
opts
table
Installation options

Returns

success
boolean
Returns true if all installations were successful, false otherwise.Note: This function returns an awaitable object when called asynchronously.

Usage

Basic Installation

-- Install a single parser
require('nvim-treesitter').install('rust')

-- Install multiple parsers
require('nvim-treesitter').install({ 'rust', 'javascript', 'python' })

Synchronous Installation

For bootstrapping scripts or when you need to wait for installation to complete:
require('nvim-treesitter').install({ 'rust', 'javascript', 'zig' })
  :wait(300000) -- max 5 minutes

Force Reinstall

require('nvim-treesitter').install('rust', { force = true })

Generate from Grammar

require('nvim-treesitter').install('c', { 
  generate = true,
  max_jobs = 4  -- Limit parallel jobs on low-memory systems
})

Install with Summary

require('nvim-treesitter').install(
  { 'lua', 'vim', 'vimdoc', 'query' },
  { summary = true }
)

Installation Process

The install function performs these steps for each language:
  1. Download: Fetches the parser source from the configured repository (usually GitHub)
  2. Extract: Unpacks the tarball to a temporary cache directory
  3. Generate (optional): Runs tree-sitter generate if requested or required
  4. Compile: Builds the parser using tree-sitter build
  5. Install: Copies the compiled parser to the installation directory
  6. Queries: Links or copies query files to make them available to Neovim
The function automatically handles parser dependencies. If a parser requires other parsers, they will be installed automatically.

Requirements

  • curl - for downloading parser sources
  • tar - for extracting archives
  • tree-sitter CLI - for compiling parsers (and optionally generating from grammar)
  • A C compiler - used by tree-sitter for compilation

See Also