setuptools entry points only way to register lexers?

Issue #1392 new
Tony Narlock
created an issue

There's no other official way to add lexers? This one is throwing me off a bit, why wouldn't someone be able to register a custom lexer easily in a pinch? There has to be a way.

I'm probably missing something obvious. Because there has to be an easier way than using setuptool's entry_points.

Other projects are resorting to vendorizing and copying in modules to /lexers manually by duplicating modules because it's cumbersome.

Comments (1)

  1. Justin Michalicek

    I came here to comment on/ask about the same thing regarding styles. I need a custom style for my Django project - the standard there is to just have a project on github, not an installable deal with a I need a custom style which would only ever be used on this project - making a separate python package so that I can use a setuptools entrypoint is overkill. I just need to be able to define the style in a class which is part of the Django project somewhere.

    A way to specify other packages or classes to look at in a config file, on the command line to pygmentize, etc. would be great.

    If this is something the project maintainer(s) would be interested in, I'd be happy to play around and see if I can get something reasonable working... with the caveat that it's the holidays and I have 2 children, one of which is 4 months old, so free time to work on these things is unpredictable.

    It seems like a toml config which get_all_FOO() and get_FOO_by_name() functions can use to load other lexers, styles, etc. would make sense. Perhaps in ~/.pygments.conf and something local to the project. I'd need to look at implementation, but similar to isort, yapf, editorconfig, etc.

  2. Log in to comment