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

Add fallback syntax highlighter using Pygments autodetection #1966

Closed
spyder-bot opened this issue Feb 17, 2015 · 5 comments
Closed

Add fallback syntax highlighter using Pygments autodetection #1966

spyder-bot opened this issue Feb 17, 2015 · 5 comments

Comments

@spyder-bot
Copy link
Collaborator

From randy.he...@clockworklab.net on 2014-09-13T07:25:15Z

Spyder supports syntax highlighting of some files through Pygments. However, each file type must be manually added to Spyder as seen here: https://bitbucket.org/spyder-ide/spyderlib/src/4954d59d388e09b136b324141d595a4104266a1c/spyderlib/widgets/sourcecode/syntaxhighlighters.py?at=default#cl-837 This means that Spyder does not make use of all of the syntax highlighters provided by Pygments (and there are a lot: http://pygments.org/docs/lexers/ ). Adding support for any additional language requires changes to Spyder's source. This also means that, if I create a Pygments plugin ( http://pygments.org/docs/plugins/ ), there is no way to make Spyder use it without manually editing Spyder's code.

Instead, I would like to request that Spyder have a fallback highlighter. If no other highlighters can be used, maybe Spyder should use Pygments' autodetection functions ( http://pygments.org/docs/api/; I think get_lexer_for_filename would be enough; guess_lexer would probably be too slow). This would add immediate support for all file types supported by Pygments, including lexer plugins.

To be completely useful, I would also suggest an option to disable syntax highlighting. That way, if the autodetection guesses the wrong file type, highlighting can be disabled on that file, and then you're no worse off than the current Spyder, which would not have highlighted the file at all. The ability to select a syntax highlighting scheme would be even better, but not strictly necessary. And finally, a GUI for making a simple lexer plugin through Spyder would round out the features, but that's much farther in the future.

FYI, my current setup:
Spyder Version: 2.3.0
Python Version: 3.4.1
Qt Version : 4.8.5, PyQt4 (API v2) 4.10.4 on Linux
pyflakes >=0.6.0: None (NOK)
pep8 >=0.6 : None (NOK)
IPython >=0.13 : 2.2.0 (OK)
pygments >=1.6 : 1.6 (OK)
sphinx >=0.6.6 : None (NOK)
psutil >=0.3 : None (NOK)
rope >=0.9.2 : None (NOK)
matplotlib >=1.0: None (NOK)
sympy >=0.7.0 : None (NOK)
pylint >=0.25 : None (NOK)

Original issue: http://code.google.com/p/spyderlib/issues/detail?id=1966

@spyder-bot
Copy link
Collaborator Author

From randy.he...@clockworklab.net on 2014-09-13T05:26:16Z

Oops; the Pygments API link should be http://pygments.org/docs/api/

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2014-09-16T12:21:17Z

This is a very well thought proposal and something I'd like to see in a future version.

Do I smell a pull request coming from you? Otherwise, you'll have to wait at least until our 2.5 version because plans for 2.4 are almost settled and well under way :)

Status: HelpNeeded
Labels: Cat-Editor

@spyder-bot
Copy link
Collaborator Author

From randy.he...@clockworklab.net on 2014-09-16T17:37:25Z

I would love to, but it's not going to come quick. A few weeks away, at least. If anyone else wants to tackle it first, I would be grateful :).

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2014-09-17T03:42:50Z

Don't worry, a few weeks is just fine :)

Take a look at our Roadmap to see the release dates for future versions: https://bitbucket.org/spyder-ide/spyderlib/wiki/Roadmap

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2015-01-24T14:06:09Z

This issue was fixed by revision 4dc76574a0d1

Status: Fixed
Labels: MS-v2.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant