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

Rename all static variables to UPPER_CASE #190

Open
cormacrelf opened this issue Nov 15, 2019 · 2 comments
Open

Rename all static variables to UPPER_CASE #190

cormacrelf opened this issue Nov 15, 2019 · 2 comments
Labels
good first issue Good for newcomers

Comments

@cormacrelf
Copy link
Collaborator

Currently it's hard to tell which variables are statics and which are locals.

How to do it:

  1. Install the latest https://github.com/rust-analyzer/rust-analyzer. You should be using this anyway, it's better than RLS now.
  2. Search for static(?: mut) [a-z]
  3. Use your editor's LSP rename function. GOTO 2.

Step 3 takes a couple seconds as the rename is propagated to all usages, including other files. Beware of starting another rename while one is in progress, as rust-analyzer's intel about usage locations can become off by a line or two and start overwriting other code.

Here's how to do it if you're smart:

  1. Install rust-analyzer
  2. Configure neovim with LanguageClient-neovim & rust-analyzer
  3. Write a vim function to get the symbol under the cursor, and issue a rename with the capitalized version of it. See https://github.com/autozimu/LanguageClient-neovim/blob/53f59715a/doc/LanguageClient.txt#L450-L459
  4. Search for static
  5. Call the function, goto 4

If there are any Vim ninjas out there with a spare half hour, maybe give it a go! Let's be real, it will probably be me in a day or two, so you don't have long.

@cormacrelf cormacrelf added the good first issue Good for newcomers label Nov 15, 2019
@burrbull
Copy link
Collaborator

Just remove
#[allow(non_upper_case_globals)]

@cormacrelf
Copy link
Collaborator Author

That doesn’t convert them to uppercase for you? Unless you mean cargo fix afterward in which case good idea maybe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants