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

Cannot add custom formatter for any of the languages listed in INCOMPATIBLE_MAGIC_LANGUAGES #298

Open
3 tasks done
flaviomartins opened this issue Mar 27, 2023 · 6 comments

Comments

@flaviomartins
Copy link

flaviomartins commented Mar 27, 2023

Checklist prior to opening an issue

  • I have followed fully the installation steps laid out in the documentation site.
  • I have restarted jupyterlab.
  • I have read the FAQ section in the documentation site.

Describe the bug
Cannot add custom formatter for any of the languages listed in INCOMPATIBLE_MAGIC_LANGUAGES

Additional context
I was trying to implement a custom formatter using sqlfluff for %sql cells but it looks like some languages are disallowed in this project.

I am thinking, maybe turning INCOMPATIBLE_MAGIC_LANGUAGES blacklist into COMPATIBLE_MAGIC_LANGUAGES whitelist and make the mechanism for whitelisting additional magic_languages just having a default formatter configured for it in the preferences?

Expected behaviour
If a default_formatter is configured for "sql" in the user preferences then the corresponding formatter would be called regardless

@ryantam626
Copy link
Owner

FWIW I am in middle to a big refactor for the project (mostly due to the evolution of jupyterlab's plugin tooling), I can look into how to integrate sqlfluff nicely here after that.

Without the the refactor, the development envrionment for this plugin is just nightmare-ish to use, so that is currently trumping all tasks.

@ryantam626
Copy link
Owner

Hello 👋 I am back with some updates.

I have completed my refactor and have some time to work on this project.

I assume you are working on sqlfluff base on this link on adding custom formatter?

A stop gap solution would be copy and paste handle_line_ending_and_magic logic and any assoicated variables needed in your custom formatter, and don't ignore the sql related magics.

I am just a bit hesitant about turning blacklist into whitelist, as I don't fully comprehend how that helps/fits in in the grand scheme of things.

With that said, I would love to add sqlfluff support, would you mind sharing what you have got if you actually implemented it 🙏

@flaviomartins
Copy link
Author

Hi Ryan, I haven't hacked anything yet. I decided to go forward without this for this year's edition (of the db course).

PS: I used jupyter-lsp and sql-language-server instead but I think having the Format button would be much better to reduce variability in students code :-)

@ryantam626
Copy link
Owner

ryantam626 commented Jul 8, 2023

Hi @flaviomartins - could you perhaps attach a notebook from your course here please?

Such that I can confirm it works for your usecase from the get go :)

@flaviomartins
Copy link
Author

Hi @ryantam626, ok, I think this notebook could be our MWE

Lab02.ipynb.zip

@ryantam626
Copy link
Owner

sweet! thanks, i will see what i can do, but my bandwidth is more limited these days so i will be a bit slow.

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

No branches or pull requests

2 participants