Skip to content

This is the lua implementation of nvim-hlchunk, you can use this neovim plugin to highlight your indent line and the current chunk (context) your cursor stayed

License

Notifications You must be signed in to change notification settings

shellRaining/hlchunk.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hlchunk.nvim

English | 简体中文

This is the lua implementation of nvim-hlchunk, and add some new features like highlighting indentline, specially thanks indent-blankline.nvim, during the process of writing this plugin, this repo provided a lot of help and inspiration for me

brief

this plugin now have four parts (future will add more... ^v^)

  1. hl_chunk
  2. hl_indent
  3. hl_line_num
  4. hl_blank

the first one is to highlight the current chunk, a chunk is defined as the closest pair of curly braces and the code in between, so it might not work very well in lua or python source code. In the future, I might define a chunk by using indentation (so, this plugin may become another indent_blankline in the future, laugh)

the second one is to highlight indentline like indent_blankline, you can choose a different indent render mode, one is base treesitter, another is base on the number of blank. the advantage of treeitter is that it is very accurate, but it may have low performance, and doesn't support some filetype, such as markdown, if you choose the latter mode, it will render faster (maybe), but will have some issues in particular situation, example below.

image

base on blank number

image

base on treesitter

the third one is similar to hl_chunk, the difference is that it will highlight line number, you can set front color or background color for it

the last one is hl_blank, which can highlight the blank with some funny char and style, you can see in the example below, you can find many chars in this website Unicode Plus

example

image

hl_chunk

image

image

hl_indent

image

hl_line_num

image

hl_blank

Requirements

neovim version >= 0.7.0 (maybe, just test at this version)

Installation

Packer

use { "shell-Raining/hlchunk.nvim" }

Plug

Plug "shell-Raining/hlchunk.nvim"

Setup

The script comes with the following defaults:

{
    chunk = {
        enable = true,
        support_filetypes = {
            "*.ts",
            "*.js",
            "*.json",
            "*.go",
            "*.c",
            "*.cpp",
            "*.rs",
            "*.h",
            "*.hpp",
            "*.lua",
            "*.vue",
        },
        chars = {
            horizontal_line = "",
            vertical_line = "",
            left_top = "",
            left_bottom = "",
            right_arrow = ">",
        },
        style = "#00ffff",
    },

    indent = {
        enable = true,
        use_treesitter = false,
        -- You can uncomment to get more indented line look like
        chars = {
            "",
            -- "¦",
            -- "┆",
            -- "┊",
        },
        -- you can uncomment to get more indented line style
        style = {
            vim.fn.synIDattr(vim.fn.synIDtrans(vim.fn.hlID("Whitespace")), "fg", "gui"),
            -- "#FF0000",
            -- "#FF7F00",
            -- "#FFFF00",
            -- "#00FF00",
            -- "#00FFFF",
            -- "#0000FF",
            -- "#8B00FF",
        },
        exclude_filetype = {
            dashboard = true,
            help = true,
            lspinfo = true,
            packer = true,
            checkhealth = true,
            man = true,
            mason = true,
            NvimTree = true,
            plugin = true,
        },
    },

    line_num = {
        enable = true,
        support_filetypes = {
            "..."
        },
        style = "#806d9c",
    },

    blank = {
        enable = true,
        chars = {
            "",
            "",
            "",
            "",
            "",
        },
        style = {
            vim.fn.synIDattr(vim.fn.synIDtrans(vim.fn.hlID("Whitespace")), "fg", "gui"),
            "#806d9c",
            "#c06f98",
        },
        exclude_filetype = "...",
    },
}

example:

require('hlchunk').setup({
    indent = {
        enable = true,

        -- if you want to use multiple indent line, just place them here, the key is like vertical_line + x, which x is a number
        chars = {
            vertical_line1 = "",
            vertical_line2 = "¦",
            vertical_line3 = "",
            vertical_line4 = "",
        },

        style = {
            "#8B00FF",
        },
    },
})

command

this plugin provides some commands to switch plugin status, which are listed below

  • EnableHL
  • DisableHL

the two commands are used to switch the whole plugin status, when use DisableHL, include hl_chunk and hl_indent will be disable

  • DisableHLChunk
  • EnableHLChunk

the two will control hl_chunk

  • DisableHLIndent
  • EnableHLIndent

the two will control hl_indent

  • DisableHLLineNum
  • EnableHLLineNum

the two will control hl_line_num

  • DisableHLBlank
  • EnableHLBlank

the two will control hl_blank

About

This is the lua implementation of nvim-hlchunk, you can use this neovim plugin to highlight your indent line and the current chunk (context) your cursor stayed

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published