Skip to content

feat(diff): infer treesitter filetype highlights from filename - #17

Merged
clabby merged 1 commit into
clabby:mainfrom
mmfallacy:feat/infer-ft-from-filename
Jul 9, 2026
Merged

clabby merged 1 commit into
clabby:mainfrom
mmfallacy:feat/infer-ft-from-filename

Conversation

@mmfallacy

Copy link
Copy Markdown
Contributor

PR Description

This PR infers the filetype from the corresponding file's path. That is,

  • diff.lua M.render() function takes in file as a parameter (lua table).
  • This file parameter is from difftastic's (via the lib) JSON output, which is a list of files with the following properties:
    • file.additions;
    • file.aligned_Lines;
    • file.language;

    This is what we currently use for setting file types where we lookup a const table.

    • file.path;

    This is the path which contains the filename including the extension vim can use to infer filetypes.

    • ...
  • When the lookup fails, we use filename from file.path to infer the filetype via vim.filetype.match.
  • Pass this to ensure_treesitter like before.

More tangibly, without modifying the lookup table
Before:
image

After:
image

Related Issues

This may essentially close #16 for filetypes that aren't yet handled.

@clabby
clabby merged commit 3aa5cc0 into clabby:main Jul 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't see syntax highlighting

2 participants