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

[Rust-Analyzer] Support SnippetTextEdit #1926

Merged
merged 1 commit into from
Jul 18, 2020

Conversation

yyoncho
Copy link
Member

@yyoncho yyoncho commented Jul 16, 2020

Fixes #1907

@@ -475,6 +475,7 @@ See `-let' for a description of the destructuring mechanism."
(TextDocumentItem (:languageId :text :uri :version) nil)
(TextDocumentSyncOptions nil (:change :openClose :save :willSave :willSaveWaitUntil))
(TextEdit (:newText :range) nil)
(SnippetTextEdit (:newText :range) (:insertTextFormat))
Copy link
Member

Choose a reason for hiding this comment

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

is this part of LSP spec? or is rust specific? if so should this go here?

Copy link
Member Author

Choose a reason for hiding this comment

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

it is implemented in vscode experimental features, at least I was unable to find it in rust analyzer client. My guess is that it will make to the spec at some point.

lsp-mode.el Outdated
(-when-let ((&SnippetTextEdit :range (&RangeToPoint :start)
:insert-text-format? :new-text) edit)
(when (eq insert-text-format? lsp/insert-text-format-snippet)
(yas-expand-snippet (lsp--to-yasnippet-snippet new-text) start (+ start (length new-text)))))))))
Copy link
Member

Choose a reason for hiding this comment

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

You may need to wrap this one with let (yas-indent-line) too. To prevent snippet indentation.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Member

@ericdallo ericdallo left a comment

Choose a reason for hiding this comment

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

Code looks good, but I didn't test it manually

@yyoncho yyoncho merged commit 9eb3324 into emacs-lsp:master Jul 18, 2020
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.

"Add #[derive]" missing from code actions with rust-analyzer
3 participants