Full Code of folke/paint.nvim for AI

main 07ffa7e0e41f cached
23 files
26.5 KB
6.8k tokens
1 requests
Download .txt
Repository: folke/paint.nvim
Branch: main
Commit: 07ffa7e0e41f
Files: 23
Total size: 26.5 KB

Directory structure:
gitextract_tkhyu1o3/

├── .editorconfig
├── .github/
│   ├── ISSUE_TEMPLATE/
│   │   ├── bug_report.yml
│   │   ├── config.yml
│   │   └── feature_request.yml
│   ├── PULL_REQUEST_TEMPLATE.md
│   ├── dependabot.yml
│   └── workflows/
│       ├── ci.yml
│       ├── labeler.yml
│       ├── pr.yml
│       ├── stale.yml
│       └── update.yml
├── .gitignore
├── .markdownlint-cli2.yaml
├── CHANGELOG.md
├── LICENSE
├── README.md
├── doc/
│   └── paint.nvim.txt
├── lua/
│   └── paint/
│       ├── config.lua
│       ├── highlight.lua
│       └── init.lua
├── selene.toml
├── stylua.toml
└── vim.yml

================================================
FILE CONTENTS
================================================

================================================
FILE: .editorconfig
================================================
root = true

[*]
insert_final_newline = true
indent_style = space
indent_size = 2
charset = utf-8


