xonsh
xonsh syntax highlighting for Sublime Text
Details
Installs
- Total 128
- Win 32
- Mac 46
- Linux 50
Feb 22 | Feb 21 | Feb 20 | Feb 19 | Feb 18 | Feb 17 | Feb 16 | Feb 15 | Feb 14 | Feb 13 | Feb 12 | Feb 11 | Feb 10 | Feb 9 | Feb 8 | Feb 7 | Feb 6 | Feb 5 | Feb 4 | Feb 3 | Feb 2 | Feb 1 | Jan 31 | Jan 30 | Jan 29 | Jan 28 | Jan 27 | Jan 26 | Jan 25 | Jan 24 | Jan 23 | Jan 22 | Jan 21 | Jan 20 | Jan 19 | Jan 18 | Jan 17 | Jan 16 | Jan 15 | Jan 14 | Jan 13 | Jan 12 | Jan 11 | Jan 10 | Jan 9 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Mac | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Linux | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Readme
- Source
- raw.githubusercontent.com
A Sublime Text 4 package for the Python-powered shell xonsh
extending the default Python package with xonsh-specific contexts
Introduction
This package adds support for the xonsh
language (for files with .xsh
and .xonshrc
extensions) by extending the syntax definitions from the default Python package with the following xonsh-specific contexts:
- Variables:
$variableA
, including the environment${...}
- Subprocess operators:
$()
$[]
${}
@()
@$()
(and!()
![]
) - Search functions:
@functionB`search_string`
- Builtin functions:
abbrevs()
aliases()
compilex()
execx()
evalx()
events()
print_color()
exit()
printx()
… and copying all the other relevant elements (Snippets, Comments, Completion Rules, Indentation Rules, Symbol List, and the Default keymap) & re-scoping them to work in the xonsh
syntax
Installation
Via Package Control: open
Command Palette
→Package Control: Install Package
→xonsh
Ctrl/⌘Cmd⇧ShiftPManually: clone this repository to your Packages directory and rename it to
xonsh
cd /path/to/sublime/packages/directory
git clone https://github.com/eugenesvk/sublime-xonsh.git
mv sublime-xonsh xonsh
Usage
Open any xonsh
file (e.g. syntax_example_screen.xsh) and verify that the selected syntax is Xonsh
and xonsh-specific contexts are properly scoped[1] and highlighted, maybe like so (depending on your color scheme):
[1]: scope naming is supposed to conform to that of the default Python package and ST's scope naming guidelines
Examples of supported syntaxes: variables
| Example | Description
| :————– | :———-
| $
| Match a single variable definition symbol to help with completions
| $varA=[1,2]
| Regular variable
| $varA[0]
| Variable indexing
| $varA[$varB]
| Variable inside an index
| funct($varB)
| Variable inside a function
| f"{$varA}"
| Variable inside a function string
| ${...}
| The environment itself
Examples of supported syntaxes: subprocess operators
Example | Description |
---|---|
@$(which ls) |
Command Substitution |
@('echo', 1) |
Python Evaluation |
$(echo 1) |
Captured Subprocess |
!(echo 1) |
… |
$[echo 1] |
Uncaptured Subprocess |
![echo 1] |
… |
Exposed scopes
List of scope names
| xonsh construct | Scope name
| :———— | :———-
| Variable | meta.variable.xonsh
variable.other.xonsh
variable.other.env.xonsh
variable.other.env.ellipsis.xonsh
punctuation.definition.variable.xonsh
| Command Substitution | meta.interpolation.command.xonsh
meta.parens.interpolation.command
keyword.operator.subprocess.pyeval.xonsh
keyword.operator.subprocess.xonsh
punctuation.section.parens.
begin
/end
.xonsh
| Python Evaluation | meta.interpolation.command.xonsh
meta.parens.interpolation.command
keyword.operator.subprocess.pyeval.xonsh
punctuation.section.parens.
begin
/end
.xonsh
| Captured Subprocess | meta.interpolation.command.xonsh
meta.parens.interpolation.command
keyword.operator.subprocess.captured.xonsh
punctuation.section.parens.
begin
/end
.xonsh
| Uncaptured Subprocess | meta.interpolation.command.xonsh
meta.brackets.interpolation.command
keyword.operator.subprocess.uncaptured.xonsh
punctuation.section.brackets.
begin
/end
.xonsh
| Search Function | meta.function-call.xonsh
meta.function-call.arguments.xonsh
meta.string.xonsh
string.quoted.backtick.xonsh
punctuation.definition.annotation.xonsh
punctuation.section.string.
begin
/end
.xonsh
punctuation.section.arguments.
begin
/end
.xonsh
Keybindings
This plugin adds two keybindings for the xonsh
scope: "
/'
that auto-pair double/single quotes even after string modifiers
Known issues
- Only works in Sublime Text 4 since build 4048 (2023 March 14th) since it's using
meta_append
/meta_prepend
APIs - Illegal Python names that would be legal in a subprocess mode are nonetheless scoped as illegal since there is no differentiation between Python and subprocess modes:
e.g.as
inecho "$HOME" as well as '$HOME'
As a workaround use"
quotes"
or dim/remove error highlighting forsource.xonsh invalid.illegal.name
Credits
The default packages' syntax files (Python, Bash, PHP), as well as fish