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

Feature: Add rename symbol support #610

Open
HerringtonDarkholme opened this issue Dec 23, 2017 · 28 comments
Open

Feature: Add rename symbol support #610

HerringtonDarkholme opened this issue Dec 23, 2017 · 28 comments

Comments

@HerringtonDarkholme
Copy link
Member

Problem

Language Server Protocol supports rename request.

Open question: should rename symbol change all related symbols in different language sections?

For example, change a component name should almost always change the component name in template as well.

@octref
Copy link
Member

octref commented Jan 16, 2018

Yeah, I deferred this since making sure it works for templates too can be a bit of work.

For example, renaming a data attribute should replace all its occurrences in interpolations, renaming <Child> in <Parent> component should also update the name in Child.vue.

@octref
Copy link
Member

octref commented Jun 6, 2018

I pushed a commit that does js rename. If you have

// foo.js
export const foo = 1
<script>
import { foo } from './foo.js'
</script>

Renaming on JS inside the Vue file works fine, renaming on the JS file does not propagate the changes to JS. To achieve that, we probably need a TS plugin. However, I'm not sure how it can communicate with Vue Language Server and get the edit location.

@chartinger
Copy link

Any updates on this issue? Would it be possible to enable working parts as, for example, experimental flags?
E.g: It would be really helpful to have "Rename Symbols" inside the script .ts part, propagating to other ts/vue-ts files, even when templates and js files are not updated.

@UniverseHan
Copy link

I would try this. Any help would be welcome.

@darrelfrancis
Copy link

darrelfrancis commented Jan 10, 2020

I wondered about why this was not implemented, and only when I read this thread did I realise the full complexity. There are several levels at which it could be implemented, with increasing levels of programming difficulty and increasing value. Even the simplest level could be useful.

Level 1.
Rename only within <script>. Hopefully this should be easy to implement? It would be important to alert to users that they need to do the template references manually.

Level 2.
If you can easily achieve rename in <template> too, that would certainly be worth implementing.

Level 3.
Cross-file symbol rename. I imagine this to be very difficult. I think people should be willing to do this stuff manually with control-shift-H, with manual checking that they are not changing coincidentally named items. Most commonly, when they are renaming an exported item, they can manually search for places it is imported. There is no reason to kill yourself programming this (and even still getting people complain when it goes wrong!)

If Level 1 (or 1 and 2) are attainable at modest effort, it would be really worthwhile, and I would use it -- and be thankful!

@darrelfrancis
Copy link

I pushed a commit that does js rename. If you have

Dear @octref,
I am new to GitHub but a big fan of Vetur. Can you give me a hint as to how to access this commit, to see if I can help?
DF

@d9k
Copy link

d9k commented Jan 24, 2020