================================================
FILE: .github/ISSUE_TEMPLATE/bug_report.yml
================================================
name: Bug Report
description: File a bug/issue
title: "bug: "
labels: [bug]
body:
  - type: markdown
    attributes:
      value: |
        **Before** reporting an issue, make sure to read the [documentation](https://github.com/folke/paint.nvim)
        and search [existing issues](https://github.com/folke/paint.nvim/issues).

        Usage questions such as ***"How do I...?"*** belong in [Discussions](https://github.com/folke/paint.nvim/discussions) and will be closed.
  - type: checkboxes
    attributes:
      label: Did you check docs and existing issues?
      description: Make sure you checked all of the below before submitting an issue
      options:
        - label: I have read all the paint.nvim docs
          required: true
        - label: I have updated the plugin to the latest version before submitting this issue
          required: true
        - label: I have searched the existing issues of paint.nvim
          required: true
        - label: I have searched the existing issues of plugins related to this issue
          required: true
  - type: input
    attributes:
      label: "Neovim version (nvim -v)"
      placeholder: "0.8.0 commit db1b0ee3b30f"
    validations:
      required: true
  - type: input
    attributes:
      label: "Operating system/version"
      placeholder: "MacOS 11.5"
    validations:
      required: true
  - type: textarea
    attributes:
      label: Describe the bug
      description: A clear and concise description of what the bug is. Please include any related errors you see in Neovim.
    validations:
      required: true
  - type: textarea
    attributes:
      label: Steps To Reproduce
      description: Steps to reproduce the behavior.
      placeholder: |
        1.
        2. 
        3.
    validations:
      required: true
  - type: textarea
    attributes:
      label: Expected Behavior
      description: A concise description of what you expected to happen.
    validations:
      required: true
  - type: textarea
    attributes:
      label: Repro
      description: Minimal `init.lua` to reproduce this issue. Save as `repro.lua` and run with `nvim -u repro.lua`
      value: |
        vim.env.LAZY_STDPATH = ".repro"
        load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

        require("lazy.minit").repro({
          spec = {
            { "folke/paint.nvim", opts = {} },
            -- add any other plugins here
          },
        })
      render: lua
    validations:
      required: false


================================================
FILE: .github/ISSUE_TEMPLATE/config.yml
================================================
blank_issues_enabled: false
contact_links:
  - name: Ask a question
    url: https://github.com/folke/paint.nvim/discussions
    about: Use Github discussions instead


================================================
FILE: .github/ISSUE_TEMPLATE/feature_request.yml
================================================
name: Feature Request
description: Suggest a new feature
title: "feature: "
labels: [enhancement]
body:
  - type: checkboxes
    attributes:
      label: Did you check the docs?
      description: Make sure you read all the docs before submitting a feature request
      options:
        - label: I have read all the paint.nvim docs
          required: true
  - type: textarea
    validations:
      required: true
    attributes:
      label: Is your feature request related to a problem? Please describe.
      description: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
  - type: textarea
    validations:
      required: true
    attributes:
      label: Describe the solution you'd like
      description: A clear and concise description of what you want to happen.
  - type: textarea
    validations:
      required: true
    attributes:
      label: Describe alternatives you've considered
      description: A clear and concise description of any alternative solutions or features you've considered.
  - type: textarea
    validations:
      required: false
    attributes:
      label: Additional context
      description: Add any other context or screenshots about the feature request here.


================================================
FILE: .github/PULL_REQUEST_TEMPLATE.md
================================================
## Description

<!-- Describe the big picture of your changes to communicate to the maintainers
  why we should accept this pull request. -->

## Related Issue(s)

<!--
  If this PR fixes any issues, please link to the issue here.
  - Fixes #<issue_number>
-->

## Screenshots

<!-- Add screenshots of the changes if applicable. -->



================================================
FILE: .github/dependabot.yml
================================================
version: 2
updates:
  - package-ecosystem: "github-actions"
    directory: "/"
    schedule:
      interval: "weekly"


================================================
FILE: .github/workflows/ci.yml
================================================
name: CI

on:
  push:
    branches: [main, master]
  pull_request:

jobs:
  ci:
    uses: folke/github/.github/workflows/ci.yml@main
    secrets: inherit
    with:
      plugin: paint.nvim
      repo: folke/paint.nvim


================================================
FILE: .github/workflows/labeler.yml
================================================
name: "PR Labeler"
on:
  - pull_request_target

jobs:
  labeler:
    uses: folke/github/.github/workflows/labeler.yml@main
    secrets: inherit


================================================
FILE: .github/workflows/pr.yml
================================================
name: PR Title

on:
  pull_request_target:
    types:
      - opened
      - edited
      - synchronize
      - reopened
      - ready_for_review

permissions:
  pull-requests: read

jobs:
  pr-title:
    uses: folke/github/.github/workflows/pr.yml@main
    secrets: inherit


================================================
FILE: .github/workflows/stale.yml
================================================
name: Stale Issues & PRs

on:
  schedule:
    - cron: "30 1 * * *"

jobs:
  stale:
    if: contains(fromJSON('["folke", "LazyVim"]'), github.repository_owner)
    uses: folke/github/.github/workflows/stale.yml@main
    secrets: inherit


================================================
FILE: .github/workflows/update.yml
================================================
name: Update Repo

on:
  workflow_dispatch:
  schedule:
    # Run every hour
    - cron: "0 * * * *"

jobs:
  update:
    if: contains(fromJSON('["folke", "LazyVim"]'), github.repository_owner)
    uses: folke/github/.github/workflows/update.yml@main
    secrets: inherit


================================================
FILE: .gitignore
================================================
*.log
/.repro
/.tests
/build
/debug
/doc/tags
foo.*
node_modules
tt.*


================================================
FILE: .markdownlint-cli2.yaml
================================================
config:
  MD013: false
  MD033: false


================================================
FILE: CHANGELOG.md
================================================
# Changelog

## 1.0.0 (2023-01-04)


### Features

* initial commit ([5b38fa4](https://github.com/folke/paint.nvim/commit/5b38fa4d4c27f95487b7dedcd61b8dc0d78966d0))


### Bug Fixes

* check for attach on FileType ([0f97a37](https://github.com/folke/paint.nvim/commit/0f97a3725474338a89d70d7ed1bb27345ec2451a))
* dont try to attach to unloaded buffers. Fixes [#1](https://github.com/folke/paint.nvim/issues/1) ([8f6ffd2](https://github.com/folke/paint.nvim/commit/8f6ffd2887366b0187eff3a960967f592c26b35f))
* resulting match to highlight should be found with plain=true ([ba9b84b](https://github.com/folke/paint.nvim/commit/ba9b84b159d35badf934ffd7a4fc257e09ae8dbb))


================================================
FILE: LICENSE
================================================
                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright [yyyy] [name of copyright owner]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.


================================================
FILE: README.md
================================================
# 🎨 Paint

Simple Neovim plugin to easily add additional highlights to your buffers.

See the `@something` comments in the screenshot. Those are not coming from the `comment` **Treesitter** parser.

![image](https://user-images.githubusercontent.com/292349/202141321-0c501a4f-163a-4a6f-8d0d-0c79d11a05a3.png)

## ❓ Why?

The reason I implemented this is because of the slow performance of [tree-sitter-comment](https://github.com/stsewd/tree-sitter-comment)
in large files. **Treesitter** will inject the `comment` language for every line
comment, which is far from ideal. I've disabled the `comment` parser, but still wanted
to see `@something` highlighted in Lua comments.

## ⚡️ Requirements

- Neovim >= 0.8.0

## 📦 Installation

Install the plugin with your preferred package manager:

```lua
-- Packer
use({
  "folke/paint.nvim",
  config = function()
    require("paint").setup({
      ---@type PaintHighlight[]
      highlights = {
        {
          -- filter can be a table of buffer options that should match,
          -- or a function called with buf as param that should return true.
          -- The example below will paint @something in comments with Constant
          filter = { filetype = "lua" },
          pattern = "%s*%-%-%-%s*(@%w+)",
          hl = "Constant",
        },
      },
    })
  end,
})
```


================================================
FILE: doc/paint.nvim.txt
================================================
*paint.nvim.txt*                                               paint.nvim docs

==============================================================================
Table of Contents                               *paint.nvim-table-of-contents*

1. Paint                                                    |paint.nvim-paint|
  - Why?                                               |paint.nvim-paint-why?|
  - Requirements                               |paint.nvim-paint-requirements|
  - Installation                               |paint.nvim-paint-installation|
2. Links                                                    |paint.nvim-links|

==============================================================================
1. Paint                                                    *paint.nvim-paint*

Simple Neovim plugin to easily add additional highlights to your buffers.

See the `@something` comments in the screenshot. Those are not coming from the
`comment` **Treesitter** parser.


WHY?                                                   *paint.nvim-paint-why?*

The reason I implemented this is because of the slow performance of
tree-sitter-comment <https://github.com/stsewd/tree-sitter-comment> in large
files. **Treesitter** will inject the `comment` language for every line
comment, which is far from ideal. I’ve disabled the `comment` parser, but
still wanted to see `@something` highlighted in Lua comments.


REQUIREMENTS                                   *paint.nvim-paint-requirements*

- Neovim >= 0.8.0


INSTALLATION                                   *paint.nvim-paint-installation*

Install the plugin with your preferred package manager:

>lua
    -- Packer
    use({
      "folke/paint.nvim",
      config = function()
        require("paint").setup({
          ---@type PaintHighlight[]
          highlights = {
            {
              -- filter can be a table of buffer options that should match,
              -- or a function called with buf as param that should return true.
              -- The example below will paint @something in comments with Constant
              filter = { filetype = "lua" },
              pattern = "%s*%-%-%-%s*(@%w+)",
              hl = "Constant",
            },
          },
        })
      end,
    })
<

==============================================================================
2. Links                                                    *paint.nvim-links*

1. *image*: https://user-images.githubusercontent.com/292349/202141321-0c501a4f-163a-4a6f-8d0d-0c79d11a05a3.png

Generated by panvimdoc <https://github.com/kdheepak/panvimdoc>

vim:tw=78:ts=8:noet:ft=help:norl:


================================================
FILE: lua/paint/config.lua
================================================
local M = {}

M.ns = vim.api.nvim_create_namespace("paint.nvim")

---@alias PaintFilterFun fun(buf):boolean
---@class PaintFilter: table<string,any>|PaintFilterFun
---@field filetype? string

---@class PaintHighlight
---@field filter PaintFilter
---@field pattern string
---@field hl string

--- @class PaintOptions
M.defaults = {
  ---@type PaintHighlight[]
  highlights = {
    {
      -- filter can be a table of buffer options that should match,
      -- or a function called with buf as param that should return true.
      -- The example below will paint @something in comments with Constant
      filter = { filetype = "lua" },
      pattern = "%s*%-%-%-%s*(@%w+)",
      hl = "Constant",
    },
  },
}

--- @type PaintOptions
M.options = {}

function M.setup(options)
  options = options or {}

  M.options = vim.tbl_deep_extend("force", {}, M.defaults, options)
end

return M


================================================
FILE: lua/paint/highlight.lua
================================================
local config = require("paint.config")

local M = {}
M.enabled = false
---@type table<number,number>
M.bufs = {}

---@param buf number
---@param first? number
---@param last? number
function M.highlight(buf, first, last)
  if not vim.api.nvim_buf_is_valid(buf) then
    return
  end

  first = first or 1
  last = last or vim.api.nvim_buf_line_count(buf)
  local lines = vim.api.nvim_buf_get_lines(buf, first - 1, last, false)

  vim.api.nvim_buf_clear_namespace(buf, config.ns, first - 1, last - 1)

  local highlights = M.get_highlights(buf)

  for l, line in ipairs(lines) do
    local lnum = first + l - 1

    for _, hl in ipairs(highlights) do
      local from, to, match = line:find(hl.pattern)

      while from do
        if match and match ~= "" then
          from, to = line:find(match, from, true)
        end

        vim.api.nvim_buf_set_extmark(
          buf,
          config.ns,
          lnum - 1,
          from - 1,
          { end_col = to, hl_group = hl.hl, priority = 110 }
        )

        from, to, match = line:find(hl.pattern, to + 1)
      end
    end
  end
end

---@return PaintHighlight[]
function M.get_highlights(buf)
  return vim.tbl_filter(
    ---@param hl PaintHighlight
    function(hl)
      return M.is(buf, hl.filter)
    end,
    config.options.highlights
  )
end

---@param buf number
---@param filter PaintFilter
function M.is(buf, filter)
  if type(filter) == "function" then
    return filter(buf)
  end
  ---@diagnostic disable-next-line: no-unknown
  for k, v in pairs(filter) do
    if vim.api.nvim_buf_get_option(buf, k) ~= v then
      return false
    end
  end
  return true
end

function M.detach(buf)
  vim.api.nvim_buf_clear_namespace(buf, config.ns, 0, -1)
  M.bufs[buf] = nil
end

function M.attach(buf)
  if M.bufs[buf] then
    return
  end
  if not (vim.api.nvim_buf_is_valid(buf) and vim.api.nvim_buf_is_loaded(buf)) then
    return
  end

  M.bufs[buf] = buf

  local ok = vim.api.nvim_buf_attach(buf, false, {
    on_lines = function(_, _, _, first, _, last)
      if not M.bufs[buf] then
        return true
      end
      vim.schedule(function()
        M.highlight(buf, first + 1, last + 1)
      end)
    end,
    on_reload = function()
      if not M.bufs[buf] then
        return true
      end
      M.highlight_buf(buf)
    end,
    on_detach = function()
      M.detach(buf)
    end,
  })
  if not ok then
    error("failed to attach")
  end
  M.highlight_buf(buf)
end

function M.highlight_buf(buf)
  local wins = vim.api.nvim_list_wins()
  for _, win in ipairs(wins) do
    if vim.api.nvim_win_get_buf(win) == buf then
      M.highlight_win(win)
    end
  end
end

-- highlights the visible range of the window
function M.highlight_win(win)
  win = win or vim.api.nvim_get_current_win()

  if not vim.api.nvim_win_is_valid(win) then
    return
  end

  local buf = vim.api.nvim_win_get_buf(win)
  if not M.bufs[buf] then
    return
  end

  vim.api.nvim_win_call(win, function()
    local first = vim.fn.line("w0")
    local last = vim.fn.line("w$")
    M.highlight(buf, first, last)
  end)
end

function M.disable()
  M.bufs = {}
  M.enabled = false
end

function M.enable()
  if M.enabled then
    M.disable()
  end
  M.enabled = true

  local group = vim.api.nvim_create_augroup("paint.nvim", { clear = true })

  vim.api.nvim_create_autocmd({ "BufWinEnter", "WinNew", "FileType" }, {
    group = group,
    callback = function(event)
      if #M.get_highlights(event.buf) > 0 then
        M.attach(event.buf)
      end
    end,
  })
  vim.api.nvim_create_autocmd("WinScrolled", {
    group = group,
    callback = function(event)
      if M.bufs[event.buf] then
        M.highlight_buf(event.buf)
      end
    end,
  })

  vim.schedule(function()
    -- attach to all bufs in visible windows
    for _, buf in pairs(vim.api.nvim_list_bufs()) do
      if vim.api.nvim_buf_is_valid(buf) and #M.get_highlights(buf) > 0 then
        M.attach(buf)
      end
    end
  end)
end

return M


================================================
FILE: lua/paint/init.lua
================================================
local M = {}

---@param opts? PaintOptions
function M.setup(opts)
  require("paint.config").setup(opts)
  require("paint.highlight").enable()
end

return M


================================================
FILE: selene.toml
================================================
std="vim"

[lints]
mixed_table="allow"


================================================
FILE: stylua.toml
================================================
indent_type = "Spaces"
indent_width = 2
column_width = 120
[sort_requires]
enabled = true



================================================
FILE: vim.yml
================================================
base: lua51
lua_versions:
  - luajit

globals:
  Snacks:
    any: true
  vim:
    any: true
  jit:
    any: true
  assert:
    any: true
  describe:
    any: true
  it:
    any: true
  before_each:
    any: true
Download .txt
gitextract_tkhyu1o3/

├── .editorconfig
├── .github/
│   ├── ISSUE_TEMPLATE/
│   │   ├── bug_report.yml
│   │   ├── config.yml
│   │   └── feature_request.yml
│   ├── PULL_REQUEST_TEMPLATE.md
│   ├── dependabot.yml
│   └── workflows/
│       ├── ci.yml
│       ├── labeler.yml
│       ├── pr.yml
│       ├── stale.yml
│       └── update.yml
├── .gitignore
├── .markdownlint-cli2.yaml
├── CHANGELOG.md
├── LICENSE
├── README.md
├── doc/
│   └── paint.nvim.txt
├── lua/
│   └── paint/
│       ├── config.lua
│       ├── highlight.lua
│       └── init.lua
├── selene.toml
├── stylua.toml
└── vim.yml
Condensed preview — 23 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (29K chars).
[
  {
    "path": ".editorconfig",
    "chars": 98,
    "preview": "root = true\n\n[*]\ninsert_final_newline = true\nindent_style = space\nindent_size = 2\ncharset = utf-8\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/bug_report.yml",
    "chars": 2543,
    "preview": "name: Bug Report\ndescription: File a bug/issue\ntitle: \"bug: \"\nlabels: [bug]\nbody:\n  - type: markdown\n    attributes:\n   "
  },
  {
    "path": ".github/ISSUE_TEMPLATE/config.yml",
    "chars": 167,
    "preview": "blank_issues_enabled: false\ncontact_links:\n  - name: Ask a question\n    url: https://github.com/folke/paint.nvim/discuss"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/feature_request.yml",
    "chars": 1248,
    "preview": "name: Feature Request\ndescription: Suggest a new feature\ntitle: \"feature: \"\nlabels: [enhancement]\nbody:\n  - type: checkb"
  },
  {
    "path": ".github/PULL_REQUEST_TEMPLATE.md",
    "chars": 334,
    "preview": "## Description\n\n<!-- Describe the big picture of your changes to communicate to the maintainers\n  why we should accept t"
  },
  {
    "path": ".github/dependabot.yml",
    "chars": 118,
    "preview": "version: 2\nupdates:\n  - package-ecosystem: \"github-actions\"\n    directory: \"/\"\n    schedule:\n      interval: \"weekly\"\n"
  },
  {
    "path": ".github/workflows/ci.yml",
    "chars": 218,
    "preview": "name: CI\n\non:\n  push:\n    branches: [main, master]\n  pull_request:\n\njobs:\n  ci:\n    uses: folke/github/.github/workflows"
  },
  {
    "path": ".github/workflows/labeler.yml",
    "chars": 144,
    "preview": "name: \"PR Labeler\"\non:\n  - pull_request_target\n\njobs:\n  labeler:\n    uses: folke/github/.github/workflows/labeler.yml@ma"
  },
  {
    "path": ".github/workflows/pr.yml",
    "chars": 275,
    "preview": "name: PR Title\n\non:\n  pull_request_target:\n    types:\n      - opened\n      - edited\n      - synchronize\n      - reopened"
  },
  {
    "path": ".github/workflows/stale.yml",
    "chars": 236,
    "preview": "name: Stale Issues & PRs\n\non:\n  schedule:\n    - cron: \"30 1 * * *\"\n\njobs:\n  stale:\n    if: contains(fromJSON('[\"folke\", "
  },
  {
    "path": ".github/workflows/update.yml",
    "chars": 272,
    "preview": "name: Update Repo\n\non:\n  workflow_dispatch:\n  schedule:\n    # Run every hour\n    - cron: \"0 * * * *\"\n\njobs:\n  update:\n  "
  },
  {
    "path": ".gitignore",
    "chars": 70,
    "preview": "*.log\n/.repro\n/.tests\n/build\n/debug\n/doc/tags\nfoo.*\nnode_modules\ntt.*\n"
  },
  {
    "path": ".markdownlint-cli2.yaml",
    "chars": 38,
    "preview": "config:\n  MD013: false\n  MD033: false\n"
  },
  {
    "path": "CHANGELOG.md",
    "chars": 666,
    "preview": "# Changelog\n\n## 1.0.0 (2023-01-04)\n\n\n### Features\n\n* initial commit ([5b38fa4](https://github.com/folke/paint.nvim/commi"
  },
  {
    "path": "LICENSE",
    "chars": 11357,
    "preview": "                                 Apache License\n                           Version 2.0, January 2004\n                   "
  },
  {
    "path": "README.md",
    "chars": 1329,
    "preview": "# 🎨 Paint\n\nSimple Neovim plugin to easily add additional highlights to your buffers.\n\nSee the `@something` comments in t"
  },
  {
    "path": "doc/paint.nvim.txt",
    "chars": 2636,
    "preview": "*paint.nvim.txt*                                               paint.nvim docs\n\n========================================"
  },
  {
    "path": "lua/paint/config.lua",
    "chars": 885,
    "preview": "local M = {}\n\nM.ns = vim.api.nvim_create_namespace(\"paint.nvim\")\n\n---@alias PaintFilterFun fun(buf):boolean\n---@class Pa"
  },
  {
    "path": "lua/paint/highlight.lua",
    "chars": 3966,
    "preview": "local config = require(\"paint.config\")\n\nlocal M = {}\nM.enabled = false\n---@type table<number,number>\nM.bufs = {}\n\n---@pa"
  },
  {
    "path": "lua/paint/init.lua",
    "chars": 156,
    "preview": "local M = {}\n\n---@param opts? PaintOptions\nfunction M.setup(opts)\n  require(\"paint.config\").setup(opts)\n  require(\"paint"
  },
  {
    "path": "selene.toml",
    "chars": 39,
    "preview": "std=\"vim\"\n\n[lints]\nmixed_table=\"allow\"\n"
  },
  {
    "path": "stylua.toml",
    "chars": 91,
    "preview": "indent_type = \"Spaces\"\nindent_width = 2\ncolumn_width = 120\n[sort_requires]\nenabled = true\n\n"
  },
  {
    "path": "vim.yml",
    "chars": 212,
    "preview": "base: lua51\nlua_versions:\n  - luajit\n\nglobals:\n  Snacks:\n    any: true\n  vim:\n    any: true\n  jit:\n    any: true\n  asser"
  }
]

About this extraction

This page contains the full source code of the folke/paint.nvim GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 23 files (26.5 KB), approximately 6.8k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!