haskell / haskell/haskell-language-server
`hls-rename-plugin` can’t rename import aliases
- Dominant language
- Haskell
- Stars
- 3k
- Forks
- 455
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 11
Description
## Is your enhancement request related to a problem? Please describe.
Sometimes I find it difficult to organize my imports, because `hls-rename-plugin` doesn’t support renaming import aliases.
For example, consider the following code:
```haskell
import qualified Data.List as L
betterTail = L.drop 1
```
Now, suppose I want to rename `L` because I want to import `Control.Lens as L` and refer to `Data.List` as `List` instead.
`hls-rename-plugin` can’t do this yet. Specifically:
- If I place my cursor on `L` in `as L`, the plugin says “No symbol to rename at given location.”
- If I place my cursor on `L` in `L.drop` and attempt to rename `L` to `List`, I get “Renaming of an imported name is unsupported.”
## Describe the solution you'd like
I want to be able to place my cursor on an import alias (whether in an import statement or in a qualified name), and rename the alias.
For example, I should be able go to either `L` below, rename it to `List`, and have all occurrences of `L` changed correctly:
```haskell
-- Before: ----------------------------
import qualified Data.List as L
betterTail = L.drop 1
-- After: -----------------------------
import qualified Data.List as List
betterTail = List.drop 1
```
### Bonus
I also want to be able to rename the following aliases *separately*:
```haskell
-- Before: ----------------------------
import Control.Monad as M
import Data.Maybe as M
isSomething = M.isJust -- from Maybe
discard = M.void -- from Monad
-- After: -----------------------------
import Control.Monad as Monad
import Data.Maybe as Maybe
isSomething = Maybe.isJust -- from Maybe
discard = Monad.void -- from Monad
```
## Describe alternatives you've considered
I tried search-and-replace, but it always felt less convenient and more error prone.
For example, if I have two aliases named `L` and `URL`, doing search-and-replace to rename `L` to `List` might also turn `URL` to `URList`.
## Additional context
I think there’s none.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.