mmims / language-batchfile Goto Github PK
View Code? Open in Web Editor NEWWindows batch file language support for Atom.
License: MIT License
Windows batch file language support for Atom.
License: MIT License
GitHub (Linguist)
It appears that only arithmetic assignments combined with assignments in quotes cause this (possibly due to mismatched quote detection?):
:: This will work...
set var=val & set var=val
:: This as well...
set "var=val" & set var=val
:: This... will, I guess?
set /a var=val & set var=val
:: This won't.
set /a "var=val" & set var=val
:: Aaaand everything's screwed.
set sadness=true
title it's over
echo weep woop
exit /b -42
A real-world example can be seen here.
I discovered two bugs on GitHub's batch file highlighting and from this I am recommended to report it here:
SETLOCAL EnableDelayedExpansion
REM Stripping quotes from a variable
SET foo=some^"quoted^"text
SET bar=!foo:^"=!
REM ^"
This look like two problems that happen simultaneously in the code above:
Because of the bugs, I worked-around by batch script.
Hello,
Could you add support for those please ?
Example:
echo OK &:: display "OK"
Digits within filenames appear to be highlighted as numbers, which can look a bit unusual. For example, a snippet for running the current SourceTree installer from Command Prompt looks like
SourceTreeSetup-2.1.2.5
The -2
, 1
, 2
, and 5
in the filename are highlighted as numbers.
When using variable string substitution, the highlight is including till the next variable's end "%".
This might get fixed by setting your matcher:
{
'match': '%[\\w -]+?(:~\\-?\\d+(,\\-?\\d+)?|:.+=.+)?%'
'name': 'variable.other.environment.batchfile'
}
to this:
%[\\w -]+?(:~\\-?\\d+(,\\-?\\d+)?|:.+?=.*?)?%
Thanks for fixing the parameter highlight. Sorry for bothering you again.
Thanks
Subhajit
A batch parameter (percent (%) number) reference doesn't seem to be scoped correctly, and as such it doesn't get colored correctly in editors, such as VS Code (1.25.1 on Windows 10 1803)
Currently, it only ends up scoped in "punctuation.definition.variable.batchfile", unlike the normal variable '%', which gets included in both scopes, "punctuation.definition.variable.begin.batchfile"
"variable.other.readwrite.batchfile"
I think the single % that is used to determine the scope "variable.parameter.batchfile" should be included in that scope, and then themes would color it like they do the rest of the parameter.
I was able to work around the issue of the % in front of a 'variable.parameter' not being scoped with the 'variable.parameter', by adding this to settings:
"editor.tokenColorCustomizations": {
"[Default Dark+]": {
"textMateRules": [
{
"scope": "punctuation.definition.variable",
"settings": {
"foreground": "#9cdcfe"
}
}
]
}
}
From @DmitrySokolov on February 1, 2018 13:49
Extension | Author (truncated) | Version |
---|---|---|
hg | mrc | 1.2.3 |
cpptools | ms- | 0.14.6 |
cmake | twx | 0.0.17 |
(2 theme extensions excluded)
Steps to Reproduce:
@echo off
setlocal
set "flag="
endlocal
exit /b 0
EXPECTED
endlocal
and the rest of command are highlighted
ACTUAL
endlocal
and the rest of command have the default font color
Reproduces without extensions: Yes
Copied from original issue: microsoft/vscode#42733
From @wlai2768 on January 7, 2018 1:40
Steps to Reproduce:
for %%i in ( %* ) do if "%%i"=="--watch" goto :do_%1_%2_watch
for %%i in (
%*
) do if "%%i"=="--watch" goto :do_%1_%2_watch
Copied from original issue: microsoft/vscode#41235
Like: ## Get runner for windows
or ## Install and start services
The keywords start
and for
not are commands, its just comments and should be ignore.
Can't you work together with https://github.com/footballhead/language-batch?
So that we have one language-batch.
When using DOS formatted text (as batchfiles usually are) there is a glitch that creates a highlighted ^M at the end of a new line.
The glitch can be reproduced by ending any line of code with :text (a colon followed by at least 2 text characters.)
You can see the bug here: https://github.com/gtwy/Fix-Windows-Time/blob/master/fix_time.bat
From @Kroc on April 6, 2018 8:35
Issue Type: Bug
There are a handful of highlighting issues with Windows Batch files:
ECHO:
is not recognised, when ECHO.
is; ECHO:
is faster as it does not do a file lookup! -- see: https://ss64.com/nt/echo.html
The OFF
in ECHO OFF
is not highlighted
The following code gets highlighting confused (the "$...
seems to throw it off)
No space between GOTO
and the label name does not highlight correctly; i.e. GOTO:EOF
CLS
keyword is not highlighted
EQU
/ NOT
and other comparison operators are not highlighted
IN
& DO
are not highlighted
command concatenator &
, and the pipe operators >
, |
are not highlighted nor pipe numbers for redirection, e.g. >NUL 2>&1
(a common way to suppress all output)
error-suppressor @
is not highlighted in any way; this needs to be highlighted when used with a command, but not within 'strings' (which may or may not be quoted, according to command used)
ENABLEEXTENSIONS
/ DISABLEDELAYEDEXPANSION
etc. not highlighted along with SETLOCAL
Syntax break-down here: (looks like the quoted paren-escape failed to be noticed)
Aside: What would be the best way to broach a discussion on using a PEG-based parser, rather than the regex-infused TextMate system for VSCode? Windows Batch files happen to be one of the best examples of extremely complex mode-like behaviour that would be easily and elegantly handled by a real state machine based approach using PEG/EBNF grammars. Grammar based parsing would also be readily shareable between language servers and other external software.
VS Code version: Code 1.22.1 (950b8b0d37a9b7061b6f0d291837ccc4015f5ecd, 2018-04-06T02:26:57.615Z)
OS version: Windows_NT x64 10.0.16299
Extensions: none
Copied from original issue: microsoft/vscode#47297
Text typed as comments in a comment block is being parsed and colored as if it's code. Not breaking, but for some reason it's annoying me to distraction.
/*
[text here is being parsed/lexed and colored]
*/
This is a feature request.
SET var=banana
ECHO %var:*NA=An% & REM Output: Anna
ECHO %var:NA=s% & REM Output: bass
SET var=f*cker
ECHO %var:**CK=bust% & REM Output: buster
ECHO %var:**C=ba% & REM Output: baker
ECHO %var:*F*C=coo% & REM Output: cooker
The first asterisk *
in the pattern should be recognized as special.
For the example screenshot below, the first asterisk right after the colon is better colored red just like the colon is:
Store package settings files in the settings/
directory instead of scoped-properties/
Package.loadSettings (C:\Users\k_sevrjugin\AppData\Local\atom\app-0.189.0\resources\app\src\package.js:565:9)
<unknown> (C:\Users\k_sevrjugin\AppData\Local\atom\app-0.189.0\resources\app\src\package.js:187:43)
From @m93a on February 18, 2018 11:36
Steps to Reproduce:
.bat
fileDoes this issue occur when all extensions are disabled?: Yes
Copied from original issue: microsoft/vscode#43923
So the label is just white and not italic, I don't know if this a bug or not but I think it looked much better when it was italic and coloured.
Hello, I'm new to Atom. I already learned how to install a package with apm in the command prompt. But I can't figure out how to install this BATCH auto complete support. I'd appreciate the help.
Type: Bug
windows batch:
if not %errorlevel%==0 echo error!!! & echo; & exit /b
if not %errorlevel%==0 echo error!!! && echo; && exit /b
if not %errorlevel%==0 echo error!!! || echo; || exit /b
the second "echo" and "exit" command not highlighting
VS Code version: Code 1.74.2 (e8a3071ea4344d9d48ef8a4df2c097372b0c5161, 2022-12-20T10:29:14.590Z)
OS version: Windows_NT x64 10.0.22621
Modes:
Sandboxed: No
Item | Value |
---|---|
CPUs | AMD Ryzen 5 5600X 6-Core Processor (12 x 3700) |
GPU Status | 2d_canvas: enabled canvas_oop_rasterization: disabled_off direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok skia_renderer: enabled_on video_decode: enabled video_encode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: disabled_off |
Load (avg) | undefined |
Memory (System) | 15.93GB (2.93GB free) |
Process Argv | K:\EasyU\driver\_common_printer_add.bat --crash-reporter-id bbaba037-8e76-4429-9304-78de16cb0895 |
Screen Reader | no |
VM | 0% |
Extension | Author (truncated) | Version |
---|---|---|
ZwLisp | Zws | 1.0.8 |
maxscript | And | 0.0.2 |
bat-snippets | bat | 0.2.0 |
auto-align | bla | 0.0.13 |
prettier-toml | bod | 0.1.0 |
vscode-better-align | cho | 1.3.1 |
xml | Dot | 2.5.1 |
vscode-glsllint | dto | 1.8.0 |
shell-format | fox | 7.2.2 |
reg | ion | 1.1.0 |
columnpaste | joh | 0.0.7 |
vscode-smart-column-indenter | lmc | 0.0.13 |
auto-build | mar | 2.1.45 |
clang-format | mjo | 1.10.0 |
vscode-language-pack-zh-hans | MS- | 1.74.12140931 |
csharp | ms- | 1.25.2 |
isort | ms- | 2022.8.0 |
python | ms- | 2022.20.1 |
vscode-pylance | ms- | 2022.12.20 |
jupyter | ms- | 2022.11.1003412109 |
jupyter-keymap | ms- | 1.0.0 |
jupyter-renderers | ms- | 1.0.12 |
vscode-jupyter-cell-tags | ms- | 0.1.6 |
vscode-jupyter-slideshow | ms- | 0.1.5 |
cpptools | ms- | 1.13.8 |
powershell | ms- | 2022.12.1 |
platformio-ide | pla | 2.5.5 |
vscode-xml | red | 0.23.0 |
vscode-yaml | red | 1.10.1 |
vscode-vba | ser | 0.8.0 |
shader | sle | 1.1.5 |
sq | sq | 0.0.1 |
even-better-toml | tam | 0.19.0 |
clang-format | xav | 1.9.0 |
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492:30256859
vstes627:30244334
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
pythondataviewer:30285071
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30581797
vsaa593:30376534
pythonvs932:30410667
cppdebug:30492333
vsclangdc:30486549
c4g48928:30535728
dsvsc012cf:30540253
azure-dev_surveyone:30548225
pyindex848:30577860
nodejswelcome1cf:30587006
2e4cg342:30602488
3d0df643:30613357
89544117:30613380
fim-prod:30623723
When echoing something that contains a simple quote ('), the following text is interpreted as a string until it finds another matching simple quote (e.g. echo It's OK.
).
This breaks all further syntax highlighting.
Could it be possible to ignore simple quote that are part of an echo? Would there be a downside to it?
Support for things like wget commands. Highlighting them like echo would be nice.
The ssh
and scp
commands are not supported.
Please add syntax highlighting for ssh
and scp
.
If a batch script references a file with a percent (%) sign in it, the percent needs to be doubled to escape it. VS code seems not to apply correct syntax highlighting to this.
Steps to Reproduce:
copy "50% done.txt" %K%
Copied from original issue: microsoft/vscode#42472
GitHub (Linguist)
:: Inline comment below
:somewhere &:: we're here
:: Another inline comment below
goto :somewhere &:: and close the door when leaving
call :somewhere &:: This seems to work correctly, though
A real-world example can be seen here.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.