Skip to content

Wisely add "end" in Ruby, Vimscript, Lua, etc. Tree-sitter aware alternative to tpope's vim-endwise

License

Notifications You must be signed in to change notification settings

brianhuster/nvim-treesitter-endwise

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wisely add "end" in Ruby, Lua, Vimscript, etc.

Untitled.mov

Introduction

This is a simple plugin that helps to end certain structures automatically. In Ruby, this means adding end after if, do, def, etc.

Supported Languages: Ruby, Lua, Vimscript, Bash, Elixir, Fish, Julia

Quick Start

You can install this plugin using your favorite plugin manager or packages feature in Neovim.

Note

This plugin does not support lazy loading.

After installing the plugin, make sure that you install the Treesitter parsers for the languages. For example, if you use nvim-treesitter:

:TSInstall ruby lua vim bash elixir fish julia

Also make sure that you have enabled Treesitter highlighting for the filetypes you want to use this plugin with.

vim.api.nvim_create_autocmd('FileType', {
    pattern = {'ruby', 'lua', 'vim', 'bash', 'elixir', 'fish', 'julia'},
    callback = function()
        vim.treesitter.start()
    end
})

If you want to enable this plugin for some filetypes only, you can use the following code:

vim.g.treesitter_endwise_filetypes = {'ruby', 'lua', 'vim', 'bash', 'elixir', 'fish', 'julia'}

Or to disable it for some filetypes:

vim.g.treesitter_endwise_filetypes_disable = {'fish'}

Additional Language Support

Please open an issue for new languages, right now I'm open PRs but I won't be implementing other languages myself (except for maybe shell script). See RRethy#2 (comment) for more information on adding support for a new language.

Credit

This is just a rewrite of https://github.com/tpope/vim-endwise to leverage Treesitter so it can be more accurate and work without having to run Neovim's slow regex based highlighting along with nvim-treesitter highlighting.

Special thanks to

About

Wisely add "end" in Ruby, Vimscript, Lua, etc. Tree-sitter aware alternative to tpope's vim-endwise

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 56.9%
  • Scheme 42.9%
  • Makefile 0.2%