-
Notifications
You must be signed in to change notification settings - Fork 616
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
Adding support for Python code cells #2978
Comments
Is there definition of cell? Another question is "cell" is python specific? or language neutral? |
There are several ways, e.g. vim-ipython-cell defines them as Spyder IDE supports They are used in other languages too, e.g. Matlab uses Julia I guess uses |
Not to clog up the works here, but after being confused about the Python specific nomenclature here, it finally dawned an me that this is a pretty old concept rebranded for a new language. I think this is completely orthogonal to the language being used, with the caveat that they are usually buried behind the language's native comment syntax. Some editors have first class support for this that is editor specific. VIM for example has manual folds, triggered with Additionally many languages have ad-hoc usages that are common to see but not standardized. For example in HTML you might bind I suggest this needs to be some kind of flag that can be enabled for any language based on it's comment syntax, possible with a flag being used to specify the syntax. The |
This is for python.
Yes. What I would like know is the name of the concept. |
@masatake awesome! 😎 Yeah, as @alerque notes it is rather Editor specific. But, there is some language specific convergence that we can use. For example, for Python a perfectly legit regex can be As for the name +1 for code cells 🙂 |
If we have to think only about Python, the PythonCell parser I showed in the comment may be enough for fixing your issue partially. I can include the PythonCell parser to u-ctags as a built-in parser after adding more patterns for the cells. I don't know well about vim. However, I guess my parser fixes your issue partially.
See the I guess your tool doesn't know If you give more options when running u-ctags, you can give vim hints for distinguishing the kinds:
I wonder vim can utilize the output enough for your purpose. As @alerque wrote, I think this issue is solved in language-neutral way. |
See #2980, too. |
Great - thanks! 👍 I hope this solves it on the VIM side. Could I suggest the following regex update for cells: --regex-PythonCell=/^[ \t]*# %[%]+[ \t]*(.*[^ \t])/\1/c/ This allows for tabs/spaces before the cell tag, and multiple |
Close universal-ctags#2978 Signed-off-by: Masatake YAMATO <yamato@redhat.com>
I'm not good at English. Could you review 7935a2c#diff-64a31aeda11dbbe0458851a2db50a7cc14894fe93fec938ce753e2144f2df80a ? |
Great stuff - thanks! 🙇 |
Close universal-ctags#2978 Signed-off-by: Masatake YAMATO <yamato@redhat.com>
@gerazov, thank you very much for reviewing. |
Close universal-ctags#2978 Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Thank you for your fast response 🤟 |
Close universal-ctags#2978 Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Cells are useful for structuring code and navigating through them in Vim using Tagbar would be very useful. Tagbar and other outline plugins depend on
ctags
to get the tags they show. I was wandering if there is a way to enable cell tagging atm, and if not is it planned for a future release?I originally posted this issue on Tagbar here it is for reference preservim/tagbar#759
Cells can be defined in several ways, e.g.
# %%
:Atm this code only shows variables in the tagbar.
The text was updated successfully, but these errors were encountered: