CRAG666 / code_runner.nvim

Neovim plugin.The best code runner you could have, it is like the one in vscode but with super powers, it manages projects like in intellij but without being slow
MIT License
534 stars 38 forks source link

Fix project patterns #107

Closed Syphdias closed 6 months ago

Syphdias commented 6 months ago

Currently some project paths cannot be recognized because they contain characters that the string.find function thinks are part of a pattern. An example would be /tmp/my-project as it contains a - (non-greedy match). Escaping the - with %- will result in an error when the command wants to change the directory or wants to find a file in the directory.

Minor change: For clarity I renamed the variable path to file_path and fixed a typo in current_proyect to current_project.

To allow for pattern matching in the keys of the table project, current_project.path needs to be set to the match instead of the key itself.

Due to the vim.fs.normalize that expands environment variables, ~, etc. the last / will be stripped from the pattern. This will lead to potentially incomplete matches. If your pattern is .*terraform%-.-/ to match /path/to/terrafrom-prod and /path/to/terraform-dev, your command will fail because the path will yield only /path/to/terraform- thus not being able to find the directory (eventhough the pattern tries to end with /).

To combat this — bit of a hack — you can append .- to retain the last /.

The pattern then would be .*terrafrom%-.-/.-:

Fixes #94