1

Update generated nvim config

This commit is contained in:
2024-06-02 22:16:32 +02:00
parent afa21f2fae
commit 847a34c6b9
26 changed files with 4399 additions and 1178 deletions

File diff suppressed because it is too large Load Diff

1219
config/neovim/config_nix.lua Normal file

File diff suppressed because it is too large Load Diff

View File

@ -2,10 +2,12 @@
INIT_PATH="$(readlink -f ~/.config/nvim/init.lua)"
cp -f "$INIT_PATH" ./config.lua
echo "Copied $INIT_PATH to ./config.lua"
cp -f "$INIT_PATH" ./config_nix.lua
echo "Copied $INIT_PATH to ./config.lua and ./config_nix.lua"
chmod +w ./config.lua
echo "Fixed permission for ./config.lua"
chmod +w ./config_nix.lua
echo "Fixed permission for ./config.lua and ./config_nix.lua"
echo ""
rm -rf ./store/*

View File

@ -0,0 +1,89 @@
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/todo-comments.nvim) and search [existing issues](https://github.com/folke/todo-comments.nvim/issues). Usage questions such as ***"How do I...?"*** belong in [Discussions](https://github.com/folke/todo-comments.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 todo-comments.nvim docs
required: true
- label: I have searched the existing issues of todo-comments.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: |
-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)
-- install plugins
local plugins = {
"folke/tokyonight.nvim",
"folke/todo-comments.nvim",
-- add any other plugins here
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
vim.cmd.colorscheme("tokyonight")
-- add anything else here
render: Lua
validations:
required: false

View File

@ -0,0 +1,36 @@
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 todo-comments.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.

View File

@ -0,0 +1,72 @@
name: CI
on:
push:
pull_request:
jobs:
tests:
strategy:
matrix:
# os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Install Neovim
shell: bash
run: |
mkdir -p /tmp/nvim
wget -q https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage -O /tmp/nvim/nvim.appimage
cd /tmp/nvim
chmod a+x ./nvim.appimage
./nvim.appimage --appimage-extract
echo "/tmp/nvim/squashfs-root/usr/bin/" >> $GITHUB_PATH
- name: Run Tests
run: |
nvim --version
[ ! -d tests ] && exit 0
nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/init.lua', sequential = true}"
docs:
runs-on: ubuntu-latest
needs: tests
if: ${{ github.ref == 'refs/heads/main' }}
steps:
- uses: actions/checkout@v3
- name: panvimdoc
uses: kdheepak/panvimdoc@main
with:
vimdoc: todo-comments.nvim
version: "Neovim >= 0.8.0"
demojify: true
treesitter: true
- name: Push changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "chore(build): auto-generate vimdoc"
commit_user_name: "github-actions[bot]"
commit_user_email: "github-actions[bot]@users.noreply.github.com"
commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
release:
name: release
if: ${{ github.ref == 'refs/heads/main' }}
needs:
- docs
- tests
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: simple
package-name: todo-comments.nvim
- uses: actions/checkout@v3
- name: tag stable versions
if: ${{ steps.release.outputs.release_created }}
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/google-github-actions/release-please-action.git"
git tag -d stable || true
git push origin :stable || true
git tag -a stable -m "Last Stable Release"
git push origin stable

View File

@ -0,0 +1,8 @@
tt.*
.tests
doc/tags
debug
.repro
foo.*
*.log
data

View File

@ -0,0 +1,13 @@
# https://github.com/Koihik/LuaFormatter/blob/master/docs/Style-Config.md
column_limit: 80
indent_width: 2
continuation_indent_width: 2
use_tab: false
chop_down_parameter: true
chop_down_table: true
chop_down_kv_table: true
single_quote_to_double_quote: true
spaces_inside_table_braces: true
align_parameter: true
keep_simple_control_block_one_line: true
extra_sep_at_table_end: true

View File

@ -0,0 +1,17 @@
{
"neodev": {
"library": {
"plugins": [
"plenary.nvim",
"nvim-web-devicons",
"trouble.nvim"
]
}
},
"lspconfig": {
"lua_ls": {
"Lua.runtime.version": "LuaJIT",
"Lua.workspace.checkThirdParty": false
}
}
}

View File

@ -0,0 +1,128 @@
# Changelog
## [1.2.0](https://github.com/folke/todo-comments.nvim/compare/v1.1.0...v1.2.0) (2024-03-27)
### Features
* added source for trouble v3 ([9935ae9](https://github.com/folke/todo-comments.nvim/commit/9935ae96190c4c177cf0a0dfaddbe4a8addf3eed))
### Bug Fixes
* **trouble:** trouble v3 support ([3e45f2f](https://github.com/folke/todo-comments.nvim/commit/3e45f2fad81e7eca409280836620310b1267e1c7))
## [1.1.0](https://github.com/folke/todo-comments.nvim/compare/v1.0.1...v1.1.0) (2023-03-31)
### Features
* **telescope:** access pickers with plugin_name... ([#191](https://github.com/folke/todo-comments.nvim/issues/191)) ([7420337](https://github.com/folke/todo-comments.nvim/commit/7420337c20d766e73eb83b5d17b4ef50331ed4cd))
## [1.0.1](https://github.com/folke/todo-comments.nvim/compare/v1.0.0...v1.0.1) (2023-03-26)
### Bug Fixes
* **icons:** fixed obsolete nerd font icons with nerdfix ([3bddf1d](https://github.com/folke/todo-comments.nvim/commit/3bddf1dc406b9212c881882c8cfc4798ee271762))
## 1.0.0 (2023-01-04)
### ⚠ BREAKING CHANGES
* todo-comments now requires Neovim >= 0.8.0. Use the `neovim-pre-0.8.0` branch for older versions
### Features
* accept argument to filter keywords ([#116](https://github.com/folke/todo-comments.nvim/issues/116)) ([67cd3a4](https://github.com/folke/todo-comments.nvim/commit/67cd3a4112f372bb1406dae35816d502f53a5af3))
* add config option to set gui style ([#117](https://github.com/folke/todo-comments.nvim/issues/117)) ([231888a](https://github.com/folke/todo-comments.nvim/commit/231888aa37ddbdcc8a58b06dcb19dacfa65bf2c7))
* add error logging for rg ([006250f](https://github.com/folke/todo-comments.nvim/commit/006250f11d34fdd4500db5fdde5133131b48bc72))
* add max line len option (Fixes [#33](https://github.com/folke/todo-comments.nvim/issues/33)) ([8b63dfc](https://github.com/folke/todo-comments.nvim/commit/8b63dfccf1ae11aeebc9fae3b3d7a6dd12bb09b5))
* added merge_keywords option that allows disabling the default groups ([3f3b8b4](https://github.com/folke/todo-comments.nvim/commit/3f3b8b4fa8b4b91c2a0142491ee22afd76c161e3))
* added methods to jump to next/prev todo comment ([c88d199](https://github.com/folke/todo-comments.nvim/commit/c88d1997e40cec2078562e405b52be863d60615a))
* added multiline context and pattern ([144cba6](https://github.com/folke/todo-comments.nvim/commit/144cba62f6753647a8c502b25475e5ed568d5358))
* added options.highlight.exclude. Fixes [#41](https://github.com/folke/todo-comments.nvim/issues/41) ([1275879](https://github.com/folke/todo-comments.nvim/commit/12758792a0d207b5a4a4fb5a11a0d321a4608108))
* added support for specifying multiple patterns for highlighting ([808a2e5](https://github.com/folke/todo-comments.nvim/commit/808a2e524b3720804716a99fd900986b9d727d4d))
* added TEST to ([5547b53](https://github.com/folke/todo-comments.nvim/commit/5547b537593a4322f876637c6ee2aa38b2ac50ee))
* added TodoLocList. Fixes [#47](https://github.com/folke/todo-comments.nvim/issues/47) ([c641728](https://github.com/folke/todo-comments.nvim/commit/c6417282c9d3948917e712b8e0b0093f9dc995e2))
* allow changing config on the fly or disable all [#27](https://github.com/folke/todo-comments.nvim/issues/27) ([2f701d0](https://github.com/folke/todo-comments.nvim/commit/2f701d0738e3b0dfae90c69435b752bbbaeb2ed3))
* allow custom todo patterns [#4](https://github.com/folke/todo-comments.nvim/issues/4) ([1732f21](https://github.com/folke/todo-comments.nvim/commit/1732f21854f0d7f9cffd6e92f9e95c13a01bd79e))
* allow searching for todos in another directory. Implements [#21](https://github.com/folke/todo-comments.nvim/issues/21) ([6de90a5](https://github.com/folke/todo-comments.nvim/commit/6de90a566ab50da6b76200a69486b6d51c8d07ee))
* allow specifying wide_fg ([#92](https://github.com/folke/todo-comments.nvim/issues/92)) ([dca8c3f](https://github.com/folke/todo-comments.nvim/commit/dca8c3fa3b515bc85652e50bf736d2cca8a87cb2))
* also deepcopy keywords ([0f6a87b](https://github.com/folke/todo-comments.nvim/commit/0f6a87bb04925775bb2fd68c063152512e033313))
* check if ripgrep is available and show error if not ([b5cdae7](https://github.com/folke/todo-comments.nvim/commit/b5cdae78f58ac23fcf4340013e4dc7197881196a))
* expose methods to jump to next/prev todo comment ([89ee420](https://github.com/folke/todo-comments.nvim/commit/89ee420be60750d074bcb95efa6f2159c0671950))
* Group search and highlight options ([fbf91af](https://github.com/folke/todo-comments.nvim/commit/fbf91af72193987e50e542c5148ffcca2ff89050))
* Improve rg and highlight pattern matching ([7a00efb](https://github.com/folke/todo-comments.nvim/commit/7a00efb6a6c585303d333b0c543c640aa888fb83))
* inital version ([7473917](https://github.com/folke/todo-comments.nvim/commit/747391791bbb67fafeb2e690f4688720392470c8))
* intergration with lsp trouble ([194e653](https://github.com/folke/todo-comments.nvim/commit/194e65323bb1e3d35075d7b3451db697f1ba75f8))
* make it possible to disable warnings when searching ([#63](https://github.com/folke/todo-comments.nvim/issues/63)) ([9983edc](https://github.com/folke/todo-comments.nvim/commit/9983edc5ef38c7a035c17c85f60ee13dbd75dcc8))
* make sign priority configurable ([edbe161](https://github.com/folke/todo-comments.nvim/commit/edbe161856eacc859987eaf28d41b67163d49791))
* multiline todo comments ([8dffc5d](https://github.com/folke/todo-comments.nvim/commit/8dffc5d3ed1495e70c05f5ca1d100f8d3a4c44aa))
* quickfix, telescope and trouble commands ([a7c12f2](https://github.com/folke/todo-comments.nvim/commit/a7c12f288c995a738688ec3a42e6a1f6d48f3b89))
* set default multiline pattern to `^.` ([8f00cdb](https://github.com/folke/todo-comments.nvim/commit/8f00cdbbeafdad95dc1da0d846d21d9eef2d510b))
* Telescope plugin ([95f04b1](https://github.com/folke/todo-comments.nvim/commit/95f04b1a1fc9b7a17731eebde4353697c5a01f9b))
* todo-comments now requires Neovim &gt;= 0.8.0. Use the `neovim-pre-0.8.0` branch for older versions ([916cd4f](https://github.com/folke/todo-comments.nvim/commit/916cd4f144e7211874082286f7d5889018b5739d))
* use flame icon for hacks ([745df54](https://github.com/folke/todo-comments.nvim/commit/745df540153b0fc18b1ffec02c8875be1bf9e0c7))
* use treesitter to highlight keywords in comments only. If not a TS buffer, then highlight all comments [#22](https://github.com/folke/todo-comments.nvim/issues/22) ([b3fbe23](https://github.com/folke/todo-comments.nvim/commit/b3fbe23185189ba20ee0012bfbbb14e8fa55406e))
* use vim.notify instead of echo ([b745d75](https://github.com/folke/todo-comments.nvim/commit/b745d7513207eb8d809e1a92fae76e643310bf91))
* use vim.treesitter.get_captures_at_pos to detect comments ([6120afa](https://github.com/folke/todo-comments.nvim/commit/6120afa159d1dd3ba112ee4360b4ab4562a9b266))
### Bug Fixes
* add . to args for ripgrep to make it work on Windows ([03fc95a](https://github.com/folke/todo-comments.nvim/commit/03fc95a8f49edc8533a70577dedc44972733d88d))
* add proper error logging when ripgrep fails ([358b8c9](https://github.com/folke/todo-comments.nvim/commit/358b8c9c387557d21cbc14f8269e229467487954))
* allow highlighting in quickfix buffers ([f4d35a2](https://github.com/folke/todo-comments.nvim/commit/f4d35a2e5b601385b299bb44b1f556956d286292))
* avoid E5108 after pressing q: ([#111](https://github.com/folke/todo-comments.nvim/issues/111)) ([fb6f16b](https://github.com/folke/todo-comments.nvim/commit/fb6f16b89e475676d45bf6b39077fb752521e6f1))
* better keyword highlight pattern ([52d814d](https://github.com/folke/todo-comments.nvim/commit/52d814d7b5234e353d7599f566b1125d256633b9))
* check if buf is valid before clearing todo namespace ([23dfdaf](https://github.com/folke/todo-comments.nvim/commit/23dfdafe1990ae7b6c0f0c69a02736bb1a839219))
* check is current_win is still valid before setting it again ([37e7347](https://github.com/folke/todo-comments.nvim/commit/37e73472656d0642224dc86d9ce4784d8e4f5b5c))
* clear namespace with pcall to fix lazy loading weirdness. Fixes [#130](https://github.com/folke/todo-comments.nvim/issues/130) ([f990cd9](https://github.com/folke/todo-comments.nvim/commit/f990cd9c1d3e701f6746b523b71784ec2498ae35))
* debug code ([b09c700](https://github.com/folke/todo-comments.nvim/commit/b09c700ecf878092e91ed4b041c6eb7c840df994))
* defer highlight updates to prevent weird behavior of treesitter ([a4e433e](https://github.com/folke/todo-comments.nvim/commit/a4e433ee690455f94b4fba8fbc3241d061dc90f3))
* dont show signs for multiline comments ([3fe59db](https://github.com/folke/todo-comments.nvim/commit/3fe59db6dd6fb07857e0b9670a3b711104dfb53a))
* escape special characters in commentstring ([5fd5086](https://github.com/folke/todo-comments.nvim/commit/5fd5086a50f8bc012f50858805080c79ccb204bf))
* exit when buffer no longer exists ([3bc3bce](https://github.com/folke/todo-comments.nvim/commit/3bc3bceb4f1122028891830b2b408cd570e21859))
* fall back to syntax Comment if treesitter is not available ([b4dec37](https://github.com/folke/todo-comments.nvim/commit/b4dec37ba24c6c31d8129f601ff5db6cb4b9c99a))
* if todo is lazyloaded, then skip VimEnter ([564dc45](https://github.com/folke/todo-comments.nvim/commit/564dc4564cd47854f36e09e3d1910acb7e41e67d))
* improved comment support with treesitter ([219bc7e](https://github.com/folke/todo-comments.nvim/commit/219bc7ef4439b6fa53bc9db1dd14b11221e83d7d))
* is_comment now checks highlighter TS queries instead of parse tree ([d5f9bfc](https://github.com/folke/todo-comments.nvim/commit/d5f9bfc164c7ea306710d1a0a9d2db255387b1db))
* is_comment. Fixes [#145](https://github.com/folke/todo-comments.nvim/issues/145) ([1814fec](https://github.com/folke/todo-comments.nvim/commit/1814feca54540497de99d474dd6c9de6b691cf01))
* jumping to todo comments didnt use the correct line for is_comment checks ([c8c5446](https://github.com/folke/todo-comments.nvim/commit/c8c54465c74761ec95399584ed670700849ae401))
* keep previous options from setup ([8560546](https://github.com/folke/todo-comments.nvim/commit/8560546c466d1f555573d37e062e95e7ae94bbab))
* listen to treesitter changes to redo highlights ([9b276eb](https://github.com/folke/todo-comments.nvim/commit/9b276ebeeced9e15707c27e0b2588e7b3e19d9c5))
* matchstr fails with error about passing a dictionary as a string when string is binary [#23](https://github.com/folke/todo-comments.nvim/issues/23) ([ca2b794](https://github.com/folke/todo-comments.nvim/commit/ca2b7945e9bb58a5a8ab341b269028dd05d7ec61))
* never use comments to highlight quickfix buffers ([7a5e9c9](https://github.com/folke/todo-comments.nvim/commit/7a5e9c991670a834ed29951e58d29551f7a73fe3))
* pass kw start to is_comment. Fixes [#153](https://github.com/folke/todo-comments.nvim/issues/153) ([d3c6ec6](https://github.com/folke/todo-comments.nvim/commit/d3c6ec66caa07a31a16d3ed4b954a88742daa909))
* properly clear todo highlights in stop ([98b1ebf](https://github.com/folke/todo-comments.nvim/commit/98b1ebf198836bdc226c0562b9f906584e6c400e))
* properly escape commentstring [#19](https://github.com/folke/todo-comments.nvim/issues/19) ([a5c255c](https://github.com/folke/todo-comments.nvim/commit/a5c255c6860ae9456f339dc35586a6d47b6fd2cf))
* Properly pass options into jump function ([#143](https://github.com/folke/todo-comments.nvim/issues/143)) ([96391ae](https://github.com/folke/todo-comments.nvim/commit/96391ae41e63a5edba260adfd7312462b54ddc8e))
* re-apply highlights when treesitter bytes changes. Fixes [#134](https://github.com/folke/todo-comments.nvim/issues/134) ([e90b17e](https://github.com/folke/todo-comments.nvim/commit/e90b17e45c39f6f37994a2f0f60dde8472b8457d))
* remove FIX from alts for FIX ([e3b96b2](https://github.com/folke/todo-comments.nvim/commit/e3b96b253150c217a603fa11b79b90fcb2d1a649))
* remove set_current_win ([d2b9b26](https://github.com/folke/todo-comments.nvim/commit/d2b9b265ae250ac3c1737180095352080059d212))
* revert extmarks to add_highlight ([4a27e05](https://github.com/folke/todo-comments.nvim/commit/4a27e05519827ba1594d5ce3fde874040f005bfe))
* ripgrep gives exit code 2 on error. Exit code 1 means no results ([3ad4967](https://github.com/folke/todo-comments.nvim/commit/3ad4967972ed463ce1dfd38161ea98862b2bdffa))
* set fg_dark and fg_light to black and white for colorschemes that dont set Normal ([b64859a](https://github.com/folke/todo-comments.nvim/commit/b64859a2313472284fb0d29d9bc9e0108725ecc4))
* show error when running Todo without doing setup() ([f0cc7d3](https://github.com/folke/todo-comments.nvim/commit/f0cc7d3eb7c017c87c1ef52bf3f51d292971ef29))
* show warning message when no results were found ([09aa8de](https://github.com/folke/todo-comments.nvim/commit/09aa8de5ddb2483cafb955645bb4f98701736a98))
* skip possibly bad regex results ([014959e](https://github.com/folke/todo-comments.nvim/commit/014959e82aabc07a16739c771bf40e7fd6de3fe9))
* sort keywords by length in descending order ([#157](https://github.com/folke/todo-comments.nvim/issues/157)) ([2adb83e](https://github.com/folke/todo-comments.nvim/commit/2adb83e0fb082a5f1c40f3def4c8b18ec767c5ee))
* todo comments was broken for non treesitter files. Fixes [#150](https://github.com/folke/todo-comments.nvim/issues/150) ([f244aa3](https://github.com/folke/todo-comments.nvim/commit/f244aa391774b29878db580eff63a9e26dc5f084))
* Update docs ([2273076](https://github.com/folke/todo-comments.nvim/commit/2273076591b9ce78f562b52e3c0b4e34102f54a5))
* update README to 0.6 diagnostic hl ([#78](https://github.com/folke/todo-comments.nvim/issues/78)) ([672cd22](https://github.com/folke/todo-comments.nvim/commit/672cd22bd15928434374ac52d0cf38dd250231df))
* updated default colors to use 0.6 diagnostic highlights ([6570fd2](https://github.com/folke/todo-comments.nvim/commit/6570fd271d17fec1966522f3a19cc6f4c88824c4))
* use nvim_win_call instead of changing current window to apply highlights ([bff9e31](https://github.com/folke/todo-comments.nvim/commit/bff9e315ac3b5854a08d5a73b898822bdec1a5c3))
* use options.search.command for telescope ([ed24570](https://github.com/folke/todo-comments.nvim/commit/ed24570d07e0ffae9969006009a91ecabfff1493))
* use seperate hl group for signs using correct SignColumn bg color ([bf138df](https://github.com/folke/todo-comments.nvim/commit/bf138dff36602a1da40bbebabef8bae61735635c))
* use white as fg for color schemes that dont define a fg for Normal ([ec820ad](https://github.com/folke/todo-comments.nvim/commit/ec820ade091c28b221eb2f6d0ee02c554a61a8e8))
* When todo-comments.nvim as optional and report an error the first time you use it. ([#129](https://github.com/folke/todo-comments.nvim/issues/129)) ([5f90941](https://github.com/folke/todo-comments.nvim/commit/5f9094198563b693439837b593815dc18768fda8))
### Performance Improvements
* defer settings up todo-comments ([5e84162](https://github.com/folke/todo-comments.nvim/commit/5e8416265a23c8b8b4711be73b465e6f6566f49b))
* defer setup to BufReadPre ++once ([455f49e](https://github.com/folke/todo-comments.nvim/commit/455f49e6e263fdd2fe1bfff2b1eb7c7457fbf68f))
* redraw was always doing the whole file! Fixes [#155](https://github.com/folke/todo-comments.nvim/issues/155) ([bca0e00](https://github.com/folke/todo-comments.nvim/commit/bca0e00644c22a3eecedce703c0db080dd6bdc55))
* throttle todo redraw calls. Fixes [#154](https://github.com/folke/todo-comments.nvim/issues/154) ([a9df434](https://github.com/folke/todo-comments.nvim/commit/a9df4342a564e9d95340f60a38a523fda27cdb2e))

View File

@ -0,0 +1,201 @@
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.

View File

@ -0,0 +1,187 @@
# ✅ Todo Comments
**todo-comments** is a lua plugin for Neovim >= 0.8.0 to highlight and search for todo comments like
`TODO`, `HACK`, `BUG` in your code base.
![image](https://user-images.githubusercontent.com/292349/118135272-ad21e980-b3b7-11eb-881c-e45a4a3d6192.png)
## ✨ Features
- **highlight** your todo comments in different styles
- optionally only highlights todos in comments using **TreeSitter**
- configurable **signs**
- open todos in a **quickfix** list
- open todos in [Trouble](https://github.com/folke/trouble.nvim)
- search todos with [Telescope](https://github.com/nvim-telescope/telescope.nvim)
## ⚡️ Requirements
- Neovim >= 0.8.0 (use the `neovim-pre-0.8.0` branch for older versions)
- a [patched font](https://www.nerdfonts.com/) for the icons, or change them to simple ASCII characters
- optional:
- [ripgrep](https://github.com/BurntSushi/ripgrep) and [plenary.nvim](https://github.com/nvim-lua/plenary.nvim) are used for searching.
- [Trouble](https://github.com/folke/trouble.nvim)
- [Telescope](https://github.com/nvim-telescope/telescope.nvim)
## 📦 Installation
Install the plugin with your preferred package manager:
### [lazy.nvim](https://github.com/folke/lazy.nvim)
```lua
{
"folke/todo-comments.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
}
```
## ⚙️ Configuration
Todo comes with the following defaults:
```lua
{
signs = true, -- show icons in the signs column
sign_priority = 8, -- sign priority
-- keywords recognized as todo comments
keywords = {
FIX = {
icon = " ", -- icon used for the sign, and in search results
color = "error", -- can be a hex color, or a named color (see below)
alt = { "FIXME", "BUG", "FIXIT", "ISSUE" }, -- a set of other keywords that all map to this FIX keywords
-- signs = false, -- configure signs for some keywords individually
},
TODO = { icon = " ", color = "info" },
HACK = { icon = " ", color = "warning" },
WARN = { icon = " ", color = "warning", alt = { "WARNING", "XXX" } },
PERF = { icon = " ", alt = { "OPTIM", "PERFORMANCE", "OPTIMIZE" } },
NOTE = { icon = " ", color = "hint", alt = { "INFO" } },
TEST = { icon = "⏲ ", color = "test", alt = { "TESTING", "PASSED", "FAILED" } },
},
gui_style = {
fg = "NONE", -- The gui style to use for the fg highlight group.
bg = "BOLD", -- The gui style to use for the bg highlight group.
},
merge_keywords = true, -- when true, custom keywords will be merged with the defaults
-- highlighting of the line containing the todo comment
-- * before: highlights before the keyword (typically comment characters)
-- * keyword: highlights of the keyword
-- * after: highlights after the keyword (todo text)
highlight = {
multiline = true, -- enable multine todo comments
multiline_pattern = "^.", -- lua pattern to match the next multiline from the start of the matched keyword
multiline_context = 10, -- extra lines that will be re-evaluated when changing a line
before = "", -- "fg" or "bg" or empty
keyword = "wide", -- "fg", "bg", "wide", "wide_bg", "wide_fg" or empty. (wide and wide_bg is the same as bg, but will also highlight surrounding characters, wide_fg acts accordingly but with fg)
after = "fg", -- "fg" or "bg" or empty
pattern = [[.*<(KEYWORDS)\s*:]], -- pattern or table of patterns, used for highlighting (vim regex)
comments_only = true, -- uses treesitter to match keywords in comments only
max_line_len = 400, -- ignore lines longer than this
exclude = {}, -- list of file types to exclude highlighting
},
-- list of named colors where we try to extract the guifg from the
-- list of highlight groups or use the hex color if hl not found as a fallback
colors = {
error = { "DiagnosticError", "ErrorMsg", "#DC2626" },
warning = { "DiagnosticWarn", "WarningMsg", "#FBBF24" },
info = { "DiagnosticInfo", "#2563EB" },
hint = { "DiagnosticHint", "#10B981" },
default = { "Identifier", "#7C3AED" },
test = { "Identifier", "#FF00FF" }
},
search = {
command = "rg",
args = {
"--color=never",
"--no-heading",
"--with-filename",
"--line-number",
"--column",
},
-- regex that will be used to match keywords.
-- don't replace the (KEYWORDS) placeholder
pattern = [[\b(KEYWORDS):]], -- ripgrep regex
-- pattern = [[\b(KEYWORDS)\b]], -- match without the extra colon. You'll likely get false positives
},
}
```
### Jumping
Two methods are available to jump to the next/previous todo comment.
```lua
vim.keymap.set("n", "]t", function()
require("todo-comments").jump_next()
end, { desc = "Next todo comment" })
vim.keymap.set("n", "[t", function()
require("todo-comments").jump_prev()
end, { desc = "Previous todo comment" })
-- You can also specify a list of valid jump keywords
vim.keymap.set("n", "]t", function()
require("todo-comments").jump_next({keywords = { "ERROR", "WARNING" }})
end, { desc = "Next error/warning todo comment" })
```
## 🚀 Usage
**Todo** matches on any text that starts with one of your defined keywords (or alt) followed by a colon:
- TODO: do something
- FIX: this should be fixed
- HACK: weird code warning
Todos are highlighted in all regular files.
Each of the commands below accept the following arguments:
- `cwd` - Specify the directory to search for comments, like:
```vim
:TodoTrouble cwd=~/projects/foobar
```
- `keywords` - Comma separated list of keywords to filter results by. Keywords are case-sensitive.
```vim
:TodoTelescope keywords=TODO,FIX
```
### 🔎 `:TodoQuickFix`
This uses the quickfix list to show all todos in your project.
![image](https://user-images.githubusercontent.com/292349/118135332-bf9c2300-b3b7-11eb-9a40-1307feb27c44.png)
### 🔎 `:TodoLocList`
This uses the location list to show all todos in your project.
![image](https://user-images.githubusercontent.com/292349/118135332-bf9c2300-b3b7-11eb-9a40-1307feb27c44.png)
### 🚦 `:TodoTrouble`
List all project todos in [trouble](https://github.com/folke/trouble.nvim)
> See screenshot at the top
### 🔭 `:TodoTelescope`
Search through all project todos with Telescope
![image](https://user-images.githubusercontent.com/292349/118135371-ccb91200-b3b7-11eb-9002-66af3b683cf0.png)
<!-- markdownlint-disable-file MD033 -->
<!-- markdownlint-configure-file { "MD013": { "line_length": 120 } } -->
<!-- markdownlint-configure-file { "MD004": { "style": "sublist" } } -->

View File

@ -0,0 +1,211 @@
*todo-comments.nvim.txt* For Neovim >= 0.8.0 Last change: 2024 May 22
==============================================================================
Table of Contents *todo-comments.nvim-table-of-contents*
1. Todo Comments |todo-comments.nvim-todo-comments|
- Features |todo-comments.nvim-todo-comments-features|
- Requirements |todo-comments.nvim-todo-comments-requirements|
- Installation |todo-comments.nvim-todo-comments-installation|
- Configuration |todo-comments.nvim-todo-comments-configuration|
- Usage |todo-comments.nvim-todo-comments-usage|
2. Links |todo-comments.nvim-links|
==============================================================================
1. Todo Comments *todo-comments.nvim-todo-comments*
**todo-comments** is a lua plugin for Neovim >= 0.8.0 to highlight and search
for todo comments like `TODO`, `HACK`, `BUG` in your code base.
FEATURES *todo-comments.nvim-todo-comments-features*
- **highlight** your todo comments in different styles
- optionally only highlights todos in comments using **TreeSitter**
- configurable **signs**
- open todos in a **quickfix** list
- open todos in Trouble <https://github.com/folke/trouble.nvim>
- search todos with Telescope <https://github.com/nvim-telescope/telescope.nvim>
REQUIREMENTS *todo-comments.nvim-todo-comments-requirements*
- Neovim >= 0.8.0 (use the `neovim-pre-0.8.0` branch for older versions)
- a patched font <https://www.nerdfonts.com/> for the icons, or change them to simple ASCII characters
- optional:
- ripgrep <https://github.com/BurntSushi/ripgrep> and plenary.nvim <https://github.com/nvim-lua/plenary.nvim> are used for searching.
- Trouble <https://github.com/folke/trouble.nvim>
- Telescope <https://github.com/nvim-telescope/telescope.nvim>
INSTALLATION *todo-comments.nvim-todo-comments-installation*
Install the plugin with your preferred package manager:
LAZY.NVIM ~
>lua
{
"folke/todo-comments.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
}
<
CONFIGURATION *todo-comments.nvim-todo-comments-configuration*
Todo comes with the following defaults:
>lua
{
signs = true, -- show icons in the signs column
sign_priority = 8, -- sign priority
-- keywords recognized as todo comments
keywords = {
FIX = {
icon = " ", -- icon used for the sign, and in search results
color = "error", -- can be a hex color, or a named color (see below)
alt = { "FIXME", "BUG", "FIXIT", "ISSUE" }, -- a set of other keywords that all map to this FIX keywords
-- signs = false, -- configure signs for some keywords individually
},
TODO = { icon = " ", color = "info" },
HACK = { icon = " ", color = "warning" },
WARN = { icon = " ", color = "warning", alt = { "WARNING", "XXX" } },
PERF = { icon = " ", alt = { "OPTIM", "PERFORMANCE", "OPTIMIZE" } },
NOTE = { icon = " ", color = "hint", alt = { "INFO" } },
TEST = { icon = "⏲ ", color = "test", alt = { "TESTING", "PASSED", "FAILED" } },
},
gui_style = {
fg = "NONE", -- The gui style to use for the fg highlight group.
bg = "BOLD", -- The gui style to use for the bg highlight group.
},
merge_keywords = true, -- when true, custom keywords will be merged with the defaults
-- highlighting of the line containing the todo comment
-- * before: highlights before the keyword (typically comment characters)
-- * keyword: highlights of the keyword
-- * after: highlights after the keyword (todo text)
highlight = {
multiline = true, -- enable multine todo comments
multiline_pattern = "^.", -- lua pattern to match the next multiline from the start of the matched keyword
multiline_context = 10, -- extra lines that will be re-evaluated when changing a line
before = "", -- "fg" or "bg" or empty
keyword = "wide", -- "fg", "bg", "wide", "wide_bg", "wide_fg" or empty. (wide and wide_bg is the same as bg, but will also highlight surrounding characters, wide_fg acts accordingly but with fg)
after = "fg", -- "fg" or "bg" or empty
pattern = [[.*<(KEYWORDS)\s*:]], -- pattern or table of patterns, used for highlighting (vim regex)
comments_only = true, -- uses treesitter to match keywords in comments only
max_line_len = 400, -- ignore lines longer than this
exclude = {}, -- list of file types to exclude highlighting
},
-- list of named colors where we try to extract the guifg from the
-- list of highlight groups or use the hex color if hl not found as a fallback
colors = {
error = { "DiagnosticError", "ErrorMsg", "#DC2626" },
warning = { "DiagnosticWarn", "WarningMsg", "#FBBF24" },
info = { "DiagnosticInfo", "#2563EB" },
hint = { "DiagnosticHint", "#10B981" },
default = { "Identifier", "#7C3AED" },
test = { "Identifier", "#FF00FF" }
},
search = {
command = "rg",
args = {
"--color=never",
"--no-heading",
"--with-filename",
"--line-number",
"--column",
},
-- regex that will be used to match keywords.
-- don't replace the (KEYWORDS) placeholder
pattern = [[\b(KEYWORDS):]], -- ripgrep regex
-- pattern = [[\b(KEYWORDS)\b]], -- match without the extra colon. You'll likely get false positives
},
}
<
JUMPING ~
Two methods are available to jump to the next/previous todo comment.
>lua
vim.keymap.set("n", "]t", function()
require("todo-comments").jump_next()
end, { desc = "Next todo comment" })
vim.keymap.set("n", "[t", function()
require("todo-comments").jump_prev()
end, { desc = "Previous todo comment" })
-- You can also specify a list of valid jump keywords
vim.keymap.set("n", "]t", function()
require("todo-comments").jump_next({keywords = { "ERROR", "WARNING" }})
end, { desc = "Next error/warning todo comment" })
<
USAGE *todo-comments.nvim-todo-comments-usage*
**Todo** matches on any text that starts with one of your defined keywords (or
alt) followed by a colon:
- TODO: do something
- FIX: this should be fixed
- HACK: weird code warning
Todos are highlighted in all regular files.
Each of the commands below accept the following arguments:
- `cwd` - Specify the directory to search for comments, like:
>vim
:TodoTrouble cwd=~/projects/foobar
<
- `keywords` - Comma separated list of keywords to filter results by. Keywords are case-sensitive.
>vim
:TodoTelescope keywords=TODO,FIX
<
:TODOQUICKFIX ~
This uses the quickfix list to show all todos in your project.
:TODOLOCLIST ~
This uses the location list to show all todos in your project.
:TODOTROUBLE ~
List all project todos in trouble <https://github.com/folke/trouble.nvim>
See screenshot at the top
:TODOTELESCOPE ~
Search through all project todos with Telescope
==============================================================================
2. Links *todo-comments.nvim-links*
1. *image*: https://user-images.githubusercontent.com/292349/118135272-ad21e980-b3b7-11eb-881c-e45a4a3d6192.png
2. *image*: https://user-images.githubusercontent.com/292349/118135332-bf9c2300-b3b7-11eb-9a40-1307feb27c44.png
3. *image*: https://user-images.githubusercontent.com/292349/118135332-bf9c2300-b3b7-11eb-9a40-1307feb27c44.png
4. *image*: https://user-images.githubusercontent.com/292349/118135371-ccb91200-b3b7-11eb-9002-66af3b683cf0.png
Generated by panvimdoc <https://github.com/kdheepak/panvimdoc>
vim:tw=78:ts=8:noet:ft=help:norl:

View File

@ -0,0 +1,67 @@
local has_telescope, telescope = pcall(require, "telescope")
if not has_telescope then
error("This plugins requires nvim-telescope/telescope.nvim")
end
local pickers = require("telescope.builtin")
local Config = require("todo-comments.config")
local Highlight = require("todo-comments.highlight")
local make_entry = require("telescope.make_entry")
local function keywords_filter(opts_keywords)
assert(not opts_keywords or type(opts_keywords) == "string", "'keywords' must be a comma separated string or nil")
local all_keywords = vim.tbl_keys(Config.keywords)
if not opts_keywords then
return all_keywords
end
local filters = vim.split(opts_keywords, ",")
return vim.tbl_filter(function(kw)
return vim.tbl_contains(filters, kw)
end, all_keywords)
end
local function todo(opts)
opts = opts or {}
opts.vimgrep_arguments = { Config.options.search.command }
vim.list_extend(opts.vimgrep_arguments, Config.options.search.args)
opts.search = Config.search_regex(keywords_filter(opts.keywords))
opts.prompt_title = "Find Todo"
opts.use_regex = true
local entry_maker = make_entry.gen_from_vimgrep(opts)
opts.entry_maker = function(line)
local ret = entry_maker(line)
ret.display = function(entry)
local display = string.format("%s:%s:%s ", entry.filename, entry.lnum, entry.col)
local text = entry.text
local start, finish, kw = Highlight.match(text)
local hl = {}
if start then
kw = Config.keywords[kw] or kw
local icon = Config.options.keywords[kw].icon
display = icon .. " " .. display
table.insert(hl, { { 1, #icon + 1 }, "TodoFg" .. kw })
text = vim.trim(text:sub(start))
table.insert(hl, {
{ #display, #display + finish - start + 2 },
"TodoBg" .. kw,
})
table.insert(hl, {
{ #display + finish - start + 1, #display + finish + 1 + #text },
"TodoFg" .. kw,
})
display = display .. " " .. text
end
return display, hl
end
return ret
end
pickers.grep_string(opts)
end
return telescope.register_extension({ exports = { ["todo-comments"] = todo, todo = todo } })

View File

@ -0,0 +1,193 @@
local Util = require("todo-comments.util")
--- @class TodoConfig
local M = {}
M.keywords = {}
--- @type TodoOptions
M.options = {}
M.loaded = false
M.ns = vim.api.nvim_create_namespace("todo-comments")
--- @class TodoOptions
-- TODO: add support for markdown todos
local defaults = {
signs = true, -- show icons in the signs column
sign_priority = 8, -- sign priority
-- keywords recognized as todo comments
keywords = {
FIX = {
icon = "", -- icon used for the sign, and in search results
color = "error", -- can be a hex color, or a named color (see below)
alt = { "FIXME", "BUG", "FIXIT", "ISSUE" }, -- a set of other keywords that all map to this FIX keywords
-- signs = false, -- configure signs for some keywords individually
},
TODO = { icon = "", color = "info" },
HACK = { icon = "", color = "warning" },
WARN = { icon = "", color = "warning", alt = { "WARNING", "XXX" } },
PERF = { icon = "", alt = { "OPTIM", "PERFORMANCE", "OPTIMIZE" } },
NOTE = { icon = "", color = "hint", alt = { "INFO" } },
TEST = { icon = "", color = "test", alt = { "TESTING", "PASSED", "FAILED" } },
},
gui_style = {
fg = "NONE", -- The gui style to use for the fg highlight group.
bg = "BOLD", -- The gui style to use for the bg highlight group.
},
merge_keywords = true, -- when true, custom keywords will be merged with the defaults
-- highlighting of the line containing the todo comment
-- * before: highlights before the keyword (typically comment characters)
-- * keyword: highlights of the keyword
-- * after: highlights after the keyword (todo text)
highlight = {
multiline = true, -- enable multine todo comments
multiline_pattern = "^.", -- lua pattern to match the next multiline from the start of the matched keyword
multiline_context = 10, -- extra lines that will be re-evaluated when changing a line
before = "", -- "fg" or "bg" or empty
keyword = "wide", -- "fg", "bg", "wide" or empty. (wide is the same as bg, but will also highlight surrounding characters)
after = "fg", -- "fg" or "bg" or empty
-- pattern can be a string, or a table of regexes that will be checked
pattern = [[.*<(KEYWORDS)\s*:]], -- pattern or table of patterns, used for highlightng (vim regex)
-- pattern = { [[.*<(KEYWORDS)\s*:]], [[.*\@(KEYWORDS)\s*]] }, -- pattern used for highlightng (vim regex)
comments_only = true, -- uses treesitter to match keywords in comments only
max_line_len = 400, -- ignore lines longer than this
exclude = {}, -- list of file types to exclude highlighting
throttle = 200,
},
-- list of named colors where we try to extract the guifg from the
-- list of hilight groups or use the hex color if hl not found as a fallback
colors = {
error = { "DiagnosticError", "ErrorMsg", "#DC2626" },
warning = { "DiagnosticWarn", "WarningMsg", "#FBBF24" },
info = { "DiagnosticInfo", "#2563EB" },
hint = { "DiagnosticHint", "#10B981" },
default = { "Identifier", "#7C3AED" },
test = { "Identifier", "#FF00FF" },
},
search = {
command = "rg",
args = {
"--color=never",
"--no-heading",
"--with-filename",
"--line-number",
"--column",
},
-- regex that will be used to match keywords.
-- don't replace the (KEYWORDS) placeholder
pattern = [[\b(KEYWORDS):]], -- ripgrep regex
-- pattern = [[\b(KEYWORDS)\b]], -- match without the extra colon. You'll likely get false positives
},
}
M._options = nil
function M.setup(options)
if vim.fn.has("nvim-0.8.0") == 0 then
error("todo-comments needs Neovim >= 0.8.0. Use the 'neovim-pre-0.8.0' branch for older versions")
end
M._options = options
if vim.api.nvim_get_vvar("vim_did_enter") == 0 then
vim.defer_fn(function()
M._setup()
end, 0)
else
M._setup()
end
end
function M._setup()
M.options = vim.tbl_deep_extend("force", {}, defaults, M.options or {}, M._options or {})
-- -- keywords should always be fully overriden
if M._options and M._options.keywords and M._options.merge_keywords == false then
M.options.keywords = M._options.keywords
end
for kw, opts in pairs(M.options.keywords) do
M.keywords[kw] = kw
for _, alt in pairs(opts.alt or {}) do
M.keywords[alt] = kw
end
end
local function tags(keywords)
local kws = keywords or vim.tbl_keys(M.keywords)
table.sort(kws, function(a, b)
return #b < #a
end)
return table.concat(kws, "|")
end
function M.search_regex(keywords)
return M.options.search.pattern:gsub("KEYWORDS", tags(keywords))
end
M.hl_regex = {}
local patterns = M.options.highlight.pattern
patterns = type(patterns) == "table" and patterns or { patterns }
for _, p in pairs(patterns) do
p = p:gsub("KEYWORDS", tags())
table.insert(M.hl_regex, p)
end
M.colors()
M.signs()
require("todo-comments.highlight").start()
M.loaded = true
end
function M.signs()
for kw, opts in pairs(M.options.keywords) do
vim.fn.sign_define("todo-sign-" .. kw, {
text = opts.icon,
texthl = "TodoSign" .. kw,
})
end
end
function M.colors()
local normal = Util.get_hl("Normal")
local fg_dark = Util.is_dark(normal.foreground or "#ffffff") and normal.foreground or normal.background
local fg_light = Util.is_dark(normal.foreground or "#ffffff") and normal.background or normal.foreground
fg_dark = fg_dark or "#000000"
fg_light = fg_light or "#ffffff"
local fg_gui = M.options.gui_style.fg
local bg_gui = M.options.gui_style.bg
local sign_hl = Util.get_hl("SignColumn")
local sign_bg = (sign_hl and sign_hl.background) and sign_hl.background or "NONE"
for kw, opts in pairs(M.options.keywords) do
local kw_color = opts.color or "default"
local hex
if kw_color:sub(1, 1) == "#" then
hex = kw_color
else
local colors = M.options.colors[kw_color]
colors = type(colors) == "string" and { colors } or colors
for _, color in pairs(colors) do
if color:sub(1, 1) == "#" then
hex = color
break
end
local c = Util.get_hl(color)
if c and c.foreground then
hex = c.foreground
break
end
end
end
if not hex then
error("Todo: no color for " .. kw)
end
local fg = Util.is_dark(hex) and fg_light or fg_dark
vim.cmd("hi def TodoBg" .. kw .. " guibg=" .. hex .. " guifg=" .. fg .. " gui=" .. bg_gui)
vim.cmd("hi def TodoFg" .. kw .. " guibg=NONE guifg=" .. hex .. " gui=" .. fg_gui)
vim.cmd("hi def TodoSign" .. kw .. " guibg=" .. sign_bg .. " guifg=" .. hex .. " gui=NONE")
end
end
return M

View File

@ -0,0 +1,403 @@
-- FIX: dddddd
-- TODO: foobar
-- dddddd
local Config = require("todo-comments.config")
local M = {}
M.enabled = false
M.bufs = {}
M.wins = {}
-- PERF: fully optimised
-- FIX: ddddddasdasdasdasdasda
-- PERF: dddd
-- ddddd
-- dddddd
-- ddddddd
-- FIXME: dddddd
-- FIX: ddd
-- HACK: hmmm, this looks a bit funky
-- TODO: What else?
-- NOTE: adding a note
--
-- FIX: this needs fixing
-- WARNING: ???
-- FIX: ddddd
-- continuation
-- @TODO foobar
-- @hack foobar
---@alias TodoDirty table<number, boolean>
---@type table<buffer, {dirty:TodoDirty}>
M.state = {}
function M.match(str, patterns)
local max_line_len = Config.options.highlight.max_line_len
if max_line_len and #str > max_line_len then
return
end
patterns = patterns or Config.hl_regex
if not type(patterns) == "table" then
patterns = { patterns }
end
for _, pattern in pairs(patterns) do
local m = vim.fn.matchlist(str, [[\v\C]] .. pattern)
if #m > 1 and m[2] then
local kw = m[2]
local start = str:find(kw)
return start, start + #kw, kw
end
end
end
-- This method returns nil if this buf doesn't have a treesitter parser
--- @return boolean? true or false otherwise
function M.is_comment(buf, row, col)
if vim.treesitter.highlighter.active[buf] then
local captures = vim.treesitter.get_captures_at_pos(buf, row, col)
for _, c in ipairs(captures) do
if c.capture == "comment" then
return true
end
end
else
local win = vim.fn.bufwinid(buf)
return win ~= -1
and vim.api.nvim_win_call(win, function()
for _, i1 in ipairs(vim.fn.synstack(row + 1, col)) do
local i2 = vim.fn.synIDtrans(i1)
local n1 = vim.fn.synIDattr(i1, "name")
local n2 = vim.fn.synIDattr(i2, "name")
if n1 == "Comment" or n2 == "Comment" then
return true
end
end
end)
end
end
local function add_highlight(buffer, ns, hl, line, from, to)
-- vim.api.nvim_buf_set_extmark(buffer, ns, line, from, {
-- end_line = line,
-- end_col = to,
-- hl_group = hl,
-- priority = 500,
-- })
vim.api.nvim_buf_add_highlight(buffer, ns, hl, line, from, to)
end
function M.get_state(buf)
if not M.state[buf] then
M.state[buf] = { dirty = {}, comments = {} }
end
return M.state[buf]
end
function M.redraw(buf, first, last)
first = math.max(first - Config.options.highlight.multiline_context, 0)
last = math.min(last + Config.options.highlight.multiline_context, vim.api.nvim_buf_line_count(buf))
local state = M.get_state(buf)
for i = first, last do
state.dirty[i] = true
end
if not M.timer then
M.timer = vim.defer_fn(M.update, Config.options.highlight.throttle)
end
end
---@type vim.loop.Timer
M.timer = nil
function M.update()
M.timer = nil
for buf, state in pairs(M.state) do
if vim.api.nvim_buf_is_valid(buf) then
if not vim.tbl_isempty(state.dirty) then
local dirty = vim.tbl_keys(state.dirty)
table.sort(dirty)
local i = 1
while i <= #dirty do
local first = dirty[i]
local last = dirty[i]
while dirty[i + 1] == dirty[i] + 1 do
i = i + 1
last = dirty[i]
end
M.highlight(buf, first, last)
i = i + 1
end
state.dirty = {}
end
else
M.state[buf] = nil
end
end
end
-- highlights the range for the given buf
function M.highlight(buf, first, last, _event)
if not vim.api.nvim_buf_is_valid(buf) then
return
end
vim.api.nvim_buf_clear_namespace(buf, Config.ns, first, last + 1)
-- clear signs
for _, sign in pairs(vim.fn.sign_getplaced(buf, { group = "todo-signs" })[1].signs) do
if sign.lnum - 1 >= first and sign.lnum - 1 <= last then
vim.fn.sign_unplace("todo-signs", { buffer = buf, id = sign.id })
end
end
local lines = vim.api.nvim_buf_get_lines(buf, first, last + 1, false)
---@type {kw: string, start:integer}?
local last_match
for l, line in ipairs(lines) do
local ok, start, finish, kw = pcall(M.match, line)
local lnum = first + l - 1
if ok and start then
---@cast kw string
if
Config.options.highlight.comments_only
and not M.is_quickfix(buf)
and not M.is_comment(buf, lnum, start - 1)
then
kw = nil
else
last_match = { kw = kw, start = start }
end
end
local is_multiline = false
if not kw and last_match and Config.options.highlight.multiline then
if
M.is_comment(buf, lnum, last_match.start)
and line:find(Config.options.highlight.multiline_pattern, last_match.start)
then
kw = last_match.kw
start = last_match.start
finish = start
is_multiline = true
else
last_match = nil
end
end
if kw then
kw = Config.keywords[kw] or kw
end
local opts = Config.options.keywords[kw]
if opts then
start = start - 1
finish = finish - 1
local hl_fg = "TodoFg" .. kw
local hl_bg = "TodoBg" .. kw
local hl = Config.options.highlight
if not is_multiline then
-- before highlights
if hl.before == "fg" then
add_highlight(buf, Config.ns, hl_fg, lnum, 0, start)
elseif hl.before == "bg" then
add_highlight(buf, Config.ns, hl_bg, lnum, 0, start)
end
-- tag highlights
if hl.keyword == "wide" or hl.keyword == "wide_bg" then
add_highlight(buf, Config.ns, hl_bg, lnum, math.max(start - 1, 0), finish + 1)
elseif hl.keyword == "wide_fg" then
add_highlight(buf, Config.ns, hl_fg, lnum, math.max(start - 1, 0), finish + 1)
elseif hl.keyword == "bg" then
add_highlight(buf, Config.ns, hl_bg, lnum, start, finish)
elseif hl.keyword == "fg" then
add_highlight(buf, Config.ns, hl_fg, lnum, start, finish)
end
end
-- after highlights
if hl.after == "fg" then
add_highlight(buf, Config.ns, hl_fg, lnum, finish, #line)
elseif hl.after == "bg" then
add_highlight(buf, Config.ns, hl_bg, lnum, finish, #line)
end
if not is_multiline then
-- signs
local show_sign = Config.options.signs
if opts.signs ~= nil then
show_sign = opts.signs
end
if show_sign then
vim.fn.sign_place(
0,
"todo-signs",
"todo-sign-" .. kw,
buf,
{ lnum = lnum + 1, priority = Config.options.sign_priority }
)
end
end
end
end
end
-- highlights the visible range of the window
function M.highlight_win(win, force)
win = win or vim.api.nvim_get_current_win()
if force ~= true and not M.is_valid_win(win) then
return
end
vim.api.nvim_win_call(win, function()
local buf = vim.api.nvim_win_get_buf(win)
local first = vim.fn.line("w0") - 1
local last = vim.fn.line("w$")
M.redraw(buf, first, last)
end)
end
function M.is_float(win)
local opts = vim.api.nvim_win_get_config(win)
return opts and opts.relative and opts.relative ~= ""
end
function M.is_valid_win(win)
if not vim.api.nvim_win_is_valid(win) then
return false
end
-- avoid E5108 after pressing q:
if vim.fn.getcmdwintype() ~= "" then
return false
end
-- dont do anything for floating windows
if M.is_float(win) then
return false
end
local buf = vim.api.nvim_win_get_buf(win)
return M.is_valid_buf(buf)
end
function M.is_quickfix(buf)
return vim.api.nvim_buf_get_option(buf, "buftype") == "quickfix"
end
function M.is_valid_buf(buf)
-- Skip special buffers
local buftype = vim.api.nvim_buf_get_option(buf, "buftype")
if buftype ~= "" and buftype ~= "quickfix" then
return false
end
local filetype = vim.api.nvim_buf_get_option(buf, "filetype")
if vim.tbl_contains(Config.options.highlight.exclude, filetype) then
return false
end
return true
end
-- will attach to the buf in the window and highlight the active buf if needed
function M.attach(win)
win = win or vim.api.nvim_get_current_win()
if not M.is_valid_win(win) then
return
end
local buf = vim.api.nvim_win_get_buf(win)
if not M.bufs[buf] then
vim.api.nvim_buf_attach(buf, false, {
on_lines = function(_event, _buf, _tick, first, _last, last_new)
if not M.enabled then
return true
end
-- detach from this buffer in case we no longer want it
if not M.is_valid_buf(buf) then
return true
end
M.redraw(buf, first, last_new)
end,
on_detach = function()
M.state[buf] = nil
M.bufs[buf] = nil
end,
})
local highlighter = require("vim.treesitter.highlighter")
local hl = highlighter.active[buf]
if hl then
-- also listen to TS changes so we can properly update the buffer based on is_comment
hl.tree:register_cbs({
on_bytes = function(_, _, row)
M.redraw(buf, row, row + 1)
end,
on_changedtree = function(changes)
for _, ch in ipairs(changes or {}) do
M.redraw(buf, ch[1], ch[3] + 1)
end
end,
})
end
M.bufs[buf] = true
M.highlight_win(win)
M.wins[win] = true
elseif not M.wins[win] then
M.highlight_win(win)
M.wins[win] = true
end
end
function M.stop()
M.enabled = false
pcall(vim.cmd, "autocmd! Todo")
pcall(vim.cmd, "augroup! Todo")
M.wins = {}
---@diagnostic disable-next-line: missing-parameter
vim.fn.sign_unplace("todo-signs")
for buf, _ in pairs(M.bufs) do
if vim.api.nvim_buf_is_valid(buf) then
pcall(vim.api.nvim_buf_clear_namespace, buf, Config.ns, 0, -1)
end
end
M.bufs = {}
end
function M.start()
if M.enabled then
M.stop()
end
M.enabled = true
-- setup autocmds
-- TODO: make some of the below configurable
vim.api.nvim_exec(
[[augroup Todo
autocmd!
autocmd BufWinEnter,WinNew * lua require("todo-comments.highlight").attach()
autocmd BufWritePost * silent! lua require'trouble'.refresh({auto = true, provider = "todo"})
autocmd WinScrolled * lua require("todo-comments.highlight").highlight_win()
autocmd ColorScheme * lua vim.defer_fn(require("todo-comments.config").colors, 10)
augroup end]],
false
)
-- attach to all bufs in visible windows
for _, win in pairs(vim.api.nvim_list_wins()) do
M.attach(win)
end
end
return M

View File

@ -0,0 +1,24 @@
local config = require("todo-comments.config")
local jump = require("todo-comments.jump")
local M = {}
M.setup = config.setup
function M.reset()
require("plenary.reload").reload_module("todo")
require("todo-comments").setup()
end
function M.disable()
require("todo-comments.highlight").stop()
end
function M.enable()
require("todo-comments.highlight").start()
end
M.jump_prev = jump.prev
M.jump_next = jump.next
return M

View File

@ -0,0 +1,54 @@
local highlight = require("todo-comments.highlight")
local config = require("todo-comments.config")
local util = require("todo-comments.util")
local M = {}
---@param up boolean
local function jump(up, opts)
opts = opts or {}
opts.keywords = opts.keywords or {}
local win = vim.api.nvim_get_current_win()
local buf = vim.api.nvim_get_current_buf()
local pos = vim.api.nvim_win_get_cursor(win)
local from = pos[1] + 1
local to = vim.api.nvim_buf_line_count(buf)
if up then
from = pos[1] - 1
to = 1
end
for l = from, to, up and -1 or 1 do
local line = vim.api.nvim_buf_get_lines(buf, l - 1, l, false)[1] or ""
local ok, start, _, kw = pcall(highlight.match, line)
if ok and start then
if config.options.highlight.comments_only and highlight.is_comment(buf, l - 1, start) == false then
kw = nil
end
end
if kw and #opts.keywords > 0 and not vim.tbl_contains(opts.keywords, kw) then
kw = nil
end
if kw then
vim.api.nvim_win_set_cursor(win, { l, start - 1 })
return
end
end
util.warn("No more todo comments to jump to")
end
function M.next(opts)
jump(false, opts)
end
function M.prev(opts)
jump(true, opts)
end
return M

View File

@ -0,0 +1,130 @@
local Config = require("todo-comments.config")
local Highlight = require("todo-comments.highlight")
local Util = require("todo-comments.util")
local M = {}
local function keywords_filter(opts_keywords)
assert(not opts_keywords or type(opts_keywords) == "string", "'keywords' must be a comma separated string or nil")
local all_keywords = vim.tbl_keys(Config.keywords)
if not opts_keywords then
return all_keywords
end
local filters = vim.split(opts_keywords, ",")
return vim.tbl_filter(function(kw)
return vim.tbl_contains(filters, kw)
end, all_keywords)
end
function M.process(lines)
local results = {}
for _, line in pairs(lines) do
local file, row, col, text = line:match("^(.+):(%d+):(%d+):(.*)$")
if file then
local item = {
filename = file,
lnum = tonumber(row),
col = tonumber(col),
line = text,
}
local start, finish, kw = Highlight.match(text)
if start then
kw = Config.keywords[kw] or kw
item.tag = kw
item.text = vim.trim(text:sub(start))
item.message = vim.trim(text:sub(finish + 1))
table.insert(results, item)
end
end
end
return results
end
function M.search(cb, opts)
opts = opts or {}
opts.cwd = opts.cwd or "."
opts.cwd = vim.fn.fnamemodify(opts.cwd, ":p")
opts.disable_not_found_warnings = opts.disable_not_found_warnings or false
if not Config.loaded then
Util.error("todo-comments isn't loaded. Did you run setup()?")
return
end
local command = Config.options.search.command
if vim.fn.executable(command) ~= 1 then
Util.error(command .. " was not found on your path")
return
end
local ok, Job = pcall(require, "plenary.job")
if not ok then
Util.error("search requires https://github.com/nvim-lua/plenary.nvim")
return
end
local args =
vim.tbl_flatten({ Config.options.search.args, Config.search_regex(keywords_filter(opts.keywords)), opts.cwd })
Job
:new({
command = command,
args = args,
on_exit = vim.schedule_wrap(function(j, code)
if code == 2 then
local error = table.concat(j:stderr_result(), "\n")
Util.error(command .. " failed with code " .. code .. "\n" .. error)
end
if code == 1 and opts.disable_not_found_warnings ~= true then
Util.warn("no todos found")
end
local lines = j:result()
cb(M.process(lines))
end),
})
:start()
end
local function parse_opts(opts)
if not opts or type(opts) ~= "string" then
return opts
end
return {
keywords = opts:match("keywords=(%S*)"),
cwd = opts:match("cwd=(%S*)"),
}
end
function M.setqflist(opts)
M.setlist(opts)
end
function M.setloclist(opts)
M.setlist(opts, true)
end
function M.setlist(opts, use_loclist)
opts = parse_opts(opts) or {}
opts.open = (opts.open ~= nil and {opts.open} or {true})[1]
M.search(function(results)
if use_loclist then
vim.fn.setloclist(0, {}, " ", { title = "Todo", id = "$", items = results })
else
vim.fn.setqflist({}, " ", { title = "Todo", id = "$", items = results })
end
if opts.open then
if use_loclist then
vim.cmd([[lopen]])
else
vim.cmd([[copen]])
end
end
local win = vim.fn.getqflist({ winid = true })
if win.winid ~= 0 then
Highlight.highlight_win(win.winid, true)
end
end, opts)
end
return M

View File

@ -0,0 +1,40 @@
--- @class Util
local M = {}
function M.get_hl(name)
local ok, hl = pcall(vim.api.nvim_get_hl_by_name, name, true)
if not ok then
return
end
for _, key in pairs({ "foreground", "background", "special" }) do
if hl[key] then
hl[key] = string.format("#%06x", hl[key])
end
end
return hl
end
function M.hex2rgb(hex)
hex = hex:gsub("#", "")
return tonumber("0x" .. hex:sub(1, 2)), tonumber("0x" .. hex:sub(3, 4)), tonumber("0x" .. hex:sub(5, 6))
end
function M.rgb2hex(r, g, b)
return string.format("#%02x%02x%02x", r, g, b)
end
function M.is_dark(hex)
local r, g, b = M.hex2rgb(hex)
local lum = (0.299 * r + 0.587 * g + 0.114 * b) / 255
return lum <= 0.5
end
function M.warn(msg)
vim.notify(msg, vim.log.levels.WARN, { title = "TodoComments" })
end
function M.error(msg)
vim.notify(msg, vim.log.levels.ERROR, { title = "TodoComments" })
end
return M

View File

@ -0,0 +1,36 @@
local Search = require("todo-comments.search")
local util = require("trouble.util")
local Config = require("todo-comments.config")
local function todo(_win, _buf, cb, opts)
Search.search(function(results)
local ret = {}
for _, item in pairs(results) do
local row = (item.lnum == 0 and 1 or item.lnum) - 1
local col = (item.col == 0 and 1 or item.col) - 1
local pitem = {
row = row,
col = col,
message = item.text,
sign = Config.options.keywords[item.tag].icon,
sign_hl = "TodoFg" .. item.tag,
-- code = string.lower(item.tag),
-- source = "todo",
severity = 0,
range = {
start = { line = row, character = col },
["end"] = { line = row, character = -1 },
},
}
table.insert(ret, util.process_item(pitem, vim.fn.bufnr(item.filename, true)))
end
if #ret == 0 then
util.warn("no todos found")
end
cb(ret)
end, opts.cmd_options)
end
return todo

View File

@ -0,0 +1,54 @@
---@diagnostic disable: inject-field
local Config = require("todo-comments.config")
local Item = require("trouble.item")
local Search = require("todo-comments.search")
---@type trouble.Source
local M = {}
---@diagnostic disable-next-line: missing-fields
M.config = {
formatters = {
todo_icon = function(ctx)
return {
text = Config.options.keywords[ctx.item.tag].icon,
hl = "TodoFg" .. ctx.item.tag,
}
end,
},
modes = {
todo = {
events = { "BufEnter", "BufWritePost" },
source = "todo",
groups = {
{ "tag", format = "{todo_icon} {tag}" },
-- { "directory" },
{ "filename", format = "{file_icon} {filename} {count}" },
},
sort = { { buf = 0 }, "filename", "pos", "message" },
format = "{todo_icon} {text} {pos}",
},
},
}
function M.get(cb)
Search.search(function(results)
local items = {} ---@type trouble.Item[]
for _, item in pairs(results) do
local row = item.lnum
local col = item.col - 1
items[#items + 1] = Item.new({
buf = vim.fn.bufadd(item.filename),
pos = { row, col },
end_pos = { row, col + #item.tag },
text = item.text,
filename = item.filename,
item = item,
source = "todo",
})
end
cb(items)
end, {})
end
return M

View File

@ -0,0 +1,4 @@
command! -nargs=* TodoQuickFix lua require("todo-comments.search").setqflist(<q-args>)
command! -nargs=* TodoLocList lua require("todo-comments.search").setloclist(<q-args>)
command! -nargs=* TodoTelescope Telescope todo-comments todo <args>
command! -nargs=* TodoTrouble Trouble todo <args>

View File

@ -0,0 +1 @@
std="vim"

View File

@ -0,0 +1,6 @@
indent_type = "Spaces"
indent_width = 2
column_width = 120
[sort_requires]
enabled = true

View File

@ -0,0 +1,49 @@
[selene]
base = "lua51"
name = "vim"
[vim]
any = true
[jit]
any = true
[[describe.args]]
type = "string"
[[describe.args]]
type = "function"
[[it.args]]
type = "string"
[[it.args]]
type = "function"
[[before_each.args]]
type = "function"
[[after_each.args]]
type = "function"
[assert.is_not]
any = true
[[assert.equals.args]]
type = "any"
[[assert.equals.args]]
type = "any"
[[assert.equals.args]]
type = "any"
required = false
[[assert.same.args]]
type = "any"
[[assert.same.args]]
type = "any"
[[assert.truthy.args]]
type = "any"
[[assert.spy.args]]
type = "any"
[[assert.stub.args]]
type = "any"