Skip to content
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

feat: provide snippets for attribute and method completions #820

Closed

Conversation

ivanwonder
Copy link
Contributor

when the user selects the attribute in the completion list, the position of the cursor is not expected. It should be in the middle of quotes.

when the user selects the attribute in the completion list, the position of the cursor is not expected. It should be in the middle of quotes.
Copy link
Member

@ayazhafiz ayazhafiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix, this has been requested for some time. However, I think it would be better to provide this in the language service package so that other Angular language servers, like CoC can take advantage of it too. It is easier to test in the upstream package as well. WDYT?

@ayazhafiz
Copy link
Member

re #521

@ivanwonder
Copy link
Contributor Author

Yes, I think it's possible to move the code to the upstream package. Because this PR only does is rewrite the insertText and replacementSpan. But I just meet a problem here, for example (clic|), there will be no provided info for the user in vscode when the replacementSpan starts from (.

insertText = `${insertText}]="\${0}"`;

Maybe I need to look into it.

@kyliau
Copy link
Contributor

kyliau commented Jun 16, 2020

Thanks for the fix, this has been requested for some time. However, I think it would be better to provide this in the language service package so that other Angular language servers, like CoC can take advantage of it too. It is easier to test in the upstream package as well. WDYT?

More to your point this feature relies on snippet, which is available in the LSP protocol but not available in the Typescript interface. I think it's a good feature to have, but we should discuss if we want to have such complex logic in the extension layer.

I've briefly read about "Actions", but do not understand enough to know how they are used. Perhaps we could explore it a little more and see if it could be used here.

https://github.com/microsoft/TypeScript/blob/6c11ceb8db0a085144ee0041793b1e7faa4c172f/lib/tsserverlibrary.d.ts#L5752-L5768

@ayazhafiz
Copy link
Member

My two cents: I don't think @angular/language-service needs to in total alignment with the tsserver API. We aren't currently. In my opinion the language service package should provide the best features it can, and then it should be the responsibility of the extension implementations to convert the features provided by the language service into types expected by the LSP implementation the extension is targeting. Of course the two pieces shouldn't diverge very far, but keeping the features of the core language service in one component makes it easier to develop new features without having to wait for users to catch up.

@ivanwonder
Copy link
Contributor Author

I think it's better to let the @angular/language-service know the client's capability.

Yes, I think it's possible to move the code to the upstream package. Because this PR only does is rewrite the insertText and replacementSpan. But I just meet a problem here, for example (clic|), there will be no provided info for the user in vscode when the replacementSpan starts from (.

insertText = `${insertText}]="\${0}"`;

Maybe I need to look into it.

I found that the vscode will filter the completion items by the text cut by textEdit.
image
If we provide it in LS, Maybe we should return the completion item label with the symbol, for example (click)

@ivanwonder
Copy link
Contributor Author

I find the issue about snippet for TSServer

@atscott
Copy link
Collaborator

atscott commented Oct 1, 2021

Closing, since we're implementing this in the @angular/language-service and then adding an option for handling it in the @angular/language-server

@atscott atscott closed this Oct 1, 2021
@ivanwonder ivanwonder deleted the completion-with-snippet branch October 7, 2021 01:31
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Nov 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants