-
Notifications
You must be signed in to change notification settings - Fork 6
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
Change highlighting of documentation snippets #25
Comments
Hey! Glad you like it! Just look at the lines where |
Thank you for the quick response! It worked but now it highlights |
Nevermind, I managed to do it. Sorry for the buzz and thanks again! |
No worries! So the solution seems to be a bit more involved then. In the Elixir syntax file add a meta scope like so: # Special attributes:
- match: (?>(?>module|type|short)?doc){{no_suffix_then_arguments}}
scope: support.attr.doc.elixir
set:
- match: \(
scope: punctuation.section.arguments.begin.elixir
set:
- meta_scope: meta.doc.elixir
- include: arguments_closing_pop
- match: ''
push:
- include: if_closing_token_pop
- include: arg_comma_and_skip_ws
# - include: markdown_comment
- include: core_syntax
- match: \s?
scope: punctuation.section.arguments.begin.elixir
set:
- meta_scope: meta.doc.elixir
- include: arguments_ws_closing_pop
- include: arg_comma_and_skip_ws
# - include: markdown_comment
- include: core_syntax And then in your themes file, like Monokai.sublime-color-scheme, change the doc string scope to "meta.doc.elixir string". {
"name": "Doc string",
"scope": "meta.doc.elixir string",
"foreground": "var(yellow5)"
} I'm going to leave this open because we should add the |
Hi! Sorry for reaching out again but how could I also customize |
Hey, happy to help! How would you like to customize the spec attribute specifically? Didn't have a plan for that yet but I could add it as a use case. |
Okay, so to make the string delimiters of the doc strings grey is the easiest part. You probably only need to set a style for In any case, it's interesting because I think I wanted to do something similar. I also wanted specs to not stick out as much. The best I could do is desaturate the color of the spec name and the type identifiers. Even ST4 doesn't give you a lot of possibilities to solve something like this I think. Anyway, hope you'll make do somehow. :) |
Maybe spec should have a meta scope, will it allow better customization? I'm not very familiar with color scheme customization, just throwing ideas around. |
Yep, I was gonna add such a scope. It will be there in the next release. But it turns out that even adding a meta scope like that isn't simple because it unfortunately doesn't cover everything and you have to add it in several more context rules. :/ Still, even with the meta scope you'll have to target every token in order to style it as a comment. |
I'm satisfied with the way |
I don't know if it belongs here but another enhancement for the ```@doc """`-String would be to fold in the whole doc-string (or maybe any """-pair) As seen in https://github.com/wojtekmach/req/blob/main/lib/req/steps.ex sometimes the doc-string gets very long and an easy way to hide it would be beneficial. @doc """
Adds default steps.
## Request steps
* `encode_headers/1`
* `put_default_headers/1`
* `encode_body/1`
* [`&put_base_url(&1, options[:base_url])`](`base_url/2`) (if `options[:base_url]` is set)
* [`&load_netrc(&1, options[:netrc])`](`load_netrc/2`) (if `options[:netrc]` is set
to an atom true for default path or a string for custom path)
* [`&auth(&1, options[:auth])`](`auth/2`) (if `options[:auth]` is set)
* [`&put_params(&1, options[:params])`](`put_params/2`) (if `options[:params]` is set)
* [`&put_range(&1, options[:range])`](`put_range/2`) (if `options[:range]` is set)
* [`&run_steps(&1, options[:steps])`](`run_steps/2`) (if `options[:steps]` is set)
## Response steps
* [`&retry(&1, options[:retry])`](`retry/2`) (if `options[:retry]` is set to
an atom true or a options keywords list)
* [`&follow_redirects(&1, options[:follow_redirects])`](`follow_redirects/2`)
* `decompress/1`
* `decode_body/1`
## Error steps
* [`&retry(&1, options[:retry])`](`retry/2`) (if `options[:retry]` is set and is a
keywords list or an atom `true`)
## Options
* `:base_url` - if set, adds the `put_base_url/2` step
* `:netrc` - if set, adds the `load_netrc/2` step
* `:auth` - if set, adds the `auth/2` step
* `:params` - if set, adds the `put_params/2` step
* `:range` - if set, adds the `put_range/2` step
* `:cache` - if set to `true`, adds `put_if_modified_since/2` step
* `:raw` if set to `true`, skips `decompress/1` and `decode_body/1` steps
* `:retry` - if set, adds the `retry/2` step to response and error steps
* `:steps` - if set, runs the `run_steps/2` step with the given steps
* `:follow_redirects` - if set, runs the `follow_redirect/2` step with the given list
of options
"""
@doc step: :request
def put_default_steps(request, options \\ []) do
request_steps =
[
{Req.Steps, :encode_headers, []},
{Req.Steps, :put_default_headers, []},
{Req.Steps, :encode_body, []}
] ++
maybe_steps(options[:base_url], [{Req.Steps, :put_base_url, [options[:base_url]]}]) ++
maybe_steps(options[:netrc], [{Req.Steps, :load_netrc, [options[:netrc]]}]) ++
maybe_steps(options[:auth], [{Req.Steps, :auth, [options[:auth]]}]) ++
maybe_steps(options[:params], [{Req.Steps, :put_params, [options[:params]]}]) ++
maybe_steps(options[:range], [{Req.Steps, :put_range, [options[:range]]}]) ++
maybe_steps(options[:cache], [{Req.Steps, :put_if_modified_since, []}]) ++
maybe_steps(options[:steps], [{Req.Steps, :run_steps, [options[:steps]]}])
retry = options[:retry]
retry = if retry == true, do: [], else: retry
raw? = options[:raw] == true
response_steps =
maybe_steps(retry, [{Req.Steps, :retry, [retry]}]) ++
[{Req.Steps, :follow_redirects, [options[:follow_redirects]]}] ++
maybe_steps(not raw?, [
{Req.Steps, :decompress, []},
{Req.Steps, :decode_body, []}
])
error_steps = maybe_steps(retry, [{Req.Steps, :retry, [retry]}])
request
|> Req.Request.append_request_steps(request_steps)
|> Req.Request.append_response_steps(response_steps)
|> Req.Request.append_error_steps(error_steps)
end |
@danilokleber can you share all of your modifications? |
@sergchernata sorry for the delay. I'm actually moving away from Sublime Text. Anyway I tried to find the patched syntax file, but could not find it. I guess the package got updated with the changes mentioned in this issue? I can't remember. Sorry I can't help. |
It's been a while 😄 I got back to Sublime Text and was happy to see that this project had made to the official Elixir editors repo. That is much deserved. Congrats and thank you! As this is still open I guess we still don't have a way to customize the look of |
Hi, welcome back and thanks! 😄 I haven't looked further into this and tbh forgot about it with time. Just gave it another go and it seems possible to add a spec_definition_pop:
- meta_scope: meta.spec.elixir
- match: (?=\()
set: [spec_metascope_pop, type_definition_next_pop, type_arguments_or_pop]
- include: type_definition_next_pop
spec_metascope_pop:
- meta_scope: meta.spec.elixir
- include: if_empty_pop The trouble is then to style all possible tokens under this meta scope. I tried the following: {
"name": "Specs",
// "scope": "meta.spec.elixir & (storage.type.custom.elixir | constant.other.keyword.elixir)",
"scope": "meta.spec.elixir storage.type.custom.elixir",
"foreground": "color(var(doc))"
} The first commented out scope selector should work, but in this instance it doesn't. Don't understand why because it works in other style rules. Go figure... |
Hey there! Firstly thanks a lot for this syntax. I am so glad I can rely on "Go to symbol/definition" after installing it!
The issue is not actually an issue. I just want to tweak my color scheme so that documentation snippets (
@doc
for example) do not highlight as Markdown or Elixir code itself. I like when they show as regular comments. Do you know which scope should I use to achieve that?The text was updated successfully, but these errors were encountered: