Closed Moosieus closed 3 months ago
I really agree with the thinking here, I'm often miffed that the function/variable right next to what I'm doing is sorted beneath the function. I do think scopes need to be defined somewhere concrete, rather than as atoms. For example, Make a Builder.SortScope
module that includes the functions local_variable()
, local_declaration()
, remote_declaration()
, etc.
A side note, is it easy, from the builder to see what's local and remote? I don't think this is the case.
I'd set sort-scopes in the same locations boosts are done now, that's where the necessary context is accessible atm.
I sorta consider it an abstraction leak, but I think it's a surmountable one.
Here's a brief completion sorting proposal I've made up:
"00"
: local variables"01"
: local declarations (declared within the immediate module oruse
)"10"
: remote declarations (from existing invocations ofalias
,require
, andimport
)"11"
: global declarations (def, do/end, if/do/else/end, SpecialForms, etc)"20"
: auto declarations (short for auto-import added by the LSP)variables = variables. Made relatively easy by Elixir's scoping rules. declarations = functions, attributes, atoms(?), and all classes of macros (macros, guards, structs, protocols, etc).
This is mainly inspired by the way TypeScript (tsserver) handles its completion suggestions, which are taxonomized and sorted as:
(source)
I like what TS does here b/c:
I think the approach works well for Elixir and Lexical b/c:
Some personal notes:
The API might look something like:
where
sort_scope
is one of: