DisposaBoy / GoSublime

A Golang plugin collection for SublimeText 3, providing code completion and other IDE-like features.
MIT License
3.42k stars 302 forks source link

Rename symbol feature #114

Closed Sh4rK closed 5 years ago

Sh4rK commented 12 years ago

It would be nice to have a feature to rename symbols (variables, structure fields, functions etc) in a syntax-aware way, and across all files of a package (or even inter-package, but I'm not sure about that).

DisposaBoy commented 12 years ago

marked as FR. I doubt I'd even look into cross-package refactory as it's not something I'm a fan of but locals and globals should be safe

augustoroman commented 9 years ago

You could now integrate gorename. It's designed for both manual cli use as well as direct text-editor integration:

Examples:

% gorename -offset file.go:#123 -to foo

  Rename the object whose identifier is at byte offset 123 within file file.go.
mdwhatcott commented 9 years ago

@DisposaBoy - +1 for adding support for gorename.

lindroth commented 9 years ago

I have been looking for a way to use gorename in an easy way all day, that would be AWESOME!

justinfx commented 9 years ago

Has anyone looked into this one yet? I thought it might be as simple as just chucking in a command that takes the current cursor pos, and an input string from the user, and shells out to gorename. But then I wondered if it needed to handle dirty views, or to just work only if the current view isn't dirty?

mdwhatcott commented 9 years ago

@justinfx - I've taken a stab at it, but I'm not sure how to get sublime to see my $PATH--I'd rather not have to hardcode a path to gorename.

https://github.com/smartystreets/sublime-gorename/blob/master/gorename.py

Am I missing something simple?

justinfx commented 9 years ago

That is something that should already be handled by GoSublime

https://github.com/DisposaBoy/GoSublime/blob/master/gosubl/gs.py

The env is a settings value that allows you to point it at the desired bin locations. For instance, I have mine include my GOBIN. So you should be able to run subprocess and pass it the env. What you are doing is more or less what I thought to do as a bare minimum, but I wondered if anyone thought it should take into consideration dirty views.

Also you may want to switch your subprocess call to use the list form, and not use shell=True. It is easier to avoid quoting and escaping issues, especially if the file path has spaces.

On Sun, 16 Nov 2014 12:58 PM Michael Whatcott notifications@github.com wrote:

@justinfx https://github.com/justinfx - I've taken a stab at it, but I'm not sure how to get sublime to see my $PATH--I'd rather not have to hardcode a path to gorename.

https://github.com/smartystreets/sublime-gorename/blob/master/gorename.py

Am I missing something simple?

— Reply to this email directly or view it on GitHub https://github.com/DisposaBoy/GoSublime/issues/114#issuecomment-63198226 .

mdwhatcott commented 9 years ago

Ok, thanks for the pointers @justinfx. Not sure if I'll be getting to this anytime soon. If my code helps someone else move this forward that's great too.

justinfx commented 9 years ago

Maybe I will take what you started and propose a merge request to GoSublime

On Sun, 16 Nov 2014 7:16 PM Michael Whatcott notifications@github.com wrote:

Ok, thanks for the pointers @justinfx https://github.com/justinfx. Not sure if I'll be getting to this anytime soon. If my code helps someone else move this forward that's great goo.

— Reply to this email directly or view it on GitHub https://github.com/DisposaBoy/GoSublime/issues/114#issuecomment-63206577 .

mdwhatcott commented 9 years ago

Go for it!

clipperhouse commented 9 years ago

+1 @justinfx

justinfx commented 9 years ago

Comments welcome, on merge request #569

justinfx commented 9 years ago

would love to see this merged. it's been 7 months since the pull request I had made.

rafaeldaime commented 8 years ago

me too...

mdwhatcott commented 8 years ago

@DisposaBoy - Thanks for creating a great plugin for go development. I've written so much code with this tool!

Being able to safely rename a variable across an entire project from within the editor is a powerful capability. This PR would be a great addition to GoSublime. Once you've had the ability to rename any token at will in other languages, programming in go feels clunky. The good news: The go plugin for Intellij already supports this behavior and it's awesome. Just sayin'.

justinfx commented 8 years ago

Pretty sure the project is abandoned. What with this pull request being a year old.

fulldump commented 7 years ago

A great golang plugin has dead :(