Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ts and tsx file associations to defaults #818

Closed
afnanenayet opened this issue Jan 30, 2024 · 0 comments · Fixed by #820
Closed

Add ts and tsx file associations to defaults #818

afnanenayet opened this issue Jan 30, 2024 · 0 comments · Fixed by #820
Assignees
Labels
enhancement New feature or request

Comments

@afnanenayet
Copy link
Owner

As noted by another user, we should add the typescript grammar file associations to the defaults in diffsitter.

          Running `diffsitter` `0.8.1` on macOS via homebrew:
⇒ diffsitter --version
diffsitter 0.8.1

It lists support for typescript / tsx:

⇒ diffsitter list
This program was compiled with support for:
- bash
- c_sharp
- cpp
- css
- go
- hcl
- java
- json
- ocaml
- php
- python
- ruby
- rust
- tsx
- typescript

Yet by default, it will fail to run against a JavaScript file:

⇒ git difftool --tool diffsitter HEAD~1 HEAD -- unpacked/_next/static/\[buildHash\]/_buildManifest.js
Error: Unsupported file type with no fallback command specified.

Until a file-association override is added to the config (${XDG_HOME:-$HOME}/.config/diffsitter/config.json5):

// ..snip..
  "grammar": {
    "dylib-overrides": null,
    "file-associations": {
      "js": "typescript",
      "jsx": "tsx"
    },
  },
// ..snip..

This would seem like a useful thing to be included in the default config that diffsitter uses:

⇒ diffsitter dump-default-config
{
  "file-associations": null,
  "formatting": {
    "default": "unified",
    "unified": {
      "addition": {
        "highlight": null,
        "regular-foreground": "green",
        "emphasized-foreground": "green",
        "bold": true,
        "underline": false,
        "prefix": "+ "
      },
      "deletion": {
        "highlight": null,
        "regular-foreground": "red",
        "emphasized-foreground": "red",
        "bold": true,
        "underline": false,
        "prefix": "- "
      }
    },
    "json": {
      "pretty_print": false
    },
    "custom": {}
  },
  "grammar": {
    "dylib-overrides": null,
    "file-associations": null
  },
  "input-processing": {
    "split-graphemes": true,
    "exclude-kinds": null,
    "include-kinds": null
  },
  "fallback-cmd": null
}

I also noted that modifying that default config to add the file-associations to the root key didn't seem to work; it only seemed to work when I added them to the grammar version of file-associations.

Originally posted by @0xdevalias in #152 (comment)

@afnanenayet afnanenayet added the enhancement New feature or request label Jan 30, 2024
@afnanenayet afnanenayet self-assigned this Jan 30, 2024
afnanenayet added a commit that referenced this issue Feb 4, 2024
Read file associations as typescript to compare js and ts files directly
against each other.

Closes #818.
afnanenayet added a commit that referenced this issue Feb 10, 2024
Read file associations as typescript to compare js and ts files directly
against each other.

Closes #818.
afnanenayet added a commit that referenced this issue Feb 11, 2024
Read file associations as typescript to compare js and ts files directly
against each other.

Closes #818.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant