akof1314 / sublime-coolformat Goto Github PK
View Code? Open in Web Editor NEWA Sublime Text plugin for Source Code Formatter
A Sublime Text plugin for Source Code Formatter
位于/packages/CoolFormat/CoolFormatLib/的CoolFormatConfig.cfconfig文件如下:
; Please visit http://akof1314.github.io/CoolFormat/doc/index.html for more information
[SynTidy]
C++=""-A2-p-N-Y-k3""
Java=""-A2-p-N-Y-k3""
C#=""-A2-p-N-Y-k3""
Objective-C=""-A1-p-N-Y-k3""
HTML=""-aan-dep-fb-fbc-fu-js-ll-n-ox-pe-qa-qn-m-wa-wj-wp-ws-sw-fo-i0-d1-ce0-ie0-oe0-w0-sbo0""
XML=""-aan-dep-fb-fbc-js-ll-n-ix-qa-qn-m-wa-wj-wp-ws-sw-fo-i1-ce0-ie0-oe0-w0""
PHP=""-sas-icd-samt-salo-saeo-saro-sabo-saao-samp-aas-rsl-iel-rpc-rst-st""
JavaScript=""-nb-cn4""
CSS=""-c2-rub-cl0-os1-cc-cf-cfp0-rs2""
JSON=""-cn3""
SQL=""-cn2-el-ml0""
经测试,C++等语言的设置可生效,HTML的设置无法生效
比如:根据文档,w0表示wrap无限制,w10表示每10个字符截断另起一行,我无论设置w几都无法截断。这只是一个测试,还有很多参数设置和不设置都一样。
我后来改成了HTML=""“‘’”
这样,使用quick format还是一样的效果,根本无法对HTML的格式化规则产生影响。
subtime time重启再试还是一样。。。
In the console, the following error appears:
dlopen(/Users/Alex/Library/Application Support/Sublime Text 3/Packages/CoolFormat/CoolFormatLib/cf_osx_arm64/libCoolFormatLib.dylib, 0x0006): tried: '/Users/Alex/Library/Application Support/Sublime Text 3/Packages/CoolFormat/CoolFormatLib/cf_osx_arm64/libCoolFormatLib.dylib' (no such file), '/usr/lib/libCoolFormatLib.dylib' (no such file)
However, only an x86 slice is available:
ls -l /Users/Alex/Library/Application\ Support/Sublime\ Text\ 3/Packages/CoolFormat/CoolFormatLib 12:19
total 8
-rw-r--r-- 1 Alex staff 550 Dec 12 12:18 CoolFormatConfig.cfconfig
drwxr-xr-x 3 Alex staff 96 Dec 12 12:18 cf_linux_x32
drwxr-xr-x 3 Alex staff 96 Dec 12 12:18 cf_linux_x64
drwxr-xr-x 3 Alex staff 96 Dec 12 12:18 cf_osx_x64
drwxr-xr-x 3 Alex staff 96 Dec 12 12:18 cf_windows_x32
drwxr-xr-x 3 Alex staff 96 Dec 12 12:18 cf_windows_x64
Attempting to symlink the x86 dylib is equally futile:
dlopen(/Users/Alex/Library/Application Support/Sublime Text 3/Packages/CoolFormat/CoolFormatLib/cf_osx_arm64/libCoolFormatLib.dylib, 0x0006): tried: '/Users/Alex/Library/Application Support/Sublime Text 3/Packages/CoolFormat/CoolFormatLib/cf_osx_arm64/libCoolFormatLib.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/libCoolFormatLib.dylib' (no such file)
不影响使用,但用2个快捷键不太精简,建议自动判断。
即,选择文本时selectedFormat
,没选时quickFormat
。
If you attempt to run CoolFormat on a file whose syntax does not match any of the supported languages, all text in the document will be deleted.
This can easily be resolved by implementing a simple verification process:
activeSyntax = view.settings().get( "syntax" )
比如 https://element.eleme.cn/#/zh-CN/component/select
<el-select v-for="(v,i) in selects" :key="i" v-model="v.model" filterable style="width: 100%">
<el-option v-for="(vv,ii) in v" :key="ii" :value="vv" />
</el-select>
How do i foramt on save?
格式化前
<div class="w530 lft category-con ml10">
<textarea class="textareaBox" name="content" id="content" style="width:450px; height:100px;"></textarea>
<div class="tips"></div>
</div>
格式化后ctrl-alt-shift-s
<div class="w530 lft category-con ml10">
<textarea class="textareaBox" name="content" id="content" style="width:450px; height:100px;">
</textarea>
<div class="tips"></div>
</div>
希望能够设置
(1)不出现</textarea>
和<div class="tips">
之间的空行。
因为每个标签间的空行,使代码变得很长(个人习惯)
(2)</textarea>
不另起一行,直接合到<textarea
后边。
预期效果
<div class="w530 lft category-con ml10">
<textarea class="textareaBox" name="content" id="content" style="width:450px; height:100px;"></textarea>
<div class="tips"></div>
</div>
原因:
self.view.settings().get('syntax')关于此语言返回Package\包名\作者\Json(sublime).sublime-syntax
Sol:
if formatted_code != '':
view.replace(edit, region, formatted_code)
else:
view.replace(edit, region, code)
修改getCFLang函数
def getCFLang(self):
lang = self.view.settings().get('syntax') # eg Packages/C++/C++.tmLanguage
sublime.message_dialog(lang)
for keys in Synlanguage.lang_dict.keys():
if lang.find(keys,9) != -1:
return Synlanguage.lang_dict[keys]
ps:#4 issues可能是这个原因
我阅读了 doc 文档,目前的 SynTidy 是:
C++=""-A14-xn-xc-xl-xk-s-C-xG-S-K-p-N-xW-w-Y-f-H-k3-j-xC""
我想在函数之间也强制加上空行。
Python would be nice to have as a fully implemented preset in CoolFormat.
Additionally, it would be very useful if users could define custom syntax preferences via an array of dictionaries @ sublime-settings
.
These custom syntaxes could be much simpler than the included presets, functioning only on characters within single lines.
For example:
[
{
syntaxes: [ "autohotkey", "processing", "regular expression" ],
// select the padding method for each character
// a space will be added to the defined sides of the character upon formatting
// OPTIONS: "left" | "right" | "both"
left_paren: "right"
right_paren: "left"
colon: "both"
ETC...
}
]
Or maybe even regEx
defined patterns instead of explicitly defined characters as in the example above.
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.