Skip to content

Instantly share code, notes, and snippets.

@blackrobot
Created September 17, 2020 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blackrobot/9aea60eaf8703f3d50f9f83ac0892561 to your computer and use it in GitHub Desktop.
Save blackrobot/9aea60eaf8703f3d50f9f83ac0892561 to your computer and use it in GitHub Desktop.
'''
put this in $PROJECT/.tmp/home/.config/ptpython/config.py
'''
from __future__ import unicode_literals
from prompt_toolkit.keys import Keys
from ptpython.layout import CompletionVisualisation
__all__ = ["configure"]
def configure(repl):
"""
Configuration method. This is called during the start-up of ptpython.
:param repl: `PythonRepl` instance.
"""
# Show function signature (bool).
repl.show_signature = False
# Show docstring (bool).
repl.show_docstring = True
# Show the "[Meta+Enter] Execute" message when pressing [Enter] only
# inserts a newline instead of executing the code.
repl.show_meta_enter_message = False
# Show completions. (NONE, POP_UP, MULTI_COLUMN or TOOLBAR)
repl.completion_visualisation = CompletionVisualisation.MULTI_COLUMN
# When CompletionVisualisation.POP_UP has been chosen, use this
# scroll_offset in the completion menu.
repl.completion_menu_scroll_offset = 0
# Show line numbers (when the input contains multiple lines.)
repl.show_line_numbers = True
# Show status bar.
repl.show_status_bar = True
# When the sidebar is visible, also show the help text.
repl.show_sidebar_help = True
# Highlight matching parethesis.
repl.highlight_matching_parenthesis = True
# Line wrapping. (Instead of horizontal scrolling.)
repl.wrap_lines = True
# Mouse support.
repl.enable_mouse_support = False
# Vi mode.
repl.vi_mode = True
# Paste mode. (When True, don't insert whitespace after new line.)
repl.paste_mode = False
# Use the classic prompt. (Display '>>>' instead of 'In [1]'.)
repl.prompt_style = "classic" # 'classic' or 'ipython'
# Don't insert a blank line after the output.
repl.insert_blank_line_after_output = False
# History Search.
# When True, going back in history will filter the history on the records
# starting with the current input. (Like readline.)
# Note: When enable, please disable the `complete_while_typing` option.
# otherwise, when there is a completion available, the arrows will
# browse through the available completions instead of the history.
repl.enable_history_search = False
# Complete while typing. (Don't require tab before the
# completion menu is shown.)
repl.complete_while_typing = not repl.enable_history_search
# Fuzzy and dictionary completion
repl.enable_fuzzy_completion = True
repl.enable_dictionary_completion = True
# Enable auto suggestions. (Pressing right arrow will complete the input,
# based on the history.)
repl.enable_auto_suggest = True
# Enable open-in-editor. Pressing C-X C-E in emacs mode or 'v' in
# Vi navigation mode will open the input in the current editor.
repl.enable_open_in_editor = False
# Enable system prompt. Pressing meta-! will display the system prompt.
# Also enables Control-Z suspend.
repl.enable_system_bindings = True
# Ask for confirmation on exit.
repl.confirm_exit = False
# Enable input validation. (Don't try to execute when the input contains
# syntax errors.)
repl.enable_input_validation = True
# Use this colorscheme for the code.
# repl.use_code_colorscheme("paraiso-dark")
repl.use_code_colorscheme("native")
# Enable 24bit True color. (Not all terminals support this. -- maybe check
# $TERM before changing.)
repl.color_depth = "DEPTH_8_BIT"
repl.enable_syntax_highlighting = True
@repl.add_key_binding(Keys.ControlSpace) # "c-space" | "c-@"
def trigger_autosuggest(event):
buff = event.current_buffer
# buff = event.cli.current_buffer
if buff.complete_state:
buff.complete_next()
else:
buff.start_completion(select_first=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment