-
-
Notifications
You must be signed in to change notification settings - Fork 777
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
Label completions #3961
Comments
For sure!! |
Is that a copilot thing perhaps? Afaik this feature is not implemented in the language server |
Yeah that's not coming from the Gleam LS. |
No, it looks to be related to the vscode. I tried it with a vanilla vscode without copilot and got the same behaviour. But yeah, you're right. It should come from the "lsp-server" - the project's name. Looking at the code, the fix is probably related to the edit: It looks like your print is using vscode, too. I really do not know how my vscode knows about this type. I'm without copilot, and all that I installed was the Gleam extension |
That's weird. #[test]
fn constructor_field_completions() {
let code = r#"
pub type Wibble {
Wibble(wibble: Int, wobble: Float)
}
pub fn main() {
let wibble = Wibble()
}
"#;
assert_completion!(TestProject::for_source(code), Position::new(5, 22));
} Snapshot 1
And note how the Now, just for test, I've changed the priority order: fn sort_text(kind: CompletionKind, label: &str) -> String {
let priority: u8 = match kind {
// CompletionKind::Label => 0,
// CompletionKind::FieldAccessor => 1,
// CompletionKind::LocallyDefined => 2,
// CompletionKind::ImportedModule => 3,
// CompletionKind::Prelude => 4,
// CompletionKind::ImportableModule => 5,
CompletionKind::Label => 5,
CompletionKind::FieldAccessor => 0,
CompletionKind::LocallyDefined => 2,
CompletionKind::ImportedModule => 3,
CompletionKind::Prelude => 4,
CompletionKind::ImportableModule => 6,
};
format!("{priority}_{label}")
} Snapshot 2
Note how the order now is different. It is also reflected in my vscode: I might be wrong here because I do not have experience with LSP and large compilers. But I didn't understand why the completions options test showed my labels |
VSCode makes suggestions based on strings in the same file. I expect this is what you are seeing here. What happens if you move the definition to a different file? |
Label completion implemented in the Gleam LS needs to work in this case also. Fault tolerance is vital for completions to be useful. |
It would be nice, when typing function calls or record constructors, to have the LSP autocomplete the names of labels.
In this example, the LSP would suggest the
wibble
label.The text was updated successfully, but these errors were encountered: