-
Notifications
You must be signed in to change notification settings - Fork 244
Description
Did you check existing requests?
- I have searched the existing issues
Describe the feature
For injected
formatter, add a lua match pattern variable to match and filter out some input_lines
, as they break formatter.
Quick and dirty proof of concept:
kanghengliu@30568d6
This commit hard codes the matching patterns. Also it does not paste back the matched lines after formatting.
update: added a filter for python only and allow matching for multiple lines.
kanghengliu@ca99f29
Provide background
When editing a markdown file, ipython magic commands and shell commands will prevent python formatters from functioning.
Example1:
%%time
print("hello")
Example2:
!pip install randomstuff
Black will break, since this is not a valid python chunk, however, modern linters will highlight the chunk just fine.
Both chunks are valid in jupyter notebook with IPython.
What is the significance of this feature?
strongly desired
Additional details
I've attempted to instruct the formatters to ignore certain patterns, however it is reasonably out of scope for code formatters to handle "broken" formats. Many formatters that i've found will not support this, and it makes sense for them to do so.
For additional use cases, see my issue at molten.nvim where I attempt to lint and format a chunk with cell magic.