Pygments style based on the Nightfox nvim theme.
pygments_nightfox_style | ||
.gitignore | ||
LICENSE | ||
pyproject.toml | ||
README.rst |
# pygments_nightfox_style Pygments Nightfox Style ======================= A style for Pygments (and IPython) based on Nightfox palette by EdenEast. `Original repository for Nightfox palette <https://github.com/EdenEast/nightfox.nvim>`_ This style has IPython specific configuration, when using this code in your IPython configuration: .. code:: python from IPython.terminal.prompts import Prompts, RichPromptDisplayHook from pygments.token import Token from prompt_toolkit.enums import EditingMode from platform import python_version import os import socket import subprocess class NightfoxPrompts(Prompts): def vi_mode(self): if (getattr(self.shell.pt_app, 'editing_mode', None) == EditingMode.VI and self.shell.prompt_includes_vi_mode): mode = str(self.shell.pt_app.app.vi_state.input_mode) if "INSERT" in mode: return 'I' if "NAV" in mode: return 'N' if "REPLACE_SINGLE" in mode: return 'r' if "REPLACE" in mode: return 'R' return 'E' # Emacs mode def in_prompt_tokens(self): git_branch = "" try: git_branch = subprocess.check_output( ["git", "branch", "--show-current"], stderr=subprocess.DEVNULL ) if git_branch: git_branch = git_branch.decode("utf-8").replace("\n", "") except subprocess.CalledProcessError: pass git_branch = str(git_branch) venv = (os.environ.get("VIRTUAL_ENV") or "").split("/")[-1] return [ (Token.IPython.Prompt.Login, os.getlogin()), (Token.IPython.Prompt.Login.Sep, ''), (Token.IPython.Prompt.Host, socket.gethostname()), (Token.IPython.Prompt.Host.Sep, ''), (Token.IPython.Prompt.Venv, venv), (Token.IPython.Prompt.Venv.Sep, ''), (Token.IPython.Prompt.Version, ' ' + python_version()), (Token.IPython.Prompt.Version.Sep, ''), (Token, '\n'), (Token.IPython.Prompt.Cwd, os.getcwd()), (Token.IPython.Prompt.Cwd.Sep, ''), (Token.IPython.Prompt.Vcs, str(' ') + git_branch if git_branch else ''), (Token.IPython.Prompt.Vcs.Sep, ''), (Token, '\n'), (Token.IPython.Prompt.Mode, self.vi_mode()), (Token.IPython.Prompt.Mode.Sep, ' '), ] def out_prompt_tokens(self): return []