-
Notifications
You must be signed in to change notification settings - Fork 43
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
[Help] How to use cell magic like "%%time", "!ls" without pyright complaining? #291
Comments
You just won't be able to use pyright like this. It can't interpret ipython magics. You could try to suppress specific warnings in specific cases. For example, I add this filter to suppress unused variable warnings when the variable starts with But I think you will still run into issues with unexpected expression warnings, or pyright failing to parse beyond the cell magic syntax error. The indentation is very likely handled by treesitter, and it's just doing it's best to recover from invalid syntax. If you wanted to fix this, you could either:
|
@benlubas Thank you for the timely reply! I tried messing around with possible solutions, also in addition explored code formatting options with conform.nvim: Linting
Formatting
|
nbQA is a really interesting project, thanks for sharing it! It does seem focused on linting and formatting though, and it doesn't have support for pyright. assuming that it can output to JSON or some other machine readable format, you could use it with a linter of your choice + nvim-lint I don't see why nbQA would be restricted to python tooling. I'd imagine it could be easily adapted to other tools if it's not already. As far as getting pyright to behave: Another approach that you could take is modifying otter.nvim. It's the plugin that sends code cell info to the LSP and syncs diagnostics and all that. Otter already has some mechanism for leaving out parts of syntax injected regions. You might be able to add a some type of filter for cell magics. this way otter will "hide" the cell magic from the language server/formatter/linter. |
Modifying otter.nvim is actually a better idea. Thanks! I noticed this PR that recently got merged. It adds a preamble for cargo to each of the otter buffer, so linting could work. I wonder if the reverse (removing cell magic in our use case) could be done. I've added an issue to otter repo that describes this method. |
Created a PR in otter.nvim to allow it to not sending matched patterns to LSP. This addresses the linting issue. However, formatting cells with cell magic will still need investigation with conform.nvim. |
With the otter.nvim PR previously merged this thread is closed. For formatting please look at my feature request above at conform.nvim |
First of all big thank you for this wonderful plugin. I'm trying to use cell magic like so:
They would execute perfectly fine via ipython, but pyright complains about the syntax. Is there a way to suppress the error message?
On a side note that may be related, I'm not sure which plugin is causing this auto indent behavior after writing a cell magic:
Screen.Recording.mov
The text was updated successfully, but these errors were encountered: