| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
python3 -m venv /path/to/your/virtualenv # or your preferred way to create a virtualenv/path/to/your/virtualenv/bin/pip install -r \
https://github.com/millerdev/PyXT/raw/master/requirements.txtType Ctrl+Shift+P and select PyXT: Command to open the PyXT command bar.
Most commands may also be invoked directly as VS Code commands (e.g., PyXT: Open File), and may be assigned a keyboard shortcut.
The command name should not be typed when it is invoked directly via its VS Code command (rather than with the PyXT Command bar). In this case, simply enter arguments as required.
Command arguments must be separated by spaces in the command bar. Auto-complete suggestions will be provided as the command is entered.
Important: white space is significant! Example: a command accepting multiple arguments might be entered as:
ag match_first ~/path/second -i --after 3
The default value of an argument may be selected by omitting its value and typing a space to advance to the next argument:
ag ~/path/second -i --after 3
Note the two spaces between ag and ~/path/second. In the case of ag, the first argument defaults to the selected text in the active text editor.
Arguments containing spaces may be enclosed in quotes. Alternately spaces may be escaped with a backslash prefix (e.g., \ ).
Commands will often provide contextual argument hints as the first item in the list of quick-pick suggestions. Accepting this suggestion will invoke the command with default values as shown.
Keybindings may be assigned to any PyXT command having a corresponding VS Code command. These commands may also be invoked directly via the Command Palette. Additionally keybindings may be added for custom commands.
Ctrl+Shift+A O to open command bar with text: open /my/favorite/directory/
{
"key": "ctrl+shift+a o",
"command": "pyxt.command",
"args": {"text": "open /my/favorite/directory/"}
}Ctrl+Shift+A D to immediately execute the command: ag 'hot search'
{
"key": "ctrl+shift+a g",
"command": "pyxt.command",
"args": {"text": "ag 'hot search'", "exec": true}
}Adding a new PyXT command is as simple as writing a Python module and loading it as a "user script." Here is a very simple "hello world" example to get started:
from pyxt.command import command
from pyxt.parser import String
from pyxt.results import result
@command(String("name", default="world"))
async def hello(editor, args):
return result([f"Hello {args.name}!"])Save the script in a file, and set the pyxt.userScript setting in VS Code. Then reload VS Code and open the PyXT: Command bar to run the new command. VS Code must be reloaded (Developer: Reload Window) or restarted to register changes if the user script is modified.
The value of pyxt.userScript may be one of the following:
The user script may define multiple @command functions and/or import other modules that define them. Note that other modules must be importable within the PyXT virtualenv (other techniques such as modifying sys.path are also possible).
python3 -m venv /path/to/virtualenv # or your preferred way to create a virtualenv
source /path/to/virtualenv/bin/activate
pip install -r requirements.txt -r test-requirements.txt
npm installAll tests can be run with Debug: Select and Start Debugging command. Python and JavaScript tests may be run this way once the .vscode project has been loaded.
Python tests may also be run in a terminal
pytestBuild .vsix package
npm run pkgInstall the extension in VS Code
code --install-extension pyxt-X.Y.Z.vsix| Back | FazBrowse Home | New Git URL |