feat: add telescope.nvim integration (#170)

Closes #169.

## Problem

Telescope never sets `filetype=diff` on preview buffers — it calls
`vim.treesitter.start(bufnr, "diff")` directly, so diffs.nvim's
`FileType` autocmd never fires.

## Solution

Add a `telescope` config toggle (same pattern as
neogit/gitsigns/committia) and a `User TelescopePreviewerLoaded` autocmd
that calls `attach()` on the preview buffer. Disabled by default; enable
with `telescope = true`.

Also adds a `diffs-telescope` vimdoc section documenting the integration
and the upstream first-line preview bug
(nvim-telescope/telescope.nvim#3626).

Includes committia.vim integration from `feat/committia`.
This commit is contained in:
Barrett Ruth 2026-03-06 13:46:15 -05:00 committed by GitHub
parent dc6fd7a387
commit d584d816bf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 61 additions and 0 deletions

View file

@ -18,6 +18,16 @@ if gs_cfg == true or type(gs_cfg) == 'table' then
end
end
local tel_cfg = (vim.g.diffs or {}).telescope
if tel_cfg == true or type(tel_cfg) == 'table' then
vim.api.nvim_create_autocmd('User', {
pattern = 'TelescopePreviewerLoaded',
callback = function()
require('diffs').attach(vim.api.nvim_get_current_buf())
end,
})
end
vim.api.nvim_create_autocmd('FileType', {
pattern = require('diffs').compute_filetypes(vim.g.diffs or {}),
callback = function(args)