Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,21 @@ Use Trouble's filtering: `Trouble todo filter = {tag = {TODO,FIX,FIXME}}`

Search through all project todos with Telescope

This command accepts the following optional arguments:

- `path` - Change how paths are displayed in the results.

```vim
:TodoTelescope path=false
:TodoTelescope path=name
```

- `position` - Disable the line and column numbers.

```vim
:TodoTelescope position=false
```

![image](https://user-images.githubusercontent.com/292349/118135371-ccb91200-b3b7-11eb-9002-66af3b683cf0.png)

> [!Note]
Expand All @@ -191,3 +206,4 @@ Search through all project todos with Telescope
<!-- markdownlint-disable-file MD033 -->
<!-- markdownlint-configure-file { "MD013": { "line_length": 120 } } -->
<!-- markdownlint-configure-file { "MD004": { "style": "sublist" } } -->

14 changes: 13 additions & 1 deletion lua/telescope/_extensions/todo-comments.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ local function keywords_filter(opts_keywords)
end, all_keywords)
end

local function format_display(entry, opts)
if opts.path == false then return "" end
local filename = opts.path == "name" and vim.fn.fnamemodify(entry.filename, ":t") or entry.filename

if opts.position == false then
return string.format("%s ", filename)
else
return string.format("%s:%s:%s ", filename, entry.lnum, entry.col)
end
end

local function todo(opts)
opts = opts or {}
opts.vimgrep_arguments = { Config.options.search.command }
Expand All @@ -33,7 +44,8 @@ local function todo(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 display = format_display(entry, opts)

local text = entry.text
local start, finish, kw = Highlight.match(text)

Expand Down
Loading