All Projects → yioneko → nvim-yati

yioneko / nvim-yati

Licence: other
Yet another tree-sitter powered indent plugin for Neovim.

Programming Languages

lua
6591 projects
rust
11053 projects
javascript
184084 projects - #8 most used programming language
PHP
23972 projects - #3 most used programming language
c
50402 projects - #5 most used programming language
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to nvim-yati

playground
Treesitter playground integrated into Neovim
Stars: ✭ 467 (+678.33%)
Mutual labels:  tree-sitter, nvim-treesitter
deep-learning-for-indentation
Extraction of mechanical properties of materials through deep learning from instrumented indentation
Stars: ✭ 35 (-41.67%)
Mutual labels:  indentation
tree-sitter-haskell
Haskell grammar for tree-sitter.
Stars: ✭ 110 (+83.33%)
Mutual labels:  tree-sitter
tree-hugger
A light-weight, extendable, high level, universal code parser built on top of tree-sitter
Stars: ✭ 96 (+60%)
Mutual labels:  tree-sitter
tree-sitter-typescript
TypeScript grammar for tree-sitter
Stars: ✭ 154 (+156.67%)
Mutual labels:  tree-sitter
SwiftTreeSitter
Swift wrappers for the tree-sitter incremental parsing system
Stars: ✭ 116 (+93.33%)
Mutual labels:  tree-sitter
LuaExtended
An improved ST3 Lua syntax definition.
Stars: ✭ 19 (-68.33%)
Mutual labels:  indentation
tree-sitter-markdown
A markdown grammar for tree-sitter
Stars: ✭ 168 (+180%)
Mutual labels:  tree-sitter
Pyxell
Multi-paradigm programming language compiled to C++, written in Python.
Stars: ✭ 42 (-30%)
Mutual labels:  indentation
tree-sitter-legesher-python
✨ Legesher's Python grammar for Tree-Sitter 🌳
Stars: ✭ 40 (-33.33%)
Mutual labels:  tree-sitter
zee
A modern text editor for the terminal written in Rust
Stars: ✭ 1,120 (+1766.67%)
Mutual labels:  tree-sitter
vscode-blockman
VSCode extension to highlight nested code blocks
Stars: ✭ 233 (+288.33%)
Mutual labels:  indentation
tree-sitter-html
HTML grammar for Tree-sitter
Stars: ✭ 56 (-6.67%)
Mutual labels:  tree-sitter
tree-sitter-julia
Julia grammar for Tree-sitter
Stars: ✭ 53 (-11.67%)
Mutual labels:  tree-sitter
tree-sitter-tlaplus
A tree-sitter grammar for TLA+
Stars: ✭ 31 (-48.33%)
Mutual labels:  tree-sitter
go-tree-sitter
Golang bindings for tree-sitter https://github.com/tree-sitter/tree-sitter
Stars: ✭ 137 (+128.33%)
Mutual labels:  tree-sitter
unindent
Report code that is unnecessarily indented
Stars: ✭ 18 (-70%)
Mutual labels:  indentation
ruby-tree-sitter
Ruby bindings to tree-sitter
Stars: ✭ 48 (-20%)
Mutual labels:  tree-sitter
rust-tree-sitter
Rust bindings to Tree-sitter
Stars: ✭ 29 (-51.67%)
Mutual labels:  tree-sitter
tree-sitter-toml
TOML grammar for tree-sitter
Stars: ✭ 23 (-61.67%)
Mutual labels:  tree-sitter

nvim-yati

Yet another tree-sitter indent plugin for Neovim.

This plugin was originally created when the experience of builtin indent module of nvim-treesitter was still terrible. Now since the maintainers came back, and it has improved a lot and become usable, I'll stop maintaining this once the 'official' one completely supersede (also hope it will!).

Currently I'm very confident that this plugin is nearly perfect and should cover most of the situations for supported languages. If you are still frustrated with the 'official' indent module, welcome to use this plugin instead as temporary solution. Feel free to submit issues for any problems.

The details of configuration are described at CONFIG.md. Take a glance at it if you are interested in internal working principles or helping development.

Setup

Install with packer.nvim:

use({ "yioneko/nvim-yati", requires = "nvim-treesitter/nvim-treesitter" })

Enable this module:

require("nvim-treesitter.configs").setup {
  yati = { enable = true },
}

Features

  • Fast, match node on demand by implementing completely in Lua, compared to executing scm query on the whole file on every indent calculation (that's why I use Lua table instead of scm query for configuration).

  • Support indent in injection region. See sample.html for example.

  • Tests covered and handles much more edge cases. Refer samples in that directory for what the indentation would be like (it is slightly opinionated since there is no actual standard for it).

  • Support for custom hooks to deal with complex scenarios. Personally I regard this as killer feature of this plugin and finally making it possible to become perfect.

    For example, the following situation is difficult to handle in pure scm query because of breaking of syntax tree in Python:

    if True:
      pass
      else # should auto dedent

    But by using custom hooks in Lua, we could use regex to test the line and check the tree programmatically to make the decision of dedent. I already create many commonly used hooks in chains.lua and other language-specific hooks in their configs.

Notes

The calculation result heavily relies on the correct tree-sitter parsing of the code. I'd recommend using plugins like windwp/nvim-autopairs to keep the syntax tree error-free while inserting. This should avoid most of the wrong indent calculations.

Supported languages

  • C/C++
  • CSS
  • GraphQL
  • HTML
  • Javascript/Typescript (jsx and tsx are also supported)
  • JSON
  • Lua
  • Markdown
  • PHP
  • Python
  • Rust
  • TOML
  • Vim
  • YAML

More languages could be supported by adding config files to configs/ directory.

Credits

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].