Skip to content

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

Open
mmfallacy wants to merge 1 commit intoclabby:mainfrom
mmfallacy:feat/infer-ft-from-filename
Open

feat(diff): infer treesitter filetype highlights from filename#17
mmfallacy wants to merge 1 commit intoclabby:mainfrom
mmfallacy:feat/infer-ft-from-filename

Conversation

@mmfallacy
Copy link
Copy Markdown

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.

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

1 participant