Jxstxs/conceal.nvim

github github
editing-support
stars 58
issues 1
subscribers 1
forks 7
CREATED

2022-10-27

UPDATED

5 months ago


conceal.nvim

A Neovim Plugin which uses Tree-sitter to conceal typical boiler Code

TL;DR

  • Conceals Boiler Code with Tree-sitter
  • Keywords can be disabled (all Keywords are enabled by default)
  • Conceal Chars can be defined (defaults are given)
  • Highlight group can be defined (uses the default groups)

Demo

Installation

Using packer.nvim

use { "Jxstxs/conceal.nvim", requires = "nvim-treesitter/nvim-treesitter" }

Requirements

  • Neovim Nightly (v0.9.0-dev-124-gbd7ca10fd, the Version i Use)
  • nvim-treesitter

Usage/Examples

local conceal = require("conceal")

-- should be run before .generate_conceals to use user Configuration
conceal.setup({
    --[[ ["language"] = {
        enabled = bool,
        keywords = {
          ["keyword"] = {
              enabled     = bool,
              conceal     = string,
              highlight   = string
          }
        }
    } ]]
    ["lua"] = {
      enabled = true,
      keywords = {
        ["local"] = {
          enabled = false -- to disable concealing for "local"
        },
        ["return"] = {
          conceal = "R" -- to set the concealing to "R"
        },
        ["for"] = {
          highlight = "keyword" -- to set the Highlight group to "@keyword"
        }
      }
    },
    ["language"] = {
      enabled = false -- to disable the whole language
    }
})

-- generate the scm queries
-- only need to be run when the Configuration changes
conceal.generate_conceals()

-- bind a <leader>tc to toggle the concealing level
vim.keymap.set("n", "<leader>tc", function()
  require("conceal").toggle_conceal()
end, { silent = true})

Features

  • Conceal Boilerplate Code with a given Highlight group and conceal char
  • Function to toggle the Concealing Level

Contributing

Contributions are always welcome! Just remember to be Kind

License

This Project uses the MIT License, as mentioned here.