Sign in Join
Wiki copytemporary

CudaText plugins: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11## Comments
22
33You can add/remove code comments, via "Comments" plugin. Plugin is preinstalled in CudaText. It gives about 6 commands in menu "Plugins / Comments". Plugin supports only adding/removing of comments, not syntax highlighting for them (highlighting is lexer's work).
44
55- **Line comments**: from some position to the nearest end-of-line. E.g. in C lexer: "//text here", in Python lexer: "# text here".
66- **Comments for range** (**Stream comments**): from some text position to some bigger text position, often in the different line. E.g. in C lexer: "/* text here */".
77- **Comments for full lines**: from newline to another newline, ie comment for several whole lines. Rarely used, e.g. used in PowerShell.
88
99For example, Python lexer supports only line comment, and don't support stream comments. PowerShell lexer supports comments for full lines, while don't support comments for any range.
1010
1111Comment chars are editable in SynWrite editor, in dialog "Lexer properties" (after you install the same lexer to SynWrite). In dialog tab "Commenting" you'll see input fields.
1212
1313Command "Toggle stream comment" in plugin adds/removes comments of last 2 types: for range, for full lines (plugin chooses needed kind).
1414
1515Where comment chars are stored:
1616
1717- Line comments: in lexer file data/lexlib/*.lcf.
1818- Range comments: in additional file data/lexlib/*.cuda-lexmap.
1919
2020### Commenting options
2121
2222Plugin "Comments" has several options, and it gives the dialog to change them: menu item "Options / Settings-plugins / Comments / Config".
2323
2424**(Line commands) Try to keep text position after (un)commenting**
2525
2626Affects all commands for line-comments.
2727
2828With option on, plugin tries to insert comment chars into leading space-area of the line. For example, with C++ (line comment chars "//"), line with 4 leading spaces:
2929
3030`    code();`
3131
3232will be changed to line with 2 leading spaces:
3333
3434`  //code();`
3535
3636After uncommenting, line will be restored to original, with 4 leading spaces.
3737
3838**(Line "at non-space") If selected few lines, insert comment at maximal common indent**
3939
4040Affects commands:
4141
4242- "Toggle line comment, at non-space char"
4343- "Add line comment, at non-space char"
4444
4545With option on, this selected block of lines in C++:
4646
4747`      code1();`\
4848`    code2();`\
4949`        code3();`
5050
5151will be changed to:
5252
5353`    //  code1();`\
5454`    //code2();`\
5555`    //    code3();`
5656
5757With option off, block will be changed to:
5858
5959`      //code1();`\
6060`    //code2();`\
6161`        //code3();`
6262
6363**(All) Move caret to next line**
6464
6565Affects commands for line-comments, when they are called without selection.
6666
6767With option on, caret will be moved 1 line down. This allows to call the command many times repeatedly, to change many lines.
6868
6969**(Line commands) Skip blank lines**
7070
7171Affects commands for line-comments, when they are called without selection.
7272
7373With option on, and the previous option "Move caret to next line" on, command will skip lines containing only space/tab chars.
7474
7575**"Toggle line comment" detects action by first non-blank line**
7676
7777Affects command "Toggle line comment".
7878
7979With option on, command detects its action (to comment or to uncomment) by the first non-blank line of the selected multi-line block.
8080
8181Here is selected block of code, selection is shown by square brackets, first selected line is blank line:
8282
8383`[`\
8484` `\
8585`    //code1();`\
8686`    code2();`\
8787`    //code3();`\
8888`    code4();`\
8989`]`
9090
9191With option off, block will be changed it to:
9292
9393`[//`\
9494`//`\
9595`    //code1();`\
9696`    //code2();`\
9797`    //code3();`\
9898`    //code4();`\
9999`]`
100100
101101With option on, block will be changed to:
102102
103103`[`\
104104` `\
105105`    code1();`\
106106`    code2();`\
107107`    code3();`\
108108`    code4();`\
109109`]`
110110
111111## Macros
112112
113113Macro is a sequence of CudaText actions, which can be saved to a file and invoked later by some command. To use macros, you must install plugin "Macros" from Addon Manager. It adds "Macros" menu to CudaText main menu bar. This menu gives items:
114114
115115- Macros...
116116- Start/stop recording
117117- Playback last recorded macro
118118- Export...
119119- Import...
120120- items for saved macros
121121
122-<figure>
123-<img src="cudatext-macro-menu.png" title="cudatext-macro-menu.png" />
124-<figcaption>cudatext-macro-menu.png</figcaption>
125-</figure>
122+![](/wiki-images/a/a3/Cudatext-macro-menu.png)
126123
127124To record a macro:
128125
129126- Call menu item "Macros / Start/stop recording", or use dialog "Macros / Macros..." which gives the button for this.
130127- Perform some actions in CudaText:
131128 - built-in commands, plugin commands (invoked by hotkey, by menu, by Command Palette)
132129 - some mouse actions (clicks/selections, they save/playback relative to caret position)
133130 - calling of Find/Replace dialog, "Go to" dialog
134131 - actions in Find/Replace dialog
135132- Call menu item "Macros / Start/stop recording" again, plugin will ask for macro name.
136133
137134During recording, CudaText shows reddish border around the editor field.
138135
139-<figure>
140-<img src="cudatext-macro-border.png" title="cudatext-macro-border.png" />
141-<figcaption>cudatext-macro-border.png</figcaption>
142-</figure>
136+![](/wiki-images/4/4c/Cudatext-macro-border.png)
143137
144138Macro saves action(s) performed inside its original editor ui-tab (but not other ui-tabs). Calling of additional dialogs (including plugin dialogs) will be recorded too. But macro doesn't save actions inside those dialogs.
145139
146140To playback macro:
147141
148142- Call menu item "Macros / macro_name", the end of this menu lists all available/saved macros.
149143- Or call dialog "Macros / Macros...", which allows to run all available macros:
150144 - running 1 time
151145 - running specified count of times
152146 - running in the loop, by options:
153147 - While text changes
154148 - Until caret on last line
155149
156150### Macro example
157151
158152For example, we have text line with HTML tags like this ("\|" shows the caret):
159153
160154`....<tag>....|...........</tag>....`
161155
162156For example, we need a macro which selects text from lefter "\>" char to righter "\<" char (ie text inside HTML tag). This action can be done via "markers" commands in Command Palette: "drop marker at caret" and "select to last marker".
163157
164158So, during macro recording, run these commands:
165159
166160- call Find dialog (or focus it with mouse), search for "\>" with "Find previous" button
167161- right-arrow key (to reset the selection)
168162- "markers: drop marker at caret"
169163- call Find dialog again (or focus it with mouse), search for "\<" with "Find next" button
170164- left-arrow key, 2 times (to reset the selection)
171165- "markers: select to last marker"
172166- "markers: remove all"
173167
174168## Project Manager
175169
176170This plugin is preinstalled in CudaText. It shows panel "Project" in the sidebar (to show this panel, call plugin by any command, or call "File / Open folder..." menu item which opens any folder as a "project"). On the project panel, on its tree-view, you can add several "root nodes", each node must be existing file or folder. For folder nodes, plugin auto shows all nested folders. You cannot add nodes on other levels, sub-nodes are auto populated from root folder nodes.
177171
178172Plugin has context menu on its panel, with items:
179173
180174- **Project file**
181175 - New project
182176 - Open project
183177 - Recent projects
184178 - Save project as...
185179 - Go to file... - this shows menu with all project files, and then tree-view selection jumps on selected file
186180 - Project properties... - this shows dialog with current project's options
187181 - Config... - this shows dialog with global Project Manager options
188182- **Root nodes** - commands for nodes on the project's root level
189183 - Add folder...
190184 - Add file...
191185 - Clear project
192186 - Remove node
193187- **Selected file** - it's shown only for files
194188- **Selected directory** - it's shown only for folders
195189- **Refresh** - it re-reads state of files/folders from disk
196190
197191To manage the selected file/folder, use context menu items "Selected file"/"Selected directory". They give useful sub-items for file operations, like shown on the picture:
198192
199-<figure>
200-<img src="cudatext-project-seldir.png" title="cudatext-project-seldir.png" />
201-<figcaption>cudatext-project-seldir.png</figcaption>
202-</figure>
193+![](/wiki-images/a/a7/Cudatext-project-seldir.png)
203194
204195Any project can have **main file**, you can choose it in the context menu: "Selected file / Set as main file". Main file's path is used by plugin External Tools, when some tool is configured with macro {ProjMainFile}. This allows tools to run compilation of the main file.
205196
206197Sometimes you may want **to forget the "temporary" project** which CudaText may create from Windows Explorer context menu. To do this, just call "Project file / New project" from the right-click menu over the project panel. This does not delete the file "settings/temporary.cuda-proj", but that file will be overwritten soon.
207198
208199### Project Manager options dialog
209200
210201"Ignore files"
211202";"-separated shell wildcards, which are [documented here](https://docs.python.org/3/library/fnmatch.html). If file name (without path) matches any of these wildcards, it will not be listed in the treeview.
212203
213204"Ignore folders"
214205";"-separated shell wildcards. If folder name matches any of these wildcards, it will not be listed in the treeview.
215206
216207"Ignore all hidden files/folders"
217208Additionally don't list all hidden items. On Unix, hidden mean "beginning with dot". On Windows, hidden means having file-system "hidden" attribute.
218209
219210"Open file after "Go to file" command"
220211If turned on, command "Project Manager: Go to file" will not only jump to chosen file in the treeview, but also open that file in editor.
221212
222213"Use 'preview tab' on item clicking"
223214If option is on, single click on treeview file item, will open file in "preview tab". Preview tab is single such tab, it's shared by all files, it has italic+underlined tab title. If option is off, clicking file item will open normal tab, separate normal tabs per each file.
224215
225216"Open files by double-click"
226217If turned on, only double-click in the treeview will open file for editing, but not the single click.
227218
228219"On opening file in Git/SVN repo..."
229220On opening a file in CudaText, Project Manager will check if this file is in the Git/SVN repository (by presence of the folder ".git" or ".svn" near the file, or in upper level folders). If yes, Project Manager will create the project from that repository and open it. This gives some slowdown of course.
230221
231222"Suggest to close tabs not belonging to project"
232223See #Sessions embedded to project.
233224
234225And options for icons:
235226
236227"File type icons"
237228Set of file/folder icons for treeview. You can install additional themes from Addons Manager, see category "filetypeicons" there. Example of such theme: "VSCode Material 24x24". This option shows themes, which are present in the folder "data/filetypeicons".
238229
239230"Toolbar icons"
240231Set of icons for Project Manager toolbar buttons. You can install additional themes from Addon Manager, see the category "projtoolbaricons" there. This option shows themes, which are present in the folder "data/projtoolbaricons".
241232
242233### Preview tab
243234
244235To see the "preview tab", call "File / Open folder" and choose a folder with some files. Folder will be opened in the side panel "Project". Make single click on a file in this project, it will open in the "preview tab". Single "preview tab" is shared by all clicked (in the project) files. It has italic font style of the caption (font style is customizable). When you begin to edit file in the "preview tab", tab becomes "normal" and looses its special status.
245236
246237"Preview tab" is always **created in the first tab-group**, even if the focused editor is located in different tab-group. It was made on purpose, to avoid the situation when "preview tab" jumps from one tab-group to another.
247238
248239Again, if you click different items in the Project Manager, and files are opened **in the first tab-group**, it's not a bug. If you need to open clicked files in different tab-groups, you can do it - by unchecking the option "Use preview tab on item clicking" in the Project Manager options.
249240
250241"Preview tab" can be dragged to another tab-group, it should work there too.
251242
252243### Switch between projects
253244
2542451\) To switch to different project, Plugin Manager gives the context menu: "Project File / Recent projects / name.cuda-proj".
255246
2562472\) Another way is using the plugin "Favorites". It gives the dialog (can be called by a hotkey), with 2 tabs: "Files" and "Projects", so you can choose one of your favorite projects from a listbox.
257248
2582493\) There is also a way to quickly switch between projects:
259250
260251- Install plugins: "Config Toolbar", "External Tools" and "Session Manager". Restart CudaText.
261252- Set CudaText option "ui_one_instance": true.
262253- In "External Tools" make a tool which starts CudaText (yes, from within CudaText) with parameter: full path of a project. The command line can look like: "c:\Apps\cudatext.exe "c:\Apps\some_project.cuda-proj"". You can add here additional parameter: full path of a session file, *.cuda-session / *.json. So this external tool will open given project (and maybe a session too). It will open it inside the same CudaText instance (because "ui_one_instance":true).
263254- Add more such tools in the "External Tools", for different projects (and maybe sessions).
264255
265-<figure>
266-<img src="cudatext-tools-and-projects.png" title="cudatext-tools-and-projects.png" />
267-<figcaption>cudatext-tools-and-projects.png</figcaption>
268-</figure>
256+![](/wiki-images/5/58/Cudatext-tools-and-projects.png)
269257
270258- In the plugin "Config Toolbar", add the toolbar drop-down menu, with menu-items referring to different tools. Or add the individual menu-items for separate tools.
271259
272-<figure>
273-<img src="cudatext-tools-and-projects-config.png" title="cudatext-tools-and-projects-config.png" />
274-<figcaption>cudatext-tools-and-projects-config.png</figcaption>
275-</figure>
260+![](/wiki-images/9/9b/Cudatext-tools-and-projects-config.png)
276261
2772624\)
278263
279264- Install plugin "Config Toolbar" (only 1 plugin here, comparing to the previous method).
280265- CudaText option "ui_one_instance" can be any.
281266- In the plugin "Config Toolbar", add the toolbar button which will switch the project and/or session. The properties of this button are tricky. In the "Command" property of the button, you must enter "exec=path_of_project_file path_of_session file". You cannot type this directly to the dialog field, but you should press the "Enter command line..." button in the dialog and enter the command line contents (full path of .cuda-proj file and/or full path of .cuda-session file). "Config Toolbar" will store your command line with the "exec=" prefix.
282267- CudaText will use the new command-line which you entered after "exec=".
283268
284269### Sessions embedded to project
285270
286271CudaText supports sessions which are not separate JSON files (*.cuda-session or *.json) but are embedded into project file (*.cuda-proj). Session is still having the same JSON format, but it's nested 2 levels into the project JSON file. Such embedded sessions are visible only to the Project Manager. When an embedded session is active, CudaText window title shows this in curly brackets: "{project_name:session_name}".
287272
288273To control sessions, use the "gear" button on the Project Manager toolbar. Several menu items are there:
289274
290275- "Project session: name". One or more menu items, one item per each session.
291276- "Save session...". Shows text input prompt, to name a session (you will be warned if you use incorrect characters or session already exists).
292277- "Delete session". Shows menu to choose which session to delete from the project.
293278- "Set default session". After you choose a session here, it will be marked in the project file, and will be auto-loaded on next project opening.
294279- "Forget session, close all tabs".
295280
296281Project Manager has the option checkbox "Suggest to close tabs not belonging to project". When option is on, you will see such confirmation message box:
297282
298283`CudaText has opened 3 tab(s) not belonging to the project "name". Close them?`\
299284`/path/to/file1`\
300285`/path2/to/file2`\
301286`*Untitled1`
302287
303288You will see this confirmation when doing:
304289
305290- "New project" action (from Project Manager context menu, or from Command Palette)
306291- "Save session..." action (from "gear" popup menu, or from Command Palette)
307292
308293You can disable that option (or press "Cancel" in the confirmation), to save even "not belonging" opened files to embedded session.
309294
310295## How to bind a hotkey to insert a snippet
311296
312297You can create plugin to insert any text fragment by any hotkey. First, create the plugin which gives the command to insert your fragment. Next, find this plugin in the Command Palette, press F9 and assign a hotkey there.
313298
314299Let's show how to make a primitive plugin which has 2 primitive commands:
315300
316301- Insert snippet "AA" at the caret position (supporting multi-carets).
317302- Surround current line with square brackets.
318303
319304Make a new plugin by calling menu item "Plugins / Make Plugin". Fieds of dialog:
320305
321306- "Plugin name": set to "My plugin".
322307- "Python module name": set to "my_snippet".
323308- "Commands caption\>method": set 2 lines:
324309
325310`My snippet>my_snippet`\
326311`My edit>my_edit`
327312
328313This will generate new plugin with 2 methods in the file "__init__.py": my_snippet and my_edit. Code will be like this:
329314
330315``` python
331316 def my_snippet(self):
332317 #
333318 #
334319 #
335320 msg_box(s, MB_OK)
336321
337322 def my_edit(self):
338323 pass
339324```
340325
341326At the top of the Python file, near "import" operators, add:
342327
343328``` python
344329import cudatext_cmd as cmds
345330```
346331
347332Now edit methods my_snippet / my_edit:
348333
349334``` python
350335 def my_snippet(self):
351336 ''' Insert my snippet '''
352337 ed.cmd(cmds.cCommand_TextInsert, 'AA')
353338
354339 def my_edit(self):
355340 ''' Surround line with brackets '''
356341 x, y, x1, y1 = ed.get_carets()[0]
357342 s = ed.get_text_line(y)
358343 s = '[' + s + ']'
359344 ed.set_text_line(y, s)
360345 msg_status('Edited!')
361346```
362347
363348All done. Restart CudaText. You must have new menu items:
364349
365350- "Plugins / My plugin / My snippet"
366351- "Plugins / My plugin / My edit"
367352
368353In the Command Palette, find these new commands, press F9 to set hotkey for them.
369354
370355## Snippets
371356
372357To use snippets you need:
373358
374359- Plugin "Snippets" (install from Addon Manager)
375360- Snippet package for needed lexer (install from Addon Manager)
376361
377362Each snippet has a name (shown in the dialog when Snippets plugin is called) and short id (letters, digits, '_', dot). You can type id in the editor and press the Tab key: snippet for this id will be inserted into text. You can also call the menu of snippets: menu item "Plugins / Snippets / Snippets menu...".
378363
379364Only those snippets are enabled, which are suitable for the current lexer. Snippet's "lexer" property can be "C,C++,Objective C" - then snippet is enabled only when one of these 3 lexers is active. If snippet has empty "lexer" property, it is always enabled.
380365
381366Dialog of Snippets plugin:
382367
383-<figure>
384-<img src="cudatext_snippets_menu.png" title="cudatext_snippets_menu.png" />
385-<figcaption>cudatext_snippets_menu.png</figcaption>
386-</figure>
368+![](/wiki-images/a/af/Cudatext_snippets_menu.png)
387369
388370Texts of snippets usually have tab-stop(s), e.g. \${1:some_text}. Plugin Snippets finds tab-stops and places "markers" for them. After markers are placed, Tab-key works specially: it jumps to the next marker. See detailed information in the [[CudaText|CudaText#Markers]].
389371
390372Plugin supports two snippets folder, but formats of data are the same, VSCode JSON format:
391373
392374- CudaText snippets. These are packages with prefix "snippets_ct" in the Addons Manager. They are installed into folder CudaText/data/snippets_ct.
393375- VSCode snippets. These are VSCode packages located in the VSCode repositories. Read the separate topic about them below. They are installed to folder CudaText/data/snippets_vs.
394376
395377### Snippets from VSCode
396378
397379Since recent versions, Snippets plugin supports snippets from VSCode editor. It gives menu items in "Plugins / Snippets":
398380
399381- "Install VSCode snippets..." - this suggests to install packages with snippets (packages usually contain more functionality, and CudaText plugin will install only snippets).
400382
401-<figure>
402-<img src="cudatext-snippets-add-vscode.png" title="cudatext-snippets-add-vscode.png" />
403-<figcaption>cudatext-snippets-add-vscode.png</figcaption>
404-</figure>
383+![](/wiki-images/b/b6/Cudatext-snippets-add-vscode.png)
405384
406385- "Remove VSCode snippets"
407386- "Visit homepage of VSCode snippets..."
408387- "Convert snippets package from old format" - this takes snippets in old .cuda-snippet format (if you have some old ones) and converts them to VSCode JSON format.
409388
410389Plugin also gives the fully featured snippet editor dialog, in menu item "Add/edit snippets...".
411390
412-<figure>
413-<img src="cudatext-snippets-editor.png" title="cudatext-snippets-editor.png" />
414-<figcaption>cudatext-snippets-editor.png</figcaption>
415-</figure>
391+![](/wiki-images/b/bc/Cudatext-snippets-editor.png)
416392
417393You can create group of snippets (in the "Manage snippets" dialog) for all lexers. To do so, enter "*" value in the "Group's lexers" field of dialog.
418394
419395Currently most of VSCode/TextMate "macros" are supported in snippets body, but not all. Refer to readme file of the plugin.
420396
421397### Snippets for HTML tags
422398
423399CudaText has preinstalled 120+ snippets for HTML tags. (You still need to install Snippets plugin.) They are enabled with HTML lexer. Just type tag name without a bracket, press Tab, and snippet is inserted. E.g. "a"\<Tab\> will insert:
424400
425401` <a href="http" title="Title" target="_blank"></a>`
426402
427403These snippets have markers, so Tab key jumps to the next marker. Last marker is usually placed after the entire tag, ie after "\>" bracket.
428404
429405### Format of snippet files
430406
431407#### Snippets tab-stops
432408
433409Specify tab-stops in the snippet text like this:
434410
435411- \${NN}
436412- \${NN:default text}
437413
438414This places markers (AKA tab-stops) in the editor, marker index NN should be from 0 to 40. After snippet insertion, tab-key goes to next marker(s) and deletes it.
439415
440416- Markers can be listed in any order (e.g. marker 4 can be between 1 and 2).
441417- Tab-key first goes to marker 1, 2, 3... and marker 0 is always the last.
442418- Markers with the same indexes will place multi-carets.
443419- Nested markers (with default text) are allowed, but only with one nesting level, e.g. \${2:text is {\$3:here}}.
444420- Marker with default text \${NN:...} can specify multi-line default text (character "}" is on another line of snippet).
445421
446422#### Snippets macros
447423
448424Special macros are handled by Snippets plugin in snippet text:
449425
450426- \${sel} - Text selected before snippet insertion (if snippet called with Tab key, it's empty string)
451427- \${cp} - Current clipboard contents
452428
453429- \${cmt_start} - Current lexer's "block comment" start symbols (or empty string)
454430- \${cmt_end} - Current lexer's "block comment" end symbols (or empty string)
455431- \${cmt_line} - Current lexer's "line comment" symbols (or empty string)
456432
457433- \${fname} - File name only, without path
458434- \${fpath} - Full file name, with path
459435- \${fdir} - Directory of file
460436- \${fext} - Extension of file
461437- \${psep} - OS path separator: backslash on Windows, slash on Unix
462438
463439- \${date:nnnn} - Current date/time formatted by string "nnnn"; see [Python docs](http://strftime.org/)
464440- \${env:nnnn} - Value of OS environment variable "nnnn"
465441- \${cmd:nnnn} - Execute shell command "nnnn" and get its output (space-separated arguments are supported, '~' for home-directory is supported on Unix)
466442
467443The following macros from Sublime Text editor are supported. They can be written as \$NAME or as \${NAME}.
468444
469445- \$TM_SELECTED_TEXT - The currently selected text or the empty string
470446- \$TM_CURRENT_LINE - The contents of the current line
471447- \$TM_CURRENT_WORD - The contents of the word under cursor or the empty string
472448- \$TM_LINE_INDEX - The zero-based line number
473449- \$TM_LINE_NUMBER - The one-based line number
474450- \$TM_FILEPATH - The full file path of the current document
475451- \$TM_DIRECTORY - The directory of the current document
476452- \$TM_FILENAME - The filename of the current document
477453- \$TM_FILENAME_BASE - The filename of the current document without its extensions
478454- \$CLIPBOARD - The contents of your clipboard
479455- \$WORKSPACE_NAME - The name of the opened workspace or folder
480456
481457- \$BLOCK_COMMENT_START - Current lexer's "block comment" start symbols (or empty string)
482458- \$BLOCK_COMMENT_END - Current lexer's "block comment" end symbols (or empty string)
483459- \$LINE_COMMENT - Current lexer's "line comment" symbols (or empty string)
484460
485461For inserting the current date and time:
486462
487463- \$CURRENT_YEAR - The current year
488464- \$CURRENT_YEAR_SHORT - The current year's last two digits
489465- \$CURRENT_MONTH - The month as two digits (e.g. '02')
490466- \$CURRENT_MONTH_NAME - The full name of the month (e.g. 'July')
491467- \$CURRENT_MONTH_NAME_SHORT - The short name of the month (e.g. 'Jul')
492468- \$CURRENT_DATE - The day of the month
493469- \$CURRENT_DAY_NAME - The name of day (e.g. 'Monday')
494470- \$CURRENT_DAY_NAME_SHORT - The short name of the day (e.g. 'Mon')
495471- \$CURRENT_HOUR - The current hour in 24-hour clock format
496472- \$CURRENT_MINUTE - The current minute
497473- \$CURRENT_SECOND - The current second
498474- \$CURRENT_SECONDS_UNIX - The number of seconds since the Unix epoch
499475
500476## Snippet Panel
501477
502478Plugin "Snippet Panel" is preinstalled in CudaText. It gives an alternative way to use short text fragments (only simple ones) in editor. It adds button to sidebar, and command "Plugins / Snippet Panel". When called, plugin shows panel in the sidebar, with a drop-down list of folders, which contain several "snippets". You can double-click snippets to insert them into text (multi-carets are supported).
503479
504480Preinstalled folders:
505481
506482- Arrows
507483- Currency symbols
508484- Greek alphabet (lower)
509485- Greek alphabet (upper)
510486- HTML - Arrows
511487- HTML - Color names
512488- HTML - Color names+values
513489- HTML - Letters
514490- HTML - Math symbols
515491- HTML - Special characters
516492- Math symbols
517493- Quote selection
518494- Special characters
519495
520496Plugin looks for its folders in two places:
521497
522498- Folder "clips" in the plugin folder.
523499- Folder CudaText/data/clips, which is absent by default, for custom user folders.
524500
525501Each snippet folder can contain one or more .txt files, in UTF-8 (no BOM) or UTF-16 (with BOM) encoding. Files have snippet per line, in the form "name=value" or simply "name" (if value missed, it equals to name). Each snippet can be simple short string, or string with \${sel} macro to replace selected text. This allows to quote currently selected text by calling snippets from "Quote selection" folder.
526502
527503## CudaLint
528504
529505CudaLint plugin allows to check correctness of documents in many syntaxes. It was initially ported from SublimeLinter 2.x plugin for Sublime Text. Each lexer must be supported with additionally installed linter, for example:
530506
531507- JavaScript is supported with linter based on JSLint tool,
532508- HTML is supported with linter based on HTML Tidy tool,
533509- CSS is supported with linter based on CSSLint tool,
534510- etc
535511
536512You will find all linters in the Addon Manager: "Plugins / Addon Manager / Install". Linters are installable like other plugins but they don't add commands, they only add folders "\[CudaText\]/py/cuda_lint_*", which are automatically used by CudaLint. After you install a linter, see readme in its folder, maybe how-to-use info is written there.
537513
538514### Linters - usage
539515
540516To run linting, use menu item "Plugins / CudaLint / Lint", or set hotkey to this command (in CudaText Command Palette, press F9). You will see statusbar message, which tells how many errors linter found. For each found error, you'll see yellow/red bookmark (you can use usual commands for these bookmarks). Plugin also shows list of errors in the "Validate" panel (to show Validate panel, click V icon on the CudaText sidebar).
541517
542518Linting can also be run by events:
543519
544520- after opening file
545521- on saving file
546522- after text is changed + pause passed
547523
548524Events aren't used by default (to not slowdown usual work). To use events, you must enable them in config. Call config by menu item in "Options / Settings-plugins".
549525
550526### Linters - Node.js
551527
552528Some linters require Node.js, so for those linters, you must install Node first. Those linters are sometimes shipped with Node modules preinstalled (in plugin folder) and sometimes you need to install Node modules via NPM. See linter's readme file for details.
553529
554530- Windows: "node.exe" must be in PATH, command "node -v" must work in console.
555531- Linux: "nodejs" package must be installed, command "nodejs -v" must work in terminal.
556532
557533### Linters - authoring
558534
559535To support more lexers, it's a good idea to port linter from SublimeLinter. To port a linter, most you need is:
560536
561537- Fix "imports" to use "cuda_lint" module, instead of SublimeLinter modules. cuda_lint gives almost the same classes which SublimeLinter gives. Except Node.js linter class - it's not supported yet. Usual Linter and PythonLinter classes are supported.
562538- Change syntax name (for Sublime Text) to CudaText lexer name, names are often different. If no such lexer for CudaText exists yet, ask for it.
563539- Remove in linter usage of Sublime Text API to read settings (often used in linters). You can add usage of settings via CudaText API ini_read, or via json module.
564540- If linter was using Node.js, take some code to run Node, from cuda_lint_csslint linter.
565541
566542### Linters - per project
567543
568544How to configure linters per project? In your project (Project Manager plugin), right-click root node of project treeview, call menu item "Project file / Project properties...". In this dialog, in the "Variablies" field, enter variable(s) like this:
569545
570546`linter_css=csslint`
571547
572548Variable prefix "linter_" required, after goes lower-case lexer name (CSS). Value of variable must be name of linter's folder (in "py" folder) without "cuda_lint_". So if linter's folder is py/cuda_lint_aaa, specify value "aaa".
573549
574550In this example, CudaLint plugin allows, for mentioned lexer CSS, only linter "csslint", even if another CSS linter (e.g. "csstree") is installed and found first.
575551
576552### Linters - method split_match
577553
578554Linters have RegEx property in class, which must find named groups:
579555
580556- "line": Line index.
581557- "col": Column index.
582558- "error": If found then CudaLint will force "error" gutter icon.
583559- "warning": If found then CudaLint will force "warning" gutter icon.
584560- "message": Message text.
585561
586562Group "file" or "filename" is not used by CudaLint, but it may present for internal linter's handling, e.g. to ignore the line containing wrong filename.
587563
588564Example from SublimeLinter's linter for "Luau":
589565
590566``` python
591567class Luau(Linter):
592568 cmd = 'luau-analyze --formatter=gnu -'
593569 regex = r'^stdin:(?P<line>\d+)\.(?P<col>\d+)\-(?P<end_line>\d+)\.(?P<end_col>\d+): (?P<code>\w+): (?P<message>.+)'
594570```
595571
596572Sometimes, finding "error"/"warning" named groups is hard, and class method "split_match" can help here. Example from SublimeLinter's linter for "Luau":
597573
598574``` python
599575 def split_match(self, match):
600576 error = super().split_match(match)
601577 error['error_type'] = 'error' if error['code'].endswith('Error') else 'warning'
602578 return error
603579```
604580
605581If CudaLint linter uses "split_match" it must be different. We cannot read error\['code'\] and cannot write error\['error_type'\]. We must adapt code to this:
606582
607583``` python
608584 def split_match(self, match):
609585 matches, line, col, error, warning, message, near = super().split_match(match)
610586 is_error = matches.group('code').endswith('Error')
611587 error = is_error
612588 warning = not is_error
613589 return matches, line, col, error, warning, message, ''
614590```
615591
616592CudaLint needs 7 tuple items in split_match() result:
617593
618594- matches: RegEx match object
619595- line: Line index
620596- col: Column index
621597- error: Error state; if casted to True, line will have "error" icon (red)
622598- warning: Warning state; if casted to True, line will have "warning" icon (yellow)
623599- message: Message string
624600- near: Ignored in CudaLint
625601
626602Example from CudaLint linter for Java. We override method because javac lints all referenced files, and we only want errors from the linted file.
627603
628604``` python
629605 def split_match(self, match):
630606 if match:
631607 if match.group('file') != self.filename:
632608 match = None
633609 return super().split_match(match)
634610```
635611
636612Example from CudaLint linter for Haml. We override method to set the line/col to 0 if a linter error occurs and there is no line number.
637613
638614``` python
639615 def split_match(self, match):
640616 match, line, col, error, warning, message, near = super().split_match(match)
641617 if line is None:
642618 line = col = 0
643619 return match, line, col, error, warning, message, near
644620```
645621
646622Example from CudaLint linter for AutoIt. Here we modify the message/error/warning.
647623
648624``` python
649625 def split_match(self, match):
650626 split_match = super(AutoIt, self).split_match(match)
651627 match, line, col, error, warning, message, near = split_match
652628 message = '{} (Col {})'.format(message, col)
653629
654630 if match and match.group('type') == 'error':
655631 error = 1
656632 message = 'Error: ' + message
657633 elif match and match.group('type') == 'warning':
658634 warning = 1
659635 message = 'Warning: ' + message
660636
661637 return match, line, col, error, warning, message, ''
662638```
663639
664640Example from CudaLint linter for JavaScript using ESLint. We override this method to silent warning by .eslintignore settings.
665641
666642``` python
667643 def split_match(self, match):
668644 v1message = 'File ignored because of your .eslintignore file. Use --no-ignore to override.'
669645 v2message = 'File ignored because of a matching ignore pattern. Use --no-ignore to override.'
670646
671647 match, line, col, error, warning, message, near = super().split_match(match)
672648 if message and (message == v1message or message == v2message):
673649 return match, None, None, None, None, '', None
674650
675651 return match, line, col, error, warning, message, near
676652```
677653
678654Example from CudaLint linter for PowerShell using PSScriptAnalyzer. We return the match with \` quotes transformed to '. We supress one message.
679655
680656``` python
681657 def split_match(self, match):
682658 match, line, col, error, warning, message, near = super().split_match(match)
683659
684660 if message == 'no PowerShell code found at all':
685661 match = None
686662 else:
687663 message = message.replace('`', '\'')
688664
689665 # If the message contains a complaint about a function
690666 # and near looks like a function reference, remove the trailing
691667 # () so it can be found.
692668 if 'function \'' in message and near and near.endswith('()'):
693669 near = near[:-2]
694670
695671 return match, line, col, error, warning, message, near
696672```
697673
698674Example from CudaLint linter for Ruby. We override method because unrelated library files can throw errors, and we only want errors from the linted file.
699675
700676``` python
701677 def split_match(self, match):
702678 if match:
703679 if match.group('file') != '-':
704680 match = None
705681 return super(Ruby,self).split_match(match)
706682```
707683
708684Example from CudaLint linter for CSSLint. We override method so that general errors that do not have a line number can be placed at the beginning of the code.
709685
710686``` python
711687 def split_match(self, match):
712688 match, line, col, error, warning, message, near = super().split_match(match)
713689 if line is None and message:
714690 line = 0
715691 col = 0
716692 return match, line, col, error, warning, message, near
717693```
718694
719695Example from CudaLint linter for Haskell. We override method to ignore errors reported in imported files.
720696
721697``` python
722698 def split_match(self, match):
723699 match, line, col, error, warning, message, near = super().split_match(match)
724700 match_filename = os.path.basename(match.groupdict()['filename'])
725701 if not match_filename.startswith('_CudaLint_'):
726702 return None, None, None, None, None, '', None
727703 return match, line, col, error, warning, message, near
728704```
729705
730706## CudaFormatter
731707
732708CudaFormatter is plugin which uses 2nd-level plugins, "formatters", to change the source code. Each "formatter" supports one or more lexers, and provides one or more actions. For example, the Addon Manager contains two formatters for XML: XML IndentX and XML Pretty Print.
733709
734710CudaFormatter is located in the "plugins" category of Addons Manager install list. 2nd-level "formatters" are located in the "formatter" category of Addons Manager install list.
735711
736712For example, how to format code in XML?
737713
738714- Use "Plugins / Addon Manager / Install" to install the CudaFormatter, and formatter(s) for XML. Restart CudaText.
739715- Open XML file (normal or "lite" lexer XML must activate).
740716- Use "Plugins / CudaFormatter / Formatter (menu)". This will show the menu of actions from appropriate formatter(s) for the XML (normal or "lite") lexer.
741717
742718Formatters may change the entire file text or only selected text. If selection is made, formatter changes only the selection, otherwise the entire text. And special formatters called "minifiers" puts the resulting text to a separate ui-tab.
743719
744720### CudaFormatter commands
745721
746722Formatter (menu)
747723Runs formatter for current editor file. If several suitable formatters are found, menu-like dialog will suggest to choose one of them. If only single formatter is found, it will be run without confirmation.
748724
749725Formatter per-lexer A...D
750726Runs formatter for current editor file, which has per-lexer label (A, B, C, D). Labels are configurable by another command. For example, for the label "B" you can have one formatter for C++, another formatter for HTML, and the 3rd one for CSS. All 3 formatters will be callable by the same command "Formatter per-lexer B".
751727
752728Formatter cross-lexer 1...4
753729Runs formatter for current editor file, which has cross-lexer label (1, 2, 3, 4). For example, when you have a formatter XY assigned to the label "2", the command "Formatter cross-lexer: 2" always runs XY, ignoring the current lexer.
754730
755731Minify to separate file
756732Finds the "minifier" formatter for the current lexer, and runs it. The resulting text is stored to separate file with name like "filename.min.css" (.css for CSS lexer). Command needs that some formatter for the current lexer is marked as "minifier" (in the formatter's install.inf file).
757733
758734Configure on_save
759735Chooses which formatters are active on file saving. The first formatter, which is suitable for current lexer, and which has the flag "on_save" attached (via plugin configuration), will be used.
760736
761737Configure per-lexer labels
762738Allows to assign per-lexer labels (A, B, C, D) to formatters. Labels allow to use commands "Formatter per-lexer A"..."Formatter per-lexer D", also via hotkeys.
763739
764740Configure formatter
765741For those formatters which have configuration file, command will suggest to open global config file (in the folder "settings" of CudaText).
766742
767743Configure formatter (local)
768744For those formatters which have configuration file, command will suggest to open "local" config (in the folder of current editor file). If local config not exists, plugin will suggest to create it from the global config.
769745
770746### How to run formatter ESLint on saving
771747
772748- Install from Addons Manager: "CudaFormatter"
773749- Install from Addons Manager: "formatter: JavaScript_JSON"
774750
775751You have package "formatter.JavaScript_JSON" installed and this package gives the formatter named "... ESLint" (for JavaScript lexer). How you can auto-run this formatter on saving?
776752
777753- Activate lexer JavaScript in the current document (can be empty).
778754- Call menu item "Plugins / CudaFormatter / Configure on_save...".
779755- Menu-like dialog appears. Choose item "... ESLint" and see that menu appears again, now showing that "... ESLint" item has "on_save" label. Now cancel the auto-shown menu.
780756
781-<figure>
782-<img src="cudatext-fmt-onsave.png" title="cudatext-fmt-onsave.png" />
783-<figcaption>cudatext-fmt-onsave.png</figcaption>
784-</figure>
757+![](/wiki-images/4/45/Cudatext-fmt-onsave.png)
785758
786759Now for all documents with JavaScript (and "JavaScript Babel") lexer, file saving will call ESLint formatter. Note: ESLint handles only named files, and files which have ESLint configuration created in the file's folder. Document "(CudaText)/py/cuda_fmt_js/readme/readme.txt" tells more details.
787760
788761### How formatter can know filename
789762
790763Some formatters need to know the processing filename and/or lexer. For example, ESLint formatter must know full filename, to make the temporary file there. How can formatter know it? Module "cuda_fmt" has submodule "fmtconfig", which has variables "ed_filename" and "ed_lexer". Python code:
791764
792765`from cuda_fmt import fmtconfig`\
793766`fn = fmtconfig.ed_filename`
794767
795768## External Tools
796769
797770### Introduction to External Tools
798771
799772Plugin "External Tools" (ExtTools) can be installed from Addon Manager. It allows to run external programs, catch their output, and then it can:
800773
801774- Display this output in the Output or Console panel of CudaText.
802775- Replace current editor selection with the output.
803776- Copy this output to a new document.
804777- Copy this output to Clipboard.
805778- And more.
806779
807780Plugin adds "Tools" top menu (near "Plugins"), which has menu item "Config" to configure all tools (in the single dialog), and menu items to run all individual tools.
808781
809-<figure>
810-<img src="cudatext-tools-menuitem.png" title="cudatext-tools-menuitem.png" />
811-<figcaption>cudatext-tools-menuitem.png</figcaption>
812-</figure>
782+![](/wiki-images/8/8d/Cudatext-tools-menuitem.png)
813783
814784Some external tools configs are shown in the Wiki topics below. Enter these strings in the "Tool properties" dialog.
815785
816-<figure>
817-<img src="cudatext-tools-props.png" title="cudatext-tools-props.png" />
818-<figcaption>cudatext-tools-props.png</figcaption>
819-</figure>
786+![](/wiki-images/8/8e/Cudatext-tools-props.png)
820787
821788Plugin allows to customize hotkeys for all individual tools, or to use the single hotkey for different tools. The single hotkey is the hotkey of the plugin's command "Tools / Run main lexer tool". What is the "main lexer tool"? For example, you have 2 tools for lexer C++, and 3 tools for lexer HTML. You open the "Tool properties" dialog for some C++ tool, and press "Set main" button to mark that tool as "main" for C++. Then you open properties of some HTML tool, press "Set main" button to mark that tool as "main" for HTML. So now the "Tools / Run main lexer tool" can determine what is the main tool for C++ and HTML.
822789
823-<figure>
824-<img src="cudatext-tools-mainlexertool.png" title="cudatext-tools-mainlexertool.png" />
825-<figcaption>cudatext-tools-mainlexertool.png</figcaption>
826-</figure>
790+![](/wiki-images/0/06/Cudatext-tools-mainlexertool.png)
827791
828792Notes:
829793
830794- The disadvantage of the plugin: it cannot show tool output lines immediately when they appear, it waits until tool is terminated. Use the #Runner plugin which supports that feature.
831795- If you see that running of tools makes the Output panel visible, you need to fix the "Capture output" option of those tools, set it to "Ignore".
832796
833797### Tool to compile by GCC
834798
835799You can test how this tool works on any Linux, because GCC is preinstalled. Test the tool on C++ example, which is created from CudaText by menu "File / New from template / C++".
836800
837801Properties:
838802
839803- Name: C - compile
840804- File name: gcc
841805- Shell command: unchecked
842806- Parameters: "{FileNameOnly}" -o "{FileNameNoExt}"
843807- Initial folder: {FileDir}
844808- Lexers: C,C++
845809- Capture output: Output panel
846810- Encoding: utf_8
847811
848812Optionally, configure "Pattern", so double click in the Output panel will put caret to the source code. Example of GCC error line in the Output panel, it will be handled by double click: "new.cpp:10:3: error: 'zz' was not declared in this scope".
849813
850814- Pattern: (?P\<file\>\[^:\]+):(?P\<line\>\d+):(?P
851- <col>
852-
853815 \d+): .+
854816
855817### Tool to run C program
856818
857819Tool is for Linux, so "File name" don't have an extension. For Windows, change "File name" field to "{FileNameNoExt}.exe".
858820
859821Tool will catch the program output in the Output panel, program text input will not work.
860822
861823- Name: C - run
862824- File name: "./{FileNameNoExt}"
863825- Shell command: checked
864826- Parameters: (empty)
865827- Initial folder: {FileDir}
866828- Lexers: C,C++
867829- Capture output: Output panel
868830- Encoding: utf_8
869831- Pattern: (empty)
870832
871833### Tool to run C program, on Windows, with input in terminal
872834
873835Tool is for Windows, it allows to run compiled C/C++ program in new console window. Text input will work in this console.
874836
875837Example C++ program:
876838
877839``` C++
878840#include <stdio.h>
879841int main ()
880842{
881843 int c;
882844 puts ("Enter text. Include a dot ('.') in a sentence to exit:");
883845 do {
884846 c=getchar();
885847 putchar (c);
886848 } while (c != '.');
887849 return 0;
888850}
889851```
890852
891853Tool props:
892854
893855- Name: C - run
894856- File name: cmd
895857- Shell command: unchecked
896858- Parameters: /K "{FileNameNoExt}.exe"
897859 - Alternative value: /C "{FileNameNoExt}.exe" && pause
898860- Initial folder: {FileDir}
899861- Lexers: C,C++
900862- Capture output: Ignore
901863- Encoding: utf_8
902864- Pattern: (empty)
903865
904866### Tool to run C program, on Linux, with input in terminal
905867
906868Tool is for Linux, it allows to run compiled C/C++ program in new terminal window. Text input will work in this terminal window.
907869
908870Example C++ program:
909871
910872``` C++
911873#include <stdio.h>
912874int main ()
913875{
914876 int c;
915877 puts ("Enter text. Include a dot ('.') in a sentence to exit:");
916878 do {
917879 c=getchar();
918880 putchar (c);
919881 } while (c != '.');
920882 return 0;
921883}
922884```
923885
924886Tool props:
925887
926888- Name: C - run
927889- Variant for xterm:
928890 - File name: xterm
929891 - Parameters: -hold -e "./{FileNameNoExt}"
930892- Variant for gnome-terminal:
931893 - File name: gnome-terminal
932894 - Parameters: -- bash -c "./{FileNameNoExt}; read -s -n1 -r -p 'Press any key... '; echo"
933895- Shell command: unchecked
934896- Initial folder: {FileDir}
935897- Lexers: C,C++
936898- Capture output: Ignore
937899- Encoding: utf_8
938900- Pattern: (empty)
939901
940902### Tool to compile+run C program
941903
942904In the External Tools dialog, press Join button, to join 2 tools created in above steps. Properties of joined tool:
943905
944906- Name: C - make+run
945907- Series: C - compile; C - run
946908- Lexers: C,C++
947909
948910### Tool to run current Batch file
949911
950912Tool properties:
951913
952914- Name: Run batch file
953915- File name: cmd.exe
954916- Shell command: unchecked
955917- Parameters: /c "{FileName}"
956918- Initial folder: {FileDir}
957919- Lexers: Batch files
958920- Capture output: Output panel
959921- Encoding: the same as file's encoding: e.g. utf_8 or cp1251 (cp1251 is Russian ANSI codepage)
960922
961923### Tool to compile by Free Pascal
962924
963925This tool is for Free Pascal 3.x on Linux x64.
964926
965927Properties:
966928
967929- Name: FPC - compile
968930- File name:
969931 - for FPC installed system-wide: fpc
970932 - for FPC installed via fpcupdeluxe: /home/user/fpcupdeluxe/fpcupdeluxe/fpc/bin/x86_64-linux/fpc.sh
971933- Shell command: unchecked
972934- Parameters: {FileNameOnly}
973935- Initial folder: {FileDir}
974936- Lexers: Pascal
975937- Capture output: Output panel
976938- Encoding: utf_8
977939
978940Optionally, configure "Pattern", so double click in the Output panel will put caret to the source code. In the "Tool properties" dialog, press "Set" button near the "Pattern" and choose there ready preset for Free Pascal.
979941
980942### Tool to call file-compare utility
981943
982944Tools, which call file-compare utility, to compare 2 files: active files in group-1 and group-2.
983945
984946#### WinMerge, KDiff, Kompare
985947
986948- Name: Compare files in G1, G2
987949- File name: (full name of executable file)
988950- Shell command: unchecked
989951- Parameters: "{FileName_g1}" "{FileName_g2}"
990952- Initial folder: (empty)
991953- Capture output: Ignore
992954
993955#### Meld
994956
995957- Name: Compare files in G1, G2
996958- File name: (full name of executable file)
997959- Shell command: unchecked
998960- Parameters: --newtab "{FileName_g1}" "{FileName_g2}"
999961- Initial folder: (empty)
1000962- Capture output: Ignore
1001963
1002964#### diff
1003965
1004966- Name: Compare files in G1, G2
1005967- File name: diff
1006968- Shell command: unchecked
1007969- Parameters: -Nau "{FileName_g1}" "{FileName_g2}"
1008970- Initial folder: (empty)
1009971- Capture output: Copy to new document
1010972
1011973### Tool to run Python scripts
1012974
1013975- Name: Python3
1014976- File name:
1015977 - on Windows: full path to "python.exe"
1016978 - on Unix: python3
1017979- Shell command:
1018980 - on Windows: checked
1019981 - on Unix: unchecked
1020982- Parameters: "{FileNameOnly}"
1021983- Initial folder: {FileDir}
1022984- Lexers: Python
1023985- Capture output: Output panel
1024986- Encoding: utf_8
1025987- Pattern: \s*File "(?P\<file\>.+)", line (?P\<line\>\d+)
1026988
1027989### Tool to preview HTML file in Chrome
1028990
1029991- Name: Preview in Chrome
1030992- File name:
1031993 - on Windows: C:\Program Files\Google\Chrome\Application\chrome.exe
1032994- Shell command:
1033995 - on Windows: unchecked
1034996- Parameters: "{FileName}"
1035997- Initial folder: (empty)
1036998- Lexers: HTML
1037999- Capture output: Ignore
10381000
10391001### Tool to open PHP documentation with given topic
10401002
10411003Tool to open PHP documentation, in .chm format, for the word under editor's caret. For Windows only. You need to install KeyHH from <http://keyworks.helpmvp.com/> , it is stable tool mentioned on several sites. Program "keyhh.exe" will be in your system PATH.
10421004
10431005Before making the tool, add "\$" char to word chars for PHP lexer. To do it, call "Plugins / Options Editor", in the Options Editor dialog find option "word_chars" and set it to "\$". You must save option to PHP lexer-specific config, so in the dialog you must check flag "For \[x\] Lexer", and choose lexer "PHP", and then write option value "\$" and press Enter.
10441006
10451007Download PHP documentation in .chm format from PHP.net, google for "php_manual_en chm", it is 16M file.
10461008
10471009Tool properties:
10481010
10491011- Name: PHP Help
10501012- File name: keyhh.exe
10511013- Shell command: unchecked
10521014- Parameters: -MyHelp -#klink {CurrentWord} "C:\Work\php_manual_en.chm"
10531015- Initial folder: (empty)
10541016- Lexers: PHP
10551017- Save before: Nothing
10561018- Capture output: Ignore
10571019
10581020### Tool to open AutoIt documentation with given topic
10591021
10601022Tool to open AutoIt documentation, in .chm format, for the word under editor's caret. For Windows only. You need to install KeyHH from <http://keyworks.helpmvp.com/> , it is stable tool mentioned on several sites. Program "keyhh.exe" will be in your system PATH.
10611023
10621024With AutoIt installed, you also have .chm documentation, its path is usually "C:\Program Files (x86)\AutoIt3\AutoIt.chm".
10631025
10641026Tool properties:
10651027
10661028- Name: AutoIt Help
10671029- File name: keyhh.exe
10681030- Shell command: unchecked
10691031- Parameters: -MyHelp -#klink {CurrentWord} "C:\Program Files (x86)\AutoIt3\AutoIt.chm"
10701032- Initial folder: (empty)
10711033- Lexers: AutoIt
10721034- Save before: Nothing
10731035- Capture output: Ignore
10741036
10751037### Tool to open .chm documentation for all lexers
10761038
10771039See above example about tool for PHP documentation. Create the similar tool
10781040
10791041- File name: keyhh.exe
10801042- Shell command: unchecked
10811043- Parameters: -MyHelp -#klink "{CurrentWord}" "{AppDir}\\..\Docs\\{Lexer}.chm"
10821044- Lexers: (empty)
10831045
10841046This tool needs renamed .chm files: for lexer AutoIt it needs "AutoIt.chm" and so on. It needs .chm files in a single folder relative to CudaText folder.
10851047
10861048### Tool for Google search
10871049
10881050This is URL (special kind of tool). In the External Tools dialog, press the "URL" button, then press "Add" to add a new URL.
10891051
10901052- Name: Google find
10911053- URL:
10921054
10931055```text
10941056http://google.com/search?q={SelectedText|q}
10951057```
10961058
10971059### Tool to open folder of current file in Windows Explorer
10981060
10991061Tool properties:
11001062
11011063- Name: Open cur dir in Explorer
11021064- File name: explorer.exe
11031065- Shell command: unchecked
11041066- Parameters: {FileDir}
11051067- Initial folder: {FileDir}
11061068
11071069### Tool to go to current file in FreeCommander
11081070
11091071- Name: Go to file in FreeCommander
11101072- File name: path\to\FreeCommander.exe
11111073- Shell command: unchecked
11121074- Parameters: "/L={FileName}" /C
11131075- Initial folder: {FileDir}
11141076
11151077# Runner
11161078
11171079Plugin Runner was written as an alternative to External Tools.
11181080
11191081- Runner is more light weight.
11201082- Runner supports Sublime Text 3 build-systems.
11211083- Runner displays tool output immediately line-by-line as it appears (External Tools can only show the entire ready output).
11221084
11231085Many build-systems from Sublime Text 3 were packaged and put to add-on collection, search for add-on "Many Build Systems". Only few build-systems were packaged into own separate packages because they have big EXE/Binary files. Some ST3 plugins have build-systems paired with some Python code - they are not supported.
11241086
11251087See the [Runner documentation on GitHub](https://github.com/halfbrained/cuda_runner/blob/main/readme/readme.txt).
11261088
11271089Here is the GIF animation which shows reaction of Runner to PHP script running:
11281090
11291091``` php
11301092<?php
11311093for($i=0; $i<10; $i++) {
11321094 sleep(1);
11331095 echo "$i is here\n";
11341096}
11351097?>
11361098```
11371099
1138-<figure>
1139-<img src="cudatext-runner-thread.gif" title="cudatext-runner-thread.gif" />
1140-<figcaption>cudatext-runner-thread.gif</figcaption>
1141-</figure>
1100+![](/wiki-images/4/48/Cudatext-runner-thread.gif)
11421101
11431102## Runner limitation for input
11441103
11451104If your Python script contains the input() function:
11461105
11471106``` python
11481107s=input('enter text: ')
11491108print('entered:', s)
11501109```
11511110
11521111it will run with a runtime error like this:
11531112
11541113`enter text: Traceback (most recent call last):`\
11551114`  File "/home/user/a.py", line 3, in <module>`\
11561115`   s=input('enter text: ')`\
11571116`EOFError: EOF when reading a line`
11581117
11591118This is the limitation of the Runner plugin. To run your Python script in this case, you should call "ExTerminal" plugin (or "Terminal Plus" plugin), and enter there: "python3 myscript.py". And make sure, that ExTerminal prompt appeared in the proper folder, with your script.
11601119
11611120## Runner tool for C
11621121
11631122Install the add-on "build-system: Many Build Systems from ST4". It supports C lexer using GCC compiler. It works on Linux/macOS out-of-the-box, on Windows you need the command "gcc" to be in the system PATH.
11641123
11651124This build-system has 2 commands:
11661125
11671126- Build: only compiles
11681127- Run: compiles and then runs the binary
11691128
11701129Example C file:
11711130
11721131``` cpp
11731132#include <stdio.h>
11741133int main(){
11751134 printf("Hello world");
11761135 return 0;
11771136}
11781137```
11791138
11801139Example output in the CudaText Output panel (Linux):
11811140
11821141 -- [10:34:08] Building: C via GCC: a.c
11831142 -- Command: gcc "/home/user/a.c" -o "/home/user/a" && "/home/user/a"
11841143 -- Working dir: /home/user
11851144 Hello world
11861145 -- Done (0.2s), return code: 0
11871146
11881147## Runner tool for C++
11891148
11901149Install the add-on "build-system: C++ using G++". It supports C++ lexer using GNU C++ compiler. It works on Linux/macOS out-of-the-box, on Windows you need the command "g++" to be in the system PATH.
11911150
11921151This build-system has 2 commands:
11931152
11941153- compile, then run the compiled binary (default command)
11951154- only run the compiled binary (it should be called from "Plugins / Runner / Build with...").
11961155
11971156Example C++ file:
11981157
11991158``` cpp
12001159#include <iostream>
12011160
12021161int main() {
12031162 std::cout << "Hello World!";
12041163 return 0;
12051164}
12061165```
12071166
12081167Example output in the CudaText Output panel (Linux):
12091168
12101169 -- [16:41:55] Building: C++: new.cpp
12111170 -- Command: g++ -std=c++11 -Wall "/home/user/new.cpp" -o "/home/user/new" && "/home/user/new"
12121171 -- Working dir: /home/user
12131172 Hello World!
12141173 -- Done (0.8s), return code: 0
12151174
12161175## Runner tool for PHP
12171176
12181177How to debug for example PHP file, with Runner. Create file "\[CudaText\]/data/buildsystems/php.sublime-build" with such text:
12191178
12201179``` json
12211180{
12221181 "file_patterns": ["*.php"],
12231182 "linux": {
12241183 "cmd": ["php", "$file"]
12251184 },
12261185 "windows": {
12271186 "cmd": ["C:\\PHP_folder\\php-win.exe", "$file"]
12281187 }
12291188}
12301189```
12311190
12321191Restart CudaText.
12331192
12341193After opening a PHP file, call Runner main command "Build", that's it. It must show script output (in the Output panel) line-by-line, as it appears.
12351194
12361195Example script to test:
12371196
12381197``` php
12391198<?php
12401199for($i=0; $i<10; $i++) {
12411200 sleep(1);
12421201 echo "$i is here\n";
12431202}
12441203?>
12451204```
12461205
12471206## Runner tool for Python
12481207
12491208In Addons Mananger, install the add-on "buildsystem: Many Build Systems from ST4". It contains the Python build-system. It even contains 2 items in the build-system:
12501209
12511210- Build
12521211- Syntax Check
12531212
12541213After opening a Python file, call Runner main command "Build", that's it. It must show script output (in the Output panel) line-by-line, as it appears.
12551214
12561215Example script to test:
12571216
12581217``` python
12591218import time
12601219
12611220for i in range(5):
12621221 time.sleep(1)
12631222 print(str(i) + " is here", flush=True)
12641223```
12651224
12661225## Runner tool for Free Pascal
12671226
12681227In Addons Manager, install the add-on "buildsystem: Free Pascal". It installs the file "\[CudaText\]/data/buildsystems/Free Pascal.sublime-build" with text like this:
12691228
12701229``` json
12711230{
12721231 "file_patterns": ["*.pp", "*.pas"],
12731232 "file_regex": "(.+?)\\((\\d+),(\\d+)\\)\\s(.+)$",
12741233 "working_dir": "$file_path",
12751234 "name": "Compile",
12761235 "cmd": ["/home/user/fpcupdeluxe/fpcupdeluxe32/fpc/bin/x86_64-linux/fpc.sh", "$file_name"],
12771236 "variants": [
12781237 {
12791238 "name": "Run",
12801239 "cmd": ["./$file_base_name"]
12811240 }
12821241 ]
12831242}
12841243```
12851244
12861245In this file, you need to adjust the path to "fpc.sh", according to your [[fpcupdeluxe]] folder. Restart CudaText.
12871246
12881247After opening a Pascal file, call Runner main command "Build", that's it. The "Build" command example output:
12891248
12901249 -- [20:07:55] Building: Free Pascal: new.pas
12911250 -- Command: ['/home/user/fpcupdeluxe/fpcupdeluxe32/fpc/bin/x86_64-linux/fpc.sh', 'new.pas']
12921251 -- Working dir: /home/user
12931252 Free Pascal Compiler version 3.2.3-425-gebc55c0f4e-dirty [2021/09/09] for x86_64
12941253 Copyright (c) 1993-2021 by Florian Klaempfl and others
12951254 Target OS: Linux for x86-64
12961255 Compiling new.pas
12971256 Linking new
12981257 3 lines compiled, 0.1 sec
12991258 -- Done (0.2s), return code: 0
13001259
13011260The config above also gives the "Run" command for the compiled binary - in the menu of "Plugins / Runner / Build with...". The "Run" command example output:
13021261
13031262 -- [20:09:09] Building: Free Pascal: new.pas
13041263 -- Command: ['./new']
13051264 -- Working dir: /home/user
13061265 Hello world.
13071266 -- Done (-0.0s), return code: 0
13081267
13091268## Runner tool for Cobol
13101269
13111270In Addons Manager, install the lexer "Cobol".
13121271
13131272Let's make build-system for GnuCOBOL on Windows. Install GnuCOBOL, usually [from this webpage](https://www.arnoldtrembley.com/GnuCOBOL.htm), to "C:\GnuCOBOL". You must have file "C:\GnuCOBOL\bin\cobc.exe".
13141273
13151274Create Batch script "c:\GnuCOBOL\bin\runcobol.cmd" with such content:
13161275
13171276 set Path=c:\gnucobol\bin
13181277 set COB_CONFIG_DIR=c:\gnucobol\config
13191278 set COB_COPY_DIR=c:\gnucobol\copy
13201279 set COB_INCLUDE_PATH=c:\gnucobol\include
13211280 set COB_LIB_PATH=c:\gnucobol\lib
13221281 cobc -x -std=mf %1
13231282
13241283Create build-system file "\[CudaText\]\data\buildsystems\cobol.sublime-build":
13251284
13261285``` json
13271286{
13281287 "file_patterns": ["*.cob", "*.cbl", "*.cpy"],
13291288 "name": "Compile",
13301289 "cmd": ["cmd.exe", "/c", "c:\\GnuCOBOL\\bin\\runcobol.cmd", "$file"],
13311290 "working_dir": "$file_path",
13321291 "file_regex": "^([^:]+):([0-9]+):",
13331292 "variants": [
13341293 {
13351294 "name": "Run",
13361295 "cmd": ["$file_path/$file_base_name.exe"]
13371296 }
13381297 ]
13391298}
13401299```
13411300
13421301Note: the build-system gives usual command "Build" and additional command "Run" to execute the .exe file, and "Run" has forward slash (Unix slash): "\$file_path/\$file_base_name.exe". Forward slash is required here, because with backslash Runner will fail to run the .exe (it will not expand the macro \$file_base_name).
13431302
13441303Now running the "Plugins / Runner / Build" can give text in the "Output panel" like this:
13451304
13461305 -- [07:49:02] Building: cobol: test.cbl
13471306 -- Command: ['cmd.exe', '/c', 'c:\\GnuCOBOL\\bin\\runcobol.cmd', 'C:\\Work\\test.cbl']
13481307 -- Working dir: C:\Work
13491308
13501309 C:\Work>set Path=c:\gnucobol\bin
13511310 C:\Work>set COB_CONFIG_DIR=c:\gnucobol\config
13521311 C:\Work>set COB_COPY_DIR=c:\gnucobol\copy
13531312 C:\Work>set COB_INCLUDE_PATH=c:\gnucobol\include
13541313 C:\Work>set COB_LIB_PATH=c:\gnucobol\lib
13551314 C:\Work>cobc -x -std=mf C:\Work\test.cbl
13561315 C:\Work\test.cbl:1: error: invalid indicator 'u' at column 7
13571316 C:\Work\test.cbl:2: warning: line not terminated by a newline [-Wmissing-newline]
13581317 C:\Work\test.cbl:3: warning: PROGRAM-ID header missing [-Wothers]
13591318 -- Done (0.3s), return code: 1
13601319
13611320# FindInFiles
13621321
13631322This plugin implements searching in many files, starting from custom folder. CudaText doesn't have the built-in feature to search in many files, and seems it will not have it in future, because FindInFiles is so powerful, it even has the Configuration dialog with dozens of options.
13641323
13651324Project Manager plugin allows to call FindInFiles functionality. Focus a folder in Project Manager, call context menu, and then "Selected directory / Find in directory..." menu item.
13661325
13671326## How to find/replace in all UI-tabs
13681327
13691328FindInFiles 4 supports search inside all UI-tabs. Hover mouse over "From:" label in the dialog, tooltip will appear. Tooltip says what to enter in the nearest input-field. Enter one of these strings in the "From" field:
13701329
13711330`<tabs>`\
13721331`{t}`
13731332
1374-<figure>
1375-<img src="cudatext-findinfiles-intabs.png" title="cudatext-findinfiles-intabs.png" />
1376-<figcaption>cudatext-findinfiles-intabs.png</figcaption>
1377-</figure>
1333+![](/wiki-images/a/ab/Cudatext-findinfiles-intabs.png)
13781334
13791335And in the "Files" field, enter "*" for all files.
13801336
13811337To discover more features of FindInFiles dialog, hover mouse over other labels/buttons.
13821338
13831339You can also **replace in all UI-tabs**, of course. To do it, fill all input fields in the FindInFiles main dialog, but instead of pressing "Find" - press "=" button and then choose "Replace with..." from appeared popup menu. Additional dialog will appear to confirm you replacement request, press "Replace" button there.
13841340
13851341Additionally, CudaText gives built-in "Replace in all tabs" feature, it is the button "Rep global" in the built-in Find/Replace dialog. This is documented in the main CudaText wiki page.
13861342
13871343## How to use FindInFiles 4
13881344
13891345FindInFiles v4 has two panels. Top panel shows found filenames, line by line. Bottom panel shows the entire document of one of the selected filenames. When you single click on a line of top panel, the bottom panel shows the content of a clicked file. When you double click the line again, the main editor of CudaText jumps to that location.
13901346
13911347## FiF3 and FiF4: comparison and future
13921348
13931349CudaText has two plugins to search in files/tabs:
13941350
13951351- FindInFiles v3 (FiF3)
13961352- FindInFiles v4 (FiF4)
13971353
13981354Important: FiF3 is almost frozen. Only serious bugs will be fixed. No plans to hide/delete FiF3. FiF4 supersedes FiF3.
13991355
14001356Detailed comparison.
14011357
14021358Common features:
14031359
14041360- Speed of search. Speed of FiF3 is stable. FiF4 can search faster or slower depending on the settings. In the "slow" mode FiF4 gives more complex Results or uses more complex filters.
14051361- Encoding detection. FiF4 allows to set more flexible plan (see submenu "=/Encoding plan").
14061362- Presets. Both versions allow to define and restore named set of search parameters. FiF4 allows to run dialog and start **immediate search** with parameters from a preset (see main menu command "Find by preset..."). FiF4 allows to restore \[pre\]previous parameters (runtime **auto saving**).
14071363- Results/Source. FiF3 allows to put Results in old/new tab or in dialog editor control. FiF4 allows to put Results only in dialog editor control and has a command to copy Results to new tab. Both allow to open the source file for specified fragment in new tab. FiF3 can place Results and Source vertically or horizontally. FiF4 has only one way.
14081364- FiF3 has commands to **count fragments** and to show only filenames. FiF4 skips such commands as unnecessary.
14091365- FiF3 can save **dialog layouts**. FiF4 saves layout as part of preset.
14101366- Like FiF3, FiF4 has the "Replace" functionality.
14111367- Like FiF3, FiF4 can search **in project** folder(s).
14121368
14131369Main new features:
14141370
14151371- FiF4 can report the found fragment with its **around lines** (see "-?+?" button).
14161372- FiF4 can search **multi-line fragments** (see "+" button).
14171373- FiF4 can search in **many start folders**.
14181374- FiF4 allows to use **lexer data** to filter and report fragments (in/out string/comment, lexer path).
14191375- FiF4 allows to show lines in the Results with its **lexer colors** from source files.
14201376- FiF4 allows to use **macro-variables** (OS environments, properties of current file/tab and free-set names) in any editable fields .
14211377- FiF4 has **statusbar** to show statistics of the last search: folders/files/fragments/timing.
14221378- FiF4 allows to **reformat Results** (change tree type and more) without new search.
14231379- FiF4 allows to show **modification time** of files in the Results.
14241380
14251381# Terminal
14261382
14271383There are currently 3 terminal plugins:
14281384
14291385- Terminal: simplest plugin.
14301386- Terminal Plus: most feature-rich plugin, but its UI may be too complex for beginners.
14311387- ExTerminal: middle in the feature set, but its UI is very simple.
14321388
14331389Let's take ExTerminal plugin, and show how to perform some task with it, under Linux. Task: run Python script which uses 'input()' function. The simpest Terminal plugin cannot handle 'input()' function, but ExTerminal will work good. Let's take Python script with content:
14341390
14351391``` python
14361392x = int(input('Enter x: '))
14371393w = int(input('Enter w: '))
14381394print(x*w)
14391395```
14401396
14411397Steps:
14421398
14431399- Save our script to file ~/myfolder/tt.py
14441400- Install ExTerminal, restart CudaText
14451401- Run ExTerminal by clicking its bottom-bar-icon
14461402- In ExTerminal, enter "cd ~/myfolder", so file tt.py will be in the current directory. You can enter "ls *.py" to see all python files in the current directory.
14471403- In ExTerminal, enter "python3 tt.py"
14481404
14491405Script should work and show 2 input-prompts.
14501406
14511407`user@user:~/myfolder$ ls *.py`\
14521408`a.py  test.py  tt.py`\
14531409`user@user:~/myfolder$ python3 tt.py`\
14541410`Enter x: 10`\
14551411`Enter w: 20`\
14561412`200`
14571413
14581414How to open ExTerminal in the directory of the current editor file? You can do this:
14591415
14601416- Hover mouse over ExTerminal button in the bottom-bar. It must show tooltip like "ExTerminal 1".
14611417- Right-click this button, popup menu appears, from the popup menu choose "New terminal". This will create another ExTerminal button+panel. New panel has the directory of the current editor file.
14621418- To not produce too much ExTerminal buttons, use "Close terminal" from the popup menu.
14631419
14641420# Configure Menu
14651421
14661422Plugin "Configure Menu" (in Addons Manager) allows to change CudaText menus. You can add items to the CudaText top-menu, top menu submenu, editor context-menu, tab header context-menu and dropdown submenu of toolbar buttons. Plugin can create file (settings/menu.json) with default menu configuration, which you edit to customize all menus. File has items like:
14671423
14681424``` json
14691425 ,{"cap":"&Save", "cmd":"cmd_FileSave"}
14701426```
14711427
14721428How to add here built-in commands? See identifiers of CudaText commands in the file "py/cudatext_cmd.py", they have prefixes "cCommand_" (low level commands) and "cmd_" (high level commands). For example, "cmd_FileSave" is the command to save current file.
14731429
14741430How to add here plugin commands? For example, you have plugin "Comments", it is in the folder "py/cuda_comments". See plugin's file install.inf, and find there needed Python methods. Then add in the "settings/menu.json" item like this:
14751431
14761432``` json
14771433 ,{"cap":"Toggle line comment", "cmd":"module=cuda_comments;cmd=cmt_toggle_line_body;"}
14781434```
14791435
14801436Here "cuda_comments" is plugin folder name, and "cmt_toggle_line_body" is Python method from install.inf.
14811437
14821438You can add items to the CudaText top-menu and/or context-menu, it is different sections in "menu.json". Possible root sections in "menu.json" are listed in the API wiki page: [[CudaText API|CudaText_API#menu_proc_-_Menu_id]].
14831439
14841440Example screenshot shows how "menu.json" will look with new items for context-menu:
14851441
1486-<figure>
1487-<img src="cudatext-editing-context-menu.png" title="cudatext-editing-context-menu.png" />
1488-<figcaption>cudatext-editing-context-menu.png</figcaption>
1489-</figure>
1442+![](/wiki-images/5/5e/Cudatext-editing-context-menu.png)
14901443
14911444Example screenshot also shows tricks: how to write items for "External Tools" items and for "Macros" items: see lines with "cuda_exttools" and with "cuda_macros". Here they are:
14921445
14931446``` json
14941447 {"cap": "SomeToolName", "cmd": "module=cuda_exttools;cmd=run;info=174420;"}
14951448 ,{"cap": "SomeMacroName", "cmd": "module=cuda_macros;cmd=run;info=87635;"}
14961449```
14971450
14981451These special lines need special integer IDs. You can find these IDs in the config files of both plugins: External Tools / Macros. For example, to find Extertal Tools IDs, open "settings/exttools.json". Here is a fragment of this file, which shows "id" value of the tool "C - compile":
14991452
15001453``` json
15011454{
15021455 "ver": "20151209",
15031456 "list": [
15041457 {
15051458 "id": 254653,
15061459 "nm": "C - compile",
15071460 "file": "gcc",
15081461 "ddir": "{FileDir}",
15091462 "shll": false,
15101463 "prms": "\"{FileNameOnly}\" -o \"{FileNameNoExt}\"",
15111464 "savs": "N",
15121465 "rslt": "OP",
15131466 "encd": "utf_8",
15141467 "lxrs": "C,C++",
15151468 "pttn": "(?P<file>[\\w\\.\\-]+):(?P<line>\\d+):(?P<col>\\d+):.+",
15161469 },
15171470```
15181471
15191472# Config Toolbar
15201473
15211474Plugin allows to change the content of the main (horizontal) toolbar: hide standard buttons, add user buttons for any actions, customize icons and nesting of menu items.
15221475
15231476For example, you installed two plugins:
15241477
15251478- Config Toolbar
15261479- Color Text
15271480
15281481And you want to call command "Apply bold" (from "Color Text") via toolbar. How to add such a button? Picture highlights your steps.
15291482
1530-<figure>
1531-<img src="cudatext-config-toolbar.png" title="cudatext-config-toolbar.png" />
1532-<figcaption>cudatext-config-toolbar.png</figcaption>
1533-</figure>
1483+![](/wiki-images/8/81/Cudatext-config-toolbar.png)
15341484
15351485- From the Command Palette, call the item "Config Toolbar: Configure buttons...". Dialog will appear from the plugin.
15361486- In the "Configure toolbar" dialog, press "Add item...", and fill fields of new dialog "Button properties".
15371487 - Caption
15381488 - Tooltip (optional)
15391489 - Command: should be "cuda_color_text.format_bold" for our task. You cannot type this text, instead press "Choose command" and find the command there, in the Command Palette-like menu.
15401490 - Icon (optional)
15411491
15421492# Intext Bookmarks
15431493
15441494Plugin allows to place special marks, and to show Goto dialog for its special marks. These are not usual CudaText bookmarks, but text lines, which are recognized only by this plugin.
15451495
15461496Plugin adds menu items in "Plugins / In-text Bookmarks":
15471497
15481498- List for current tab -- show all marks in the current document
15491499- List for all tabs -- show all marks in all opened UI-tabs
15501500- Go to next
15511501- Go to previous
15521502- Add -- add a new mark at caret position
15531503
15541504"Special" lines are supported even for files without lexer, and files with lexer if lexer doesn't support comments. For such poor files, plugin will add special lines like "//NOTE: comment_text".
15551505
15561506You can customize that special lines, using plugin configuration dialog: menu item "Options / Settings-plugins / In-text Bookmarks". Dialog gives such options:
15571507
15581508- Bookmark signs: NOTE: NB! TODO: todo: todo. FIX:
15591509- Comment sign: //
15601510
15611511That configuration means that for "poor" files (without lexer, or with lexer without line comments), plugin uses lines beginning with "//NOTE:" or "//NB!" or "//TODO:" etc. For files with rich lexers, plugin uses lexer's line-comment prefix.
15621512
15631513# Color Text
15641514
15651515Plugin "Color Text" gives several commands (in the Plugins menu) to add coloring to text ranges. Plugin uses the selected text, without selection it uses word under first caret. On applying the coloring, plugin marks file as "modified". Plugin is suitable for files with any lexer, it adds its colors over the lexer highlight.
15661516
1567-<figure>
1568-<img src="cudatext-color-text.png" title="cudatext-color-text.png" />
1569-<figcaption>cudatext-color-text.png</figcaption>
1570-</figure>
1517+![](/wiki-images/0/0b/Cudatext-color-text.png)
15711518
15721519The data of coloring is saved to additional 'helper file' with extension .cuda-colortext, in the folder of the original file. After you delete this 'helper file', plugin will not load its data on next start.
15731520
15741521Not only background color can be changed, but also border color, and font styles (bold, italic, stikeout). To specify colors/styles, you have to edit the plugin config file. To edit the config file, call menu item "Options / Settings-plugins / Color Text". Config file has sections for colors/styles, and usual options:
15751522
15761523- "all_words": Colorize all occurrences of fragment.
15771524- "case_sensitive": Case sensitive search for other occurrences.
15781525- "whole_words": Colorize only those occurrences, which are whole words.
15791526- "show_on_map": Show added colored marks also on micro-map.
15801527
15811528# Insert Pics
15821529
15831530CudaText gives the plugin API to show pictures between the text lines. These spaces between lines are called "gaps". Plugin "Insert Pics" exists to show picture files in gaps. It saves pictures in the helper files (using Base64 encoding), with extension .cuda-pic, near the original text file. Files with pictures look like this:
15841531
1585-<figure>
1586-<img src="cudatext-insert-pics.png" title="cudatext-insert-pics.png" />
1587-<figcaption>cudatext-insert-pics.png</figcaption>
1588-</figure>
1532+![](/wiki-images/8/8f/Cudatext-insert-pics.png)
15891533
15901534- You can use any lexer for files with pictures.
15911535- You can add the unlimited number of pictures. But only one picture per "gap".
15921536- You can add/delete pictures later, using plugin's commands in menu "Plugins / Insert Pics".
15931537- When you delete the "helper file" (located in the same folder), all pictures will be lost for plugin.
15941538
15951539# Complete From Text
15961540
15971541Plugin allows to show auto-completion listbox with words from the current file (or all opened UI-tabs, by option). E.g. if you typed "op" and press Ctrl+Space (default auto-completion hotkey), it may suggest previously mentioned words "operations", "opinion", "option" etc. Plugin is not smart like "LSP Client" plugin, so expect lot of 'false positives' in its listbox.
15981542
1599-<figure>
1600-<img src="cudatext-complete-from-text.png" title="cudatext-complete-from-text.png" />
1601-<figcaption>cudatext-complete-from-text.png</figcaption>
1602-</figure>
1543+![](/wiki-images/1/11/Cudatext-complete-from-text.png)
16031544
16041545In the picture above, one word was taken from C lexer's C.acp file (this is a feature).
16051546
16061547Plugin is preconfigured to work with small set of lexers: none-lexer, Ini files, Markdown, reStructuredText, Properties. Here is how to use it for let's say "C" lexer:
16071548
16081549- Install the plugin
16091550- Call menu item "Options / Settings-plugins / Complete From Text"
16101551- This opens the "plugins.ini" file
16111552- Find section "\[complete_from_text\]", add ",c" (without quotes) to the line "lexers="
16121553- Restart CudaText
16131554
16141555Plugin has more options in that "plugins.ini" file:
16151556
16161557- 'lexers': comma-separated lexer names, ie for which lexers to work; specify none-lexer as '-'.
16171558- 'min_len': minimal word length, words of smaller length will be ignored.
16181559- 'max_lines': if document has bigger count of lines, ignore this document.
16191560- 'case_sens': case-sensitive; words starting with 'A' will be ignored when you typed 'a'.
16201561- 'no_comments': ignore words inside "syntax comments" (lexer specific).
16211562- 'no_strings': ignore words inside "syntax strings" (lexer specific).
16221563- 'what_editors': which documents (ie UI tabs) to read to get words. Values:
16231564 - 0: only current document.
16241565 - 1: all opened documents.
16251566 - 2: all opened documents with the same lexer.
16261567- 'use_acp': add suggestions from autocomplete files in 'data/autocomplete'
16271568- 'case_split': expands suggestions, autocompletion for 'AB' will include 'AzzBzz', so to get 'ValueError' just typing 'VE' (or 'VaE', 'VErr', 'ValErr' etc.) and calling on autocompletion will suggest it.
16281569- 'underscore_split': expands suggestions, autocompletion for 'AB' will include 'AZZ_BZZ', so to get 'supports_bytes_environ' just typing 'sb' (or 'sbe', 'supbyenv' etc.) and calling on autocompletion will suggest it.
16291570
16301571Plugin supports CudaText option "nonword_chars", so for example words with '\$' char are also added to completions, if CudaText option is configured so.
16311572
16321573# Embedded Editor
16331574
16341575Plugin "Embedded Editor" shows "included" file in embedded editor - additional editor UI control is shown between the text lines. For example, you can open included CSS / JS files while editing the HTML file.
16351576
1636-<figure>
1637-<img src="cudatext-embedded-editor.png" title="cudatext-embedded-editor.png" />
1638-<figcaption>cudatext-embedded-editor.png</figcaption>
1639-</figure>
1577+![](/wiki-images/5/55/Cudatext-embedded-editor.png)
16401578
16411579It adds menu item to show/hide embedded editor in the current document, for the current caret position: "Plugins / Embedded Editor / Toggle".
16421580
16431581By default, plugin searches for the included filename inside double-quotes, surrounding the caret position. This works OK for HTML and many other documents.
16441582
16451583For example, when you have opened file "/folder/file.html", and placed caret inside first double-quotes:
16461584
16471585``` html
16481586 <link href="css/style.css" rel="stylesheet" type="text/css"/>
16491587```
16501588
16511589then embedded editor will be opened for file "/folder/css/style.css".
16521590
16531591The search can be configured, though. For example, plugin can be used in Pascal files for include-directives:
16541592
16551593``` pascal
16561594 {$I path/filename.inc}
16571595```
16581596
16591597Plugin has 2 config files, you will see 2 menu items in the "Options / Settings-plugins / Embedded Editor". Read more about config files in the readme.txt of plugin.
16601598
16611599# Breadcrumbs
16621600
16631601Plugin "Breadcrumbs" shows the toolbar widget (modern name is breadcrumb bar) below or on top of the editor for quick file-system navigation. For example, when you have active editor with filename "/home/user/mydir/myfile.ext", widget shows buttons:
16641602
16651603 [ home / user / mydir / myfile.ext ]
16661604
16671605It can also show the "~" button for the home directory (by option):
16681606
16691607 [ ~ / mydir / myfile.ext ]
16701608
1671-<figure>
1672-<img src="cudatext-breadcrumbs.png" title="cudatext-breadcrumbs.png" />
1673-<figcaption>cudatext-breadcrumbs.png</figcaption>
1674-</figure>
1609+![](/wiki-images/b/be/Cudatext-breadcrumbs.png)
16751610
16761611Clicking on each button shows the popup with file-system listing, showing the folder containing the clicked item. This popup supports basic tree-view navigation, you can click files there to open them in CudaText.
16771612
16781613Plugin can also show buttons for Code-Tree nodes. This must be enabled first in the config file - turn on the option "code_navigation". Clicking the buttons from the code-tree shows the same tree-popup but with a different content - with symbols of the documents. Clicking the nodes in the tree-popup scrolls the document to different symbols.
16791614
16801615# Spell Checker
16811616
16821617Frequent question: how to make spell checking 'live', ie run it after each change? Do this:
16831618
16841619- Menu "Options / Settings-plugins / Spell Checker / Configure events": check there all events.
16851620- Menu "Options / Settings-plugins / Spell Checker / Configure": check that your file-extension is enabled in the option "file_extension_list". Option value "*" means that all extensions are enabled.
16861621- Restart CudaText.
16871622
16881623Now checking should be 'live'. Note: it needs a pause after text editing (about 1 second), because it uses "on_change_slow" to avoid slowdown on editing.
16891624
16901625# LSP Client
16911626
16921627Plugin "LSP Client" allows to use Microsoft LSP protocol in CudaText with servers for many languages. It requires that CudaText uses Python 3.6 or newer (otherwise you will see the error messagebox).
16931628
16941629LSP Client gives several commands in the "Plugins / LSP Client", and all these commands work only if server supports them. Some of LSP commands are:
16951630
16961631- Auto-completion: integrated with CudaText command "Auto-completion menu" (in the Command Palette).
16971632- Go to definition: integrated with CudaText command "Go to definition" (in the Command Palette, and in the editor context menu).
16981633- Function signature help: integrated with CudaText command "Show function hint" (in the Command Palette).
16991634- Hover: shows the tooltip when you hover mouse above identifiers. You need the Ctrl key pressed while you hover.
17001635
1701-<figure>
1702-<img src="cudatext-lsp-hover_.png" title="cudatext-lsp-hover_.png" />
1703-<figcaption>cudatext-lsp-hover_.png</figcaption>
1704-</figure>
1636+![](/wiki-images/b/b0/Cudatext-lsp-hover_.png)
17051637
17061638- Find references: finds all locations where an identifier (under first caret) is used and shows menu with locations.
17071639
1708-<figure>
1709-<img src="cudatext-lsp-refs.png" title="cudatext-lsp-refs.png" />
1710-<figcaption>cudatext-lsp-refs.png</figcaption>
1711-</figure>
1640+![](/wiki-images/c/ce/Cudatext-lsp-refs.png)
17121641
17131642- Code linting: checking the correctness of the source code, places underlines and/or bookmarks on "incorrect lines". This feature is also implemented in #CudaLint and usually it works better/faster there.
17141643- Document formatting: formatting of the source code by LSP server. This feature is also implemented in #CudaFormatter and usually it works better/faster there.
17151644
17161645All LSP servers should have a homepage with description of their functions, and installation information.
17171646
17181647In the server config "lsp_*.json", key "lexers", you need to specify the mapping between CudaText lexer names and LSP language names. For example, while CudaText lexer name is "Bash script", LSP language name is "bash". And while CudaText lexer name is "C#", LSP language name is "csharp".
17191648
17201649``` json
17211650{
17221651 "lexers": {
17231652 "C#": "csharp"
17241653 },
17251654 ...
17261655}
17271656```
17281657
17291658LSP Client also has the settings file, use menu item to open it: "Options / Settings-plugins / LSP Client".
17301659
17311660## LSP server for Python
17321661
17331662Project homepage is <https://github.com/python-lsp/python-lsp-server> . Note that this is fork of old, unmaintained, project "PyLS". Server supports:
17341663
17351664- Auto-completion
17361665- Go to definition
17371666- Function signature help
17381667- Hover
17391668- Find references
17401669- Code linting
17411670- Document formatting
17421671
17431672Use "pip" to install the server:
17441673
17451674`pip install python-lsp-server`\
17461675
17471676This will expose the command "pylsp" on your PATH. Confirm that installation succeeded by running:
17481677
17491678`pylsp --help`\
17501679
17511680Create the file "\[CudaText\]/settings/lsp_py.json" with text like this:
17521681
17531682``` json
17541683{
17551684 "lexers": {
17561685 "Python": "python"
17571686 },
17581687 "cmd_windows": ["pylsp.exe"],
17591688 "cmd_macos": ["pylsp"],
17601689 "cmd_unix": ["pylsp"]
17611690}
17621691```
17631692
17641693Open some Python script, and call some commands of LSP Client. It will run the server, and it should work.
17651694
17661695## LSP server for Python, pyright
17671696
176816971\. Install the server:
17691698
17701699`pip install pyright`
17711700
17721701- On Windows, add folder of "pyright-langserver.exe" to system PATH.
17731702- On Linux/Unix, get the full path of the program, we will use this path in the next step.
17741703
17751704`which pyright-langserver`
17761705
17771706It outputs on Ubuntu:
17781707
17791708`/home/user/.local/bin/pyright-langserver`
17801709
17811710- On macOS, install pyright via PIP, not via Homebrew. On macOS, see what output you have after you call this command: "nodeenv env". If you see certificate error, try to fix it with the following command:
17821711
17831712`/Applications/Python\ 3.10/Install\ Certificates.command`
17841713
178517142\. Create config (CudaText)/settings/lsp_pyright.json:
17861715
17871716``` json
17881717{
17891718 "lexers": {
17901719 "Python": "python"
17911720 },
17921721 "cmd_windows": ["pyright-langserver.exe", "--stdio"],
17931722 "cmd_unix": ["/home/user/.local/bin/pyright-langserver", "--stdio"],
17941723 "cmd_macos": ["/Library/Frameworks/Python.framework/Versions/3.10/bin/pyright-langserver", "--stdio"],
17951724 "log_stderr": true
17961725}
17971726```
17981727
179917283\. To disable type checking (which may be confusing), add key "settings" to the above config:
18001729
18011730``` json
18021731 "settings": {
18031732 "python.analysis": {
18041733 "typeCheckingMode": "off"
18051734 }
18061735 }
18071736```
18081737
18091738## LSP server for JavaScript/ReactJS
18101739
18111740- Install lexer for ReactJS: "JavaScript Babel", from "Addons Manager".
18121741- Install TypeScript and the LSP server. In Terminal:
18131742
18141743`npm install -g typescript typescript-language-server`
18151744
18161745- Create CudaText LSP config: file "settings/lsp_js.json" with such content:
18171746
18181747``` json
18191748{
18201749 "name": "JavaScript",
18211750 "lexers": {
18221751 "JavaScript": "javascript",
18231752 "JavaScript Babel": "javascriptreact"
18241753 },
18251754 "cmd_unix": [
18261755 "typescript-language-server",
18271756 "--stdio"
18281757 ],
18291758 "cmd_windows": [
18301759 "typescript-language-server.cmd",
18311760 "--stdio"
18321761 ]
18331762}
18341763```
18351764
18361765This assumes that "typescript-language-server" is in the PATH (it is true on Ubuntu). For Windows, you need to find the folder of "typescript-language-server.cmd" and add it to PATH.
18371766
18381767## LSP server for TypeScript
18391768
18401769- Install TypeScript lexer from "Addons Manager".
18411770- Install TypeScript and the LSP server. In Terminal:
18421771
18431772`npm install -g typescript typescript-language-server`
18441773
18451774- Create CudaText LSP config: file "settings/lsp_ts.json" with such content:
18461775
18471776``` json
18481777{
18491778 "lexers": {
18501779 "TypeScript": "ts"
18511780 },
18521781 "cmd_unix": [
18531782 "typescript-language-server",
18541783 "--stdio"
18551784 ],
18561785 "cmd_windows": [
18571786 "typescript-language-server.cmd",
18581787 "--stdio"
18591788 ]
18601789}
18611790```
18621791
18631792This assumes that "typescript-language-server" is in the PATH (it is true on Ubuntu). For Windows, you need to find the folder of "typescript-language-server.cmd" and add it to PATH.
18641793
18651794According to <https://www.zeusedit.com/lsp/typescript.html>, sometimes more complex config file may be needed. Here it is on Ubuntu:
18661795
18671796``` json
18681797{
18691798 "lexers": {
18701799 "TypeScript": "ts"
18711800 },
18721801 "cmd_unix": [
18731802 "typescript-language-server",
18741803 "--stdio",
18751804 "--log-level=4",
18761805 "--tsserver-log-verbosity=verbose",
18771806 "--tsserver-path=/usr/local/lib/node_modules/typescript/lib/"
18781807 ],
18791808 "cmd_windows": [
18801809 "typescript-language-server.cmd",
18811810 "--stdio",
18821811 "--log-level=4",
18831812 "--tsserver-log-verbosity=verbose",
18841813 "--tsserver-path=\"%APPDATA%\\npm\\node_modules\\typescript\\lib\\\""
18851814 ]
18861815}
18871816```
18881817
18891818How did I get the last path? It may be different on different Linux'es. It is from the "node_modules" dir which contains the **globally installed** Node.js modules. I found it by running "which typescript-language-server", it gave "/usr/local/bin/typescript-language-server". Then I checked symlink target for "/usr/local/bin/typescript-language-server" - it points to the sub-dir of needed "node_modules".
18901819
18911820Test the auto-completion on this "test.ts" file (with TypeScript lexer):
18921821
18931822`document.body.g`
18941823
18951824## LSP server for C/C++
18961825
18971826Install one of the servers following the instructions:
18981827
18991828- clangd: <https://clangd.llvm.org/installation.html>
19001829 - For Windows, you need to download "clangd-windows-x.x.x.zip" from <https://github.com/clangd/clangd/releases> . You need to add folder of "clangd.exe" to the OS PATH in Windows settings.
19011830- ccls: <https://github.com/MaskRay/ccls/wiki/Build> + <https://github.com/MaskRay/ccls/wiki/Install>
19021831
19031832To use the server in LSP Client, create a file "lsp_c.json" in the "settings" directory with such content:
19041833
19051834``` json
19061835{
19071836 "lexers": {
19081837 "C++": "cpp",
19091838 "C": "c"
19101839 },
19111840 "cmd_unix": [
19121841 "clangd-12",
19131842 ],
19141843 "cmd_windows": [
19151844 "clangd",
19161845 ],
19171846}
19181847```
19191848
19201849Replace "clangd*" with "ccls" if it was chosen.
19211850
19221851On Windows: you must add the "bin" directory of mingw64 to the PATH so clangd is in the PATH.
19231852
19241853## LSP server for C#
19251854
19261855First, install C# lexer from "Addons Manager".
19271856
192818571\. Get OmniSharp server from GitHub <https://github.com/OmniSharp/omnisharp-roslyn/releases> . For Windows 64-bit it is the package "omnisharp-win-x64.zip" or "omnisharp-win-x64-net6.0.zip". Unzip this package to the folder "C:\OmniSharp", for example. It's not required to add that folder to system PATH.
19291858
193018592\. You need to install MSBuild. As of May 2022, OmniSharp does not include MSBuild. Download link can be found at the bottom of this page: <https://visualstudio.microsoft.com/downloads/?q=build+tools> - see "Build Tools for Visual Studio 2022". In the installation check the following option: ".NET desktop build tools". If you won't install MSBuild, OmniSharp server will fail, see more info here: <https://github.com/OmniSharp/omnisharp-vscode/issues/5120> .
19311860
193218613\. Create LSP config file: (CudaText)/settings/lsp_cs.json:
19331862
19341863``` json
19351864{
19361865 "lexers": {
19371866 "C#": "csharp"
19381867 },
19391868 "cmd_windows": [
19401869 "C:\\OmniSharp\\OmniSharp.exe", "-lsp", "-z"
19411870 ]
19421871}
19431872```
19441873
19451874Note that backslashes must be doubled (because of JSON format).
19461875
194718764\. To test that server works: create a file "test.cs" (with C# lexer active). Call auto-completion after "date.A".
19481877
19491878``` csharp
19501879using System;
19511880
19521881public class DateExample
19531882{
19541883 public static void Main()
19551884 {
19561885 DateTime date;
19571886 date.A
19581887 }
19591888}
19601889```
19611890
19621891## LSP server for CSS/SCSS/LESS
19631892
19641893The CSS (and SCSS, LESS) server is not easy to install, so here is the instruction, from the author of LSP Client:
19651894
19661895- Download the repository of VSCode: <https://github.com/microsoft/vscode>
19671896- From the repository, get the folder "extensions/css-language-features/server" and enter in it.
19681897- Replace the file "tsconfig.json" with content:
19691898
19701899``` json
19711900{
19721901 "compilerOptions": {
19731902 "target": "es2018",
19741903 "lib": [
19751904 "es2018"
19761905 ],
19771906 "module": "commonjs",
19781907 "strict": true,
19791908 "alwaysStrict": true,
19801909 "noImplicitAny": true,
19811910 "noImplicitReturns": true,
19821911 "noImplicitOverride": true,
19831912 "noUnusedLocals": true,
19841913 "noUnusedParameters": true,
19851914 "forceConsistentCasingInFileNames": true,
19861915
19871916 "outDir": "./out"
19881917 },
19891918 "files": [
19901919 "src/node/cssServerMain.ts"
19911920 ]
19921921}
19931922```
19941923
19951924- Install dependencies and TypeScript. In Terminal:
19961925
19971926`npm install`\
19981927`npm install -g typescript`
19991928
20001929- Compile it. In Terminal:
20011930
20021931`npx tsc`
20031932
20041933Server should be compiled.
20051934
20061935Create config file (CudaText)/settings/lsp_css.json:
20071936
20081937``` json
20091938{
20101939 "name": "vsc-css",
20111940 "lexers": {
20121941 "CSS": "css",
20131942 "SCSS": "scss",
20141943 "Sass": "sass",
20151944 "LESS": "less",
20161945 },
20171946 "cmd_unix": [
20181947 "node",
20191948 "path_to_server/server/out/node/cssServerMain.js",
20201949 "--stdio"
20211950 ]
20221951}
20231952```
20241953
20251954## LSP server for HTML
20261955
20271956CudaText does not support built-in HTML auto-completion when caret is inside style="..." blocks. But LSP server supports it. Install server using Node.js:
20281957
20291958`npm install --global vscode-html-ls-bin`
20301959
20311960Make config file (CudaText)/settings/lsp_html.json:
20321961
20331962``` json
20341963{
20351964 "lexers": {
20361965 "HTML": "html",
20371966 },
20381967 "cmd_windows": ["html-ls.cmd", "--stdio"],
20391968 "cmd_unix": ["html-ls", "--stdio"]
20401969}
20411970```
20421971
20431972Make sure the script "html-ls" ("html-ls.cmd" on Windows) is in the PATH.
20441973
20451974You may see wrong sorting of CSS properties in the auto-completion list, when auto-completion is called for CSS prop with dash char. To fix that, you need to remove dash char "-" from the "nonword_chars" option. Do it via lexer-specific config for HTML.
20461975
20471976## LSP server for Java
20481977
20491978**Part 1. Information for Windows.**
20501979
20511980- Install lexer "Java" from Addons Manager.
20521981
20531982- Install [Java SE Development Kit 19](https://www.oracle.com/java/technologies/downloads/#jdk19-windows) or later. If you have usual Java (JRE) then better remove it first. Then run in Console:
20541983
20551984`java -version`
20561985
20571986It must show something like this:
20581987
20591988`java version "19.0.1" 2022-10-18`\
20601989`Java(TM) SE Runtime Environment (build 19.0.1+10-21)`\
20611990`Java HotSpot(TM) 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)`
20621991
20631992- Download package "jdt-language-server-1.9.0-2022*.tar.gz" from [Eclipse JDT Language Server milestone builds](https://download.eclipse.org/jdtls/milestones/?d) and extract it to "C:\Java\jdt-language-server".
20641993
20651994- Create "C:\Java\jLSP.cmd" batch file with the following contents (edit if necessary):
20661995
20671996```batch
20681997@echo off
20691998echo.
20701999echo Usage: jLSP.cmd CacheDir
20712000echo where "CacheDir" is an absolute path to your data directory. eclipse.jdt.ls stores workspace specific information in it. This should be unique per workspace/project.
20722001echo.
20732002
20742003:: language server installation folder (adjust to suit)
20752004set Directory=C:/Java/jdt-language-server
20762005:: language server jar file (update based on version file of jar)
20772006set JarFile=%Directory%/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar
20782007:: language server config folder location
20792008set Config=%Directory%/config_win
20802009
20812010set CacheDir=%~1
20822011echo Directory: %Directory%
20832012echo JarFile: %JarFile%
20842013echo Config: %Config%
20852014echo CacheDir: %CacheDir%
20862015
20872016java -Dosgi.bundles.defaultStartLevel=4 -Declipse.product=org.eclipse.jdt.ls.core.product -Dlog.level=ALL -noverify -Xmx1G -jar %JarFile% -configuration %Config% --add-modules=ALL-SYSTEM --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED -data %CacheDir%
20882017```
20892018
20902019- Create LSP config file: (CudaText)/settings/lsp_java.json:
20912020
20922021``` json
20932022{
20942023 "lexers": {
20952024 "Java": "java"
20962025 },
20972026 "cmd_windows": ["C:\\Java\\jLSP.cmd", "./cache_for_proj1"]
20982027}
20992028```
21002029
21012030Use testing file "test.java". Place caret on last code line after "System.g" and call auto-completion.
21022031
21032032``` java
21042033public class Example {
21052034 public static void main(String[] args) {
21062035 System.g
21072036 }
21082037}
21092038```
21102039
21112040**Part 2. Information for Linux.**
21122041
21132042- Install lexer "Java" from Addons Manager.
21142043
21152044- Install "Java SE Development Kit" from [Oracle website](https://www.oracle.com/java/technologies/downloads/#jdk19-linux) or from OS package manager. If you have usual Java (JRE) then better remove it first.
21162045
21172046On Ubuntu this command works (2022 year):
21182047
21192048`sudo apt install openjdk-17-jre-headless `
21202049
21212050Then run in Console:
21222051
21232052`java -version`
21242053
21252054It must show something like this:
21262055
21272056`openjdk version "17.0.4" 2022-07-19`\
21282057`OpenJDK Runtime Environment (build 17.0.4+8-Ubuntu-120.04)`\
21292058`OpenJDK 64-Bit Server VM (build 17.0.4+8-Ubuntu-120.04, mixed mode, sharing)`
21302059
21312060- Download package "jdt-language-server-1.9.0-2022*.tar.gz" from [Eclipse JDT Language Server milestone builds](https://download.eclipse.org/jdtls/milestones/?d) and extract it to "~\jdt-language-server".
21322061
21332062- Create "~\jLSP.sh" shell script with the following contents, and make it executable:
21342063
21352064``` bash
21362065#!/bin/bash
21372066echo
21382067echo Usage: jLSP.sh CacheDir
21392068echo where "CacheDir" is an absolute path to your data directory. eclipse.jdt.ls stores workspace specific information in it. This should be unique per workspace/project.
21402069echo
21412070
21422071# language server installation folder (adjust to suit)
21432072Directory=~/jdt-language-server
21442073# language server jar file (update based on version file of jar)
21452074JarFile=$Directory/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar
21462075# language server config folder location
21472076Config=$Directory/config_linux
21482077
21492078CacheDir=$1
21502079echo Directory: $Directory
21512080echo JarFile: $JarFile
21522081echo Config: $Config
21532082echo CacheDir: $CacheDir
21542083
21552084java -Dosgi.bundles.defaultStartLevel=4 -Declipse.product=org.eclipse.jdt.ls.core.product -Dlog.level=ALL -noverify -Xmx1G -jar $JarFile -configuration $Config --add-modules=ALL-SYSTEM --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED -data $CacheDir
21562085```
21572086
21582087- Create LSP config file: (CudaText)/settings/lsp_java.json:
21592088
21602089``` json
21612090{
21622091 "lexers": {
21632092 "Java": "java",
21642093 },
21652094 "cmd_unix": ["~/jLSP.sh", "./cache_for_proj1"],
21662095}
21672096```
21682097
21692098Use testing file "test.java". Place caret on last code line after "System.g" and call auto-completion.
21702099
21712100``` java
21722101public class Example {
21732102 public static void main(String[] args) {
21742103 System.g
21752104 }
21762105}
21772106```
21782107
21792108## LSP server for Nim
21802109
21812110Server from <https://github.com/PMunch/nimlsp> works good.
21822111
21832112Config file (CudaText)/settings/lsp_nim.json:
21842113
21852114``` json
21862115{
21872116 "name": "nim-lsp",
21882117 "lexers": {
21892118 "Nim": "nim"
21902119 },
21912120 "cmd_unix": [
21922121 "~/.nimble/bin/nimlsp"
21932122 ]
21942123}
21952124```
21962125
21972126## LSP server for Rust
21982127
21992128RLS server ( <https://github.com/rust-lang/rls> ) has been deprecated and is no longer supported. It has been replaced with Rust-analyzer. Users are encouraged to uninstall RLS and follow the instructions in the Rust-analyzer manual to install it. User needs to download binary file for his system: <https://github.com/rust-lang/rust-analyzer#quick-start>
22002129
22012130Create config (CudaText)/settings/lsp_rust.json:
22022131
22032132``` json
22042133{
22052134 "lexers": {
22062135 "Rust": "rust"
22072136 },
22082137 "cmd_windows": ["rust-analyzer-x86_64-pc-windows-msvc.exe"],
22092138 "cmd_unix": ["rust-analyzer-x86_64-unknown-linux-gnu"]
22102139}
22112140```
22122141
22132142## LSP server for AutoHotkey
22142143
22152144- Download the repository of AutoHotkey2: <https://github.com/thqby/vscode-autohotkey2-lsp>
22162145- Extract and enter the directory: "vscode-autohotkey2-lsp-main"
22172146- Install dependencies and TypeScript. In Terminal:
22182147
22192148`npm install`\
22202149`npm install -g typescript`
22212150
22222151- Enter the directory "server", and compile the server. In Terminal:
22232152
22242153`npx tsc`
22252154
22262155Server should be compiled now. To use the server in LSP Client, create the file "lsp_ahk.json" in the "settings" with such content:
22272156
22282157``` json
22292158{
22302159 "name": "AutoHotkey2",
22312160 "lexers": {
22322161 "AutoHotkey": "ahk"
22332162 },
22342163 "cmd_unix": [
22352164 "node",
22362165 "path_to_server/server/out/server.js",
22372166 "--stdio"
22382167 ]
22392168}
22402169```
22412170
22422171## LSP server for Red
22432172
224421731\) On Linux x64.
22452174
22462175- Install Red. Download "red" binary, "chmod +x red", then copy it to PATH dir (/usr/bin on Ubuntu). Command "red" must work from Terminal. Red release 0.6.4 may give errors with the LSP server, so better install build from 30-Sep-2021.
22472176- Install server from <https://github.com/bitbegin/redlangserver>, put the repo e.g. to ~/redlangserver.
22482177- Create file "redlangserver.sh" and put it to some PATH dir. Content:
22492178
22502179``` bash
22512180#!/bin/bash
22522181red ~/redlangserver/server.red
22532182```
22542183
22552184- Create file (CudaText)/settings/lsp_red.json with content:
22562185
22572186``` json
22582187{
22592188 "lexers": {
22602189 "Red": "red"
22612190 },
22622191 "cmd_unix": ["redlangserver.sh"],
22632192 "cmd_windows": ["c:\\red\\red.exe", "--cli", "c:\\red\\redlangserver\\server.red"]
22642193}
22652194```
22662195
22672196Server should work now. It gives: mouse hover tooltips (Ctrl + mouse hovering over names), go to definition.
22682197
226921982\) On Windows 10 x64.
22702199
22712200- Install Red to "c:\Red". Tested the build from 02-Oct-2021.
22722201- Install server from <https://github.com/bitbegin/redlangserver>, put the repo to "c:\Red\redlangserver".
22732202- Run once the command "c:\red\red.exe --cli", it will print "Compiling Red console..." with the big pause.
22742203- Create file (CudaText)\settings\lsp_red.json with the same content as for Unix. Adjust path to Red folder, if needed.
22752204
22762205Server should work now. It gives: mouse hover tooltips (Ctrl + mouse hovering over names), go to definition (works not always, logic when it works is unclear).
22772206
22782207Note: don't create .bat or .cmd file with the "red.exe" calling, because it does not work in LSP Client for some reason.
22792208
22802209## LSP server for PHP
22812210
228222111\. Install PHP, Composer. PHP versions 7.4.3 and 8.1 are OK.
22832212
228422132\. Install php-dom extension. php-dom extension is the only needed for this server to work, and it must be installed before you run "composer update".
22852214
228622153\. Clone Git repo <https://github.com/zobo/php-language-server> , and get the full path to the file "php-language-server.php", it will be needed in the next step. See readme "Installation" part, you must do some steps with Composer first, e.g. "composer update" inside php-language-server directory.
22872216
228822174\. Create LSP config (CudaText)/settings/lsp_php.json:
22892218
22902219``` json
22912220{
22922221 "name": "PHP",
22932222 "lexers": {
22942223 "PHP": "php"
22952224 },
22962225 "tcp_port": 12345,
22972226 "cmd_unix": [
22982227 "php",
22992228 "folder_of_server/bin/php-language-server.php",
23002229 "--tcp-server=127.0.0.1:12345"
23012230 ],
23022231 "cmd_windows": [
23032232 "php",
23042233 "D:\\programm\\php\\php-language-server\\bin\\php-language-server.php",
23052234 "--tcp-server=127.0.0.1:12345"
23062235 ]
23072236}
23082237```
23092238
23102239Server should work now. It gives these features: <https://github.com/zobo/php-language-server#features> .
23112240
23122241Auto-completion works, it is not working if you open .php file that is outside of current CudaText project directory. In LSP Client config there is a parameter named "root_dir_source". For zobo's server to index .php files they must be inside this dir. In CudaText Project Manager you must save your project file to your php project location, otherwise the root_dir will be wrong.
23132242
23142243Note: on Windows, in rare cases hanging php.exe process can prevent LSP server from starting. If you see "ReadLoopError" in Console, try to kill all "php" processes and try again.
23152244
23162245## LSP server for Bash
23172246
23182247- Install Node.js, see readme here: <https://github.com/nodesource/distributions/blob/master/README.md>
23192248- Install Bash server, see readme here: <https://github.com/bash-lsp/bash-language-server>
23202249- Install Shellcheck from <https://www.shellcheck.net/> - "We strongly recommend that you install shellcheck to enable linting"
23212250- On Windows, maybe you need to add folder of "bash-language-server.cmd" to system PATH.
23222251- Create file (CudaText)/settings/lsp_bash.json with content:
23232252
23242253``` json
23252254{
23262255 "lexers": {
23272256 "Bash script": "bash"
23282257 },
23292258 "cmd_windows": ["bash-language-server.cmd", "start"],
23302259 "cmd_unix": ["bash-language-server", "start"]
23312260}
23322261```
23332262
23342263## LSP server for D
23352264
23362265First, install D lexer from "Addons Manager".
23372266
233822671\. Install DLang into "C:\D", for example. For 64-bit compiler, add folder "C:\D\dmd2\windows\bin64" to system PATH. Check that "dmd" and "dub" commands run OK from Windows console.
23392268
234022692\. Install the LSP server, run from console:
23412270
23422271`dub fetch dls`
23432272
23442273This must show output like
23452274
23462275`C:\D>dub fetch dls`\
23472276`Fetching dls 0.26.2...`\
23482277`` Please note that you need to use `dub run <pkgname>` or add it to dependencies of your package to actually use/run it. dub does not do actual installation of packages outside of its own ecosystem. ``
23492278
235022793\. Compile the LSP server, run from console:
23512280
23522281`dub run dls:bootstrap`
23532282
23542283This must show output like
23552284
23562285`C:\D>dub run dls:bootstrap`\
23572286`Building package dls:bootstrap in C:\Users\user\AppData\Local\dub\packages\dls-0.26.2\dls\bootstrap\`\
23582287`Running pre-generate commands for dls:i18n...`\
23592288`Performing "debug" build using C:\D\dmd2\windows\bin64\dmd.exe for x86_64.`\
23602289`dls:protocol 0.26.2: building configuration "library"...`\
23612290`dls:i18n 0.26.2: building configuration "library"...`\
23622291`dls:bootstrap 0.26.2: building configuration "application"...`\
23632292`Linking...`\
23642293`Running ../Users/user/AppData/Local/dub/packages/dls-0.26.2/dls/bootstrap/dls_bootstrap.exe`\
23652294`C:\Users\user\AppData\Local\dub\packages\.bin\dls-latest\dls.exe`
23662295
23672296Copy to clipboard the last printed filename with dls.exe.
23682297
236922984\. Create the CudaText LSP config: (CudaText)/settings/lsp_d.json. The dls.exe filename is from the previous step. Note: backslashes must be doubled (because of JSON format).
23702299
23712300``` json
23722301{
23732302 "lexers": {
23742303 "D": "dlang"
23752304 },
23762305 "cmd_windows": [
23772306 "C:\\Users\\user\\AppData\\Local\\dub\\packages\\.bin\\dls-latest\\dls.exe", "--stdio"
23782307 ]
23792308}
23802309```
23812310
238223115\. Create test file "test.d" (with lexer D). Test that auto-completion works after "b.":
23832312
23842313``` d
23852314class A {int a; int a2;}
23862315class B: A {int a3;}
23872316
23882317void foo(B b)
23892318{
23902319 b.
23912320}
23922321```
23932322
23942323## LSP server for Go
23952324
23962325Install lexer Go from "Addons Manager".
23972326
239823271\. Install Go. Make sure that Go binary is in the system PATH, and GOPATH variable is also set.
23992328
240023292\. Install the LSP server:
24012330
24022331`go install golang.org/x/tools/gopls@latest`
24032332
24042333In Ubuntu, this must create binary "gopls" in the folder "~/go/bin" (on Windows it may be "C:\Go\bin"), which is in the PATH. Check that "gopls" runs:
24052334
24062335`gopls version`
24072336
24082337It must give output like:
24092338
24102339`golang.org/x/tools/gopls v0.9.5`\
24112340`    golang.org/x/tools/gopls@v0.9.5 h1:F3TO5th6TUg40FHrpxZfMkMlVaaTmByeEvylgVHGH2A=`
24122341
241323423\. Create CudaText LSP config (CudaText)/settings/lsp_go.json:
24142343
24152344``` json
24162345{
24172346 "lexers": {
24182347 "Go": "go"
24192348 },
24202349 "cmd_unix": [
24212350 "gopls"
24222351 ],
24232352 "cmd_windows": [
24242353 "gopls.exe"
24252354 ]
24262355}
24272356```
24282357
242923584\. See the content of GOPATH env variable, and create file "test.go" (with lexer Go) in that folder. Check that auto-completion works after "fmt.F":
24302359
24312360``` go
24322361package aa
24332362import ("fmt")
24342363
24352364func main() {
24362365 fmt.F
24372366}
24382367```
24392368
24402369## LSP server for Lua
24412370
244223711\. Install server for the command line from <https://github.com/sumneko/lua-language-server> . Find the full path of the file "lua-language-server" ("lua-language-server.exe" on Windows).
24432372
244423732\. Create LSP config (CudaText)/settings/lsp_lua.json:
24452374
24462375``` json
24472376{
24482377 "lexers": {
24492378 "Lua": "lua"
24502379 },
24512380 "log_stderr": true,
24522381 "cmd_windows": ["D:\\Programs\\lua-lsp\\bin\\lua-language-server.exe"],
24532382 "cmd_unix": ["/path/to/lua-language-server"]
24542383}
24552384```
24562385
24572386## LSP server for Scala
24582387
24592388Install lexer "Scala" from Addons Manager. Information for Windows.
24602389
246123901\. Install Coursier: <https://get-coursier.io/docs/cli-installation>
24622391
246323922\. Install Metals. Make sure "metals.bat" is in the system PATH.
24642393
24652394`cs install metals`
24662395
246723963\. Create LSP config file (CudaText)/settings/lsp_scala.json:
24682397
24692398``` json
24702399{
24712400 "lexers": {
24722401 "Scala": "scala"
24732402 },
24742403 "cmd_windows": ["metals.bat"]
24752404}
24762405```
24772406
24782407Testing file for auto-completion:
24792408
24802409`object Hello extends App {`\
24812410`    println("Hello, world")`\
24822411`}`
24832412
24842413## LSP server for Fortran
24852414
24862415Install lexer "Fortran" from Addons Manager. Steps show how to use server on Linux (Ubuntu 20.04) with Python 3 installed.
24872416
248824171\. Install the LSP server:
24892418
24902419`pip install fortran-language-server`
24912420
24922421Check that command runs OK:
24932422
24942423`fortls -?`
24952424
24962425And check its full path:
24972426
24982427`which fortls`
24992428
25002429Here it prints: "/home/user/.local/bin/fortls". We will need that full path in the next step, because short program name "fortls" gave errors for me.
25012430
250224312\. Create LSP config file: (CudaText)/settings/lsp_fortran.json:
25032432
25042433``` json
25052434{
25062435 "lexers": {
25072436 "Fortran": "fortran"
25082437 },
25092438 "cmd_unix": [
25102439 "/home/user/.local/bin/fortls"
25112440 ]
25122441}
25132442```
25142443
251524443\. Make test file "test.for" (with Fortran lexer). Test auto-completion after "CALL myv".
25162445
25172446``` fortran
25182447PROGRAM myprog
25192448USE test_free, ONLY: scaled_vector
25202449TYPE(scaled_vector) :: myvec
25212450CALL myv
25222451END PROGRAM
25232452```
25242453
25252454## LSP server for Markdown
25262455
252724561\. Get precompiled Marksman LSP server from GitHub: <https://github.com/artempyanykh/marksman/releases>
25282457
252924582\. On Windows, copy "marksman.exe" to some folder in PATH. On Linux, copy "marksman-linux" to this recommended folder in PATH: ~/.local/bin. Set executable permission for Linux binary.
25302459
25312460`chmod +x marksman-linux`
25322461
253324623\. Create config file (CudaText)/settings/lsp_md.json:
25342463
25352464``` json
25362465{
25372466 "lexers": {
25382467 "Markdown": "markdown"
25392468 },
25402469 "cmd_windows": ["marksman.exe"],
25412470 "cmd_unix": ["marksman-linux"]
25422471}
25432472```
25442473
25452474Now auto-completion / goto-definition / hover-tooltip must work on this "test.md" file:
25462475
25472476``` md
25482477[reference][abcd]
25492478[reference][a123]
25502479
25512480Some text.
25522481
25532482[abcd]: url "title"
25542483[a123]: url "title2"
25552484```
25562485
25572486## LSP server for V
25582487
25592488- Install V lexer (from "Addons Manager / Plugins / Install")
25602489- Install V language
25612490- Install v-analyzer binary from <https://github.com/v-analyzer/v-analyzer> to a folder (that is included in PATH)
25622491- Create "lsp_v.json" in CudaText's "settings" folder with the following content:
25632492
25642493``` json
25652494{
25662495 "lexers": {
25672496 "V": "v"
25682497 },
25692498 "cmd_windows": ["v-analyzer.exe"],
25702499 "cmd_unix": ["v-analyzer"],
25712500 "cmd_macos": ["v-analyzer"]
25722501}
25732502```
25742503
25752504## LSP server Vale
25762505
25772506Steps for Windows OS.
25782507
25792508- Install Vale server. Add path of "vale-ls.exe" to system PATH.
25802509- Create "lsp_vale.json" in CudaText's "settings" folder. Specify empty lexer name.
25812510
25822511``` json
25832512{
25842513 "lexers": {
25852514 "": ""
25862515 },
25872516
25882517 "cmd_windows": ["vale-ls.exe"],
25892518 "log_stderr": true,
25902519 "settings": {
25912520 "configPath": ""
25922521 }
25932522}
25942523```
25952524
25962525- You need to put config file to %UserProfile% folder. For example: "C:\Users\john\\.vale.ini".
25972526- Do not forget to run: "vale sync".
25982527- Vale server did not support filenames with spaces on Windows OS. To fix it, update Vale to 0.3.7 or newer.
25992528
26002529---
26012530*From the Free Pascal wiki, page "CudaText plugins", as it stood on 2024-05-05 after a change by Alextp, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
26022531Category: CudaText

Back to history