Renaming symbols have been working great at least for year in vuejs plugin for IntelliJ Idea (https://github.com/JetBrains/intellij-plugins/tree/master/vuejs).

@vegerot
Copy link

vegerot commented Mar 25, 2020

@octref How feasible would it be to implement level 1 in vue-language-server?

I'm using VSCode at work but the rest of them use WebStorm and it's becoming more attractive all the time...

@Shujee
Copy link

Shujee commented Apr 2, 2020

I'm looking forward to this one too. Any ETA on this?

@vegerot
Copy link

vegerot commented Apr 2, 2020

Truth is I've been using WebStorm for the last week and I gotta say while VSCode is a way better editor, WebStorm is SO much better in terms of Vue support. Just finished a big refactor where I've been changing file names, moving file paths, renaming variables, changing types, etc. and WebStorm does it all automatically. Fixes everything including tests and documentation.

I switch back and forth between VSCode and WebStorm every other day because I find editing in WebStorm to be awful, and truth is Vetur is REALLY good, and nearly everything I need or want Vetur can do, but there are occasions when I need more power and WebStorm provides that stunningly.

edit: not just renaming and moving, but things like extracting components into separate files, a really cool graph feature that you can right click on a component and it will show a cool graph of all the components linked to it, inline css previews and pickers, method parameter decorations (that's a VSCode vs. WebStorm thing though, not Vetur), are some more things I've noticed in the last week

@heavenkiller2018
Copy link

Any updates on this issue?
E.g: It would be really helpful to have "Rename Symbols" inside the script .ts part, propagating to other ts/vue-ts files, even when templates and js files are not updated.

@yoyo930021
Copy link
Member

yoyo930021 commented Jul 31, 2020

@heavenkiller2018
You can follow #2016.
This problem is difficult about with program sync, I have tried before.
There are two typescript programs when vscode.
The one is handling .ts files in VSCode built-in.
The one is handling .vue files in Vetur.
They can't communicate on now.

@littlee
Copy link

littlee commented Aug 7, 2020

tracking this issue 👀

@Predarion
Copy link

Please implement this it would be so helpful!

@nicoespeon
Copy link

Hi there 👋

I recently mentioned that I adapted one of my extension that brings automated refactorings so it works with .vue files too: https://marketplace.visualstudio.com/items?itemName=nicoespeon.abracadabra

"Rename symbol" is an essential refactoring (the most essential?). The extension used to delegate that to VS Code because it does a very good job. But I realized it wasn't supported for Vue files!

So I worked on that yesterday and I'm happy to say that I've shipped a change today (v4.11.0) to support renaming symbols in .vue files!

The UX is similar to the one you'd have with VS Code (although I didn't managed to get the input box just below the symbol). It's seamless since you trigger that with F2. If you find any issue with that when working on .vue files, please open an issue on https://github.com/nicoespeon/abracadabra/issues

I hope that could help you until this is supported by Vetur directly 👍 (it's getting there, but supporting automated refactorings isn't something easy to implement and takes time!)

@littlee
Copy link

littlee commented Nov 20, 2020

After those days, I've rewritten my project to React :neckbeard: :neckbeard: :neckbeard:

@JoJk0
Copy link

JoJk0 commented Jan 22, 2021

Any updates, or alternative extensions that work at the moment?

@chartinger
Copy link

@JoJk0 Depending on your needs you may have a look at VueDX, Volar or Abracadabra

It is really confusing at the moment with different extensions and approaches, each with their own pros and cons.

@itpropro
Copy link

It would be great to have it at least in the HTML part...

@deisner
Copy link
Contributor

deisner commented Mar 11, 2021

I believe there's already an issue for this, but unfortunately Abracadabra doesn't work inside the <template> of a .vue file. Unless I'm mistaken, it's not possible to rename an HTML tag (which is all I really need right now). @nicoespeon

@yoyo930021
Copy link
Member

I believe there's already an issue for this, but unfortunately Abracadabra doesn't work inside the <template> of a .vue file. Unless I'm mistaken, it's not possible to rename an HTML tag (which is all I really need right now). @nicoespeon

Renaming HTML tag is another issue. #565
This part is not difficult, it just takes time to process.

@nicoespeon
Copy link

@deisner indeed, Abracadabra will only work in the <script> tag. Basically, it interprets this part as JS code, so you have refactorings available here. But it's not aware of Vue.js syntax so you can't really do Vue-specific refactorings with it.

@eladcandroid
Copy link

eladcandroid commented May 20, 2021

@octref Do you have any plan here?

@zhangenming
Copy link

I reinstalled my editor several times because I thought there was something wrong with it :(

@SushyDev
Copy link

SushyDev commented Feb 5, 2022

No rename option here still?

@grojguy
Copy link

grojguy commented Mar 3, 2022

I just found VueDX extension. https://marketplace.visualstudio.com/items?itemName=znck.vue-language-features

Seems great, and working great so far!

@tokiory
Copy link

tokiory commented Apr 30, 2023

Bump. There's still no rename feature.
I'm using neovim with ts-server and vetur. Anyone has a solution for this stack?

@thomasaull
Copy link

@tokiory Maybe give volar a try, it‘s recommended in the vue docs and supports renaming of symbols (in TS projects at least)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests