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

enable building only with Cargo #490

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wis
Copy link

@wis wis commented Jun 20, 2024

Hello! thank you for creating this awesome project, I'm finding it immensely useful and fun to use.
I tried using ast-grep many times, but I was never able to get it to work and have the query return what I want. I just tried tree-grepper and in about 10 minutes, with the help of the Tree-sitter ":Inspect" Playground in Neovim, which looks like this:

Tree-sitter Inspect in Neovim

...and with the help of ChatGPT to refine the tree-sitter query, I was able to have the query return what I wanted exactly:

[
  {
    "file": "mod.rs",
    "file_type": "rust",
    "matches": [
      {
        "kind": "string_content",
        "name": "string",
        "text": "lrld",
        "start": {
          "row": 1486,
          "column": 10
        },
        "end": {
          "row": 1486,
          "column": 14
        }
      },
      {
        "kind": "string_content",
        "name": "string",
        "text": "sldr",
        "start": {
          "row": 1489,
          "column": 10
        },
        "end": {
          "row": 1489,
          "column": 14
        }
      },
      {
        "kind": "string_content",
        "name": "string",
        "text": "scnl",
        "start": {
          "row": 1498,
          "column": 10
        },
        "end": {
          "row": 1498,
          "column": 14
        }
      },
      {
        "kind": "string_content",
        "name": "string",
        "text": "rpt-any",
        "start": {
          "row": 1542,
          "column": 10
        },
        "end": {
          "row": 1542,
          "column": 17
        }
      },
      "............"
]

The query:

(
  (match_expression
    "match"
    value: (identifier)
    body: (match_block
      "{"
      (match_arm
        pattern: (match_pattern
            (string_literal
              "\"" 
              (string_content) @string
            )
        )
      )
    )
  )
)

but before actually getting to try it out, I had a lot of trouble and wasted quite a lot of time trying to get to try to use it, by building it, since trying out the Nix package manager on Arch didn't work for me, it didn't install correctly and outputs something something "socket permission error" when I try to use a Nix command.

I think enabling only a Cargo build option, without Nix, would be helpful to a lot more people and would enable a lot more people to try the software. a Cargo only build would also enable you to publish a pre-built binary to crates.io, so it would make installing for people even more easier.

Edit: see prior issues about this, which this PR potentially fixes #229 #261 #293

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.

cargo build failing
1 participant