MIT License

项目介绍

shellRaining/hlchunk.nvim 是一个托管在 GitHub 上的开源项目,主要使用 Lua 编写,采用 MIT License 许可证,目前获得 923 个 Star、46 次 Fork。

仓库全名
shellRaining/hlchunk.nvim
开源许可证
MIT License
Star 数
923
Fork 数
46
未关闭 Issue
37

README 摘要

hlchunk.nvim English | 简体中文 What can this plugin do Similar to indent-blankline, this plugin can highlight the indent line, and highlight the code chunk according to the current cursor position. plugin performance Using profile.nvim for performance analysis, all experiments were conducted on macOS with alacritty, Neovim window height was 66 lines, the code file was typescript.js, starting from the first line to the…

完整内容见 GitHub 原始 README 或本页 。

常见问题

hlchunk.nvim 用什么语言开发?

主要使用 Lua 编写,采用 MIT License 许可证,目前有 923 个 Star。

hlchunk.nvim 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 hlchunk.nvim 的源码?

可以直接克隆仓库:git clone https://github.com/shellRaining/hlchunk.nvim.git,默认分支为 main;安装与运行步骤见仓库 README。

hlchunk.nvim 最近还在维护吗?

仓库最近一次更新为 8月6日,当前有 37 个未关闭 Issue;Star 数为 923,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

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

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
1022
价值分
566
活跃状态
活跃

语言占比

Lua
Makefile
Shell

Release

README

hlchunk.nvim

English | 简体中文

What can this plugin do

Similar to indent-blankline, this plugin can highlight the indent line, and highlight the code chunk according to the current cursor position.

plugin performance

Using profile.nvim for performance analysis, all experiments were conducted on macOS with alacritty, Neovim window height was 66 lines, the code file was typescript.js, starting from the first line to the five hundredth line. The average rendering time per render was 0.7ms.

I did a lot of work to minimize rendering time as much as possible

  1. Asynchronous rendering to reduce stuttering

  2. Using C functions to speed up some function calls

  3. Caching extmarks for each line as much as possible to reduce indentation calculations

  4. Using throttle functions to batch the rendering process as much as possible

If you want to reduce the sudden stuttering when scrolling the window, maybe you will like hlchunk.nvim~

For detailed optimization work, you can see my blog (written in Chinese): https://www.shellraining.top/docs/tools/hlchunk/profile.html

Brief introduction

This plugin now have four parts

  1. chunk
  2. indent
  3. line_num
  4. blank

One picture to understand what these mods do

more details about each mod

NOTICE: you can click the picture to get more information about how to configure like this

chunk

image

indent

image image image

line_num

image

blank

image

Requirements

neovim version >= 0.10.0

Installation (with lazy.nvim)

{
  "shellRaining/hlchunk.nvim",
  event = { "BufReadPre", "BufNewFile" },
  config = function()
    require("hlchunk").setup({})
  end
},

Setup

This plugin is composed of multiple mods, so they have some common configuration items as follows:

local default_conf = {
    enable = false,
    style = {},
    notify = false,
    priority = 0,
    exclude_filetypes = {
        aerial = true,
        dashboard = true,
        -- some other filetypes
    }
}
  1. enable: control whether a certain mod is enabled
  2. style: used to control the style of the mod, different mods will have different style configuration methods, you can check their respective documentation for details
  3. notify: used to control whether a certain mod displays notification messages (through the notify function)
  4. priority: used to control the rendering priority of a certain mod, the higher the priority, the higher the priority of display, by default chunk > indent > blank > line_num
  5. exclude_filetypes: used to control that a certain mod is not enabled for certain file types

The specific configuration methods for each mod can be found in their respective documentation, the links are as follows:

You can config the whole plugin by using setup function:

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

Require the specific mod alone also work

local indent = require('hlchunk.mods.indent')
indent({
    style = {
        -- ...
    }
}):enable() -- don't forget call enable method

notice

Because this plugin use shiftwidth function to get the indent width, so for files that do not set the indent width manually, there may be inaccurate situations, you can set the indent width manually:

vim.bo.shiftwidth = xxx

If you feel boring to set the indent width manually, you can use autoindent.nvim or indent-o-matic to guess indent automatically.

command

Sometimes (e.g., for performance reasons), you may want to manually disable a certain mod, you can follow the rules below: enter DisableHLxxxx, replacing xxxx with the name of the mod you want to disable, for example, to disable chunk, you can enter DisableHLchunk.

Similarly, to enable a mod, enter EnableHLxxxx.

However, for mods with enable set to false, the plugin itself will not create a user command (because there is no need).

Contributing

Contributions are welcome. The repo ships a lightweight pre-commit hook that runs selene and stylua --check on staged Lua files. Enable it once per clone:

git config core.hooksPath .githooks

Before opening a PR, run make selene && make stylua && make test locally. See AGENTS.md for the project map and ARCHITECTURE.md for the module layout.

评论

暂无评论