-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
Workspace symbols #674
Workspace symbols #674
Conversation
It's worth noting that this isn't a feature I ever use, so I might be way off the mark here. Here are the current limitations:
I'm not wedded to these limitations, and I'd like to hear from someone who uses these features. |
80537e6
to
0b78f7e
Compare
OK, some more screwing around reveals that this is kinda related to opening Neovim in a vertical split mode, I guess? So I start my editor this way: I start off in Same happens with The error does NOT manifest itself if the editor is opened with a single pane. Finally, trying to invoke listing of file symbols shows this big error:
Hope any of that helps. |
Oh btw, this also happens not just when clicking the buffers with the mouse. Doing C-h and C-l causes the error as well. |
This looks to be a problem with the plugin, as evidenced by the fact that it seems to only manifest itself when something editor-specific is happening. The LSP has no idea what's going on with the editor. The response you sent looks like a valid document symbols response. I'm not a vim user, so maybe @scottming has ideas. The ["end"] in selection range is suspicious though. |
Sorry, which plugin? I can make a super mini Elixir project and see if we can have that reproduced on your machine (if you use NeoVim at all, that is). |
whatever you're using to enable language servers with vim. Maybe "LSP client" is better terminology. |
Well I suppose it's NeoVim's builtin LSP software. Any ideas how can I troubleshoot this further? I am busy enough and not being versed in the implementation details of my editor is a conscious choice that I am not looking to change, I am afraid. Is there any other way I can help? |
One of our contributors, @scottming has been helpful with this stuff in the past. |
acbc218
to
1e45238
Compare
@scohen @dimitarvp I can replicate this error, will take a look today or tomorrow. |
@scohen My apologies for not posting the output of listing workspace symbols. My bad. I'll do that and post the output Later™. |
1e45238
to
4e74e7d
Compare
4e74e7d
to
4fa75d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried out this branch and found that it works very well when searching for function definition symbols, but when I want to search for modules, it still first returns functions and the functions from dependencies. I think when the first letter is capitalized, it should prioritize returning modules, and it should prioritize returning the last module with a high degree of match.
Additionally, when I enter the attribute @user, it doesn't return anything. Is this intentional?
...e_control/test/lexical/remote_control/search/indexer/extractors/function_definition_test.exs
Outdated
Show resolved
Hide resolved
That's not how workspace symbols works or is supposed to work. You're searching for all symbols, not a specific type, and if a symbol has some text in it, you're going to get that symbol back. We can control ordering to an extent though different editors sort things differently.
I've noticed this too, i don't know what reverted to cause this.
I get module attributes when i search for their names ( |
@scottming I fixed the dependencies issue, I added nil to the app for testing, which pulled in anything that didn't have an app, which included a lot of dependencies. I removed nil from the application list, so you shouldn't see any deps in your completions any more. As for the module attributes, I pulled out the leading |
03e890d
to
efb2e2e
Compare
So if I want to quickly search for a module using this feature, how should I do it, especially when I don't quite remember the context of the module(Like only remember the |
Searching for "User" should find it just fine. |
Because your editor is ranking them that way, we merely provide symbols. It's also doing something annoying by implying that the path has something to do with the returned results. That said, we do rank them higher because the term I want to be very clear here, we are providing a list of workspace symbols that match a query. Your editor then takes this list and orders it the way it sees fit. You're disagreeing with that ranking; we don't have much control over it. |
That's your opinion. It's quite possible that someone wants to see where they use |
Actually, I double-checked and found that Response[DEBUG][2024-04-17 10:15:48] .../vim/lsp/rpc.lua:387 "rpc.receive" {
id = 32,
jsonrpc = "2.0",
result = { {
kind = 12,
location = {
range = {
["end"] = {
character = 35,
line = 9
},
start = {
character = 6,
line = 9
}
},
uri = "file:///Users/scottming/Code/live_demo/test/support/fixtures/catalog_fixtures.ex"
},
name = "LiveDemo.CatalogFixtures.product_fixture/1"
}, {
kind = 12,
location = {
range = {
["end"] = {
character = 22,
line = 37
},
start = {
character = 6,
line = 37
}
},
uri = "file:///Users/scottming/Code/live_demo/lib/live_demo/catalog.ex"
},
name = "LiveDemo.Catalog.get_product!/1"
}, {
kind = 12,
location = {
range = {
["end"] = {
character = 49,
line = 72
},
start = {
character = 7,
line = 72
}
},
uri = "file:///Users/scottming/Code/live_demo/lib/live_demo_web/live/product_live/form_component.ex"
},
name = "LiveDemoWeb.ProductLive.FormComponent.save_product/3"
}, {
kind = 12,
location = {
range = {
["end"] = {
character = 50,
line = 57
},
start = {
character = 7,
line = 57
}
},
uri = "file:///Users/scottming/Code/live_demo/lib/live_demo_web/live/product_live/form_component.ex"
},
name = "LiveDemoWeb.ProductLive.FormComponent.save_product/3"
}, {
kind = 12,
location = {
range = {
["end"] = {
character = 19,
line = 19
},
start = {
character = 6,
line = 19
}
},
uri = "file:///Users/scottming/Code/live_demo/lib/live_demo/catalog.ex"
},
name = "LiveDemo.Catalog.list_products/0"
}, {
kind = 12,
location = {
range = {
["end"] = {
character = 49,
line = 69
},
start = {
character = 6,
line = 69
}
},
uri = "file:///Users/scottming/Code/live_demo/lib/live_demo/catalog.ex"
},
name = "LiveDemo.Catalog.update_product/2"
}, {
kind = 12,
location = {
range = {
["end"] = {
character = 34,
line = 51
},
start = {
character = 6,
line = 51
}
},
uri = "file:///Users/scottming/Code/live_demo/lib/live_demo/catalog.ex"
},
name = "LiveDemo.Catalog.create_product/1"
}, {
kind = 12,
location = {
range = {
["end"] = {
character = 42,
line = 87
},
start = {
character = 6,
line = 87
}
},
uri = "file:///Users/scottming/Code/live_demo/lib/live_demo/catalog.ex"
},
name = "LiveDemo.Catalog.delete_product/1"
}, {
kind = 12,
location = {
range = {
["end"] = {
character = 56,
line = 100
},
start = {
character = 6,
line = 100
}
},
uri = "file:///Users/scottming/Code/live_demo/lib/live_demo/catalog.ex"
},
name = "LiveDemo.Catalog.change_product/2"
}, {
kind = 2,
location = {
range = {
["end"] = {
character = 38,
line = 0
},
start = {
character = 10,
line = 0
}
},
uri = "file:///Users/scottming/Code/live_demo/lib/live_demo_web/live/product_live/show.ex"
},
name = "LiveDemoWeb.ProductLive.Show"
}, {
kind = 2,
location = {
range = {
["end"] = {
character = 39,
line = 0
},
start = {
character = 10,
line = 0
}
},
uri = "file:///Users/scottming/Code/live_demo/lib/live_demo_web/live/product_live/index.ex"
},
name = "LiveDemoWeb.ProductLive.Index"
}, {
kind = 2,
location = {
range = {
["end"] = {
character = 47,
line = 0
},
start = {
character = 10,
line = 0
}
},
uri = "file:///Users/scottming/Code/live_demo/lib/live_demo_web/live/product_live/form_component.ex"
},
name = "LiveDemoWeb.ProductLive.FormComponent"
}, {
kind = 2,
location = {
range = {
["end"] = {
character = 34,
line = 0
},
start = {
character = 10,
line = 0
}
},
uri = "file:///Users/scottming/Code/live_demo/lib/live_demo/catalog/product.ex"
},
name = "LiveDemo.Catalog.Product"
} }
} mix phx.new live_demo
mix phx.gen.live Catalog Product products title:string description:string price:decimal views:integer |
I explained why the ordering is the way it is. I feel like we can go back and forth on this, but ordering is more a property of the fuzzy matcher while this pr is about enabling workspace symbols. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorting issues may require more thought, but can be addressed in the future PR or client-side
Wired up workspace symbols. Things work, but this needs some _love_. The search is kind of slow, and results are not particularly relevant. I also don't use this feature much, so I don't know if we're supposed to find _everything_ or, say, definitions. I'm putting this up here as a draft PR while I open another branch that will work toward improving relevance and performance.
Made somewhat significant changes to the fuzzy matcher to improve performance and relevance of the results. I found that the matcher was returning a ton of results when it was returning references to things, so I pared it down to only consider definitions, which seems to improve the relevance of results a lot. I also only had it return definitions in one of the current project's applications, as searching your dependencies for a definition didn't seem to be a common use case. The fuzzy matcher also now considers the type of the entry being indexed when it builds the subject. This gives us much nicer and more relevant search results, and gives us the ability to tune them more specifically in the future.
* Re-added @ in module attributes * Removed entries with nil app names
efb2e2e
to
bc30452
Compare
Workspace symbols support. Workspace symbols finds all things that match a query in a project.