Skip to content

Commit

Permalink
make r2ai-plugin work r2pm
Browse files Browse the repository at this point in the history
  • Loading branch information
dnakov committed Nov 8, 2024
1 parent 59f891f commit cadf630
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
1 change: 0 additions & 1 deletion main.py

This file was deleted.

1 change: 1 addition & 0 deletions r2ai/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def run_rcfile_once(ai):
def main(args, commands, dorepl=True):

os.environ["TOKENIZERS_PARALLELISM"] = "false"
os.environ["TRANSFORMERS_NO_ADVISORY_WARNINGS"] = "1"

try:
r2aihome = os.path.dirname(os.path.realpath(__file__))
Expand Down
17 changes: 16 additions & 1 deletion r2ai/plugin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
"""Entrypoint for the r2ai plugin and repl."""

import sys
import os
import builtins
import traceback

current_dir = os.path.dirname(os.path.realpath(__file__))
parent_dir = os.path.dirname(current_dir)
sys.path.insert(0, parent_dir)
os.environ["TRANSFORMERS_NO_ADVISORY_WARNINGS"] = "1"
try:
venv_dir = os.path.join(parent_dir, 'venv')
if os.path.exists(venv_dir):
site_packages = os.path.join(venv_dir, 'lib', 'python{}.{}'.format(*sys.version_info[:2]), 'site-packages')
if os.path.exists(site_packages):
sys.path.insert(0, site_packages)
except Exception:
pass

import r2lang
from r2ai.main import r2ai_singleton, run_rcfile_once, runline, help_message

Expand Down
17 changes: 10 additions & 7 deletions r2ai/tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,13 @@ def tab_init():
pass
except Exception:
pass
readline.set_completer(completer.complete)
readline.set_completer_delims('\t\n;')
readline.set_completion_display_matches_hook(completer.display_matches)
if readline.__doc__.find("GNU") != -1:
readline.parse_and_bind('tab: complete')
else:
readline.parse_and_bind("bind ^I rl_complete")
try:
readline.set_completer(completer.complete)
readline.set_completer_delims('\t\n;')
readline.set_completion_display_matches_hook(completer.display_matches)
if readline.__doc__.find("GNU") != -1:
readline.parse_and_bind('tab: complete')
else:
readline.parse_and_bind("bind ^I rl_complete")
except Exception as e:
pass

0 comments on commit cadf630

Please sign in to comment.