-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
nixd: path completion #530
base: main
Are you sure you want to change the base?
Conversation
nixd/lib/Controller/Completion.cpp
Outdated
} | ||
} | ||
|
||
// otherwise, fallback to VLACompletionProvider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 goto
s.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 switch
able 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
goto
s.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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? |
Support completion for path expression.