All Projects → nvim-treesitter → playground

nvim-treesitter / playground

Licence: Apache-2.0 license
Treesitter playground integrated into Neovim

Programming Languages

lua
6591 projects

Projects that are alternatives of or similar to playground

nvim-yati
Yet another tree-sitter powered indent plugin for Neovim.
Stars: ✭ 60 (-87.15%)
Mutual labels:  tree-sitter, nvim-treesitter
awesome-tree-sitter
Curated list of awesome tree-sitter language grammars, bindings, tools, libraries
Stars: ✭ 29 (-93.79%)
Mutual labels:  tree-sitter
tree-sitter.el
An Emacs dynamic module exposing tree-sitter.
Stars: ✭ 59 (-87.37%)
Mutual labels:  tree-sitter
tree-sitter-hcl
A tree-sitter grammar for HCL (HashiCorp Configuration Language), used by projects such as Terraform.
Stars: ✭ 65 (-86.08%)
Mutual labels:  tree-sitter
haskell-tree-sitter
Haskell bindings for tree-sitter
Stars: ✭ 123 (-73.66%)
Mutual labels:  tree-sitter
kosmikoa.nvim
A dark color scheme for Neovim with support for LSP, Treesitter. This mirror is deprecated. Use the repo at https://sr.ht/~novakane/kosmikoa.nvim/
Stars: ✭ 23 (-95.07%)
Mutual labels:  tree-sitter
Tree Sitter
An incremental parsing system for programming tools
Stars: ✭ 7,083 (+1416.7%)
Mutual labels:  tree-sitter
tree-sitter-haskell
Haskell grammar for tree-sitter.
Stars: ✭ 110 (-76.45%)
Mutual labels:  tree-sitter
tree-sitter-java
Java grammar for tree-sitter
Stars: ✭ 73 (-84.37%)
Mutual labels:  tree-sitter
ltreesitter
Standalone tree sitter bindings for the Lua language
Stars: ✭ 62 (-86.72%)
Mutual labels:  tree-sitter
tree-sitter-lua
Lua grammar for tree-sitter.
Stars: ✭ 40 (-91.43%)
Mutual labels:  tree-sitter
tree-sitter-cli
CLI tool for creating and testing tree-sitter parsers
Stars: ✭ 43 (-90.79%)
Mutual labels:  tree-sitter
tree-sitter-regex
Tree-sitter parser for regular expressions
Stars: ✭ 42 (-91.01%)
Mutual labels:  tree-sitter
tree-sitter-rust
Rust grammar for tree-sitter
Stars: ✭ 199 (-57.39%)
Mutual labels:  tree-sitter
tree-sitter-elixir
ananthakumaran.in/tree-sitter-elixir
Stars: ✭ 43 (-90.79%)
Mutual labels:  tree-sitter
tree-sitter-php
PHP grammar for tree-sitter
Stars: ✭ 83 (-82.23%)
Mutual labels:  tree-sitter
reason-tree-sitter
ReasonML bindings for tree-sitter
Stars: ✭ 22 (-95.29%)
Mutual labels:  tree-sitter
tree-sitter-css
CSS grammar for Tree-sitter
Stars: ✭ 57 (-87.79%)
Mutual labels:  tree-sitter
tree-sitter-julia
Julia grammar for Tree-sitter
Stars: ✭ 53 (-88.65%)
Mutual labels:  tree-sitter
go-tree-sitter
Golang bindings for tree-sitter https://github.com/tree-sitter/tree-sitter
Stars: ✭ 137 (-70.66%)
Mutual labels:  tree-sitter

Neovim Treesitter Playground

View treesitter information directly in Neovim!

nvim-treesitter-playground

Requirements

Setup

Install the plugin (vim-plug shown):

Plug 'nvim-treesitter/nvim-treesitter'
Plug 'nvim-treesitter/playground'

It's also recommended that you install the query parser for query editor highlighting. Run this after installing the above plugins.

:TSInstall query

The configuration is like any other nvim-treesitter module.

require "nvim-treesitter.configs".setup {
  playground = {
    enable = true,
    disable = {},
    updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code
    persist_queries = false, -- Whether the query persists across vim sessions
    keybindings = {
      toggle_query_editor = 'o',
      toggle_hl_groups = 'i',
      toggle_injected_languages = 't',
      toggle_anonymous_nodes = 'a',
      toggle_language_display = 'I',
      focus_language = 'f',
      unfocus_language = 'F',
      update = 'R',
      goto_node = '<cr>',
      show_help = '?',
    },
  }
}

Usage

The tree can be toggled using the command :TSPlaygroundToggle.

Keybindings

  • R: Refreshes the playground view when focused or reloads the query when the query editor is focused.
  • o: Toggles the query editor when the playground is focused.
  • a: Toggles visibility of anonymous nodes.
  • i: Toggles visibility of highlight groups.
  • I: Toggles visibility of the language the node belongs to.
  • t: Toggles visibility of injected languages.
  • f: Focuses the language tree under the cursor in the playground. The query editor will now be using the focused language.
  • F: Unfocuses the currently focused language.
  • <cr>: Go to current node in code buffer

Query Editor

Press o to show the query editor. Write your query like (node) @capture, put the cursor under the capture to highlight the matches.

Completions

When you are on a query buffer, you can get a list of suggestions with Ctrl-X Ctrl-O. See :h 'omnifunc'.

Query Linter

The playground can lint query files for you. For that, you need to activate the query_linter module:

require "nvim-treesitter.configs".setup {
  query_linter = {
    enable = true,
    use_virtual_text = true,
    lint_events = {"BufWrite", "CursorHold"},
  },
}

image

Show treesitter and syntax highlight groups under the cursor

The playground comes with :TSHighlightCapturesUnderCursor that shows any treesitter or syntax highlight groups under the cursor.

image

image

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].