这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@rszyma
Copy link
Contributor

@rszyma rszyma commented Nov 8, 2025

Closes #183

This PR adds completion for local file paths.

It works by suggesting only next possible segments in a path, not recursively all files. It's similar to gopls path suggestions of modules.

TODO

  • Fix completion for ./$0 not working, because it's being parsed as BinaryOp(BinaryOp(BINARY_OP@0..2)) (a division operation?), while I'd expect it to parse as literal, just like ./asdf/$0 parses as Literal(Literal(LITERAL@0..7)). This should either be fixed in in parser or though some hack. This also applies to ../$0 and ~/$0.
  • Paths with dynamic parts (with a variable) should never trigger completion, it's not handled explicitly currently.
  • Maybe replace glob lib with something native? Maybe std::fs::read_dir? We don't need full glob capability.
  • Add tests? (not sure how to test this...)

@rszyma rszyma force-pushed the filepath-completion branch 2 times, most recently from f9c7185 to 97cb525 Compare November 8, 2025 17:44
@rszyma rszyma force-pushed the filepath-completion branch from 97cb525 to 5183704 Compare November 8, 2025 17:53
> use of deprecated function `std::env::home_dir`: This function's
behavior may be unexpected on Windows. Consider using a crate from
crates.io instead.
@rszyma
Copy link
Contributor Author

rszyma commented Nov 8, 2025

This is good enough for review now.
I'm not sure how to handle unit tests for this, any ideas? Should I just skip writing them?

From some manual testing I did, it works in every case I could think of:

  • ./folder/$0, ../folder/$0, ~/folder/$0
  • ./$0, ../$0, ~/$0
  • all above, but in a .nix file placed in sub-directory of a workspace

edit: also tested for absolute paths

@rszyma rszyma marked this pull request as ready for review November 8, 2025 22:34
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.

Feature Request: Completion for paths

1 participant