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

Highlight decorator name #283

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

verhovsky
Copy link

In this code

@my_decorator
def foo():
  return 1
module [0, 0] - [3, 0]
  decorated_definition [0, 0] - [2, 10]
    decorator [0, 0] - [0, 13]
      identifier [0, 1] - [0, 13]
    definition: function_definition [1, 0] - [2, 10]
      name: identifier [1, 4] - [1, 7]
      parameters: parameters [1, 7] - [1, 9]
      body: block [2, 2] - [2, 10]
        return_statement [2, 2] - [2, 10]
          integer [2, 9] - [2, 10]

with the current rules, only the @ is highlighted as a function in the Zed editor. This change is to make the my_decorator part also get highlighted as a function.

The reason this special case is needed is because decorators can be expressions, you can write something like this

decorators = [dec_a, dec_b, dec_c]

@(decorators[1])
def foo():
  return 1

but the vast majority of the time you're just doing @my_decorator.

@verhovsky
Copy link
Author

I haven't tried this because

  CXX(target) Release/obj.target/tree_sitter_python_binding/bindings/node/binding.o
In file included from ../bindings/node/binding.cc:1:
../node_modules/nan/nan.h:2548:8: error: no matching member function for call to 'SetAccessor'
  tpl->SetAccessor(
  ~~~~~^~~~~~~~~~~

@verhovsky
Copy link
Author

It seems like on GitHub, the current rule makes everything in the expression highlight as a function, but in Zed the opposite, only the @ is highlighted.

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.

1 participant