elixir-ls icon indicating copy to clipboard operation
elixir-ls copied to clipboard

Feature Request: Add refactor functionality

Open eddy147 opened this issue 4 years ago • 9 comments

Environment

Ubuntu 20.04

  • Elixir & Erlang versions (elixir --version): Erlang/OTP 23 [erts-11.1] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [hipe] Elixir 1.11.2 (compiled with Erlang/OTP 23)

  • Operating system: Distributor ID: Ubuntu Description: Ubuntu 20.04.1 LTS Release: 20.04 Codename: focal

  • Editor or IDE name (e.g. Emacs/VSCode): VSCode and neovim

  • Editor Plugin/LSP Client name: neovim: elixir-editors/vim-elixir + https://github.com/elixir-lsp/coc-elixir vscode: elixirLS 0.6.2

For other language servers I am used to the refactor/rename functionality, where I can rename functions/variables and the plugin will rename it smartly (other than find and replace).

I am missing that in elixirLS or I can not find it in the documentation. I have tried it in vscode and in (neo)vim.

eddy147 avatar Dec 12 '20 14:12 eddy147

Hi, thanks for the request. Indeed ElixirLS does not currently support refactoring/renaming, but if someone were to tackle it we'd be glad to help get it merged. (I renamed the title of your request to make it more obviously a feature request).

axelson avatar Dec 12 '20 18:12 axelson

Building the web one link at a time...

I was directed here by this StackOverflow question.

HaleTom avatar Apr 27 '21 13:04 HaleTom

Hi, thanks for the request. Indeed ElixirLS does not currently support refactoring/renaming, but if someone were to tackle it we'd be glad to help get it merged. (I renamed the title of your request to make it more obviously a feature request).

@axelson I'd love to see this feature as well as other refactoring capabilities. If you could point me in the right direction, I'd love to take a crack at this.

I'm guessing refactoring commands would go in apps/language_server/lib/language_server/providers/execute_command, perhaps in a nested refactoring directory. Am I on the right track here?

garrettmichaelgeorge avatar May 20 '21 21:05 garrettmichaelgeorge

@garrettmichaelgeorge yes, you are on the right track.

https://github.com/elixir-lsp/elixir-ls/pull/521 is finishing up the implementation of ManipulatePipes which is the only thing that would fall under refactoring at this point. In the future we could add a refactoring directory, but I don't think we need that yet since there's only a small handful of commands currently supported.

axelson avatar May 23 '21 21:05 axelson

Sorry I haven't had a chance to follow up on this yet.

I know there's been a lot of (edit: exciting!) discussion lately about recent efforts like Rfx and Sourceror.

While I was focusing on building Sourceror to be this foundation, folks like Andy Leak started working on a framework to build refactoring operations called Rfx. It's nicely coming together and it will soon be ready enough to be able to use Sourceror to perform complex refactoring operations and integrate with existing tooling like ElixirLS or Credo, so check it out too! — https://dorgan.netlify.app/posts/2021/07/preparing-the-ground-for-source-code-manipulation/

With those libraries tackling Elixir source code manipulation at a deeper level, I'm wondering if I should hold off on attempting something here and instead support their development.

garrettmichaelgeorge avatar Sep 03 '21 15:09 garrettmichaelgeorge

Hi, I would love to see this implemented. But I imagine this is not currently possible with the "find all references" as it currently is, seems like "find all references" is really clunky, sometimes it works and gives me a list of references on my lsp-mode buffer, sometimes it just doesn't do anything. Gotta find the references first before being able to rename them.

Sleepful avatar Aug 04 '22 05:08 Sleepful

@lukaszsamson do you have any thoughts about it? Is it possible? :)

GGuinea avatar Aug 12 '22 15:08 GGuinea

any updates on it ? would be really nice to have it and to refactor (at least rename) without pain )

nichita-pasecinic avatar Sep 03 '22 19:09 nichita-pasecinic

Hi all, if you'd like this to be built please just leave a :+1: on the issue itself. Comments asking for this to be implemented are not helpful and end up just making noise for the maintainers.

If you're interested, please contribute to some of the tools that are operating in this space. Once one of them is stable and can handle all the edge cases for a given refactoring we can consider bringing it in. Here's some refactoring tools that I'm aware of that you can checkout, try, and submit PRs to:

  • https://github.com/hrzndhrn/recode
  • https://github.com/ckochx/ex_factor/
  • https://github.com/andyl/rfx

axelson avatar Sep 05 '22 02:09 axelson

I'm definitely in favour of introducing refactor functionality. Let's divide it into separate and actionable items. "Add refactor" is simply not actionable

lukaszsamson avatar Oct 06 '22 16:10 lukaszsamson

@lukaszsamson any thoughts on what the separate items would be?

I'm happy to create an issue for rename functionality if that is helpful? I've started trying to pick up from the POC here - https://github.com/Tuxified/elixir-ls/pull/1 (his original PR here - https://github.com/elixir-lsp/elixir-ls/pull/676)

timgent avatar Oct 21 '22 08:10 timgent

This is a serious problem for me

MapperMalte avatar Jun 04 '23 01:06 MapperMalte

Refactoring is not high on my priority list. I'd be happy if someone from the community was wiling to continue the work started by others in the experimental server

lukaszsamson avatar Jun 04 '23 06:06 lukaszsamson

I'm definitely in favour of introducing refactor functionality. Let's divide it into separate and actionable items. "Add refactor" is simply not actionable

If 'Add refactor' is not actionable, pls add feature requests that are, and ask the the community to pick that up, before you close this request.

eddy147 avatar Jun 08 '23 08:06 eddy147

If 'Add refactor' is not actionable, pls add feature requests that are, and ask the the community to pick that up, before you close this request.

That's not how it works. How can the maintainers guess what exactly the community wants. There are already a few ones open e.g. https://github.com/elixir-lsp/elixir-ls/issues/765, https://github.com/elixir-lsp/elixir-ls/pull/676 https://github.com/elixir-lsp/elixir-ls/pull/861 https://github.com/elixir-lsp/elixir-ls/pull/803. If you have ideas pleas onen new issues/PRs. The progress on those has slowed down though since @scohen stopped contributting

lukaszsamson avatar Jun 08 '23 08:06 lukaszsamson

The progress on those has slowed down though since @scohen stopped contributting

@lukaszsamson I'd like to talk to you about what's going on here, can we schedule some time on slack?

scohen avatar Jun 12 '23 17:06 scohen