Sign in Join
Wiki copytemporary

CudaText plugins: what changed

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

Title: CudaText plugins

OldNewLine
1+## Comments
2+
3+You 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).
4+
5+- **Line comments**: from some position to the nearest end-of-line. E.g. in C lexer: "//text here", in Python lexer: "# text here".
6+- **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 */".
7+- **Comments for full lines**: from newline to another newline, ie comment for several whole lines. Rarely used, e.g. used in PowerShell.
8+
9+For 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.
10+
11+Comment 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.
12+
13+Command "Toggle stream comment" in plugin adds/removes comments of last 2 types: for range, for full lines (plugin chooses needed kind).
14+
15+Where comment chars are stored:
16+
17+- Line comments: in lexer file data/lexlib/*.lcf.
18+- Range comments: in additional file data/lexlib/*.cuda-lexmap.
19+
20+### Commenting options
21+
22+Plugin "Comments" has several options, and it gives the dialog to change them: menu item "Options / Settings-plugins / Comments / Config".
23+
24+**(Line commands) Try to keep text position after (un)commenting**
25+
26+Affects all commands for line-comments.
27+
28+With 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:
29+
30+`    code();`
31+
32+will be changed to line with 2 leading spaces:
33+
34+`  //code();`
35+
36+After uncommenting, line will be restored to original, with 4 leading spaces.
37+
38+**(Line "at non-space") If selected few lines, insert comment at maximal common indent**
39+
40+Affects commands:
41+
42+- "Toggle line comment, at non-space char"
43+- "Add line comment, at non-space char"
44+
45+With option on, this selected block of lines in C++:
46+
47+`      code1();`\
48+`    code2();`\
49+`        code3();`
50+
51+will be changed to:
52+
53+`    //  code1();`\
54+`    //code2();`\
55+`    //    code3();`
56+
57+With option off, block will be changed to:
58+
59+`      //code1();`\
60+`    //code2();`\
61+`        //code3();`
62+
63+**(All) Move caret to next line**
64+
65+Affects commands for line-comments, when they are called without selection.
66+
67+With option on, caret will be moved 1 line down. This allows to call the command many times repeatedly, to change many lines.
68+
69+**(Line commands) Skip blank lines**
70+
71+Affects commands for line-comments, when they are called without selection.
72+
73+With option on, and the previous option "Move caret to next line" on, command will skip lines containing only space/tab chars.
74+
75+**"Toggle line comment" detects action by first non-blank line**
76+
77+Affects command "Toggle line comment".
78+
79+With option on, command detects its action (to comment or to uncomment) by the first non-blank line of the selected multi-line block.
80+
81+Here is selected block of code, selection is shown by square brackets, first selected line is blank line:
82+
83+`[`\
84+` `\
85+`    //code1();`\
86+`    code2();`\
87+`    //code3();`\
88+`    code4();`\
89+`]`
90+
91+With option off, block will be changed it to:
92+
93+`[//`\
94+`//`\
95+`    //code1();`\
96+`    //code2();`\
97+`    //code3();`\
98+`    //code4();`\
99+`]`
100+
101+With option on, block will be changed to:
102+
103+`[`\
104+` `\
105+`    code1();`\
106+`    code2();`\
107+`    code3();`\
108+`    code4();`\
109+`]`
110+
111+## Macros
112+
113+Macro 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:
114+
115+- Macros...
116+- Start/stop recording
117+- Playback last recorded macro
118+- Export...
119+- Import...
120+- items for saved macros
121+
122+<figure>
123+<img src="cudatext-macro-menu.png" title="cudatext-macro-menu.png" />
124+<figcaption>cudatext-macro-menu.png</figcaption>
125+</figure>
126+
127+To record a macro:
128+
129+- Call menu item "Macros / Start/stop recording", or use dialog "Macros / Macros..." which gives the button for this.
130+- Perform some actions in CudaText:
131+ - built-in commands, plugin commands (invoked by hotkey, by menu, by Command Palette)
132+ - some mouse actions (clicks/selections, they save/playback relative to caret position)
133+ - calling of Find/Replace dialog, "Go to" dialog
134+ - actions in Find/Replace dialog
135+- Call menu item "Macros / Start/stop recording" again, plugin will ask for macro name.
136+
137+During recording, CudaText shows reddish border around the editor field.
138+
139+<figure>
140+<img src="cudatext-macro-border.png" title="cudatext-macro-border.png" />
141+<figcaption>cudatext-macro-border.png</figcaption>
142+</figure>
143+
144+Macro 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.
145+
146+To playback macro:
147+
148+- Call menu item "Macros / macro_name", the end of this menu lists all available/saved macros.
149+- Or call dialog "Macros / Macros...", which allows to run all available macros:
150+ - running 1 time
151+ - running specified count of times
152+ - running in the loop, by options:
153+ - While text changes
154+ - Until caret on last line
155+
156+### Macro example
157+
158+For example, we have text line with HTML tags like this ("\|" shows the caret):
159+
160+`....<tag>....|...........</tag>....`
161+
162+For 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".
163+
164+So, during macro recording, run these commands:
165+
166+- call Find dialog (or focus it with mouse), search for "\>" with "Find previous" button
167+- right-arrow key (to reset the selection)
168+- "markers: drop marker at caret"
169+- call Find dialog again (or focus it with mouse), search for "\<" with "Find next" button
170+- left-arrow key, 2 times (to reset the selection)
171+- "markers: select to last marker"
172+- "markers: remove all"
173+
174+## Project Manager
175+
176+This 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.
177+
178+Plugin has context menu on its panel, with items:
179+
180+- **Project file**
181+ - New project
182+ - Open project
183+ - Recent projects
184+ - Save project as...
185+ - Go to file... - this shows menu with all project files, and then tree-view selection jumps on selected file
186+ - Project properties... - this shows dialog with current project's options
187+ - Config... - this shows dialog with global Project Manager options
188+- **Root nodes** - commands for nodes on the project's root level
189+ - Add folder...
190+ - Add file...
191+ - Clear project
192+ - Remove node
193+- **Selected file** - it's shown only for files
194+- **Selected directory** - it's shown only for folders
195+- **Refresh** - it re-reads state of files/folders from disk
196+
197+To 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:
198+
199+<figure>
200+<img src="cudatext-project-seldir.png" title="cudatext-project-seldir.png" />
201+<figcaption>cudatext-project-seldir.png</figcaption>
202+</figure>
203+
204+Any 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.
205+
206+Sometimes 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.
207+
208+### Project Manager options dialog
209+
210+"Ignore files"
211+";"-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.
212+
213+"Ignore folders"
214+";"-separated shell wildcards. If folder name matches any of these wildcards, it will not be listed in the treeview.
215+
216+"Ignore all hidden files/folders"
217+Additionally don't list all hidden items. On Unix, hidden mean "beginning with dot". On Windows, hidden means having file-system "hidden" attribute.
218+
219+"Open file after "Go to file" command"
220+If 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.
221+
222+"Use 'preview tab' on item clicking"
223+If 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.
224+
225+"Open files by double-click"
226+If turned on, only double-click in the treeview will open file for editing, but not the single click.
227+
228+"On opening file in Git/SVN repo..."
229+On 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.
230+
231+"Suggest to close tabs not belonging to project"
232+See #Sessions embedded to project.
233+
234+And options for icons:
235+
236+"File type icons"
237+Set 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".
238+
239+"Toolbar icons"
240+Set 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".
241+
242+### Preview tab
243+
244+To 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.
245+
246+"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.
247+
248+Again, 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.
249+
250+"Preview tab" can be dragged to another tab-group, it should work there too.
251+
252+### Switch between projects
253+
254+1\) To switch to different project, Plugin Manager gives the context menu: "Project File / Recent projects / name.cuda-proj".
255+
256+2\) 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.
257+
258+3\) There is also a way to quickly switch between projects:
259+
260+- Install plugins: "Config Toolbar", "External Tools" and "Session Manager". Restart CudaText.
261+- Set CudaText option "ui_one_instance": true.
262+- 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).
263+- Add more such tools in the "External Tools", for different projects (and maybe sessions).
264+
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>
269+
270+- 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.
271+
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>
276+
277+4\)
278+
279+- Install plugin "Config Toolbar" (only 1 plugin here, comparing to the previous method).
280+- CudaText option "ui_one_instance" can be any.
281+- 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.
282+- CudaText will use the new command-line which you entered after "exec=".
283+
284+### Sessions embedded to project
285+
286+CudaText 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}".
287+
288+To control sessions, use the "gear" button on the Project Manager toolbar. Several menu items are there:
289+
290+- "Project session: name". One or more menu items, one item per each session.
291+- "Save session...". Shows text input prompt, to name a session (you will be warned if you use incorrect characters or session already exists).
292+- "Delete session". Shows menu to choose which session to delete from the project.
293+- "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.
294+- "Forget session, close all tabs".
295+
296+Project Manager has the option checkbox "Suggest to close tabs not belonging to project". When option is on, you will see such confirmation message box:
297+
298+`CudaText has opened 3 tab(s) not belonging to the project "name". Close them?`\
299+`/path/to/file1`\
300+`/path2/to/file2`\
301+`*Untitled1`
302+
303+You will see this confirmation when doing:
304+
305+- "New project" action (from Project Manager context menu, or from Command Palette)
306+- "Save session..." action (from "gear" popup menu, or from Command Palette)
307+
308+You can disable that option (or press "Cancel" in the confirmation), to save even "not belonging" opened files to embedded session.
309+
310+## How to bind a hotkey to insert a snippet
311+
312+You 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.
313+
314+Let's show how to make a primitive plugin which has 2 primitive commands:
315+
316+- Insert snippet "AA" at the caret position (supporting multi-carets).
317+- Surround current line with square brackets.
318+
319+Make a new plugin by calling menu item "Plugins / Make Plugin". Fieds of dialog:
320+
321+- "Plugin name": set to "My plugin".
322+- "Python module name": set to "my_snippet".
323+- "Commands caption\>method": set 2 lines:
324+
325+`My snippet>my_snippet`\
326+`My edit>my_edit`
327+
328+This will generate new plugin with 2 methods in the file "__init__.py": my_snippet and my_edit. Code will be like this:
329+
330+``` python
331+ def my_snippet(self):
332+ #
333+ #
334+ #
335+ msg_box(s, MB_OK)
336+
337+ def my_edit(self):
338+ pass
339+```
340+
341+At the top of the Python file, near "import" operators, add:
342+
343+``` python
344+import cudatext_cmd as cmds
345+```
346+
347+Now edit methods my_snippet / my_edit:
348+
349+``` python
350+ def my_snippet(self):
351+ ''' Insert my snippet '''
352+ ed.cmd(cmds.cCommand_TextInsert, 'AA')
353+
354+ def my_edit(self):
355+ ''' Surround line with brackets '''
356+ x, y, x1, y1 = ed.get_carets()[0]
357+ s = ed.get_text_line(y)
358+ s = '[' + s + ']'
359+ ed.set_text_line(y, s)
360+ msg_status('Edited!')
361+```
362+
363+All done. Restart CudaText. You must have new menu items:
364+
365+- "Plugins / My plugin / My snippet"
366+- "Plugins / My plugin / My edit"
367+
368+In the Command Palette, find these new commands, press F9 to set hotkey for them.
369+
370+## Snippets
371+
372+To use snippets you need:
373+
374+- Plugin "Snippets" (install from Addon Manager)
375+- Snippet package for needed lexer (install from Addon Manager)
376+
377+Each 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...".
378+
379+Only 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.
380+
381+Dialog of Snippets plugin:
382+
383+<figure>
384+<img src="cudatext_snippets_menu.png" title="cudatext_snippets_menu.png" />
385+<figcaption>cudatext_snippets_menu.png</figcaption>
386+</figure>
387+
388+Texts 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]].
389+
390+Plugin supports two snippets folder, but formats of data are the same, VSCode JSON format:
391+
392+- CudaText snippets. These are packages with prefix "snippets_ct" in the Addons Manager. They are installed into folder CudaText/data/snippets_ct.
393+- 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.
394+
395+### Snippets from VSCode
396+
397+Since recent versions, Snippets plugin supports snippets from VSCode editor. It gives menu items in "Plugins / Snippets":
398+
399+- "Install VSCode snippets..." - this suggests to install packages with snippets (packages usually contain more functionality, and CudaText plugin will install only snippets).
400+
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>
405+
406+- "Remove VSCode snippets"
407+- "Visit homepage of VSCode snippets..."
408+- "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.
409+
410+Plugin also gives the fully featured snippet editor dialog, in menu item "Add/edit snippets...".
411+
412+<figure>
413+<img src="cudatext-snippets-editor.png" title="cudatext-snippets-editor.png" />
414+<figcaption>cudatext-snippets-editor.png</figcaption>
415+</figure>
416+
417+You 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.
418+
419+Currently most of VSCode/TextMate "macros" are supported in snippets body, but not all. Refer to readme file of the plugin.
420+
421+### Snippets for HTML tags
422+
423+CudaText 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:
424+
425+` <a href="http" title="Title" target="_blank"></a>`
426+
427+These snippets have markers, so Tab key jumps to the next marker. Last marker is usually placed after the entire tag, ie after "\>" bracket.
428+
429+### Format of snippet files
430+
431+#### Snippets tab-stops
432+
433+Specify tab-stops in the snippet text like this:
434+
435+- \${NN}
436+- \${NN:default text}
437+
438+This 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.
439+
440+- Markers can be listed in any order (e.g. marker 4 can be between 1 and 2).
441+- Tab-key first goes to marker 1, 2, 3... and marker 0 is always the last.
442+- Markers with the same indexes will place multi-carets.
443+- Nested markers (with default text) are allowed, but only with one nesting level, e.g. \${2:text is {\$3:here}}.
444+- Marker with default text \${NN:...} can specify multi-line default text (character "}" is on another line of snippet).
445+
446+#### Snippets macros
447+
448+Special macros are handled by Snippets plugin in snippet text:
449+
450+- \${sel} - Text selected before snippet insertion (if snippet called with Tab key, it's empty string)
451+- \${cp} - Current clipboard contents
452+
453+- \${cmt_start} - Current lexer's "block comment" start symbols (or empty string)
454+- \${cmt_end} - Current lexer's "block comment" end symbols (or empty string)
455+- \${cmt_line} - Current lexer's "line comment" symbols (or empty string)
456+
457+- \${fname} - File name only, without path
458+- \${fpath} - Full file name, with path
459+- \${fdir} - Directory of file
460+- \${fext} - Extension of file
461+- \${psep} - OS path separator: backslash on Windows, slash on Unix
462+
463+- \${date:nnnn} - Current date/time formatted by string "nnnn"; see [Python docs](http://strftime.org/)
464+- \${env:nnnn} - Value of OS environment variable "nnnn"
465+- \${cmd:nnnn} - Execute shell command "nnnn" and get its output (space-separated arguments are supported, '~' for home-directory is supported on Unix)
466+
467+The following macros from Sublime Text editor are supported. They can be written as \$NAME or as \${NAME}.
468+
469+- \$TM_SELECTED_TEXT - The currently selected text or the empty string
470+- \$TM_CURRENT_LINE - The contents of the current line
471+- \$TM_CURRENT_WORD - The contents of the word under cursor or the empty string
472+- \$TM_LINE_INDEX - The zero-based line number
473+- \$TM_LINE_NUMBER - The one-based line number
474+- \$TM_FILEPATH - The full file path of the current document
475+- \$TM_DIRECTORY - The directory of the current document
476+- \$TM_FILENAME - The filename of the current document
477+- \$TM_FILENAME_BASE - The filename of the current document without its extensions
478+- \$CLIPBOARD - The contents of your clipboard
479+- \$WORKSPACE_NAME - The name of the opened workspace or folder
480+
481+- \$BLOCK_COMMENT_START - Current lexer's "block comment" start symbols (or empty string)
482+- \$BLOCK_COMMENT_END - Current lexer's "block comment" end symbols (or empty string)
483+- \$LINE_COMMENT - Current lexer's "line comment" symbols (or empty string)
484+
485+For inserting the current date and time:
486+
487+- \$CURRENT_YEAR - The current year
488+- \$CURRENT_YEAR_SHORT - The current year's last two digits
489+- \$CURRENT_MONTH - The month as two digits (e.g. '02')
490+- \$CURRENT_MONTH_NAME - The full name of the month (e.g. 'July')
491+- \$CURRENT_MONTH_NAME_SHORT - The short name of the month (e.g. 'Jul')
492+- \$CURRENT_DATE - The day of the month
493+- \$CURRENT_DAY_NAME - The name of day (e.g. 'Monday')
494+- \$CURRENT_DAY_NAME_SHORT - The short name of the day (e.g. 'Mon')
495+- \$CURRENT_HOUR - The current hour in 24-hour clock format
496+- \$CURRENT_MINUTE - The current minute
497+- \$CURRENT_SECOND - The current second
498+- \$CURRENT_SECONDS_UNIX - The number of seconds since the Unix epoch
499+
500+## Snippet Panel
501+
502+Plugin "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).
503+
504+Preinstalled folders:
505+
506+- Arrows
507+- Currency symbols
508+- Greek alphabet (lower)
509+- Greek alphabet (upper)
510+- HTML - Arrows
511+- HTML - Color names
512+- HTML - Color names+values
513+- HTML - Letters
514+- HTML - Math symbols
515+- HTML - Special characters
516+- Math symbols
517+- Quote selection
518+- Special characters
519+
520+Plugin looks for its folders in two places:
521+
522+- Folder "clips" in the plugin folder.
523+- Folder CudaText/data/clips, which is absent by default, for custom user folders.
524+
525+Each 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.
526+
527+## CudaLint
528+
529+CudaLint 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:
530+
531+- JavaScript is supported with linter based on JSLint tool,
532+- HTML is supported with linter based on HTML Tidy tool,
533+- CSS is supported with linter based on CSSLint tool,
534+- etc
535+
536+You 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.
537+
538+### Linters - usage
539+
540+To 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).
541+
542+Linting can also be run by events:
543+
544+- after opening file
545+- on saving file
546+- after text is changed + pause passed
547+
548+Events 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".
549+
550+### Linters - Node.js
551+
552+Some 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.
553+
554+- Windows: "node.exe" must be in PATH, command "node -v" must work in console.
555+- Linux: "nodejs" package must be installed, command "nodejs -v" must work in terminal.
556+
557+### Linters - authoring
558+
559+To support more lexers, it's a good idea to port linter from SublimeLinter. To port a linter, most you need is:
560+
561+- 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.
562+- 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.
563+- 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.
564+- If linter was using Node.js, take some code to run Node, from cuda_lint_csslint linter.
565+
566+### Linters - per project
567+
568+How 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:
569+
570+`linter_css=csslint`
571+
572+Variable 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".
573+
574+In 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.
575+
576+### Linters - method split_match
577+
578+Linters have RegEx property in class, which must find named groups:
579+
580+- "line": Line index.
581+- "col": Column index.
582+- "error": If found then CudaLint will force "error" gutter icon.
583+- "warning": If found then CudaLint will force "warning" gutter icon.
584+- "message": Message text.
585+
586+Group "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.
587+
588+Example from SublimeLinter's linter for "Luau":
589+
590+``` python
591+class Luau(Linter):
592+ cmd = 'luau-analyze --formatter=gnu -'
593+ regex = r'^stdin:(?P<line>\d+)\.(?P<col>\d+)\-(?P<end_line>\d+)\.(?P<end_col>\d+): (?P<code>\w+): (?P<message>.+)'
594+```
595+
596+Sometimes, finding "error"/"warning" named groups is hard, and class method "split_match" can help here. Example from SublimeLinter's linter for "Luau":
597+
598+``` python
599+ def split_match(self, match):
600+ error = super().split_match(match)
601+ error['error_type'] = 'error' if error['code'].endswith('Error') else 'warning'
602+ return error
603+```
604+
605+If 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:
606+
607+``` python
608+ def split_match(self, match):
609+ matches, line, col, error, warning, message, near = super().split_match(match)
610+ is_error = matches.group('code').endswith('Error')
611+ error = is_error
612+ warning = not is_error
613+ return matches, line, col, error, warning, message, ''
614+```
615+
616+CudaLint needs 7 tuple items in split_match() result:
617+
618+- matches: RegEx match object
619+- line: Line index
620+- col: Column index
621+- error: Error state; if casted to True, line will have "error" icon (red)
622+- warning: Warning state; if casted to True, line will have "warning" icon (yellow)
623+- message: Message string
624+- near: Ignored in CudaLint
625+
626+Example from CudaLint linter for Java. We override method because javac lints all referenced files, and we only want errors from the linted file.
627+
628+``` python
629+ def split_match(self, match):
630+ if match:
631+ if match.group('file') != self.filename:
632+ match = None
633+ return super().split_match(match)
634+```
635+
636+Example 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.
637+
638+``` python
639+ def split_match(self, match):
640+ match, line, col, error, warning, message, near = super().split_match(match)
641+ if line is None:
642+ line = col = 0
643+ return match, line, col, error, warning, message, near
644+```
645+
646+Example from CudaLint linter for AutoIt. Here we modify the message/error/warning.
647+
648+``` python
649+ def split_match(self, match):
650+ split_match = super(AutoIt, self).split_match(match)
651+ match, line, col, error, warning, message, near = split_match
652+ message = '{} (Col {})'.format(message, col)
653+
654+ if match and match.group('type') == 'error':
655+ error = 1
656+ message = 'Error: ' + message
657+ elif match and match.group('type') == 'warning':
658+ warning = 1
659+ message = 'Warning: ' + message
660+
661+ return match, line, col, error, warning, message, ''
662+```
663+
664+Example from CudaLint linter for JavaScript using ESLint. We override this method to silent warning by .eslintignore settings.
665+
666+``` python
667+ def split_match(self, match):
668+ v1message = 'File ignored because of your .eslintignore file. Use --no-ignore to override.'
669+ v2message = 'File ignored because of a matching ignore pattern. Use --no-ignore to override.'
670+
671+ match, line, col, error, warning, message, near = super().split_match(match)
672+ if message and (message == v1message or message == v2message):
673+ return match, None, None, None, None, '', None
674+
675+ return match, line, col, error, warning, message, near
676+```
677+
678+Example from CudaLint linter for PowerShell using PSScriptAnalyzer. We return the match with \` quotes transformed to '. We supress one message.
679+
680+``` python
681+ def split_match(self, match):
682+ match, line, col, error, warning, message, near = super().split_match(match)
683+
684+ if message == 'no PowerShell code found at all':
685+ match = None
686+ else:
687+ message = message.replace('`', '\'')
688+
689+ # If the message contains a complaint about a function
690+ # and near looks like a function reference, remove the trailing
691+ # () so it can be found.
692+ if 'function \'' in message and near and near.endswith('()'):
693+ near = near[:-2]
694+
695+ return match, line, col, error, warning, message, near
696+```
697+
698+Example from CudaLint linter for Ruby. We override method because unrelated library files can throw errors, and we only want errors from the linted file.
699+
700+``` python
701+ def split_match(self, match):
702+ if match:
703+ if match.group('file') != '-':
704+ match = None
705+ return super(Ruby,self).split_match(match)
706+```
707+
708+Example 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.
709+
710+``` python
711+ def split_match(self, match):
712+ match, line, col, error, warning, message, near = super().split_match(match)
713+ if line is None and message:
714+ line = 0
715+ col = 0
716+ return match, line, col, error, warning, message, near
717+```
718+
719+Example from CudaLint linter for Haskell. We override method to ignore errors reported in imported files.
720+
721+``` python
722+ def split_match(self, match):
723+ match, line, col, error, warning, message, near = super().split_match(match)
724+ match_filename = os.path.basename(match.groupdict()['filename'])
725+ if not match_filename.startswith('_CudaLint_'):
726+ return None, None, None, None, None, '', None
727+ return match, line, col, error, warning, message, near
728+```
729+
730+## CudaFormatter
731+
732+CudaFormatter 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.
733+
734+CudaFormatter 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.
735+
736+For example, how to format code in XML?
737+
738+- Use "Plugins / Addon Manager / Install" to install the CudaFormatter, and formatter(s) for XML. Restart CudaText.
739+- Open XML file (normal or "lite" lexer XML must activate).
740+- Use "Plugins / CudaFormatter / Formatter (menu)". This will show the menu of actions from appropriate formatter(s) for the XML (normal or "lite") lexer.
741+
742+Formatters 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.
743+
744+### CudaFormatter commands
745+
746+Formatter (menu)
747+Runs 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.
748+
749+Formatter per-lexer A...D
750+Runs 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".
751+
752+Formatter cross-lexer 1...4
753+Runs 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.
754+
755+Minify to separate file
756+Finds 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).
757+
758+Configure on_save
759+Chooses 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.
760+
761+Configure per-lexer labels
762+Allows 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.
763+
764+Configure formatter
765+For those formatters which have configuration file, command will suggest to open global config file (in the folder "settings" of CudaText).
766+
767+Configure formatter (local)
768+For 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.
769+
770+### How to run formatter ESLint on saving
771+
772+- Install from Addons Manager: "CudaFormatter"
773+- Install from Addons Manager: "formatter: JavaScript_JSON"
774+
775+You 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?
776+
777+- Activate lexer JavaScript in the current document (can be empty).
778+- Call menu item "Plugins / CudaFormatter / Configure on_save...".
779+- 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.
780+
781+<figure>
782+<img src="cudatext-fmt-onsave.png" title="cudatext-fmt-onsave.png" />
783+<figcaption>cudatext-fmt-onsave.png</figcaption>
784+</figure>
785+
786+Now 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.
787+
788+### How formatter can know filename
789+
790+Some 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:
791+
792+`from cuda_fmt import fmtconfig`\
793+`fn = fmtconfig.ed_filename`
794+
795+## External Tools
796+
797+### Introduction to External Tools
798+
799+Plugin "External Tools" (ExtTools) can be installed from Addon Manager. It allows to run external programs, catch their output, and then it can:
800+
801+- Display this output in the Output or Console panel of CudaText.
802+- Replace current editor selection with the output.
803+- Copy this output to a new document.
804+- Copy this output to Clipboard.
805+- And more.
806+
807+Plugin 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.
808+
809+<figure>
810+<img src="cudatext-tools-menuitem.png" title="cudatext-tools-menuitem.png" />
811+<figcaption>cudatext-tools-menuitem.png</figcaption>
812+</figure>
813+
814+Some external tools configs are shown in the Wiki topics below. Enter these strings in the "Tool properties" dialog.
815+
816+<figure>
817+<img src="cudatext-tools-props.png" title="cudatext-tools-props.png" />
818+<figcaption>cudatext-tools-props.png</figcaption>
819+</figure>
820+
821+Plugin 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.
822+
823+<figure>
824+<img src="cudatext-tools-mainlexertool.png" title="cudatext-tools-mainlexertool.png" />
825+<figcaption>cudatext-tools-mainlexertool.png</figcaption>
826+</figure>
827+
828+Notes:
829+
830+- 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.
831+- 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".
832+
833+### Tool to compile by GCC
834+
835+You 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++".
836+
837+Properties:
838+
839+- Name: C - compile
840+- File name: gcc
841+- Shell command: unchecked
842+- Parameters: "{FileNameOnly}" -o "{FileNameNoExt}"
843+- Initial folder: {FileDir}
844+- Lexers: C,C++
845+- Capture output: Output panel
846+- Encoding: utf_8
847+
848+Optionally, 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".
849+
850+- Pattern: (?P\<file\>\[^:\]+):(?P\<line\>\d+):(?P
851+ <col>
852+
853+ \d+): .+
854+
855+### Tool to run C program
856+
857+Tool is for Linux, so "File name" don't have an extension. For Windows, change "File name" field to "{FileNameNoExt}.exe".
858+
859+Tool will catch the program output in the Output panel, program text input will not work.
860+
861+- Name: C - run
862+- File name: "./{FileNameNoExt}"
863+- Shell command: checked
864+- Parameters: (empty)
865+- Initial folder: {FileDir}
866+- Lexers: C,C++
867+- Capture output: Output panel
868+- Encoding: utf_8
869+- Pattern: (empty)
870+
871+### Tool to run C program, on Windows, with input in terminal
872+
873+Tool is for Windows, it allows to run compiled C/C++ program in new console window. Text input will work in this console.
874+
875+Example C++ program:
876+
877+``` C++
878+#include <stdio.h>
879+int main ()
880+{
881+ int c;
882+ puts ("Enter text. Include a dot ('.') in a sentence to exit:");
883+ do {
884+ c=getchar();
885+ putchar (c);
886+ } while (c != '.');
887+ return 0;
888+}
889+```
890+
891+Tool props:
892+
893+- Name: C - run
894+- File name: cmd
895+- Shell command: unchecked
896+- Parameters: /K "{FileNameNoExt}.exe"
897+ - Alternative value: /C "{FileNameNoExt}.exe" && pause
898+- Initial folder: {FileDir}
899+- Lexers: C,C++
900+- Capture output: Ignore
901+- Encoding: utf_8
902+- Pattern: (empty)
903+
904+### Tool to run C program, on Linux, with input in terminal
905+
906+Tool is for Linux, it allows to run compiled C/C++ program in new terminal window. Text input will work in this terminal window.
907+
908+Example C++ program:
909+
910+``` C++
911+#include <stdio.h>
912+int main ()
913+{
914+ int c;
915+ puts ("Enter text. Include a dot ('.') in a sentence to exit:");
916+ do {
917+ c=getchar();
918+ putchar (c);
919+ } while (c != '.');
920+ return 0;
921+}
922+```
923+
924+Tool props:
925+
926+- Name: C - run
927+- Variant for xterm:
928+ - File name: xterm
929+ - Parameters: -hold -e "./{FileNameNoExt}"
930+- Variant for gnome-terminal:
931+ - File name: gnome-terminal
932+ - Parameters: -- bash -c "./{FileNameNoExt}; read -s -n1 -r -p 'Press any key... '; echo"
933+- Shell command: unchecked
934+- Initial folder: {FileDir}
935+- Lexers: C,C++
936+- Capture output: Ignore
937+- Encoding: utf_8
938+- Pattern: (empty)
939+
940+### Tool to compile+run C program
941+
942+In the External Tools dialog, press Join button, to join 2 tools created in above steps. Properties of joined tool:
943+
944+- Name: C - make+run
945+- Series: C - compile; C - run
946+- Lexers: C,C++
947+
948+### Tool to run current Batch file
949+
950+Tool properties:
951+
952+- Name: Run batch file
953+- File name: cmd.exe
954+- Shell command: unchecked
955+- Parameters: /c "{FileName}"
956+- Initial folder: {FileDir}
957+- Lexers: Batch files
958+- Capture output: Output panel
959+- Encoding: the same as file's encoding: e.g. utf_8 or cp1251 (cp1251 is Russian ANSI codepage)
960+
961+### Tool to compile by Free Pascal
962+
963+This tool is for Free Pascal 3.x on Linux x64.
964+
965+Properties:
966+
967+- Name: FPC - compile
968+- File name:
969+ - for FPC installed system-wide: fpc
970+ - for FPC installed via fpcupdeluxe: /home/user/fpcupdeluxe/fpcupdeluxe/fpc/bin/x86_64-linux/fpc.sh
971+- Shell command: unchecked
972+- Parameters: {FileNameOnly}
973+- Initial folder: {FileDir}
974+- Lexers: Pascal
975+- Capture output: Output panel
976+- Encoding: utf_8
977+
978+Optionally, 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.
979+
980+### Tool to call file-compare utility
981+
982+Tools, which call file-compare utility, to compare 2 files: active files in group-1 and group-2.
983+
984+#### WinMerge, KDiff, Kompare
985+
986+- Name: Compare files in G1, G2
987+- File name: (full name of executable file)
988+- Shell command: unchecked
989+- Parameters: "{FileName_g1}" "{FileName_g2}"
990+- Initial folder: (empty)
991+- Capture output: Ignore
992+
993+#### Meld
994+
995+- Name: Compare files in G1, G2
996+- File name: (full name of executable file)
997+- Shell command: unchecked
998+- Parameters: --newtab "{FileName_g1}" "{FileName_g2}"
999+- Initial folder: (empty)
1000+- Capture output: Ignore
1001+
1002+#### diff
1003+
1004+- Name: Compare files in G1, G2
1005+- File name: diff
1006+- Shell command: unchecked
1007+- Parameters: -Nau "{FileName_g1}" "{FileName_g2}"
1008+- Initial folder: (empty)
1009+- Capture output: Copy to new document
1010+
1011+### Tool to run Python scripts
1012+
1013+- Name: Python3
1014+- File name:
1015+ - on Windows: full path to "python.exe"
1016+ - on Unix: python3
1017+- Shell command:
1018+ - on Windows: checked
1019+ - on Unix: unchecked
1020+- Parameters: "{FileNameOnly}"
1021+- Initial folder: {FileDir}
1022+- Lexers: Python
1023+- Capture output: Output panel
1024+- Encoding: utf_8
1025+- Pattern: \s*File "(?P\<file\>.+)", line (?P\<line\>\d+)
1026+
1027+### Tool to preview HTML file in Chrome
1028+
1029+- Name: Preview in Chrome
1030+- File name:
1031+ - on Windows: C:\Program Files\Google\Chrome\Application\chrome.exe
1032+- Shell command:
1033+ - on Windows: unchecked
1034+- Parameters: "{FileName}"
1035+- Initial folder: (empty)
1036+- Lexers: HTML
1037+- Capture output: Ignore
1038+
1039+### Tool to open PHP documentation with given topic
1040+
1041+Tool 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.
1042+
1043+Before 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.
1044+
1045+Download PHP documentation in .chm format from PHP.net, google for "php_manual_en chm", it is 16M file.
1046+
1047+Tool properties:
1048+
1049+- Name: PHP Help
1050+- File name: keyhh.exe
1051+- Shell command: unchecked
1052+- Parameters: -MyHelp -#klink {CurrentWord} "C:\Work\php_manual_en.chm"
1053+- Initial folder: (empty)
1054+- Lexers: PHP
1055+- Save before: Nothing
1056+- Capture output: Ignore
1057+
1058+### Tool to open AutoIt documentation with given topic
1059+
1060+Tool 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.
1061+
1062+With AutoIt installed, you also have .chm documentation, its path is usually "C:\Program Files (x86)\AutoIt3\AutoIt.chm".
1063+
1064+Tool properties:
1065+
1066+- Name: AutoIt Help
1067+- File name: keyhh.exe
1068+- Shell command: unchecked
1069+- Parameters: -MyHelp -#klink {CurrentWord} "C:\Program Files (x86)\AutoIt3\AutoIt.chm"
1070+- Initial folder: (empty)
1071+- Lexers: AutoIt
1072+- Save before: Nothing
1073+- Capture output: Ignore
1074+
1075+### Tool to open .chm documentation for all lexers
1076+
1077+See above example about tool for PHP documentation. Create the similar tool
1078+
1079+- File name: keyhh.exe
1080+- Shell command: unchecked
1081+- Parameters: -MyHelp -#klink "{CurrentWord}" "{AppDir}\\..\Docs\\{Lexer}.chm"
1082+- Lexers: (empty)
1083+
1084+This 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.
1085+
1086+### Tool for Google search
1087+
1088+This is URL (special kind of tool). In the External Tools dialog, press the "URL" button, then press "Add" to add a new URL.
1089+
1090+- Name: Google find
1091+- URL:
1092+
1093+```text
1094+http://google.com/search?q={SelectedText|q}
1095+```
1096+
1097+### Tool to open folder of current file in Windows Explorer
1098+
1099+Tool properties:
1100+
1101+- Name: Open cur dir in Explorer
1102+- File name: explorer.exe
1103+- Shell command: unchecked
1104+- Parameters: {FileDir}
1105+- Initial folder: {FileDir}
1106+
1107+### Tool to go to current file in FreeCommander
1108+
1109+- Name: Go to file in FreeCommander
1110+- File name: path\to\FreeCommander.exe
1111+- Shell command: unchecked
1112+- Parameters: "/L={FileName}" /C
1113+- Initial folder: {FileDir}
1114+
1115+# Runner
1116+
1117+Plugin Runner was written as an alternative to External Tools.
1118+
1119+- Runner is more light weight.
1120+- Runner supports Sublime Text 3 build-systems.
1121+- Runner displays tool output immediately line-by-line as it appears (External Tools can only show the entire ready output).
1122+
1123+Many 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.
1124+
1125+See the [Runner documentation on GitHub](https://github.com/halfbrained/cuda_runner/blob/main/readme/readme.txt).
1126+
1127+Here is the GIF animation which shows reaction of Runner to PHP script running:
1128+
1129+``` php
1130+<?php
1131+for($i=0; $i<10; $i++) {
1132+ sleep(1);
1133+ echo "$i is here\n";
1134+}
1135+?>
1136+```
1137+
1138+<figure>
1139+<img src="cudatext-runner-thread.gif" title="cudatext-runner-thread.gif" />
1140+<figcaption>cudatext-runner-thread.gif</figcaption>
1141+</figure>
1142+
1143+## Runner limitation for input
1144+
1145+If your Python script contains the input() function:
1146+
1147+``` python
1148+s=input('enter text: ')
1149+print('entered:', s)
1150+```
1151+
1152+it will run with a runtime error like this:
1153+
1154+`enter text: Traceback (most recent call last):`\
1155+`  File "/home/user/a.py", line 3, in <module>`\
1156+`   s=input('enter text: ')`\
1157+`EOFError: EOF when reading a line`
1158+
1159+This 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.
1160+
1161+## Runner tool for C
1162+
1163+Install 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.
1164+
1165+This build-system has 2 commands:
1166+
1167+- Build: only compiles
1168+- Run: compiles and then runs the binary
1169+
1170+Example C file:
1171+
1172+``` cpp
1173+#include <stdio.h>
1174+int main(){
1175+ printf("Hello world");
1176+ return 0;
1177+}
1178+```
1179+
1180+Example output in the CudaText Output panel (Linux):
1181+
1182+ -- [10:34:08] Building: C via GCC: a.c
1183+ -- Command: gcc "/home/user/a.c" -o "/home/user/a" && "/home/user/a"
1184+ -- Working dir: /home/user
1185+ Hello world
1186+ -- Done (0.2s), return code: 0
1187+
1188+## Runner tool for C++
1189+
1190+Install 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.
1191+
1192+This build-system has 2 commands:
1193+
1194+- compile, then run the compiled binary (default command)
1195+- only run the compiled binary (it should be called from "Plugins / Runner / Build with...").
1196+
1197+Example C++ file:
1198+
1199+``` cpp
1200+#include <iostream>
1201+
1202+int main() {
1203+ std::cout << "Hello World!";
1204+ return 0;
1205+}
1206+```
1207+
1208+Example output in the CudaText Output panel (Linux):
1209+
1210+ -- [16:41:55] Building: C++: new.cpp
1211+ -- Command: g++ -std=c++11 -Wall "/home/user/new.cpp" -o "/home/user/new" && "/home/user/new"
1212+ -- Working dir: /home/user
1213+ Hello World!
1214+ -- Done (0.8s), return code: 0
1215+
1216+## Runner tool for PHP
1217+
1218+How to debug for example PHP file, with Runner. Create file "\[CudaText\]/data/buildsystems/php.sublime-build" with such text:
1219+
1220+``` json
1221+{
1222+ "file_patterns": ["*.php"],
1223+ "linux": {
1224+ "cmd": ["php", "$file"]
1225+ },
1226+ "windows": {
1227+ "cmd": ["C:\\PHP_folder\\php-win.exe", "$file"]
1228+ }
1229+}
1230+```
1231+
1232+Restart CudaText.
1233+
1234+After 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.
1235+
1236+Example script to test:
1237+
1238+``` php
1239+<?php
1240+for($i=0; $i<10; $i++) {
1241+ sleep(1);
1242+ echo "$i is here\n";
1243+}
1244+?>
1245+```
1246+
1247+## Runner tool for Python
1248+
1249+In 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:
1250+
1251+- Build
1252+- Syntax Check
1253+
1254+After 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.
1255+
1256+Example script to test:
1257+
1258+``` python
1259+import time
1260+
1261+for i in range(5):
1262+ time.sleep(1)
1263+ print(str(i) + " is here", flush=True)
1264+```
1265+
1266+## Runner tool for Free Pascal
1267+
1268+In Addons Manager, install the add-on "buildsystem: Free Pascal". It installs the file "\[CudaText\]/data/buildsystems/Free Pascal.sublime-build" with text like this:
1269+
1270+``` json
1271+{
1272+ "file_patterns": ["*.pp", "*.pas"],
1273+ "file_regex": "(.+?)\\((\\d+),(\\d+)\\)\\s(.+)$",
1274+ "working_dir": "$file_path",
1275+ "name": "Compile",
1276+ "cmd": ["/home/user/fpcupdeluxe/fpcupdeluxe32/fpc/bin/x86_64-linux/fpc.sh", "$file_name"],
1277+ "variants": [
1278+ {
1279+ "name": "Run",
1280+ "cmd": ["./$file_base_name"]
1281+ }
1282+ ]
1283+}
1284+```
1285+
1286+In this file, you need to adjust the path to "fpc.sh", according to your [[fpcupdeluxe]] folder. Restart CudaText.
1287+
1288+After opening a Pascal file, call Runner main command "Build", that's it. The "Build" command example output:
1289+
1290+ -- [20:07:55] Building: Free Pascal: new.pas
1291+ -- Command: ['/home/user/fpcupdeluxe/fpcupdeluxe32/fpc/bin/x86_64-linux/fpc.sh', 'new.pas']
1292+ -- Working dir: /home/user
1293+ Free Pascal Compiler version 3.2.3-425-gebc55c0f4e-dirty [2021/09/09] for x86_64
1294+ Copyright (c) 1993-2021 by Florian Klaempfl and others
1295+ Target OS: Linux for x86-64
1296+ Compiling new.pas
1297+ Linking new
1298+ 3 lines compiled, 0.1 sec
1299+ -- Done (0.2s), return code: 0
1300+
1301+The config above also gives the "Run" command for the compiled binary - in the menu of "Plugins / Runner / Build with...". The "Run" command example output:
1302+
1303+ -- [20:09:09] Building: Free Pascal: new.pas
1304+ -- Command: ['./new']
1305+ -- Working dir: /home/user
1306+ Hello world.
1307+ -- Done (-0.0s), return code: 0
1308+
1309+## Runner tool for Cobol
1310+
1311+In Addons Manager, install the lexer "Cobol".
1312+
1313+Let'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".
1314+
1315+Create Batch script "c:\GnuCOBOL\bin\runcobol.cmd" with such content:
1316+
1317+ set Path=c:\gnucobol\bin
1318+ set COB_CONFIG_DIR=c:\gnucobol\config
1319+ set COB_COPY_DIR=c:\gnucobol\copy
1320+ set COB_INCLUDE_PATH=c:\gnucobol\include
1321+ set COB_LIB_PATH=c:\gnucobol\lib
1322+ cobc -x -std=mf %1
1323+
1324+Create build-system file "\[CudaText\]\data\buildsystems\cobol.sublime-build":
1325+
1326+``` json
1327+{
1328+ "file_patterns": ["*.cob", "*.cbl", "*.cpy"],
1329+ "name": "Compile",
1330+ "cmd": ["cmd.exe", "/c", "c:\\GnuCOBOL\\bin\\runcobol.cmd", "$file"],
1331+ "working_dir": "$file_path",
1332+ "file_regex": "^([^:]+):([0-9]+):",
1333+ "variants": [
1334+ {
1335+ "name": "Run",
1336+ "cmd": ["$file_path/$file_base_name.exe"]
1337+ }
1338+ ]
1339+}
1340+```
1341+
1342+Note: 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).
1343+
1344+Now running the "Plugins / Runner / Build" can give text in the "Output panel" like this:
1345+
1346+ -- [07:49:02] Building: cobol: test.cbl
1347+ -- Command: ['cmd.exe', '/c', 'c:\\GnuCOBOL\\bin\\runcobol.cmd', 'C:\\Work\\test.cbl']
1348+ -- Working dir: C:\Work
1349+
1350+ C:\Work>set Path=c:\gnucobol\bin
1351+ C:\Work>set COB_CONFIG_DIR=c:\gnucobol\config
1352+ C:\Work>set COB_COPY_DIR=c:\gnucobol\copy
1353+ C:\Work>set COB_INCLUDE_PATH=c:\gnucobol\include
1354+ C:\Work>set COB_LIB_PATH=c:\gnucobol\lib
1355+ C:\Work>cobc -x -std=mf C:\Work\test.cbl
1356+ C:\Work\test.cbl:1: error: invalid indicator 'u' at column 7
1357+ C:\Work\test.cbl:2: warning: line not terminated by a newline [-Wmissing-newline]
1358+ C:\Work\test.cbl:3: warning: PROGRAM-ID header missing [-Wothers]
1359+ -- Done (0.3s), return code: 1
1360+
1361+# FindInFiles
1362+
1363+This 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.
1364+
1365+Project 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.
1366+
1367+## How to find/replace in all UI-tabs
1368+
1369+FindInFiles 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:
1370+
1371+`<tabs>`\
1372+`{t}`
1373+
1374+<figure>
1375+<img src="cudatext-findinfiles-intabs.png" title="cudatext-findinfiles-intabs.png" />
1376+<figcaption>cudatext-findinfiles-intabs.png</figcaption>
1377+</figure>
1378+
1379+And in the "Files" field, enter "*" for all files.
1380+
1381+To discover more features of FindInFiles dialog, hover mouse over other labels/buttons.
1382+
1383+You 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.
1384+
1385+Additionally, 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.
1386+
1387+## How to use FindInFiles 4
1388+
1389+FindInFiles 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.
1390+
1391+## FiF3 and FiF4: comparison and future
1392+
1393+CudaText has two plugins to search in files/tabs:
1394+
1395+- FindInFiles v3 (FiF3)
1396+- FindInFiles v4 (FiF4)
1397+
1398+Important: FiF3 is almost frozen. Only serious bugs will be fixed. No plans to hide/delete FiF3. FiF4 supersedes FiF3.
1399+
1400+Detailed comparison.
1401+
1402+Common features:
1403+
1404+- 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.
1405+- Encoding detection. FiF4 allows to set more flexible plan (see submenu "=/Encoding plan").
1406+- 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**).
1407+- 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.
1408+- FiF3 has commands to **count fragments** and to show only filenames. FiF4 skips such commands as unnecessary.
1409+- FiF3 can save **dialog layouts**. FiF4 saves layout as part of preset.
1410+- Like FiF3, FiF4 has the "Replace" functionality.
1411+- Like FiF3, FiF4 can search **in project** folder(s).
1412+
1413+Main new features:
1414+
1415+- FiF4 can report the found fragment with its **around lines** (see "-?+?" button).
1416+- FiF4 can search **multi-line fragments** (see "+" button).
1417+- FiF4 can search in **many start folders**.
1418+- FiF4 allows to use **lexer data** to filter and report fragments (in/out string/comment, lexer path).
1419+- FiF4 allows to show lines in the Results with its **lexer colors** from source files.
1420+- FiF4 allows to use **macro-variables** (OS environments, properties of current file/tab and free-set names) in any editable fields .
1421+- FiF4 has **statusbar** to show statistics of the last search: folders/files/fragments/timing.
1422+- FiF4 allows to **reformat Results** (change tree type and more) without new search.
1423+- FiF4 allows to show **modification time** of files in the Results.
1424+
1425+# Terminal
1426+
1427+There are currently 3 terminal plugins:
1428+
1429+- Terminal: simplest plugin.
1430+- Terminal Plus: most feature-rich plugin, but its UI may be too complex for beginners.
1431+- ExTerminal: middle in the feature set, but its UI is very simple.
1432+
1433+Let'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:
1434+
1435+``` python
1436+x = int(input('Enter x: '))
1437+w = int(input('Enter w: '))
1438+print(x*w)
1439+```
1440+
1441+Steps:
1442+
1443+- Save our script to file ~/myfolder/tt.py
1444+- Install ExTerminal, restart CudaText
1445+- Run ExTerminal by clicking its bottom-bar-icon
1446+- 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.
1447+- In ExTerminal, enter "python3 tt.py"
1448+
1449+Script should work and show 2 input-prompts.
1450+
1451+`user@user:~/myfolder$ ls *.py`\
1452+`a.py  test.py  tt.py`\
1453+`user@user:~/myfolder$ python3 tt.py`\
1454+`Enter x: 10`\
1455+`Enter w: 20`\
1456+`200`
1457+
1458+How to open ExTerminal in the directory of the current editor file? You can do this:
1459+
1460+- Hover mouse over ExTerminal button in the bottom-bar. It must show tooltip like "ExTerminal 1".
1461+- 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.
1462+- To not produce too much ExTerminal buttons, use "Close terminal" from the popup menu.
1463+
1464+# Configure Menu
1465+
1466+Plugin "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:
1467+
1468+``` json
1469+ ,{"cap":"&Save", "cmd":"cmd_FileSave"}
1470+```
1471+
1472+How 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.
1473+
1474+How 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:
1475+
1476+``` json
1477+ ,{"cap":"Toggle line comment", "cmd":"module=cuda_comments;cmd=cmt_toggle_line_body;"}
1478+```
1479+
1480+Here "cuda_comments" is plugin folder name, and "cmt_toggle_line_body" is Python method from install.inf.
1481+
1482+You 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]].
1483+
1484+Example screenshot shows how "menu.json" will look with new items for context-menu:
1485+
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>
1490+
1491+Example 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:
1492+
1493+``` json
1494+ {"cap": "SomeToolName", "cmd": "module=cuda_exttools;cmd=run;info=174420;"}
1495+ ,{"cap": "SomeMacroName", "cmd": "module=cuda_macros;cmd=run;info=87635;"}
1496+```
1497+
1498+These 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":
1499+
1500+``` json
1501+{
1502+ "ver": "20151209",
1503+ "list": [
1504+ {
1505+ "id": 254653,
1506+ "nm": "C - compile",
1507+ "file": "gcc",
1508+ "ddir": "{FileDir}",
1509+ "shll": false,
1510+ "prms": "\"{FileNameOnly}\" -o \"{FileNameNoExt}\"",
1511+ "savs": "N",
1512+ "rslt": "OP",
1513+ "encd": "utf_8",
1514+ "lxrs": "C,C++",
1515+ "pttn": "(?P<file>[\\w\\.\\-]+):(?P<line>\\d+):(?P<col>\\d+):.+",
1516+ },
1517+```
1518+
1519+# Config Toolbar
1520+
1521+Plugin 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.
1522+
1523+For example, you installed two plugins:
1524+
1525+- Config Toolbar
1526+- Color Text
1527+
1528+And you want to call command "Apply bold" (from "Color Text") via toolbar. How to add such a button? Picture highlights your steps.
1529+
1530+<figure>
1531+<img src="cudatext-config-toolbar.png" title="cudatext-config-toolbar.png" />
1532+<figcaption>cudatext-config-toolbar.png</figcaption>
1533+</figure>
1534+
1535+- From the Command Palette, call the item "Config Toolbar: Configure buttons...". Dialog will appear from the plugin.
1536+- In the "Configure toolbar" dialog, press "Add item...", and fill fields of new dialog "Button properties".
1537+ - Caption
1538+ - Tooltip (optional)
1539+ - 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.
1540+ - Icon (optional)
1541+
1542+# Intext Bookmarks
1543+
1544+Plugin 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.
1545+
1546+Plugin adds menu items in "Plugins / In-text Bookmarks":
1547+
1548+- List for current tab -- show all marks in the current document
1549+- List for all tabs -- show all marks in all opened UI-tabs
1550+- Go to next
1551+- Go to previous
1552+- Add -- add a new mark at caret position
1553+
1554+"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".
1555+
1556+You can customize that special lines, using plugin configuration dialog: menu item "Options / Settings-plugins / In-text Bookmarks". Dialog gives such options:
1557+
1558+- Bookmark signs: NOTE: NB! TODO: todo: todo. FIX:
1559+- Comment sign: //
1560+
1561+That 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.
1562+
1563+# Color Text
1564+
1565+Plugin "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.
1566+
1567+<figure>
1568+<img src="cudatext-color-text.png" title="cudatext-color-text.png" />
1569+<figcaption>cudatext-color-text.png</figcaption>
1570+</figure>
1571+
1572+The 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.
1573+
1574+Not 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:
1575+
1576+- "all_words": Colorize all occurrences of fragment.
1577+- "case_sensitive": Case sensitive search for other occurrences.
1578+- "whole_words": Colorize only those occurrences, which are whole words.
1579+- "show_on_map": Show added colored marks also on micro-map.
1580+
1581+# Insert Pics
1582+
1583+CudaText 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:
1584+
1585+<figure>
1586+<img src="cudatext-insert-pics.png" title="cudatext-insert-pics.png" />
1587+<figcaption>cudatext-insert-pics.png</figcaption>
1588+</figure>
1589+
1590+- You can use any lexer for files with pictures.
1591+- You can add the unlimited number of pictures. But only one picture per "gap".
1592+- You can add/delete pictures later, using plugin's commands in menu "Plugins / Insert Pics".
1593+- When you delete the "helper file" (located in the same folder), all pictures will be lost for plugin.
1594+
1595+# Complete From Text
1596+
1597+Plugin 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.
1598+
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>
1603+
1604+In the picture above, one word was taken from C lexer's C.acp file (this is a feature).
1605+
1606+Plugin 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:
1607+
1608+- Install the plugin
1609+- Call menu item "Options / Settings-plugins / Complete From Text"
1610+- This opens the "plugins.ini" file
1611+- Find section "\[complete_from_text\]", add ",c" (without quotes) to the line "lexers="
1612+- Restart CudaText
1613+
1614+Plugin has more options in that "plugins.ini" file:
1615+
1616+- 'lexers': comma-separated lexer names, ie for which lexers to work; specify none-lexer as '-'.
1617+- 'min_len': minimal word length, words of smaller length will be ignored.
1618+- 'max_lines': if document has bigger count of lines, ignore this document.
1619+- 'case_sens': case-sensitive; words starting with 'A' will be ignored when you typed 'a'.
1620+- 'no_comments': ignore words inside "syntax comments" (lexer specific).
1621+- 'no_strings': ignore words inside "syntax strings" (lexer specific).
1622+- 'what_editors': which documents (ie UI tabs) to read to get words. Values:
1623+ - 0: only current document.
1624+ - 1: all opened documents.
1625+ - 2: all opened documents with the same lexer.
1626+- 'use_acp': add suggestions from autocomplete files in 'data/autocomplete'
1627+- '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.
1628+- '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.
1629+
1630+Plugin supports CudaText option "nonword_chars", so for example words with '\$' char are also added to completions, if CudaText option is configured so.
1631+
1632+# Embedded Editor
1633+
1634+Plugin "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.
1635+
1636+<figure>
1637+<img src="cudatext-embedded-editor.png" title="cudatext-embedded-editor.png" />
1638+<figcaption>cudatext-embedded-editor.png</figcaption>
1639+</figure>
1640+
1641+It adds menu item to show/hide embedded editor in the current document, for the current caret position: "Plugins / Embedded Editor / Toggle".
1642+
1643+By default, plugin searches for the included filename inside double-quotes, surrounding the caret position. This works OK for HTML and many other documents.
1644+
1645+For example, when you have opened file "/folder/file.html", and placed caret inside first double-quotes:
1646+
1647+``` html
1648+ <link href="css/style.css" rel="stylesheet" type="text/css"/>
1649+```
1650+
1651+then embedded editor will be opened for file "/folder/css/style.css".
1652+
1653+The search can be configured, though. For example, plugin can be used in Pascal files for include-directives:
1654+
1655+``` pascal
1656+ {$I path/filename.inc}
1657+```
1658+
1659+Plugin 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.
1660+
1661+# Breadcrumbs
1662+
1663+Plugin "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:
1664+
1665+ [ home / user / mydir / myfile.ext ]
1666+
1667+It can also show the "~" button for the home directory (by option):
1668+
1669+ [ ~ / mydir / myfile.ext ]
1670+
1671+<figure>
1672+<img src="cudatext-breadcrumbs.png" title="cudatext-breadcrumbs.png" />
1673+<figcaption>cudatext-breadcrumbs.png</figcaption>
1674+</figure>
1675+
1676+Clicking 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.
1677+
1678+Plugin 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.
1679+
1680+# Spell Checker
1681+
1682+Frequent question: how to make spell checking 'live', ie run it after each change? Do this:
1683+
1684+- Menu "Options / Settings-plugins / Spell Checker / Configure events": check there all events.
1685+- 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.
1686+- Restart CudaText.
1687+
1688+Now 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.
1689+
1690+# LSP Client
1691+
1692+Plugin "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).
1693+
1694+LSP Client gives several commands in the "Plugins / LSP Client", and all these commands work only if server supports them. Some of LSP commands are:
1695+
1696+- Auto-completion: integrated with CudaText command "Auto-completion menu" (in the Command Palette).
1697+- Go to definition: integrated with CudaText command "Go to definition" (in the Command Palette, and in the editor context menu).
1698+- Function signature help: integrated with CudaText command "Show function hint" (in the Command Palette).
1699+- Hover: shows the tooltip when you hover mouse above identifiers. You need the Ctrl key pressed while you hover.
1700+
1701+<figure>
1702+<img src="cudatext-lsp-hover_.png" title="cudatext-lsp-hover_.png" />
1703+<figcaption>cudatext-lsp-hover_.png</figcaption>
1704+</figure>
1705+
1706+- Find references: finds all locations where an identifier (under first caret) is used and shows menu with locations.
1707+
1708+<figure>
1709+<img src="cudatext-lsp-refs.png" title="cudatext-lsp-refs.png" />
1710+<figcaption>cudatext-lsp-refs.png</figcaption>
1711+</figure>
1712+
1713+- 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.
1714+- Document formatting: formatting of the source code by LSP server. This feature is also implemented in #CudaFormatter and usually it works better/faster there.
1715+
1716+All LSP servers should have a homepage with description of their functions, and installation information.
1717+
1718+In 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".
1719+
1720+``` json
1721+{
1722+ "lexers": {
1723+ "C#": "csharp"
1724+ },
1725+ ...
1726+}
1727+```
1728+
1729+LSP Client also has the settings file, use menu item to open it: "Options / Settings-plugins / LSP Client".
1730+
1731+## LSP server for Python
1732+
1733+Project homepage is <https://github.com/python-lsp/python-lsp-server> . Note that this is fork of old, unmaintained, project "PyLS". Server supports:
1734+
1735+- Auto-completion
1736+- Go to definition
1737+- Function signature help
1738+- Hover
1739+- Find references
1740+- Code linting
1741+- Document formatting
1742+
1743+Use "pip" to install the server:
1744+
1745+`pip install python-lsp-server`\
1746+
1747+This will expose the command "pylsp" on your PATH. Confirm that installation succeeded by running:
1748+
1749+`pylsp --help`\
1750+
1751+Create the file "\[CudaText\]/settings/lsp_py.json" with text like this:
1752+
1753+``` json
1754+{
1755+ "lexers": {
1756+ "Python": "python"
1757+ },
1758+ "cmd_windows": ["pylsp.exe"],
1759+ "cmd_macos": ["pylsp"],
1760+ "cmd_unix": ["pylsp"]
1761+}
1762+```
1763+
1764+Open some Python script, and call some commands of LSP Client. It will run the server, and it should work.
1765+
1766+## LSP server for Python, pyright
1767+
1768+1\. Install the server:
1769+
1770+`pip install pyright`
1771+
1772+- On Windows, add folder of "pyright-langserver.exe" to system PATH.
1773+- On Linux/Unix, get the full path of the program, we will use this path in the next step.
1774+
1775+`which pyright-langserver`
1776+
1777+It outputs on Ubuntu:
1778+
1779+`/home/user/.local/bin/pyright-langserver`
1780+
1781+- 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:
1782+
1783+`/Applications/Python\ 3.10/Install\ Certificates.command`
1784+
1785+2\. Create config (CudaText)/settings/lsp_pyright.json:
1786+
1787+``` json
1788+{
1789+ "lexers": {
1790+ "Python": "python"
1791+ },
1792+ "cmd_windows": ["pyright-langserver.exe", "--stdio"],
1793+ "cmd_unix": ["/home/user/.local/bin/pyright-langserver", "--stdio"],
1794+ "cmd_macos": ["/Library/Frameworks/Python.framework/Versions/3.10/bin/pyright-langserver", "--stdio"],
1795+ "log_stderr": true
1796+}
1797+```
1798+
1799+3\. To disable type checking (which may be confusing), add key "settings" to the above config:
1800+
1801+``` json
1802+ "settings": {
1803+ "python.analysis": {
1804+ "typeCheckingMode": "off"
1805+ }
1806+ }
1807+```
1808+
1809+## LSP server for JavaScript/ReactJS
1810+
1811+- Install lexer for ReactJS: "JavaScript Babel", from "Addons Manager".
1812+- Install TypeScript and the LSP server. In Terminal:
1813+
1814+`npm install -g typescript typescript-language-server`
1815+
1816+- Create CudaText LSP config: file "settings/lsp_js.json" with such content:
1817+
1818+``` json
1819+{
1820+ "name": "JavaScript",
1821+ "lexers": {
1822+ "JavaScript": "javascript",
1823+ "JavaScript Babel": "javascriptreact"
1824+ },
1825+ "cmd_unix": [
1826+ "typescript-language-server",
1827+ "--stdio"
1828+ ],
1829+ "cmd_windows": [
1830+ "typescript-language-server.cmd",
1831+ "--stdio"
1832+ ]
1833+}
1834+```
1835+
1836+This 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.
1837+
1838+## LSP server for TypeScript
1839+
1840+- Install TypeScript lexer from "Addons Manager".
1841+- Install TypeScript and the LSP server. In Terminal:
1842+
1843+`npm install -g typescript typescript-language-server`
1844+
1845+- Create CudaText LSP config: file "settings/lsp_ts.json" with such content:
1846+
1847+``` json
1848+{
1849+ "lexers": {
1850+ "TypeScript": "ts"
1851+ },
1852+ "cmd_unix": [
1853+ "typescript-language-server",
1854+ "--stdio"
1855+ ],
1856+ "cmd_windows": [
1857+ "typescript-language-server.cmd",
1858+ "--stdio"
1859+ ]
1860+}
1861+```
1862+
1863+This 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.
1864+
1865+According to <https://www.zeusedit.com/lsp/typescript.html>, sometimes more complex config file may be needed. Here it is on Ubuntu:
1866+
1867+``` json
1868+{
1869+ "lexers": {
1870+ "TypeScript": "ts"
1871+ },
1872+ "cmd_unix": [
1873+ "typescript-language-server",
1874+ "--stdio",
1875+ "--log-level=4",
1876+ "--tsserver-log-verbosity=verbose",
1877+ "--tsserver-path=/usr/local/lib/node_modules/typescript/lib/"
1878+ ],
1879+ "cmd_windows": [
1880+ "typescript-language-server.cmd",
1881+ "--stdio",
1882+ "--log-level=4",
1883+ "--tsserver-log-verbosity=verbose",
1884+ "--tsserver-path=\"%APPDATA%\\npm\\node_modules\\typescript\\lib\\\""
1885+ ]
1886+}
1887+```
1888+
1889+How 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".
1890+
1891+Test the auto-completion on this "test.ts" file (with TypeScript lexer):
1892+
1893+`document.body.g`
1894+
1895+## LSP server for C/C++
1896+
1897+Install one of the servers following the instructions:
1898+
1899+- clangd: <https://clangd.llvm.org/installation.html>
1900+ - 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.
1901+- ccls: <https://github.com/MaskRay/ccls/wiki/Build> + <https://github.com/MaskRay/ccls/wiki/Install>
1902+
1903+To use the server in LSP Client, create a file "lsp_c.json" in the "settings" directory with such content:
1904+
1905+``` json
1906+{
1907+ "lexers": {
1908+ "C++": "cpp",
1909+ "C": "c"
1910+ },
1911+ "cmd_unix": [
1912+ "clangd-12",
1913+ ],
1914+ "cmd_windows": [
1915+ "clangd",
1916+ ],
1917+}
1918+```
1919+
1920+Replace "clangd*" with "ccls" if it was chosen.
1921+
1922+On Windows: you must add the "bin" directory of mingw64 to the PATH so clangd is in the PATH.
1923+
1924+## LSP server for C#
1925+
1926+First, install C# lexer from "Addons Manager".
1927+
1928+1\. 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.
1929+
1930+2\. 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> .
1931+
1932+3\. Create LSP config file: (CudaText)/settings/lsp_cs.json:
1933+
1934+``` json
1935+{
1936+ "lexers": {
1937+ "C#": "csharp"
1938+ },
1939+ "cmd_windows": [
1940+ "C:\\OmniSharp\\OmniSharp.exe", "-lsp", "-z"
1941+ ]
1942+}
1943+```
1944+
1945+Note that backslashes must be doubled (because of JSON format).
1946+
1947+4\. To test that server works: create a file "test.cs" (with C# lexer active). Call auto-completion after "date.A".
1948+
1949+``` csharp
1950+using System;
1951+
1952+public class DateExample
1953+{
1954+ public static void Main()
1955+ {
1956+ DateTime date;
1957+ date.A
1958+ }
1959+}
1960+```
1961+
1962+## LSP server for CSS/SCSS/LESS
1963+
1964+The CSS (and SCSS, LESS) server is not easy to install, so here is the instruction, from the author of LSP Client:
1965+
1966+- Download the repository of VSCode: <https://github.com/microsoft/vscode>
1967+- From the repository, get the folder "extensions/css-language-features/server" and enter in it.
1968+- Replace the file "tsconfig.json" with content:
1969+
1970+``` json
1971+{
1972+ "compilerOptions": {
1973+ "target": "es2018",
1974+ "lib": [
1975+ "es2018"
1976+ ],
1977+ "module": "commonjs",
1978+ "strict": true,
1979+ "alwaysStrict": true,
1980+ "noImplicitAny": true,
1981+ "noImplicitReturns": true,
1982+ "noImplicitOverride": true,
1983+ "noUnusedLocals": true,
1984+ "noUnusedParameters": true,
1985+ "forceConsistentCasingInFileNames": true,
1986+
1987+ "outDir": "./out"
1988+ },
1989+ "files": [
1990+ "src/node/cssServerMain.ts"
1991+ ]
1992+}
1993+```
1994+
1995+- Install dependencies and TypeScript. In Terminal:
1996+
1997+`npm install`\
1998+`npm install -g typescript`
1999+
2000+- Compile it. In Terminal:
2001+
2002+`npx tsc`
2003+
2004+Server should be compiled.
2005+
2006+Create config file (CudaText)/settings/lsp_css.json:
2007+
2008+``` json
2009+{
2010+ "name": "vsc-css",
2011+ "lexers": {
2012+ "CSS": "css",
2013+ "SCSS": "scss",
2014+ "Sass": "sass",
2015+ "LESS": "less",
2016+ },
2017+ "cmd_unix": [
2018+ "node",
2019+ "path_to_server/server/out/node/cssServerMain.js",
2020+ "--stdio"
2021+ ]
2022+}
2023+```
2024+
2025+## LSP server for HTML
2026+
2027+CudaText does not support built-in HTML auto-completion when caret is inside style="..." blocks. But LSP server supports it. Install server using Node.js:
2028+
2029+`npm install --global vscode-html-ls-bin`
2030+
2031+Make config file (CudaText)/settings/lsp_html.json:
2032+
2033+``` json
2034+{
2035+ "lexers": {
2036+ "HTML": "html",
2037+ },
2038+ "cmd_windows": ["html-ls.cmd", "--stdio"],
2039+ "cmd_unix": ["html-ls", "--stdio"]
2040+}
2041+```
2042+
2043+Make sure the script "html-ls" ("html-ls.cmd" on Windows) is in the PATH.
2044+
2045+You 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.
2046+
2047+## LSP server for Java
2048+
2049+**Part 1. Information for Windows.**
2050+
2051+- Install lexer "Java" from Addons Manager.
2052+
2053+- 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:
2054+
2055+`java -version`
2056+
2057+It must show something like this:
2058+
2059+`java version "19.0.1" 2022-10-18`\
2060+`Java(TM) SE Runtime Environment (build 19.0.1+10-21)`\
2061+`Java HotSpot(TM) 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)`
2062+
2063+- 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".
2064+
2065+- Create "C:\Java\jLSP.cmd" batch file with the following contents (edit if necessary):
2066+
2067+```batch
2068+@echo off
2069+echo.
2070+echo Usage: jLSP.cmd CacheDir
2071+echo 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.
2072+echo.
2073+
2074+:: language server installation folder (adjust to suit)
2075+set Directory=C:/Java/jdt-language-server
2076+:: language server jar file (update based on version file of jar)
2077+set JarFile=%Directory%/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar
2078+:: language server config folder location
2079+set Config=%Directory%/config_win
2080+
2081+set CacheDir=%~1
2082+echo Directory: %Directory%
2083+echo JarFile: %JarFile%
2084+echo Config: %Config%
2085+echo CacheDir: %CacheDir%
2086+
2087+java -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%
2088+```
2089+
2090+- Create LSP config file: (CudaText)/settings/lsp_java.json:
2091+
2092+``` json
2093+{
2094+ "lexers": {
2095+ "Java": "java"
2096+ },
2097+ "cmd_windows": ["C:\\Java\\jLSP.cmd", "./cache_for_proj1"]
2098+}
2099+```
2100+
2101+Use testing file "test.java". Place caret on last code line after "System.g" and call auto-completion.
2102+
2103+``` java
2104+public class Example {
2105+ public static void main(String[] args) {
2106+ System.g
2107+ }
2108+}
2109+```
2110+
2111+**Part 2. Information for Linux.**
2112+
2113+- Install lexer "Java" from Addons Manager.
2114+
2115+- 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.
2116+
2117+On Ubuntu this command works (2022 year):
2118+
2119+`sudo apt install openjdk-17-jre-headless `
2120+
2121+Then run in Console:
2122+
2123+`java -version`
2124+
2125+It must show something like this:
2126+
2127+`openjdk version "17.0.4" 2022-07-19`\
2128+`OpenJDK Runtime Environment (build 17.0.4+8-Ubuntu-120.04)`\
2129+`OpenJDK 64-Bit Server VM (build 17.0.4+8-Ubuntu-120.04, mixed mode, sharing)`
2130+
2131+- 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".
2132+
2133+- Create "~\jLSP.sh" shell script with the following contents, and make it executable:
2134+
2135+``` bash
2136+#!/bin/bash
2137+echo
2138+echo Usage: jLSP.sh CacheDir
2139+echo 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.
2140+echo
2141+
2142+# language server installation folder (adjust to suit)
2143+Directory=~/jdt-language-server
2144+# language server jar file (update based on version file of jar)
2145+JarFile=$Directory/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar
2146+# language server config folder location
2147+Config=$Directory/config_linux
2148+
2149+CacheDir=$1
2150+echo Directory: $Directory
2151+echo JarFile: $JarFile
2152+echo Config: $Config
2153+echo CacheDir: $CacheDir
2154+
2155+java -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
2156+```
2157+
2158+- Create LSP config file: (CudaText)/settings/lsp_java.json:
2159+
2160+``` json
2161+{
2162+ "lexers": {
2163+ "Java": "java",
2164+ },
2165+ "cmd_unix": ["~/jLSP.sh", "./cache_for_proj1"],
2166+}
2167+```
2168+
2169+Use testing file "test.java". Place caret on last code line after "System.g" and call auto-completion.
2170+
2171+``` java
2172+public class Example {
2173+ public static void main(String[] args) {
2174+ System.g
2175+ }
2176+}
2177+```
2178+
2179+## LSP server for Nim
2180+
2181+Server from <https://github.com/PMunch/nimlsp> works good.
2182+
2183+Config file (CudaText)/settings/lsp_nim.json:
2184+
2185+``` json
2186+{
2187+ "name": "nim-lsp",
2188+ "lexers": {
2189+ "Nim": "nim"
2190+ },
2191+ "cmd_unix": [
2192+ "~/.nimble/bin/nimlsp"
2193+ ]
2194+}
2195+```
2196+
2197+## LSP server for Rust
2198+
2199+RLS 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>
2200+
2201+Create config (CudaText)/settings/lsp_rust.json:
2202+
2203+``` json
2204+{
2205+ "lexers": {
2206+ "Rust": "rust"
2207+ },
2208+ "cmd_windows": ["rust-analyzer-x86_64-pc-windows-msvc.exe"],
2209+ "cmd_unix": ["rust-analyzer-x86_64-unknown-linux-gnu"]
2210+}
2211+```
2212+
2213+## LSP server for AutoHotkey
2214+
2215+- Download the repository of AutoHotkey2: <https://github.com/thqby/vscode-autohotkey2-lsp>
2216+- Extract and enter the directory: "vscode-autohotkey2-lsp-main"
2217+- Install dependencies and TypeScript. In Terminal:
2218+
2219+`npm install`\
2220+`npm install -g typescript`
2221+
2222+- Enter the directory "server", and compile the server. In Terminal:
2223+
2224+`npx tsc`
2225+
2226+Server should be compiled now. To use the server in LSP Client, create the file "lsp_ahk.json" in the "settings" with such content:
2227+
2228+``` json
2229+{
2230+ "name": "AutoHotkey2",
2231+ "lexers": {
2232+ "AutoHotkey": "ahk"
2233+ },
2234+ "cmd_unix": [
2235+ "node",
2236+ "path_to_server/server/out/server.js",
2237+ "--stdio"
2238+ ]
2239+}
2240+```
2241+
2242+## LSP server for Red
2243+
2244+1\) On Linux x64.
2245+
2246+- 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.
2247+- Install server from <https://github.com/bitbegin/redlangserver>, put the repo e.g. to ~/redlangserver.
2248+- Create file "redlangserver.sh" and put it to some PATH dir. Content:
2249+
2250+``` bash
2251+#!/bin/bash
2252+red ~/redlangserver/server.red
2253+```
2254+
2255+- Create file (CudaText)/settings/lsp_red.json with content:
2256+
2257+``` json
2258+{
2259+ "lexers": {
2260+ "Red": "red"
2261+ },
2262+ "cmd_unix": ["redlangserver.sh"],
2263+ "cmd_windows": ["c:\\red\\red.exe", "--cli", "c:\\red\\redlangserver\\server.red"]
2264+}
2265+```
2266+
2267+Server should work now. It gives: mouse hover tooltips (Ctrl + mouse hovering over names), go to definition.
2268+
2269+2\) On Windows 10 x64.
2270+
2271+- Install Red to "c:\Red". Tested the build from 02-Oct-2021.
2272+- Install server from <https://github.com/bitbegin/redlangserver>, put the repo to "c:\Red\redlangserver".
2273+- Run once the command "c:\red\red.exe --cli", it will print "Compiling Red console..." with the big pause.
2274+- Create file (CudaText)\settings\lsp_red.json with the same content as for Unix. Adjust path to Red folder, if needed.
2275+
2276+Server 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).
2277+
2278+Note: don't create .bat or .cmd file with the "red.exe" calling, because it does not work in LSP Client for some reason.
2279+
2280+## LSP server for PHP
2281+
2282+1\. Install PHP, Composer. PHP versions 7.4.3 and 8.1 are OK.
2283+
2284+2\. 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".
2285+
2286+3\. 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.
2287+
2288+4\. Create LSP config (CudaText)/settings/lsp_php.json:
2289+
2290+``` json
2291+{
2292+ "name": "PHP",
2293+ "lexers": {
2294+ "PHP": "php"
2295+ },
2296+ "tcp_port": 12345,
2297+ "cmd_unix": [
2298+ "php",
2299+ "folder_of_server/bin/php-language-server.php",
2300+ "--tcp-server=127.0.0.1:12345"
2301+ ],
2302+ "cmd_windows": [
2303+ "php",
2304+ "D:\\programm\\php\\php-language-server\\bin\\php-language-server.php",
2305+ "--tcp-server=127.0.0.1:12345"
2306+ ]
2307+}
2308+```
2309+
2310+Server should work now. It gives these features: <https://github.com/zobo/php-language-server#features> .
2311+
2312+Auto-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.
2313+
2314+Note: 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.
2315+
2316+## LSP server for Bash
2317+
2318+- Install Node.js, see readme here: <https://github.com/nodesource/distributions/blob/master/README.md>
2319+- Install Bash server, see readme here: <https://github.com/bash-lsp/bash-language-server>
2320+- Install Shellcheck from <https://www.shellcheck.net/> - "We strongly recommend that you install shellcheck to enable linting"
2321+- On Windows, maybe you need to add folder of "bash-language-server.cmd" to system PATH.
2322+- Create file (CudaText)/settings/lsp_bash.json with content:
2323+
2324+``` json
2325+{
2326+ "lexers": {
2327+ "Bash script": "bash"
2328+ },
2329+ "cmd_windows": ["bash-language-server.cmd", "start"],
2330+ "cmd_unix": ["bash-language-server", "start"]
2331+}
2332+```
2333+
2334+## LSP server for D
2335+
2336+First, install D lexer from "Addons Manager".
2337+
2338+1\. 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.
2339+
2340+2\. Install the LSP server, run from console:
2341+
2342+`dub fetch dls`
2343+
2344+This must show output like
2345+
2346+`C:\D>dub fetch dls`\
2347+`Fetching dls 0.26.2...`\
2348+`` 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. ``
2349+
2350+3\. Compile the LSP server, run from console:
2351+
2352+`dub run dls:bootstrap`
2353+
2354+This must show output like
2355+
2356+`C:\D>dub run dls:bootstrap`\
2357+`Building package dls:bootstrap in C:\Users\user\AppData\Local\dub\packages\dls-0.26.2\dls\bootstrap\`\
2358+`Running pre-generate commands for dls:i18n...`\
2359+`Performing "debug" build using C:\D\dmd2\windows\bin64\dmd.exe for x86_64.`\
2360+`dls:protocol 0.26.2: building configuration "library"...`\
2361+`dls:i18n 0.26.2: building configuration "library"...`\
2362+`dls:bootstrap 0.26.2: building configuration "application"...`\
2363+`Linking...`\
2364+`Running ../Users/user/AppData/Local/dub/packages/dls-0.26.2/dls/bootstrap/dls_bootstrap.exe`\
2365+`C:\Users\user\AppData\Local\dub\packages\.bin\dls-latest\dls.exe`
2366+
2367+Copy to clipboard the last printed filename with dls.exe.
2368+
2369+4\. 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).
2370+
2371+``` json
2372+{
2373+ "lexers": {
2374+ "D": "dlang"
2375+ },
2376+ "cmd_windows": [
2377+ "C:\\Users\\user\\AppData\\Local\\dub\\packages\\.bin\\dls-latest\\dls.exe", "--stdio"
2378+ ]
2379+}
2380+```
2381+
2382+5\. Create test file "test.d" (with lexer D). Test that auto-completion works after "b.":
2383+
2384+``` d
2385+class A {int a; int a2;}
2386+class B: A {int a3;}
2387+
2388+void foo(B b)
2389+{
2390+ b.
2391+}
2392+```
2393+
2394+## LSP server for Go
2395+
2396+Install lexer Go from "Addons Manager".
2397+
2398+1\. Install Go. Make sure that Go binary is in the system PATH, and GOPATH variable is also set.
2399+
2400+2\. Install the LSP server:
2401+
2402+`go install golang.org/x/tools/gopls@latest`
2403+
2404+In 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:
2405+
2406+`gopls version`
2407+
2408+It must give output like:
2409+
2410+`golang.org/x/tools/gopls v0.9.5`\
2411+`    golang.org/x/tools/gopls@v0.9.5 h1:F3TO5th6TUg40FHrpxZfMkMlVaaTmByeEvylgVHGH2A=`
2412+
2413+3\. Create CudaText LSP config (CudaText)/settings/lsp_go.json:
2414+
2415+``` json
2416+{
2417+ "lexers": {
2418+ "Go": "go"
2419+ },
2420+ "cmd_unix": [
2421+ "gopls"
2422+ ],
2423+ "cmd_windows": [
2424+ "gopls.exe"
2425+ ]
2426+}
2427+```
2428+
2429+4\. 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":
2430+
2431+``` go
2432+package aa
2433+import ("fmt")
2434+
2435+func main() {
2436+ fmt.F
2437+}
2438+```
2439+
2440+## LSP server for Lua
2441+
2442+1\. 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).
2443+
2444+2\. Create LSP config (CudaText)/settings/lsp_lua.json:
2445+
2446+``` json
2447+{
2448+ "lexers": {
2449+ "Lua": "lua"
2450+ },
2451+ "log_stderr": true,
2452+ "cmd_windows": ["D:\\Programs\\lua-lsp\\bin\\lua-language-server.exe"],
2453+ "cmd_unix": ["/path/to/lua-language-server"]
2454+}
2455+```
2456+
2457+## LSP server for Scala
2458+
2459+Install lexer "Scala" from Addons Manager. Information for Windows.
2460+
2461+1\. Install Coursier: <https://get-coursier.io/docs/cli-installation>
2462+
2463+2\. Install Metals. Make sure "metals.bat" is in the system PATH.
2464+
2465+`cs install metals`
2466+
2467+3\. Create LSP config file (CudaText)/settings/lsp_scala.json:
2468+
2469+``` json
2470+{
2471+ "lexers": {
2472+ "Scala": "scala"
2473+ },
2474+ "cmd_windows": ["metals.bat"]
2475+}
2476+```
2477+
2478+Testing file for auto-completion:
2479+
2480+`object Hello extends App {`\
2481+`    println("Hello, world")`\
2482+`}`
2483+
2484+## LSP server for Fortran
2485+
2486+Install lexer "Fortran" from Addons Manager. Steps show how to use server on Linux (Ubuntu 20.04) with Python 3 installed.
2487+
2488+1\. Install the LSP server:
2489+
2490+`pip install fortran-language-server`
2491+
2492+Check that command runs OK:
2493+
2494+`fortls -?`
2495+
2496+And check its full path:
2497+
2498+`which fortls`
2499+
2500+Here 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.
2501+
2502+2\. Create LSP config file: (CudaText)/settings/lsp_fortran.json:
2503+
2504+``` json
2505+{
2506+ "lexers": {
2507+ "Fortran": "fortran"
2508+ },
2509+ "cmd_unix": [
2510+ "/home/user/.local/bin/fortls"
2511+ ]
2512+}
2513+```
2514+
2515+3\. Make test file "test.for" (with Fortran lexer). Test auto-completion after "CALL myv".
2516+
2517+``` fortran
2518+PROGRAM myprog
2519+USE test_free, ONLY: scaled_vector
2520+TYPE(scaled_vector) :: myvec
2521+CALL myv
2522+END PROGRAM
2523+```
2524+
2525+## LSP server for Markdown
2526+
2527+1\. Get precompiled Marksman LSP server from GitHub: <https://github.com/artempyanykh/marksman/releases>
2528+
2529+2\. 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.
2530+
2531+`chmod +x marksman-linux`
2532+
2533+3\. Create config file (CudaText)/settings/lsp_md.json:
2534+
2535+``` json
2536+{
2537+ "lexers": {
2538+ "Markdown": "markdown"
2539+ },
2540+ "cmd_windows": ["marksman.exe"],
2541+ "cmd_unix": ["marksman-linux"]
2542+}
2543+```
2544+
2545+Now auto-completion / goto-definition / hover-tooltip must work on this "test.md" file:
2546+
2547+``` md
2548+[reference][abcd]
2549+[reference][a123]
2550+
2551+Some text.
2552+
2553+[abcd]: url "title"
2554+[a123]: url "title2"
2555+```
2556+
2557+## LSP server for V
2558+
2559+- Install V lexer (from "Addons Manager / Plugins / Install")
2560+- Install V language
2561+- Install v-analyzer binary from <https://github.com/v-analyzer/v-analyzer> to a folder (that is included in PATH)
2562+- Create "lsp_v.json" in CudaText's "settings" folder with the following content:
2563+
2564+``` json
2565+{
2566+ "lexers": {
2567+ "V": "v"
2568+ },
2569+ "cmd_windows": ["v-analyzer.exe"],
2570+ "cmd_unix": ["v-analyzer"],
2571+ "cmd_macos": ["v-analyzer"]
2572+}
2573+```
2574+
2575+## LSP server Vale
2576+
2577+Steps for Windows OS.
2578+
2579+- Install Vale server. Add path of "vale-ls.exe" to system PATH.
2580+- Create "lsp_vale.json" in CudaText's "settings" folder. Specify empty lexer name.
2581+
2582+``` json
2583+{
2584+ "lexers": {
2585+ "": ""
2586+ },
2587+
2588+ "cmd_windows": ["vale-ls.exe"],
2589+ "log_stderr": true,
2590+ "settings": {
2591+ "configPath": ""
2592+ }
2593+}
2594+```
2595+
2596+- You need to put config file to %UserProfile% folder. For example: "C:\Users\john\\.vale.ini".
2597+- Do not forget to run: "vale sync".
2598+- Vale server did not support filenames with spaces on Windows OS. To fix it, update Vale to 0.3.7 or newer.
2599+
2600+---
2601+*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).*
2602+Category: CudaText

Back to history