Closed piechologist closed 4 months ago
I don't think we should include @function.definition
here. As you probably noticed, it's quite hard to check for definitions consistently, and multiple dispatch means you cannot easily jump to the definition of a function from the call (you'd need type information). This feature would be better handled by the language server.
Good to seeing you here, @savq! I noticed your #133 and it would be nice to have the queries in Zed resemble those in Neovim etc. as closely as possible.
I don't think we should include
@function.definition
here.
I'm open to remove the @function.definition
additions in highlights.scm
(I guess you mean the captures for highlighting). My reasoning was to use a different color/style for the LHS of short function definitions to make them stand out. But yes, it's a lot of code for a small benefit.
As for outline.scm
, I attempt to catch all possible function and macro definitions. Zed's outline modal has a great fuzzy search that makes it easy to find what you're looking for. The outline is for the active buffer only and you can jump to the definition within this buffer. The query to match short function definitions caused me some headache - as you assumed! I tried to match each of the following cases:
foo1(x) = 2x
Base.foo1(x) = 2x
foo2(x)::Int = 2x
Base.foo2(x)::Int = 2x
foo3(x::T)::Int where {T<:Int} = 2x
Base.foo3(x::T)::Int where {T<:Int} = 2x
foo4(x::T) where {T<:Int} = 2x
Base.foo4(x::T) where {T<:Int} = 2x
My query works but is super ugly. Splitting the long lines makes it even more confusing, imho. I'd appreciate if you (or anybody else) could point me to a more elegant solution. The complexity comes from the optional, nested nodes.
As you probably noticed, it's quite hard to check for definitions consistently, and multiple dispatch means you cannot easily jump to the definition of a function from the call (you'd need type information). This feature would be better handled by the language server.
I agree, my PR deals only with highlighting and feeding the outline modal.
My reasoning was to use a different color/style for the LHS of short function definitions to make them stand out. But yes, it's a lot of code for a small benefit.
Yeah, that makes sense. I try to distinguish function signatures by highlighting =
with the same highlight as function
, but I don't know if @keyword.function
is usable in zed. It looks like this:
Anyways, the highlights can be simplified a bit.
signature
doesn't need to be inside another pattern, so you can write a pattern similar to the one for short functions:
(signature
[
(call_expression ...)
(typed_expression ...)
])
instead of
(function_definition
(signature
(call_expression ...)))
(function_definition
(signature
(typed_expression ...)))
(macro_definition
(signature
(call_expression ...)))
That's kind of the reason signature
exists 😅
I try to distinguish function signatures by highlighting
=
with the same highlight asfunction
, but I don't know if@keyword.function
is usable in zed.
I like that idea! In Zed, @keyword.function
gives the same color as @keyword
. I added two commits and now the source file and the outline modal look like that:
You see the default One Dark theme plus @function.definition
with font_style italic added to my settings.json.
I think it looks good enough for an update. Changed version to 0.1.1.
Shall we also add tab_size = 4
from issue #2 ? That's what the Julia documentation suggests.
Otherwise, feel free to merge, @Pangoraw…
I've been using the commits for a week now and haven't run into issues.
I'd hit the merge button if there are no objections.
Closes #2
I think tab size = 4 is great. Thank you @piechologist! Feel free to merge
Thank you @Pangoraw for getting this repo off the ground!
There was a minor upgrade to the grammar and I have changed the commit in
extension.toml
accordingly.The rest of this PR deals with the scheme and toml files in
language/julia/
. The commit messages should be comprehensive. I tested the changes locally. Let me know if I should make further changes.I'm wondering if we should keep the following lines but I haven't touched them as they seem to do no harm:
collapsed_placeholder = "# ..."
copied over from another language?#offset!
is only used by nvim. Zed seems to ignore that.