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

Feature Request: Support custom SCM query files via --scm option #2470

Open
houcheng opened this issue Nov 27, 2024 · 8 comments
Open

Feature Request: Support custom SCM query files via --scm option #2470

houcheng opened this issue Nov 27, 2024 · 8 comments
Labels
enhancement New feature or request

Comments

@houcheng
Copy link

Issue

Hi!

I would like to suggest adding a new command-line option --scm that allows users to provide custom SCM query files. The provided SCM files should follow the Tree-sitter naming convention: either tree-sitter-{lang}-tags.scm or {lang}.scm.

When processing files, the system should first check if a user-provided SCM file matches the current programming language before falling back to the default queries folder.

If you think this feature would be valuable, I'd be happy to work on implementing it and submit a PR. Please let me know if you're interested and if you have any specific requirements or guidelines for the implementation.

Thanks for considering this request!

Version and model info

No response

@paul-gauthier
Copy link
Collaborator

Thanks for trying aider and filing this issue.

Help me understand why you want this? Why not just contribute the scm to aider so everyone can use it?

Which language(s) in particular are you intending to use?

@paul-gauthier paul-gauthier added the question Further information is requested label Nov 27, 2024
@houcheng
Copy link
Author

houcheng commented Nov 27, 2024

Thanks for the response and for creating aider!

I'd be happy to share my F# query SCM file with aider right away! I've been using it with F# and it works well.

The only catch is that I currently have to use it with my local setup because F# isn't in tree-sitter-languages yet (though I've submitted a PR for that). My setup includes:

  • A locally built tree-sitter-languages with F# support
  • A modified grep-ast package
  • My custom F# query SCM file

Even if I contribute the F# query file to aider now, other users would need to either:

  • Wait for my tree-sitter-languages PR to be merged, or
  • Build tree-sitter-languages locally like I did

That's what made me think of the --scm option - it'd make it easier for folks to try out new language support before everything's officially integrated.

Let me know if this helps explain things better!

@paul-gauthier
Copy link
Collaborator

That makes sense. Can you share the process you used to build the F# tree sitter and integrate it into aider?

@houcheng
Copy link
Author

houcheng commented Nov 27, 2024

Thanks! Here are my detailed setup steps (I'm on Windows).

Prerequisites:

  • Conda env
  • x64 MSVC: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
  1. Build tree-sitter-languages:

    • python build.py # this downloads source repos to vendor/
    • python setup.py build
    • python setup.py bdist_wheel
  2. Build ast-grep with .fs/.fsx => fsharp modification

  3. Build aider with F# query SCM file

  4. Install the 3 built wheels then verify tree-sitter version is still 0.21.3

@paul-gauthier paul-gauthier added enhancement New feature or request and removed question Further information is requested labels Nov 30, 2024
@houcheng
Copy link
Author

houcheng commented Dec 1, 2024

@paul-gauthier

Oops, sorry, i thought you were asking the languages package, for the f# tree sitter, I've modified some of its binding interface for fitting with the tree-sitter-languages package and here is the repos: https://github.com/houcheng/tree-sitter-fsharp

The building for F# tree sitter requires node 22 and MSVC2019 for generating code from grammar.js and building native binaries.
Here is my summary of steps:

"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64

npm install
npm run build
cd fsharp
npx tree-sitter generate
cd ..
python setup.py clean
python setup.py build
python setup.py bdist_wheel

Thank you~

@spiiin
Copy link

spiiin commented Dec 10, 2024

@houcheng, thank you for explaining how to use F# with Aider. I am trying to build tree-sitter-languages locally while the PRs is under review. Could you also share the file tree-sitter-fsharp-tags.scm?

@spiiin
Copy link

spiiin commented Dec 12, 2024

tree-sitter-fsharp-tags.scm.txt
Tests
Never mind, I made my own, although I'm not sure about what I did, but it seems to work. I believe the requested feature will be very useful.

@paul-gauthier
Copy link
Collaborator

Thanks for trying aider and filing this issue.

Please see these two related issues for relevant updates:

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

No branches or pull requests

3 participants