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

Fix the interference issue caused by organizing aliases. #761

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

scottming
Copy link
Collaborator

When I'm writing functions, I occasionally need to handle unused variables, but I find that organizing aliases still returns results. This causes a lot of interference, especially when there's a bug in nvim, as pressing keys quickly can mess up my code.

CleanShot 2024-06-01 at 10 19 06@2x

We should not return the results of organizing aliases when the cursor is not on a line with an alias or when the current token is not an alias.

@scottming scottming requested a review from scohen June 1, 2024 02:49
@scohen
Copy link
Collaborator

scohen commented Jun 1, 2024

I would also like organize aliases to show up if you're inside of a scope with aliases, for example

defmodule WithAliases do
  alias Foo.Bar
  alias Baz.Quux

  |
end

@scottming
Copy link
Collaborator Author

scottming commented Jun 2, 2024

I would also like organize aliases to show up if you're inside of a scope with aliases, for example

Do you have any suggestions regarding the implementation for it? It seems to conflict somewhat with the goals of this PR.
@scohen

@scohen
Copy link
Collaborator

scohen commented Jun 3, 2024

the implementation would be something like:

  1. Get the scope of the cursor
  2. determine if the immediate parent is a module
  3. determine if that module has any aliases

@scottming
Copy link
Collaborator Author

determine if the immediate parent is a module

Checking this is a bit cumbersome because its ancestors include these before reaching defmodule.

{:__block__, [],
{{:__block__, [line: 1, column: 17], [:do]},
{{:__block__, [line: 1, column: 17], [:do]},

so I think maybe we could just check that both before and after the current cursor are blanks.

@scohen
Copy link
Collaborator

scohen commented Jun 10, 2024

Checking this is a bit cumbersome because its ancestors include these before reaching

This feels like a problem that can be solved.

@scohen
Copy link
Collaborator

scohen commented Jun 10, 2024

(also, blocks are annoying)

@scottming
Copy link
Collaborator Author

This feels like a problem that can be solved.

Please take a look when you have a chance. The block is really annoying, but I think the last commit has limited room for improvement.

@scottming scottming force-pushed the fix-origanize-alias branch 2 times, most recently from d747d8c to 965921f Compare June 28, 2024 02:10
When I'm writing functions, I occasionally need to handle unused variables, but I find that organizing aliases still returns results. This causes a lot of interference, especially when there's a bug in nvim, as pressing keys quickly can mess up my code.

We should not return the results of organizing aliases when the cursor is not on a line with an alias or when the current token is not an alias.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants