welkineins / vscode-astyle Goto Github PK
View Code? Open in Web Editor NEWFormat C/C++/Obj-C code with Astyle in VSCode
License: MIT License
Format C/C++/Obj-C code with Astyle in VSCode
License: MIT License
"astyle.astylerc": "${workspaceFolder}/.vscode/astylerc"
"astyle.cmd_options": [
// 使用kr风格
"--style=kr",
// 将tab转为4个空格
"--convert-tabs",
// 对于控制流程如果是当行的加入花括号
"--add-braces",
// 缩进case标签
"--indent-switches",
// 缩进标签
"--indent-labels",
// 缩进预处理
"--indent-preprocessor",
//缩进一行的注释
"--indent-col1-comments",
//缩进命名空间
"--indent-namespaces",
//控制关键字 后添加空格
"--pad-header",
// 操作符号添加空格
"--pad-oper",
//一行的块代码添加花括号
"--add-brackets",
//对于一行的代码保持不换行
"--keep-one-line-blocks",
// 缩进4个空格
"--indent=spaces=4",
"--min-conditional-indent=0",
"--max-instatement-indent=40",
//块之间添加空行
"--break-blocks",
//括号内的参数和括号不添加空格
"--unpad-paren",
// 指针符号贴近变量名
"--align-pointer=name",
// 引用符号贴近变量名
"--align-reference=name"
// 模式设置为C
//"--mode=c"
]
when set the option cmd and option file at the same time. astyle format by option cmd ,
i thinks it should format by the stylerc rules
Currently update astyle settings will not take affect immediately, but after vscode restart.
We should pop up to notify user to restart vscode, or reload extension directly.
Astyle 3.0 supports the --dry-run option to report on changes without actually applying them.
http://astyle.sourceforge.net/astyle.html#_dry-run
However, in Visual Studio there is no option in the Astyle config UI to select it, and when I manually add it to the parameter list text I get an error, when run,
130: Invalid Artistic Style options: dry-run
If I try to format a C file I get:
"Failed to launch astyle. (reason: "Cannot process the input stream,,Artistic Style has terminated, Error: Command failed: astyle Cannot process the input stream Artistic Style has terminated ")"
Info:
astyle version 2.03
vsc version 1.23.1
Node version 7.9.0
User config:
"C_Cpp.formatting": "Disabled",
Astyle is in the path and it works...
Thanks for the help.
Hi,
I have vscode cpptools installed, and seems it uses clang-format by default, and I have no idea how to resolve the conflict and get the astyle working.
Thank you.
when I create an new file, change language mode to java, write java code in it. then i format it without save to disk, it does not work. certainly it works if i save it..
Input file:
int f1()
{
return 0;
}
// two empty lines
int f2()
{
return 0;
}
// one empty line
int f3()
{
return 0;
}
SHIFT+ALT+F:
int f1()
{
return 0;
}
// two empty lines
int f2()
{
return 0;
}
// one empty line
int f3()
{
return 0;
}
astyle f.cpp:
int f1()
{
return 0;
}
// two empty lines
int f2()
{
return 0;
}
// one empty line
int f3()
{
return 0;
}
There is no astyle config file.
Differences are:
VSCode About:
Version: 1.33.1 (system setup)
Commit: 51b0b28134d51361cf996d2f0a1c698247aeabd8
Date: 2019-04-11T08:27:14.102Z
Electron: 3.1.6
Chrome: 66.0.3359.181
Node.js: 10.2.0
V8: 6.6.346.32
OS: Windows_NT x64 10.0.16299
Failed to launch astyle. (reason: "Cannot open options file ${workspaceRoot}/astylerc")
Using vscode 0.6.1 and just upgraded to Astyle extension 0.6.1.
It works if I changed to the full path. i.e /Users/XXX/Project/astylerc.
I have a custom astylerc
file which works flawlessly with [email protected]
from the command line.
However, when I use the plugin and provide
"astyle.executable": "<blabla>",
"astyle.astylerc": "<blabla>",
"C_Cpp.formatting" : "Disabled"
I see interesting behaviour that each invocation of formatting adds a new line:
p.s. macOS 10.13.3
, [email protected]
, [email protected]
.
Current variable substitution is only support on astyle rc option, we should extend it to all options
I would like the ability to use the command line to pass options to astyle.
This could be done instead of or in addition to using the options file.
Thanks
Is it possible to only run astyle on selected code? The only option in my context menu is to do the entire file. Is there any possibility of this feature being added?
AStyle does a passable job of formatting (simple) Haxe code, and I'd imagine that's the case for a lot of other languages that are not part of the officially supported / listed ones too. However, it seems like the extension is currently restricted to those.
It would be nice to have a simple setting for this, like:
"astyle.additional_languages": ["Haxe"]
The following c file is the example:
https://github.com/kalatestimine/UGUI/blob/master/ugui.c
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.