Skip to content

jcarlos7121/blockle.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

blockle.nvim

Toggle Ruby blocks between do ... end and { ... }.

A spiritual successor to vim-blockle, which is no longer maintained. This one is rewritten from scratch for Neovim in Lua and uses the Ruby treesitter parser to find blocks accurately (no regex guessing).

Requirements

  • Neovim 0.9+
  • nvim-treesitter with the ruby parser installed

Install

With lazy.nvim:

{
  "jcarlos7121/blockle.nvim",
  ft = "ruby",
  opts = {},
}

With packer.nvim:

use({
  "jcarlos7121/blockle.nvim",
  ft = "ruby",
  config = function() require("blockle").setup() end,
})

Configuration

Defaults:

require("blockle").setup({
  keymap = "<Leader>b", -- set to false to skip the default mapping
})

If you'd rather map it yourself:

require("blockle").setup({ keymap = false })
vim.keymap.set("n", "<Leader>rb", require("blockle").toggle, { desc = "Toggle Ruby block" })

Behavior

Place the cursor anywhere inside a block, then press <Leader>b:

# before
[1, 2, 3].each do |n|
  puts n
end

# after
[1, 2, 3].each { |n| puts n }

And the reverse — { ... } expands to multi-line do ... end. Block parameters (|x, y|) are preserved.

License

MIT

About

Neovim/Lua successor to the abandoned vim-blockle — toggle Ruby blocks between do/end and {}

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages