Skip to content

Improve 'async' contextual keyword highlighting #290

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

Merged
merged 1 commit into from
Dec 20, 2018

Conversation

rhysd
Copy link
Contributor

@rhysd rhysd commented Dec 20, 2018

async is a contextual keyword. For example, when it is used in context of scope resolution (::), async can be used as module name. In the case, the async name should be highlighted as normal identifier, not a keyword.

This patch restricts highlighting async as keyword only when space or newline is following. So now async in module resolution such as foo::async::X is highlighted as normal module name.

Here is a screenshot:

2018-12-20 11 51 12

@rust-highfive
Copy link

r? @steveklabnik

(rust_highfive has picked a reviewer for you, use r? to override)

@da-x da-x merged commit b5308ef into rust-lang:master Dec 20, 2018
@da-x
Copy link
Member

da-x commented Dec 20, 2018

According to the docs async is supposed to be a strict keyword, but only since edition 2018. We have the following issue for the renaming of async module in request: seanmonstar/reqwest#357 to be compatible with edition 2018.

Until edition 2018 is default in Rust and Cargo, we should default to highlighting like it's edition 2015, and in the future, auto-detect the currently configured edition in Cargo.toml and perform syntax highlighting accordingly. For now, a bridging solution that handles the contextual use of async suffices.

Thanks!

alok added a commit to alok/rust.vim that referenced this pull request Feb 5, 2019
* remotes/original/master: (423 commits)
  Use 'setfiletype' to avoid load 'ftplugin/rust.vim' twice  (rust-lang#301)
  avoid setting `isfname`
  allow 'pub use'
  Set `include` and improve `includeexpr`
  Revert "BufWritePre should be <buffer>"
  Recognize edition2015 and edition2018 doc test specifiers
  Revert "RustTest: specify module name to run exact one test case"
  RustTest: specify module name to run exact one test case
  RustTest: use :terminal for running tests
  ftplugin/rust.vim: Better to narrow augroup scope
  rustfmt: remove incorrect version check
  rustfmt: simplify regex tests
  Improve 'async' contextual keyword highlighting (rust-lang#290)
  RustFmt: fix non-existant temp file
  Add new keywords (rust-lang#282)
  Add SyntasticInfo if exists to the output of RustInfo
  Check that Syntastic is new enough
  Update rust.txt
  Add `cargo#guessrun` function & `Cgrun` command
  Fix RunRustfmt() for Vim 7.x
  ...
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.

4 participants