summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSangHyeon Jade Lee <dltkdgus1764@gmail.com>2017-07-23 18:13:33 +0900
committerSangHyeon Jade Lee <dltkdgus1764@gmail.com>2017-07-23 18:13:39 +0900
commit2982f0cf7d427c8c31ed83f1738d89a42e789617 (patch)
tree99d02a14f99f734a95075dfe2e37d0a13b437043
parentb6221f4a07478b51b3009d273f285d4185a0a8b0 (diff)
add foramt files for vscode efl format apply
Signed-off-by: SangHyeon Jade Lee <dltkdgus1764@gmail.com>
-rw-r--r--tools/format/0001-Add-new-Feature-Selection-Range-Formatting.patch145
-rw-r--r--tools/format/ecrustify.cfg278
-rw-r--r--tools/format/vscode_format_guide32
3 files changed, 455 insertions, 0 deletions
diff --git a/tools/format/0001-Add-new-Feature-Selection-Range-Formatting.patch b/tools/format/0001-Add-new-Feature-Selection-Range-Formatting.patch
new file mode 100644
index 0000000..6b74131
--- /dev/null
+++ b/tools/format/0001-Add-new-Feature-Selection-Range-Formatting.patch
@@ -0,0 +1,145 @@
1From 10d4a7250c06eba3a9dc2920270fb4c9b2267f76 Mon Sep 17 00:00:00 2001
2From: SangHyeon Jade Lee <dltkdgus1764@gmail.com>
3Date: Sun, 23 Jul 2017 17:37:24 +0900
4Subject: [PATCH] Add new Feature Selection Range Formatting
5
6Add new Feature Selection Range Formatting,
7Now you can apply your format in selected lines only.
8Default Key for Selection Range Formatting is
9Ctrl + K + F.
10
11Signed-off-by: SangHyeon Jade Lee <dltkdgus1764@gmail.com>
12---
13 CHANGELOG.md | 3 +++
14 package.json | 4 ++--
15 src/extension.ts | 4 ++++
16 src/formatter.ts | 36 ++++++++++++++++++++++++++++++------
17 4 files changed, 39 insertions(+), 8 deletions(-)
18
19diff --git a/CHANGELOG.md b/CHANGELOG.md
20index 9940fd9..0ccecb5 100644
21--- a/CHANGELOG.md
22+++ b/CHANGELOG.md
23@@ -1,5 +1,8 @@
24 # Changelog
25
26+#### 2.4.2
27+- Added new feature for Range Selection Rormatting - Modified by SangHyeon Jade Lee
28+
29 #### 2.4.1
30 - Fixed extension activation (#10)
31
32diff --git a/package.json b/package.json
33index eed23fb..a2ccefc 100644
34--- a/package.json
35+++ b/package.json
36@@ -2,7 +2,7 @@
37 "name": "uncrustify",
38 "displayName": "Uncrustify",
39 "description": "Code format using uncrustify",
40- "version": "2.4.1",
41+ "version": "2.4.2",
42 "publisher": "LaurentTreguier",
43 "license": "MIT",
44 "homepage": "https://github.com/LaurentTreguier/vscode-uncrustify",
45@@ -127,7 +127,7 @@
46 "devDependencies": {
47 "@types/node": "^8.0.14",
48 "@types/request": "^2.0.0",
49- "typescript": "^2.4.2",
50+ "typescript": "^2.4.3",
51 "vscode": "^1.1.0"
52 }
53 }
54\ No newline at end of file
55diff --git a/src/extension.ts b/src/extension.ts
56index 43ffc5c..b685006 100644
57--- a/src/extension.ts
58+++ b/src/extension.ts
59@@ -83,6 +83,10 @@ export function activate(context: vsc.ExtensionContext) {
60 context.subscriptions.push(formatterSub);
61 logger.dbg('registered formatter');
62
63+ let rangeformatterSub = vsc.languages.registerDocumentRangeFormattingEditProvider(util.MODES, new Formatter());
64+ context.subscriptions.push(rangeformatterSub);
65+ logger.dbg('registered rangeformatter');
66+
67 let configurationSub = vsc.workspace.registerTextDocumentContentProvider('uncrustify', new Configurator());
68 context.subscriptions.push(configurationSub);
69
70diff --git a/src/formatter.ts b/src/formatter.ts
71index 2582a59..148474d 100644
72--- a/src/formatter.ts
73+++ b/src/formatter.ts
74@@ -5,12 +5,31 @@ import * as vsc from 'vscode';
75 import * as logger from './logger';
76 import * as util from './util';
77
78-export default class Formatter implements vsc.DocumentFormattingEditProvider {
79+export default class Formatter implements vsc.DocumentFormattingEditProvider, vsc.DocumentRangeFormattingEditProvider {
80+
81 public provideDocumentFormattingEdits(
82 document: vsc.TextDocument,
83 options: vsc.FormattingOptions,
84 token: vsc.CancellationToken
85 ): Thenable<vsc.TextEdit[]> {
86+ return this.formatUncrustify(document, null, options, token);
87+ }
88+
89+ public provideDocumentRangeFormattingEdits(
90+ document: vsc.TextDocument,
91+ range: vsc.Range,
92+ options: vsc.FormattingOptions,
93+ token: vsc.CancellationToken
94+ ): Thenable<vsc.TextEdit[]> {
95+ return this.formatUncrustify(document, range, options, token);
96+ }
97+
98+ private formatUncrustify(
99+ document: vsc.TextDocument,
100+ range: vsc.Range,
101+ options: vsc.FormattingOptions,
102+ token: vsc.CancellationToken
103+ ): Thenable<vsc.TextEdit[]> {
104 return new Promise((resolve, reject) => {
105 token.onCancellationRequested(reject);
106
107@@ -35,7 +54,9 @@ export default class Formatter implements vsc.DocumentFormattingEditProvider {
108 }
109
110 let uncrustifyExecutable = vsc.workspace.getConfiguration('uncrustify').get('executablePath', 'uncrustify');
111- let args = ['-l', languageMap[document.languageId], '-c', configPath];
112+ let args;
113+ if (range) args = ['-l', languageMap[document.languageId], '-c', configPath, '--frag'];
114+ else args = ['-l', languageMap[document.languageId], '-c', configPath];
115 let output = '';
116 let error = '';
117 let uncrustify = cp.spawn(uncrustifyExecutable, args);
118@@ -53,9 +74,11 @@ export default class Formatter implements vsc.DocumentFormattingEditProvider {
119
120 uncrustify.stdout.on('data', (data) => output += data);
121 uncrustify.stdout.on('close', () => {
122- let lastLine = document.lineCount - 1;
123- let lastCol = document.lineAt(lastLine).text.length;
124- let range = new vsc.Range(0, 0, lastLine, lastCol);
125+ if (!range) {
126+ let lastLine = document.lineCount - 1;
127+ let lastCol = document.lineAt(lastLine).text.length;
128+ range = new vsc.Range(0, 0, lastLine, lastCol);
129+ }
130
131 resolve([new vsc.TextEdit(range, output)]);
132 });
133@@ -63,7 +86,8 @@ export default class Formatter implements vsc.DocumentFormattingEditProvider {
134 uncrustify.stderr.on('data', (data) => error += data);
135 uncrustify.stderr.on('close', () => logger.dbg('uncrustify exited with error: ' + error));
136
137- uncrustify.stdin.write(document.getText());
138+ if (range) uncrustify.stdin.write(document.getText(range));
139+ else uncrustify.stdin.write(document.getText());
140 uncrustify.stdin.end();
141 });
142 }
143--
1442.7.4
145
diff --git a/tools/format/ecrustify.cfg b/tools/format/ecrustify.cfg
new file mode 100644
index 0000000..4da8de5
--- /dev/null
+++ b/tools/format/ecrustify.cfg
@@ -0,0 +1,278 @@
1align_enum_equ_span=6
2align_func_params=false
3align_func_proto_gap=1
4align_func_proto_span=5
5#align_func_proto_star_style=2
6align_keep_tabs=false
7align_left_shift=false
8align_mix_var_proto=false
9align_nl_cont=true
10align_number_left=false
11align_on_operator=false
12align_on_tabstop=false
13align_pp_define_span=4
14align_right_cmt_at_col=6
15align_right_cmt_gap=6
16align_right_cmt_mix=true
17align_right_cmt_span=1
18align_same_func_call_params=false
19align_single_line_brace=false
20align_single_line_func=false
21align_typedef_func=2
22align_typedef_gap=1
23align_typedef_span=2
24align_typedef_star_style=2
25align_var_def_attribute=false
26align_var_def_colon=false
27align_var_def_inline=false
28align_var_def_star_style=2
29align_var_struct_gap=0
30align_var_struct_span=10
31align_with_tabs=false
32cmt_c_group=false
33cmt_c_nl_end=false
34cmt_c_nl_start=false
35cmt_cpp_group=false
36cmt_cpp_nl_end=false
37cmt_cpp_nl_start=false
38cmt_cpp_to_c=false
39cmt_indent_multi=true
40cmt_insert_before_preproc=false
41cmt_insert_file_header=""
42cmt_multi_check_last=true
43cmt_star_cont=false
44eat_blanks_after_open_brace=true
45eat_blanks_before_close_brace=true
46indent_access_spec_body=false
47indent_align_assign=false
48indent_align_string=true
49indent_bool_paren=false
50indent_brace=2
51indent_brace_parent=false
52indent_brace_width=true
53indent_braces=false
54indent_braces_no_func=false
55indent_class_colon=false
56indent_class=false
57indent_col1_comment=false
58indent_columns=2
59indent_comma_paren=false
60indent_else_if=false
61indent_extern=false
62indent_func_call_param=false
63indent_func_class_param=false
64indent_func_ctor_var_param=false
65indent_func_def_param=false
66indent_func_param_double=false
67indent_func_proto_param=false
68indent_namespace=false
69indent_preserve_sql=false
70indent_relative_single_line_comments=false
71indent_square_nl=false
72indent_template_param=false
73indent_with_tabs=0
74ls_for_split_full=false
75ls_func_split_full=false
76mod_full_paren_if_bool=false
77mod_move_case_break=false
78mod_paren_on_return=remove
79mod_pawn_semicolon=false
80mod_remove_empty_return=false
81mod_remove_extra_semicolon=true
82mod_sort_import=false
83mod_sort_include=false
84mod_sort_using=false
85nl_after_brace_close=false
86nl_after_brace_open_cmt=false
87nl_after_brace_open=true
88nl_after_case=false
89nl_after_func_body=2
90nl_after_func_body_one_liner=2
91nl_after_multiline_comment=false
92nl_after_return=false
93nl_after_semicolon=false
94nl_after_vbrace_open=true
95nl_assign_leave_one_liners=true
96nl_before_case=true
97nl_brace_else=force
98nl_class_leave_one_liners=true
99nl_collapse_empty_body=false
100nl_create_for_one_liner=false
101nl_create_if_one_liner=false
102nl_create_while_one_liner=false
103nl_define_macro=false
104nl_do_brace=force
105nl_ds_struct_enum_close_brace=false
106nl_ds_struct_enum_cmt=false
107nl_else_brace=force
108nl_elseif_brace=force
109nl_enum_brace=force
110nl_enum_leave_one_liners=true
111nl_func_decl_end=remove
112nl_func_decl_args=ignore
113nl_func_leave_one_liners=true
114nl_func_type_name=force
115nl_getset_leave_one_liners=true
116nl_if_brace=force
117nl_if_leave_one_liners=true
118nl_max=2
119nl_multi_line_cond=false
120nl_multi_line_define=false
121nl_squeeze_ifdef=false
122nl_struct_brace=force
123nl_switch_brace=force
124nl_union_brace=force
125nl_while_brace=force
126output_tab_size=2
127pp_define_at_level=false
128pp_if_indent_code=false
129pp_indent_at_level=false
130pp_region_indent_code=false
131sp_after_assign=force
132sp_after_cast=remove
133sp_after_comma=force
134sp_after_ptr_star=remove
135sp_after_ptr_star_func=remove
136sp_arith=force
137sp_assign=force
138sp_balance_nested_parens=false
139sp_before_assign=force
140sp_before_comma=remove
141sp_before_nl_cont=remove
142sp_before_ptr_star=force
143sp_before_ptr_star_func=force
144sp_before_sparen=force
145sp_between_ptr_star=remove
146sp_bool=force
147sp_compare=force
148sp_func_proto_paren=remove
149sp_func_def_paren=remove
150sp_inside_fparen=remove
151sp_inside_paren=remove
152sp_paren_paren=remove
153sp_pp_concat=ignore
154sp_pp_stringify=ignore
155sp_type_func=force
156sp_func_call_paren=remove
157
158set COMMENT_EMBED __UNUSED__
159set COMMENT_EMBED EAPI
160set COMMENT_EMBED EOAPI
161set COMMENT_EMBED EOLIAN
162set FOR EINA_LIST_FOREACH
163set FOR EINA_LIST_REVERSE_FOREACH
164set FOR EINA_LIST_FOREACH_SAFE
165set FOR EINA_LIST_FREE
166set FOR EINA_ITERATOR_FOREACH
167set FOR EINA_INLIST_FOREACH
168set FOR EINA_INLIST_REVERSE_FOREACH
169set FOR EINA_INLIST_FOREACH_SAFE
170set FOR EINA_ARRAY_ITER_NEXT
171set FOR udev_list_entry_foreach
172set TYPE EINA_MAGIC
173set TYPE EINA_INLIST
174set TYPE Eina_Bool
175set TYPE Eina_List
176set TYPE Eina_Accessor
177set TYPE Eina_Array
178set TYPE Eina_Benchmark
179set TYPE Eina_Binbuf
180set TYPE Eina_Clist
181set TYPE Eina_Counter
182set TYPE Eina_File_Direct_Info
183set TYPE Eina_File
184set TYPE Eina_Hash_Tuple
185set TYPE Eina_Lock
186set TYPE Eina_RWLock
187set TYPE Eina_Condition
188set TYPE Eina_Mempool_Backend_ABI1
189set TYPE Eina_Mempool_Backend_ABI2
190set TYPE Eina_Inlist
191set TYPE Eina_Inlist_Sorted_State
192set TYPE Eina_Iterator
193set TYPE Eina_Iterator_Array
194set TYPE Eina_Lalloc
195set TYPE Eina_List_Accounting
196set TYPE Eina_Log_Domain
197set TYPE Eina_Matrixsparse
198set TYPE Eina_Matrixsparse_Row
199set TYPE Eina_Mempool
200set TYPE Eina_Mempool_Backend
201set TYPE Eina_Module
202set TYPE Eina_Prefix
203set TYPE Eina_QuadTree_Item
204set TYPE Eina_Rbtree
205set TYPE Eina_Rectangle_Pool
206set TYPE Eina_Simple_XML_Node_Data
207set TYPE Eina_Simple_XML_Node_CData
208set TYPE Eina_Simple_XML_Node_Processing
209set TYPE Eina_Simple_XML_Node_Doctype
210set TYPE Eina_Simple_XML_Node_Comment
211set TYPE Eina_Simple_XML_Attribute
212set TYPE Eina_Strbuf
213set TYPE Eina_Tiler
214set TYPE Eina_Tile_Grid_Info
215set TYPE Eina_Tile_Grid_Slicer
216set TYPE Eina_Trash
217set TYPE Eina_UStrbuf
218set TYPE Ecore_Version
219set TYPE Ecore_Con_Server
220set TYPE Ecore_Con_Client
221set TYPE Ecore_Con_Url
222set TYPE Ecore_Con_Event_Client_Add
223set TYPE Ecore_Con_Event_Client_Upgrade
224set TYPE Ecore_Con_Event_Client_Del
225set TYPE Ecore_Con_Event_Client_Error
226set TYPE Ecore_Con_Event_Server_Add
227set TYPE Ecore_Con_Event_Server_Upgrade
228set TYPE Ecore_Con_Event_Server_Del
229set TYPE Ecore_Con_Event_Server_Error
230set TYPE Ecore_Con_Event_Client_Data
231set TYPE Ecore_Con_Event_Server_Data
232set TYPE Ecore_Con_Event_Client_Write
233set TYPE Ecore_Con_Event_Server_Write
234set TYPE Ecore_Con_Event_Url_Data
235set TYPE Ecore_Con_Event_Url_Complete
236set TYPE Ecore_Con_Event_Url_Progress
237set TYPE Ecore_DirectFB_Window
238set TYPE Ecore_Win32_Window
239set TYPE Ecore_WinCE_Window
240set TYPE Ecore_Cocoa_Window
241set TYPE Ecore_Evas
242set TYPE Ecore_Getopt_Desc_Callback
243set TYPE Ecore_Event_Signal_Realtime
244set TYPE Ecore_Exe_Event_Data_Line
245set TYPE Ecore_Fd_Handler
246set TYPE Ecore_Animator
247set TYPE Ecore_Timer
248set TYPE Ecore_Idle_Enterer
249set TYPE Ecore_Thread
250set TYPE Ecore_Pipe
251set TYPE Ecore_Job
252set TYPE Ecore_IMF_Event_Delete_Surrounding
253set TYPE Ecore_Ipc_Server
254set TYPE Ecore_Ipc_Client
255set TYPE Ecore_Ipc_Event_Client_Data
256set TYPE Ecore_Ipc_Event_Server_Data
257set TYPE Ecore_X_Event_Randr_Output_Property_Notify
258set TYPE Ecore_X_Event_Damage
259set TYPE Ecore_X_Image
260set TYPE Evas_Engine_Info_Buffer
261set TYPE Evas_Engine_Info_Software_X11
262set TYPE Evas_Native_Surface
263set TYPE Evas_Pixel_Import_Source
264set TYPE Evas_Event_Mouse_Down
265set TYPE Evas_Event_Mouse_Move
266set TYPE Evas_Event_Mouse_Wheel
267set TYPE Evas_Event_Multi_Down
268set TYPE Evas_Event_Multi_Move
269set TYPE Edje_Edit_Script_Error
270set TYPE Edje_Message_String_Float_Set
271set TYPE Edje_External_Param
272set TYPE Edje_External_Param_Info
273set TYPE Edje_External_Type
274set TYPE Edje_External_Type_Info
275set TYPE Efl_Event
276set TYPE Eo
277set TYPE Efl_Object
278set TYPE Evas_Object
diff --git a/tools/format/vscode_format_guide b/tools/format/vscode_format_guide
new file mode 100644
index 0000000..487b0e3
--- /dev/null
+++ b/tools/format/vscode_format_guide
@@ -0,0 +1,32 @@
1Visual Studio Code EFL Style Format Guide
2
31. Install ecrustify from formatting git(https://git.enlightenment.org/tools/formatting.git/)
4 $git clone https://git.enlightenment.org/tools/formatting.git/
5 $cd formatting/ecrustify
6 $./autogen.sh
7 $make -j8 && sudo make install && sudo ldconfig
8 $ecrusity --version
9
102. Copy ecrustify.cfg file in this directory to user local config path.
11
123. Download Uncrustify VSCode Extension(https://github.com/LaurentTreguier/vscode-uncrustify)
13 and apply my 0001-Add-new-Feature-Selection-Range-Formatting.patch in Uncrustify Extension.
14 $git clone https://github.com/LaurentTreguier/vscode-uncrustify.git
15 $cp {PATH}/0001-Add-new-Feature-Selection-Range-Formatting.patch ./vscode-uncrustify
16 $cd vscode-uncrustify
17 $git apply 0001-Add-new-Feature-Selection-Range-Formatting.patch
18
194. Launch VSCode and open uncrustify extension directory and test debugging.
20 Edit your settings.json with adding below commands.
21
22 "C_Cpp.clang_format_path": null,
23 "uncrustify.executablePath": "ecrustify",
24 "uncrustify.configPath": "{LOCAL_CONFIG_PATH}/ecrustify.cfg",
25 "uncrustify.graphicalConfig": false
26
27 Default Key Binding :
28 Full Document Formatting : Shift + Ctrl + I (This may be overrided by some other operation)
29 Selected Range Formatting : Ctrl + K + F
30
315. Install vscode-uncrustify to VSCode.
32 Copy vscode-uncrustify to ~/.vscode/extensions/