nixd: path completion#530
Conversation
| } | ||
| } | ||
|
|
||
| // otherwise, fallback to VLACompletionProvider |
There was a problem hiding this comment.
You can determine whether or not providing VLA completion based on the upExpr result. For example if an ExprPath is encountered, then provide path completion, otherwise if ExprVar, provide VLA completion. Try to determine expr kind first, may make the source code more concise.
There was a problem hiding this comment.
When writing code, I believe that in future there will be more and more different completion modes added, and ultimately form something like that:
IMO the nested levels of codes will be too deep if we just adding if, so I refactor this part of code. But since we only have 3 completion modes at this time, I will revert changes here and use nested if.
Another solution here will be some gotos.
There was a problem hiding this comment.
IMO the nested levels of codes will be too deep if we just adding if, so I refactor this part of code. But since we only have 3 completion modes at this time,
These three completion modes are switchable by the "context" of nix codes. For example, I suppose the attrpath completion only makes sense if there is actually an attrpath user typing, and path completion only makes sense if we are in attrpath.
Another solution here will be some
gotos.
No, we are not writing automata.
Different platform will sort directory entry differently, change CHECK-NEXT to CHECK.
| // if we are in a literal path, use PathCompletionProvider | ||
| if (Parent->kind() == Node::NK_ExprPath) { | ||
| const auto &Path = static_cast<const nixf::ExprPath &>(*Parent); | ||
| if (Path.parts().isLiteral()) { |
There was a problem hiding this comment.
| if (Path.parts().isLiteral()) { | |
| if (Path.parts().isLiteral()) |
remove this curly brace?
| fs::make_absolute(CurFileDir, Path); | ||
| } | ||
|
|
||
| if (fs::exists(Path) && fs::is_directory(Path)) { |
There was a problem hiding this comment.
can we do this in std::filesystem?
|
Also |
|
Is this really the responsibility of the nix lsp? This generic functionality is available through a variety of plugins such as https://marketplace.visualstudio.com/items?itemName=ionutvmi.path-autocomplete If you're going ahead with this, how do you plan to reconcile with other plugins providing the same completions? |
|
To add to the previous comment, path completion was also added to Helix in helix-editor/helix#2608 a few months ago and works OOTB. |
|
I think it might be possible to extend path completion with variables that are not otherwise available to normal path completion(like top-down paths with self). Other than that though, I think it should be left to other tools |
ed5029e to
6707401
Compare

Support completion for path expression.