Aider-AI / aider

aider is AI pair programming in your terminal
https://aider.chat/
Apache License 2.0
22.72k stars 2.11k forks source link

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

Open houcheng opened 5 days ago

houcheng commented 5 days ago

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 commented 5 days ago

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?

houcheng commented 5 days ago

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:

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

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 commented 5 days ago

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

houcheng commented 5 days ago

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

Prerequisites:

  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

houcheng commented 1 day ago

@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~