{"id":27298610,"url":"https://github.com/swissiety/lsplexer4pygments","last_synced_at":"2025-08-15T20:36:53.579Z","repository":{"id":45077519,"uuid":"444251151","full_name":"swissiety/LspLexer4Pygments","owner":"swissiety","description":"enable Pygments to leverage a LSP server - more precisely LSPs SemanticToken Request feature - for syntax highlighting","archived":false,"fork":false,"pushed_at":"2023-12-14T14:04:21.000Z","size":5069,"stargazers_count":5,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-19T07:40:57.553Z","etag":null,"topics":["lsp","lsp-client","mkdocs","pygments","pygments-lexer","syntax-highlighting"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/swissiety.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-01-04T01:39:52.000Z","updated_at":"2025-02-13T20:03:16.000Z","dependencies_parsed_at":"2025-04-12T00:37:19.259Z","dependency_job_id":"c962fed1-15c5-4c89-925a-719d65c908f7","html_url":"https://github.com/swissiety/LspLexer4Pygments","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/swissiety/LspLexer4Pygments","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swissiety%2FLspLexer4Pygments","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swissiety%2FLspLexer4Pygments/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swissiety%2FLspLexer4Pygments/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swissiety%2FLspLexer4Pygments/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swissiety","download_url":"https://codeload.github.com/swissiety/LspLexer4Pygments/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swissiety%2FLspLexer4Pygments/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263066557,"owners_count":23408387,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lsp","lsp-client","mkdocs","pygments","pygments-lexer","syntax-highlighting"],"created_at":"2025-04-12T00:37:13.816Z","updated_at":"2025-07-02T03:02:16.118Z","avatar_url":"https://github.com/swissiety.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LspLexer4Pygments\nconnects [Pygments](https://github.com/pygments/pygments) with a [Language Server Protocol](https://microsoft.github.io/language-server-protocol/) (LSP) server for syntax highlighting purposes.\n\nThis tool uses the *semantic tokens* feature of LSP (LSP 3.16) and maps the retrieved information to Pygments tokens, which are then used by Pygments to highlight your input accordingly.\n\nPygments can colorize input for cli, HTML, LaTeX, ... so you can use Pygments and LspLexer4Pygments for syntax highlighting of a custom LspServer implementation to enhance your web based documentation e.g. via [MkDocs](https://github.com/mkdocs/mkdocs), your thesis, a scientific paper, etc.\n\n## Requirements\n- the used language server can communicate via STDIO and needs to support the semantic tokens capability\n- Python 3.2\n\n## Installation\n(assumption: you already have python and pip installed)\n```Shell\npip install git+https://github.com/swissiety/LspLexer4Pygments.git\n```\n\n## Configuration options\n\nmandatory: *(hint: path expansion is disabled! So no environment vars etc.)*\n\u003e lspcommand=\"path/to/a/lsp_server/executable_or_command\"\n\noptional:\n\u003e filetype=\"file_extension\" (default: txt) \n\n\n\n## Usage Examples\n### LaTeX document (config: for **JimpleLSP**)\nCommand to translate Jimple code from file **code/jimple_listing1.jimple** to a file **pyg_export/jimple_listing1.pyg**\n```Shell\n python3 -m pygments -x -P filetype=jimple \\\n \t-P lspcommand=\"java -jar /path/to/content_root/of/LspLexer4Pygments/examples/jimplelsp-0.0.11.jar\" \\\n\t-l lspserver -o pyg_export/jimple_listing1.pyg code/jimple_listing1.jimple\n```\n\nExample LaTeX document (subdirectory for the translated results are in **pyg_export/**)\n```latex\n\n\\documentclass{article}\n\\usepackage[utf8x]{inputenc}\n\\usepackage{texments}\n\\usestyle{default} \t\t% Mandatory! other useful styles are: bw, borland, vs\n\n\\begin{document}\n\n\t\\input{pyg_export/jimple_listing1.pyg}\n\n\\end{document}\n\n```\n\n\n### Web based documentation (via MkDocs)\nget your LSP server binary. e.g. download the latest *jimplelsp.jar* release on github to support highlighting for [Soot](https://github.com/soot-oss/soot)s Jimple\n```Shell\ncurl -s -L -o ./jimplelsp.jar \\\n\t$(curl -s https://api.github.com/repos/swissiety/jimpleLsp/releases/latest | \\\n\t\tgrep 'browser_download_url\".*jar\"' | cut -d ':' -f 2,3 | tr -d \\\")\n```\n\nset config for Pygments in your mkdocs.yml (adapt \"name: jimple\" **(1)**, \"filetype: jimple\" and the lspcommand accordingly; \"lang:\" must be lspserver or lsplexer)\n```Dockerfile\nmarkdown_extensions:\n  - pymdownx.highlight:\n      linenums: true            # not necessary but nice\n      use_pygments: true\n      extend_pygments_lang:\n        - name: jimple          # name for your language config\n          lang: lspserver\n          options:\n            filetype: jimple    # adapt here if necessary\n            lspcommand: \"java -jar /workspace/LspLexer4Pygments/examples/jimplelsp-0.0.11.jar\"  #adapt here \n  - pymdownx.superfences\n```\n\nspecify your specified language name from **(1)** directly after the ticks of the surrounding code block\n```\n   ```jimple\n      /* this is not the .jimple file content you're looking for ;-) */\n      ...\n    ```\n```\n\n\n### Command line interface / cli\ngeneric (replace the placeholders) use installed LspLexer4Pygments\n```Shell\npython3 -m pygments -x \\\n\t-P filetype=%FILETYPE% -P lspcommand=\"%LSPSERVERBINARY%\" \\\n\t-l lspserver %INPUTFILE%\n```\n\ngeneric (replace the placeholders) executed from content-root\n```Shell\npython3 -m pygments -x \\\n\t-P filetype=%FILETYPE%-P lspcommand=%LSPSERVERBINARY% \\\n\t-l lsplexer/lexer.py:LspLexer %INPUTFILE%\n```\n\ncli save to export.html executed from content-root\n```Shell\npython3 -m pygments -x -f html -O full \\\n\t-P filetype=%FILETYPE% -P lspcommand=%LSPSERVERBINARY% \\\n\t-l lsplexer/lexer.py:LspLexer -o export.html %INPUTFILE%\n```\n\nuse the provided example as input (executing the given **.jar** via java) executed from content-root\n```Shell\npython3 -m pygments -x \\\n\t-P filetype=jimple \\\n\t-P lspcommand=\"java -jar examples/jimplelsp-0.0.11.jar\" \\\n\t-l lsplexer/lexer.py:LspLexer examples/hello_world.jimple\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswissiety%2Flsplexer4pygments","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswissiety%2Flsplexer4pygments","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswissiety%2Flsplexer4pygments/lists"}