bash-language-server icon indicating copy to clipboard operation
bash-language-server copied to clipboard

Add Rename Symbol Capability

Open alichtman opened this issue 6 years ago • 14 comments

What needs to be done in order to add the ability to rename symbols?

alichtman avatar Nov 27 '19 13:11 alichtman

It shouldn't be that much work. But one would need to read up on the LSP protocol.

skovhus avatar Dec 13 '19 10:12 skovhus

Yeah, that would be a great feature!

mxp7064 avatar May 09 '20 18:05 mxp7064

I'm willing to put up $100 (to you or a charity of the implementors choice) towards a bounty on this if anyone is interested.

josegonzalez avatar Feb 10 '21 15:02 josegonzalez

Also willing to put down $1k from the Dokku Open Collective in addition to my personal $100 (redeemable in March, as that's when we'll have 1k) towards the bounty as well. I also welcome others to chip in further :)

My reason for putting so much is that Dokku itself uses a significant amount of bash and this sort of functionality was sorely missed by a refactoring I was doing last night...

josegonzalez avatar Feb 10 '21 16:02 josegonzalez

@josegonzalez that is a really nice offer! Donating to charity would be a great incentive to fix this.

Let me know what you expect from this feature. Same file symbol renaming? Cross file renaming? The last part is a bit more tricky but could be doable.

skovhus avatar Feb 10 '21 18:02 skovhus

I think same file seems like a reasonable first pass, especially for variables. Not sure how cross-file renaming might work, but would definitely be useful for Dokku since we typically source things from other files.


Honestly I'd love if this project was as good as the golang lsp in sublime text (with the hovercard and everything) as it would make lots of tooling in bash much easier to develop. Anything I can do to push in that direction is great.

josegonzalez avatar Feb 10 '21 19:02 josegonzalez

Which features are you missing the most? Feel free to share a screenshot (I haven't used the LSP you mentioned). :)

skovhus avatar Feb 10 '21 19:02 skovhus

Mind joining the gliderlabs slack? I can probably more easily send you screenshots and discuss there :) . My nick is savant.

josegonzalez avatar Feb 10 '21 19:02 josegonzalez

A few notes on how the golang one shows:

Screen Shot 2021-02-11 at 1 49 13 AM

For bash:

  • The window box here doesn't always appear (seems mostly miss, not hit).
  • Variable declaration doesn't include how the variable was declared, and doesn't work at all when hovering over the actual declaration. Would be cool to include what the variable type was declared as (Guessing based on the initial value declared and saying "unknown" if not specified would be fine imo).
  • The function definition is not shown. Would be cool if we could perform reflection on the command and fetch any declared desc variable, and maybe arguments as well. I think maybe using declare to fetch properties and then maybe introspect if they are arguments ($1, $2, $@) might be neat as a standard.
  • References only ever shows references in opened files, not across the entire codebase.
  • There is no Format document. I realize this is somewhat subjective. Would be awesome if this project was written in golang as then you could use shfmt for it's formatter, but thats probably implementable in this project as well.
    • Dokku uses shfmt with a few args, though honestly we'd be fine with removing those args and just using the project as is. We use it with: shfmt -bn -ci -i 2 -w ..
      • -bn: Binary ops like && and | may start a line.
      • -ci: Switch cases will be indented.
      • -i 2: indent 2
      • -w: write the output

josegonzalez avatar Feb 11 '21 07:02 josegonzalez

Thanks for this comprehensive list! We should probably split this up into a few different issues and evaluate what provides the most value.

For the rename symbol capability, then I hope to have a stab at this and figure out what needs to be done. 👍 Would be great to donate the ~$1K to charity!

References only ever shows references in opened files, not across the entire codebase.

By quickly looking at some Dokku repositories it seems that you are not using any file extensions for shell scripts. We currently preparse all files matching this glob.

We do not pre-parse files without any file extension (but we could do that!).

Context: https://github.com/bash-lsp/bash-language-server/issues/47#issuecomment-594370106

skovhus avatar Feb 11 '21 07:02 skovhus

Just wanted to pop in and see if there's any progress happening on this. Thank everyone.

mike-lloyd03 avatar Oct 27 '21 20:10 mike-lloyd03

I was thinking the same thing @mike-lloyd03!

Has there been any progress on this? This project is so close to reaching its full potential :)

NiciTheNici avatar Feb 10 '22 23:02 NiciTheNici

With rename and the new Shellcheck integration merged https://github.com/bash-lsp/bash-language-server/pull/342 bash-language-server will be feature complete and amazing! :)

David-Else avatar Apr 02 '22 09:04 David-Else

Well, that's great news. Thanks everyone!

alichtman avatar Apr 02 '22 21:04 alichtman

Would love to see this happening, also putting in 20-30$ into charity if that happens.

gabyx avatar Jun 17 '23 10:06 gabyx

Charity would be great! I’m also wondering if we should enable GitHub sponsors to encourage more people to contribute.

The amount of code contributions is a bit lower for this project than my other OSS projects. Wondering if the combination of TypeScript tooling for a diverse crowd doing bash script is the reason.

skovhus avatar Jun 17 '23 10:06 skovhus

Charity would be great! I’m also wondering if we should enable GitHub sponsors to encourage more people to contribute.

The amount of code contributions is a bit lower for this project than my other OSS projects. Wondering if the combination of TypeScript tooling for a diverse crowd doing bash script is the reason.

Maybe, not sure, I might guess that bash is more used in *nix envs where Go/Rust etc... is at play too. So its a different skill set, sadly than in the Web/Typescript world...

gabyx avatar Jun 17 '23 12:06 gabyx

Released as 5.1.0 and vscode client 1.40.

Thanks you @mcecode

skovhus avatar Dec 27 '23 12:12 skovhus