Difference between revisions of "CudaText plugins"

From Lazarus wiki
Jump to navigationJump to search
(more text about macros)
 
(96 intermediate revisions by 2 users not shown)
Line 13: Line 13:
 
Command "Toggle stream comment" in plugin adds/removes comments of last 2 types: for range, for full lines (plugin chooses needed kind).
 
Command "Toggle stream comment" in plugin adds/removes comments of last 2 types: for range, for full lines (plugin chooses needed kind).
  
Comment chars are saved:
+
Where comment chars are stored:
  
* Line comments: in lexer file data/lexlib/nnn.lcf.
+
* Line comments: in lexer file data/lexlib/*.lcf.
* Range comments: in files data/lexlib/nnn.cuda-lexmap.
+
* Range comments: in additional file data/lexlib/*.cuda-lexmap.
  
== Macros ==
+
===Commenting options===
  
Macro is a sequence of CudaText actions, which can be saved to a file and invoked later by some command.
+
Plugin "Comments" has several options, and it gives the dialog to change them: menu item "Options / Settings-plugins / Comments / Config".
To use macros, you must install plugin "Macros" from Addon Manager. It adds "Macros" menu to CudaText main menu bar. This menu gives items:
 
  
* Macros...
+
'''(Line commands) Try to keep text position after (un)commenting'''
* Start record
 
* Stop record
 
* Cancel record
 
* Export...
 
* Import...
 
* (items for saved macros)
 
  
To record a macro:
+
Affects all commands for line-comments.
  
* call menu item "Macros / Start record", or use dialog "Macros / Macros..." which gives "Start record" button too
+
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:
* pefrorm some action(s) in CudaText:
 
** built-in commands, plugin commands (invoked by hotkey, by menu, by Command Palette)
 
** some mouse actions (clicks/selections, they save/playback relative to caret position)
 
** calling of Find/Replace dialog, "Go to" dialog
 
** actions in Find/Replace dialog
 
* call menu item "Macros / Stop record" to save your macro, plugin will ask for macro name
 
  
Macro saves action(s) performed inside its original editor tab (not other tabs). And it doesn't save actions inside plugin dialogs (e.g. FindInFiles).
+
    code();
  
To playback macro:
+
will be changed to line with 2 leading spaces:
  
* call menu item "Macros / (macro name)", the end of this menu lists all available/saved macros
+
  //code();
* or call dialog "Macros / Macros..." which allows to run available macros: it can be simple running, running N times, or running in loop ([x] While text changes, [x] Until caret on last line)
 
  
== Project Manager ==
+
After uncommenting, line will be restored to original, with 4 leading spaces.
  
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.
+
'''(Line "at non-space") If selected few lines, insert comment at maximal common indent'''
  
Plugin has context menu on its panel, with items:
+
Affects commands:
 +
* "Toggle line comment, at non-space char"
 +
* "Add line comment, at non-space char"
  
* Project file
+
With option on, this selected block of lines in C++:
** New project
 
** Open project
 
** Recent projects
 
** Save project as...
 
** Go to file... - this shows menu with all project files, and then tree-view selection jumps on selected file
 
** Project properties... - this shows dialog with current project's options
 
** Config... - this shows dialog with global Project Manager options
 
* Root nodes - commands for nodes on the project's root level
 
** Add folder...
 
** Add file...
 
** Clear project
 
** Remove node
 
* Selected file - it's shown only for files
 
* Selected directory - it's shown only for folders
 
* Refresh - it re-reads state of files/folders from disk
 
  
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.
+
      code1();
 +
    code2();
 +
        code3();
  
=== Project Manager options dialog ===
+
will be changed to:
 +
 
 +
    //  code1();
 +
    //code2();
 +
    //    code3();
 +
 
 +
With option off, block will be changed to:
  
;"Ignore files": ";"-separated shell wildcards, which are [https://docs.python.org/3/library/fnmatch.html documented here]. If file name (without path) matches any of these wildcards, it will not be listed in the treeview.
+
      //code1();
;"Ignore folders": ";"-separated shell wildcards. If folder name matches any of these wildcards, it will not be listed in the treeview.
+
    //code2();
;"Ignore all hidden files/folders": Additionally don't list all hidden items. On Unix, hidden mean "beginning with dot". On Windows, hidden means having file-system "hidden" attribute.
+
        //code3();
;"Open file after "Go to file" command": 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.
 
;"Use 'preview tab' on item clicking": 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.
 
;"Open files by double-click": If turned on, only double-click in the treeview will open file for editing, but not the single click.
 
;"On opening file in Git/SVN repo...": 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.
 
;"Suggest to close tabs not belonging to project": See [[#Sessions embedded to project]].
 
  
And options for icons:
+
'''(All) Move caret to next line'''
  
;"File type icons": 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".
+
Affects commands for line-comments, when they are called without selection.
;"Toolbar icons": 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".
 
  
=== Preview tab ===
+
With option on, caret will be moved 1 line down. This allows to call the command many times repeatedly, to change many lines.
  
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.
+
'''(Line commands) Skip blank lines'''
  
"Preview tab" is always '''created in the first tab-group''', even if the focused editor is located in different tab-group.
+
Affects commands for line-comments, when they are called without selection.
It was made on purpose, to avoid the situation when "preview tab" jumps from one tab-group to another.
 
  
Again, if you click different items in the Project Manager, and files are opened '''in the first tab-group''', it's not a bug.
+
With option on, and the previous option "Move caret to next line" on, command will skip lines containing only space/tab chars.
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.
 
  
"Preview tab" can be dragged to another tab-group, it should work there too.
+
'''"Toggle line comment" detects action by first non-blank line'''
  
=== Switch between projects ===
+
Affects command "Toggle line comment".
  
1) To switch to different project, Plugin Manager gives the context menu: "Project File / Recent projects / name.cuda-proj".
+
With option on, command detects its action (to comment or to uncomment) by the first non-blank line of the selected multi-line block.
  
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.
+
Here is selected block of code, selection is shown by square brackets, first selected line is blank line:
  
3) There is also a way to quickly switch between projects:
+
[
 +
 
 +
    //code1();
 +
    code2();
 +
    //code3();
 +
    code4();
 +
]
  
* Install plugins: "Config Toolbar", "External Tools" and "Session Manager". Restart CudaText.
+
With option off, block will be changed it to:
* Set CudaText option "ui_one_instance": true.
 
* 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).
 
* Add more such tools in the "External Tools", for different projects (and maybe sessions).
 
  
[[File:cudatext-tools-and-projects.png]]
+
[//
 +
//
 +
    //code1();
 +
    //code2();
 +
    //code3();
 +
    //code4();
 +
]
  
* 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.
+
With option on, block will be changed to:
  
[[File:cudatext-tools-and-projects-config.png]]
+
[
 +
 
 +
    code1();
 +
    code2();
 +
    code3();
 +
    code4();
 +
]
  
4) There is a method for CudaText 1.145.1 or newer.
+
== Macros ==
  
* Install plugin "Config Toolbar" (only 1 plugin here, comparing to the previous method).
+
Macro is a sequence of CudaText actions, which can be saved to a file and invoked later by some command.
* CudaText option "ui_one_instance" can be any.
+
To use macros, you must install plugin "Macros" from Addon Manager. It adds "Macros" menu to CudaText main menu bar. This menu gives items:
* 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.
 
* CudaText will use the new command-line which you entered after "exec=".
 
  
=== Sessions embedded to project ===
+
* Macros...
 +
* Start/stop recording
 +
* Playback last recorded macro
 +
* Export...
 +
* Import...
 +
* items for saved macros
  
CudaText 1.159+ 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}".
+
[[File:cudatext-macro-menu.png]]
  
To control sessions, use the "gear" button on the Project Manager toolbar. Several menu items are there:
+
To record a macro:
  
* "Project session: name". One or more menu items, one item per each session.
+
* Call menu item "Macros / Start/stop recording", or use dialog "Macros / Macros..." which gives the button for this.
* "Save session...". Shows text input prompt, to name a session (you will be warned if you use incorrect characters or session already exists).
+
* Perform some actions in CudaText:
* "Delete session". Shows menu to choose which session to delete from the project.
+
** built-in commands, plugin commands (invoked by hotkey, by menu, by Command Palette)
* "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.
+
** some mouse actions (clicks/selections, they save/playback relative to caret position)
* "Forget session, close all tabs".
+
** calling of Find/Replace dialog, "Go to" dialog
 +
** actions in Find/Replace dialog
 +
* Call menu item "Macros / Start/stop recording" again, plugin will ask for macro name.
  
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:
+
During recording, CudaText shows reddish border around the editor field.
  
CudaText has opened 3 tab(s) not belonging to the project "name". Close them?
+
[[File:cudatext-macro-border.png]]
/path/to/file1
 
/path2/to/file2
 
*Untitled1
 
  
You will see this confirmation when doing:
+
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.
  
* "New project" action (from Project Manager context menu, or from Command Palette)
+
To playback macro:
* "Save session..." action (from "gear" popup menu, or from Command Palette)
 
 
 
You can disable that option (or press "Cancel" in the confirmation), to save even "not belonging" opened files to embedded session.
 
  
== Snippets ==
+
* Call menu item "Macros / macro_name", the end of this menu lists all available/saved macros.
 +
* Or call dialog "Macros / Macros...", which allows to run all available macros:
 +
** running 1 time
 +
** running specified count of times
 +
** running in the loop, by options:
 +
*** While text changes
 +
*** Until caret on last line
  
To use snippets you need:
+
===Macro example===
 +
For example, we have text line with HTML tags like this ("|" shows the caret):
  
* plugin "Snippets" (install from Addon Manager)
+
....<tag>....|...........</tag>....
* snippet package for needed lexer (install from Addon Manager)
 
  
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 editor and press Tab key: snippet for this id will be inserted into text. You can insert snippets also by choosing in dialog: call menu item "Plugins / Snippets".
+
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".
  
Only those snippets are enabled, which are suitable for the current lexer. For example, a snippet may be for lexers "C,C++,Objective C" - it is enabled only when these lexers are active. If a snippet has no lexer property, it is always enabled.
+
So, during macro recording, run these commands:
  
Dialog of Snippets plugin:
+
* call Find dialog (or focus it with mouse), search for ">" with "Find previous" button
 +
* right-arrow key (to reset the selection)
 +
* "markers: drop marker at caret"
 +
* call Find dialog again (or focus it with mouse), search for "<" with "Find next" button
 +
* left-arrow key, 2 times (to reset the selection)
 +
* "markers: select to last marker"
 +
* "markers: remove all"
  
[[File:cudatext_snippets_menu.png]]
+
== Project Manager ==
  
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 special in editor, it jumps to next marker. See detailed information in the [[CudaText#Markers]].
+
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.
  
=== Snippets from VSCode ===
+
Plugin has context menu on its panel, with items:
Since recent versions, Snippets plugin supports snippets from VSCode editor. It gives menu items in "Plugins / Snippets":
 
  
* "Install VSCode snippets..." - this suggests to install packages with snippets (packages usually contain more functionality, and CudaText plugin will install only snippets).
+
* '''Project file'''
 +
** New project
 +
** Open project
 +
** Recent projects
 +
** Save project as...
 +
** Go to file... - this shows menu with all project files, and then tree-view selection jumps on selected file
 +
** Project properties... - this shows dialog with current project's options
 +
** Config... - this shows dialog with global Project Manager options
 +
* '''Root nodes''' - commands for nodes on the project's root level
 +
** Add folder...
 +
** Add file...
 +
** Clear project
 +
** Remove node
 +
* '''Selected file''' - it's shown only for files
 +
* '''Selected directory''' - it's shown only for folders
 +
* '''Refresh''' - it re-reads state of files/folders from disk
  
[[File:cudatext-snippets-add-vscode.png]]
+
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:
  
* "Remove VSCode snippets"
+
[[File:cudatext-project-seldir.png]]
* "Visit homepage of VSCode snippets..."
 
* "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.
 
  
Plugin also gives the fully featured snippet editor dialog, in menu item "Add/edit snippets...".
+
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.
  
[[File:cudatext-snippets-editor.png]]
+
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.
  
Currently most of VSCode/TextMate "macros" are supported in snippets body, but not all. Refer to readme file of the plugin.
+
=== Project Manager options dialog ===
  
=== Snippets for HTML tags ===
+
;"Ignore files": ";"-separated shell wildcards, which are [https://docs.python.org/3/library/fnmatch.html documented here]. If file name (without path) matches any of these wildcards, it will not be listed in the treeview.
 +
;"Ignore folders": ";"-separated shell wildcards. If folder name matches any of these wildcards, it will not be listed in the treeview.
 +
;"Ignore all hidden files/folders": Additionally don't list all hidden items. On Unix, hidden mean "beginning with dot". On Windows, hidden means having file-system "hidden" attribute.
 +
;"Open file after "Go to file" command": 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.
 +
;"Use 'preview tab' on item clicking": 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.
 +
;"Open files by double-click": If turned on, only double-click in the treeview will open file for editing, but not the single click.
 +
;"On opening file in Git/SVN repo...": 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.
 +
;"Suggest to close tabs not belonging to project": See [[#Sessions embedded to project]].
  
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:
+
And options for icons:
  
  <a href="http" title="Title" target="_blank"></a>
+
;"File type icons": 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".
 +
;"Toolbar icons": 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".
  
These snippets have markers, so Tab key jumps to the next marker. Last marker is usually placed after the entire tag, ie after ">" bracket.
+
=== Preview tab ===
  
===Format of snippet files===
+
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.
  
====Snippets tab-stops====
+
"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.
  
Specify tab-stops in the snippet text like this:
+
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.
  
* ${NN}
+
"Preview tab" can be dragged to another tab-group, it should work there too.
* ${NN:default text}
 
  
This places markers (AKA tab-stops) in the editor, marker index NN should be from 0 to 40.
+
=== Switch between projects ===
After snippet insertion, tab-key goes to next marker(s) and deletes it.
 
  
* Markers can be listed in any order (e.g. marker 4 can be between 1 and 2).
+
1) To switch to different project, Plugin Manager gives the context menu: "Project File / Recent projects / name.cuda-proj".
* Tab-key first goes to marker 1, 2, 3... and marker 0 is always the last.
 
* Markers with the same indexes will place multi-carets.
 
* Nested markers (with default text) are allowed, but only with one nesting level, e.g. ${2:text is {$3:here}}.
 
* Marker with default text ${NN:...} can specify multi-line default text (character "}" is on another line of snippet).
 
  
====Snippets macros====
+
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.
Special macros are handled by Snippets plugin in snippet text:
+
 
 +
3) There is also a way to quickly switch between projects:
  
* ${sel} - Text selected before snippet insertion (if snippet called with Tab key, it's empty string)
+
* Install plugins: "Config Toolbar", "External Tools" and "Session Manager". Restart CudaText.
* ${cp} - Current clipboard contents
+
* Set CudaText option "ui_one_instance": true.
 +
* 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).
 +
* Add more such tools in the "External Tools", for different projects (and maybe sessions).
  
* ${cmt_start} - Current lexer's "block comment" start symbols (or empty string)
+
[[File:cudatext-tools-and-projects.png]]
* ${cmt_end} - Current lexer's "block comment" end symbols (or empty string)
 
* ${cmt_line} - Current lexer's "line comment" symbols (or empty string)
 
  
* ${fname} - File name only, without path
+
* 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.
* ${fpath} - Full file name, with path
 
* ${fdir} - Directory of file
 
* ${fext} - Extension of file
 
* ${psep} - OS path separator: backslash on Windows, slash on Unix
 
  
* ${date:nnnn} - Current date/time formatted by string "nnnn"; see [http://strftime.org/ Python docs]
+
[[File:cudatext-tools-and-projects-config.png]]
* ${env:nnnn} - Value of OS environment variable "nnnn"
 
  
The following macros from Sublime Text editor are supported. They can be written as $NAME or as ${NAME}.
+
4)
  
* $TM_SELECTED_TEXT - The currently selected text or the empty string
+
* Install plugin "Config Toolbar" (only 1 plugin here, comparing to the previous method).
* $TM_CURRENT_LINE - The contents of the current line
+
* CudaText option "ui_one_instance" can be any.
* $TM_CURRENT_WORD - The contents of the word under cursor or the empty string
+
* 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.
* $TM_LINE_INDEX - The zero-based line number
+
* CudaText will use the new command-line which you entered after "exec=".
* $TM_LINE_NUMBER - The one-based line number
+
 
* $TM_FILEPATH - The full file path of the current document
+
=== Sessions embedded to project ===
* $TM_DIRECTORY - The directory of the current document
+
 
* $TM_FILENAME - The filename of the current document
+
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}".
* $TM_FILENAME_BASE - The filename of the current document without its extensions
 
* $CLIPBOARD - The contents of your clipboard
 
* $WORKSPACE_NAME - The name of the opened workspace or folder
 
  
* $BLOCK_COMMENT_START - Current lexer's "block comment" start symbols (or empty string)
+
To control sessions, use the "gear" button on the Project Manager toolbar. Several menu items are there:
* $BLOCK_COMMENT_END - Current lexer's "block comment" end symbols (or empty string)
 
* $LINE_COMMENT - Current lexer's "line comment" symbols (or empty string)
 
  
For inserting the current date and time:
+
* "Project session: name". One or more menu items, one item per each session.
* $CURRENT_YEAR - The current year
+
* "Save session...". Shows text input prompt, to name a session (you will be warned if you use incorrect characters or session already exists).
* $CURRENT_YEAR_SHORT - The current year's last two digits
+
* "Delete session". Shows menu to choose which session to delete from the project.
* $CURRENT_MONTH - The month as two digits (e.g. '02')
+
* "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.
* $CURRENT_MONTH_NAME - The full name of the month (e.g. 'July')
+
* "Forget session, close all tabs".
* $CURRENT_MONTH_NAME_SHORT - The short name of the month (e.g. 'Jul')
 
* $CURRENT_DATE - The day of the month
 
* $CURRENT_DAY_NAME - The name of day (e.g. 'Monday')
 
* $CURRENT_DAY_NAME_SHORT - The short name of the day (e.g. 'Mon')
 
* $CURRENT_HOUR - The current hour in 24-hour clock format
 
* $CURRENT_MINUTE - The current minute
 
* $CURRENT_SECOND - The current second
 
* $CURRENT_SECONDS_UNIX - The number of seconds since the Unix epoch
 
  
====Snippets file names====
+
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:
  
Snippets are stored in separate files with extensions:
+
CudaText has opened 3 tab(s) not belonging to the project "name". Close them?
 +
/path/to/file1
 +
/path2/to/file2
 +
*Untitled1
  
* .cuda-snippet or .synw-snippet: main format.
+
You will see this confirmation when doing:
* .cuda-snips: compact format for collections of tiny snippets.
 
  
Encoding is UTF-8, no BOM. Files can be placed in any subfolder of "data/snippets" folder, file/folder names have no meaning, but it's recommended to name subfolders like AuthorName.SyntaxName, so users can easily find newly installed snippets.
+
* "New project" action (from Project Manager context menu, or from Command Palette)
 +
* "Save session..." action (from "gear" popup menu, or from Command Palette)
  
====Format of .cuda-snippet====
+
You can disable that option (or press "Cancel" in the confirmation), to save even "not belonging" opened files to embedded session.
  
First lines have format "key=value" (no spaces around "="), where "key" is one of strings:
+
== How to bind a hotkey to insert a snippet ==
 +
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.
  
* "name": snippet full name, shown in dialog.
+
Let's show how to make a primitive plugin which has 2 primitive commands:
* "id": snippet short alias for Tab-key (latin letters, digits, "_.$"), line is optional.
 
* "lex": lexers list, comma-separated, for which snippet is active, line is optional, empty means snippet always active.
 
  
Then follows the line "text=" without value, and all next lines - are snippet contents.
+
* Insert snippet "AA" at the caret position (supporting multi-carets).
 +
* Surround current line with square brackets.
  
* Trailing blank lines are discarded.
+
Make a new plugin by calling menu item "Plugins / Make Plugin". Fieds of dialog:
* Use tab-chars in text indents, they are auto replaced to spaces if current editor configured so.
 
  
====Format of .cuda-snips====
+
* "Plugin name": set to "My plugin".
 +
* "Python module name": set to "my_snippet".
 +
* "Commands caption>method": set 2 lines:
  
File contains one or several lines, one snippet per line. Empty lines, lines starting with "#" or space, are ignored. Format of lines:
+
My snippet>my_snippet
 +
My edit>my_edit
  
* id text
+
This will generate new plugin with 2 methods in the file "__init__.py": my_snippet and my_edit. Code will be like this:
* /N=name text
+
<syntaxhighlight lang="python">
* id /N=name text
+
    def my_snippet(self):
* id /L=lexers text
+
        #
* id /L=lexers /N=name text
+
        #
* id /L="lexers" /N="name" text
+
        #
 +
        msg_box(s, MB_OK)
 +
   
 +
    def my_edit(self):
 +
        pass
 +
</syntaxhighlight>
  
Here "id" is short alias for Tab-key, "name" (if not set, it's the same as "id") is full name for dialog, "lexers" is comma-separated lexer list, "text" is snippet contents. Contents can have escaped special chars: "\n", "\r", "\t" (tab-char), "\\" (backslash).
+
At the top of the Python file, near "import" operators, add:
 +
<syntaxhighlight lang="python">
 +
import cudatext_cmd as cmds
 +
</syntaxhighlight>
  
== Snippet Panel ==
+
Now edit methods my_snippet / my_edit:
 +
<syntaxhighlight lang="python">
 +
    def my_snippet(self):
 +
        ''' Insert my snippet '''
 +
        ed.cmd(cmds.cCommand_TextInsert, 'AA')
 +
   
 +
    def my_edit(self):
 +
        ''' Surround line with brackets '''
 +
        x, y, x1, y1 = ed.get_carets()[0]
 +
        s = ed.get_text_line(y)
 +
        s = '[' + s + ']'
 +
        ed.set_text_line(y, s)
 +
        msg_status('Edited!')
 +
</syntaxhighlight>
 +
 
 +
All done. Restart CudaText. You must have new menu items:
  
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).
+
* "Plugins / My plugin / My snippet"
 +
* "Plugins / My plugin / My edit"
  
Preinstalled folders:
+
In the Command Palette, find these new commands, press F9 to set hotkey for them.
  
* Arrows
+
== Snippets ==
* Currency symbols
 
* Greek alphabet (lower)
 
* Greek alphabet (upper)
 
* HTML - Arrows
 
* HTML - Color names
 
* HTML - Color names+values
 
* HTML - Letters
 
* HTML - Math symbols
 
* HTML - Special characters
 
* Math symbols
 
* Quote selection
 
* Special characters
 
  
Plugin looks for its folders in two places:
+
To use snippets you need:
  
* Folder "clips" in the plugin folder.
+
* Plugin "Snippets" (install from Addon Manager)
* Folder CudaText/data/clips, which is absent by default, for custom user folders.
+
* Snippet package for needed lexer (install from Addon Manager)
  
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.
+
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...".
  
== CudaLint ==
+
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.
  
CudaLint plugin allows to check correctness of documents in many syntaxes.
+
Dialog of Snippets plugin:
It was initially ported from SublimeLinter 2.x plugin for Sublime Text.
 
Each lexer must be supported with additionally installed linter, for example:
 
  
* JavaScript is supported with linter based on JSLint tool,
+
[[File:cudatext_snippets_menu.png]]
* HTML is supported with linter based on HTML Tidy tool,
 
* CSS is supported with linter based on CSSLint tool,
 
* etc
 
  
You will find all linters in the Addon Manager: "Plugins / Addon Manager / Install".
+
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#Markers]].
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.
 
  
=== Linters - usage ===
+
Plugin supports two snippets folder, but formats of data are the same, VSCode JSON format:
  
To run linting, use menu item "Plugins / CudaLint / Lint", or set hotkey to this command
+
* CudaText snippets. These are packages with prefix "snippets_ct" in the Addons Manager. They are installed into folder CudaText/data/snippets_ct.
(in CudaText Command Palette, press F9). You will see statusbar message, which tells how many errors
+
* 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.
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).
 
  
Linting can also be run by events:
+
=== Snippets from VSCode ===
 +
Since recent versions, Snippets plugin supports snippets from VSCode editor. It gives menu items in "Plugins / Snippets":
  
* after opening file
+
* "Install VSCode snippets..." - this suggests to install packages with snippets (packages usually contain more functionality, and CudaText plugin will install only snippets).
* on saving file
 
* after text is changed + pause passed
 
  
Events aren't used by default (to not slowdown usual work). To use events, you must enable them in config.
+
[[File:cudatext-snippets-add-vscode.png]]
Call config by menu item in "Options / Settings-plugins".
 
  
=== Linters - Node.js ===
+
* "Remove VSCode snippets"
 +
* "Visit homepage of VSCode snippets..."
 +
* "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.
  
Some linters require Node.js, so for those linters, you must install Node first.
+
Plugin also gives the fully featured snippet editor dialog, in menu item "Add/edit snippets...".
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.
 
  
* Windows: "node.exe" must be in PATH, command "node -v" must work in console.
+
[[File:cudatext-snippets-editor.png]]
* Linux: "nodejs" package must be installed, command "nodejs -v" must work in terminal.
 
  
=== Linters - authoring ===
+
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.
  
To support more lexers, it's a good idea to port linter from SublimeLinter. To port a linter, most you need is:
+
Currently most of VSCode/TextMate "macros" are supported in snippets body, but not all. Refer to readme file of the plugin.
  
* 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.
+
=== Snippets for HTML tags ===
* 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.
 
* 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.
 
* If linter was using Node.js, take some code to run Node, from cuda_lint_csslint linter.
 
  
=== Linters - per project ===
+
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:
  
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:
+
  <a href="http" title="Title" target="_blank"></a>
  
linter_css=csslint
+
These snippets have markers, so Tab key jumps to the next marker. Last marker is usually placed after the entire tag, ie after ">" bracket.
  
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".
+
===Format of snippet files===
  
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.
+
====Snippets tab-stops====
  
== CudaFormatter ==
+
Specify tab-stops in the snippet text like this:
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.
 
  
For example, how to format code in XML?
+
* ${NN}
 +
* ${NN:default text}
  
* Use "Plugins / Addon Manager / Install" to install the CudaFormatter, and formatter(s) for XML. Restart CudaText.
+
This places markers (AKA tab-stops) in the editor, marker index NN should be from 0 to 40.
* Open XML file.
+
After snippet insertion, tab-key goes to next marker(s) and deletes it.
* Use "Plugins / CudaFormatter / Formatter (menu)". This will show the menu of actions from appropriate formatter(s) for current file.
 
  
Formatters may change entire file text or only selected text. If selection is made, formatter changes only the selection, otherwise the entire text.
+
* Markers can be listed in any order (e.g. marker 4 can be between 1 and 2).
 +
* Tab-key first goes to marker 1, 2, 3... and marker 0 is always the last.
 +
* Markers with the same indexes will place multi-carets.
 +
* Nested markers (with default text) are allowed, but only with one nesting level, e.g. ${2:text is {$3:here}}.
 +
* Marker with default text ${NN:...} can specify multi-line default text (character "}" is on another line of snippet).
  
===CudaFormatter commands===
+
====Snippets macros====
 +
Special macros are handled by Snippets plugin in snippet text:
  
* Formatter (menu): Runs formatter for current editor file. If several formatters are found, menu dialog will suggest to choose one of them.
+
* ${sel} - Text selected before snippet insertion (if snippet called with Tab key, it's empty string)
 +
* ${cp} - Current clipboard contents
  
* Formatter A...D: Runs formatter for current editor file, which has label (A, B, C, D) set. Labels are configurable by another command.
+
* ${cmt_start} - Current lexer's "block comment" start symbols (or empty string)
 +
* ${cmt_end} - Current lexer's "block comment" end symbols (or empty string)
 +
* ${cmt_line} - Current lexer's "line comment" symbols (or empty string)
  
* Configure on_save: Chooses which formatters are active on file saving. The first formatter, which is suitable for current lexer, and has the flag "on_save", will be used to format text on file saving.
+
* ${fname} - File name only, without path
 +
* ${fpath} - Full file name, with path
 +
* ${fdir} - Directory of file
 +
* ${fext} - Extension of file
 +
* ${psep} - OS path separator: backslash on Windows, slash on Unix
  
* Configure labels: Allows to assign labels (A, B, C, D) to formatters. Labels allow to use commands "Formatter A"..."Formatter D", e.g. via hotkeys. So you can use command "Formatter A" via some hotkey, and be sure that for all lexers "Formatter A" will use desired formatters.
+
* ${date:nnnn} - Current date/time formatted by string "nnnn"; see [http://strftime.org/ Python docs]
 +
* ${env:nnnn} - Value of OS environment variable "nnnn"
 +
* ${cmd:nnnn} - Execute shell command "nnnn" and get its output (space-separated arguments are supported, '~' for home-directory is supported on Unix)
  
* Configure formatter: For those formatters which support config file, command will suggest to open global config file (in the folder "settings" of CudaText).
+
The following macros from Sublime Text editor are supported. They can be written as $NAME or as ${NAME}.
  
* Configure formatter (local): For those formatters which suppots config 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 global config.
+
* $TM_SELECTED_TEXT - The currently selected text or the empty string
 +
* $TM_CURRENT_LINE - The contents of the current line
 +
* $TM_CURRENT_WORD - The contents of the word under cursor or the empty string
 +
* $TM_LINE_INDEX - The zero-based line number
 +
* $TM_LINE_NUMBER - The one-based line number
 +
* $TM_FILEPATH - The full file path of the current document
 +
* $TM_DIRECTORY - The directory of the current document
 +
* $TM_FILENAME - The filename of the current document
 +
* $TM_FILENAME_BASE - The filename of the current document without its extensions
 +
* $CLIPBOARD - The contents of your clipboard
 +
* $WORKSPACE_NAME - The name of the opened workspace or folder
  
== External Tools ==
+
* $BLOCK_COMMENT_START - Current lexer's "block comment" start symbols (or empty string)
 +
* $BLOCK_COMMENT_END - Current lexer's "block comment" end symbols (or empty string)
 +
* $LINE_COMMENT - Current lexer's "line comment" symbols (or empty string)
  
=== Introduction to External Tools ===
+
For inserting the current date and time:
 +
* $CURRENT_YEAR - The current year
 +
* $CURRENT_YEAR_SHORT - The current year's last two digits
 +
* $CURRENT_MONTH - The month as two digits (e.g. '02')
 +
* $CURRENT_MONTH_NAME - The full name of the month (e.g. 'July')
 +
* $CURRENT_MONTH_NAME_SHORT - The short name of the month (e.g. 'Jul')
 +
* $CURRENT_DATE - The day of the month
 +
* $CURRENT_DAY_NAME - The name of day (e.g. 'Monday')
 +
* $CURRENT_DAY_NAME_SHORT - The short name of the day (e.g. 'Mon')
 +
* $CURRENT_HOUR - The current hour in 24-hour clock format
 +
* $CURRENT_MINUTE - The current minute
 +
* $CURRENT_SECOND - The current second
 +
* $CURRENT_SECONDS_UNIX - The number of seconds since the Unix epoch
  
Plugin "External Tools" (ExtTools) can be installed from Addon Manager. It allows to run external programs, catch their output, and then it can:
+
== Snippet Panel ==
  
* Display this output in the Output or Console panel of CudaText.
+
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).
* Replace current editor selection with the output.
 
* Copy this output to a new document.
 
* Copy this output to Clipboard.
 
* And more.
 
  
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.
+
Preinstalled folders:
  
[[File:cudatext-tools-menuitem.png]]
+
* Arrows
 +
* Currency symbols
 +
* Greek alphabet (lower)
 +
* Greek alphabet (upper)
 +
* HTML - Arrows
 +
* HTML - Color names
 +
* HTML - Color names+values
 +
* HTML - Letters
 +
* HTML - Math symbols
 +
* HTML - Special characters
 +
* Math symbols
 +
* Quote selection
 +
* Special characters
  
Some external tools configs are shown in the Wiki topics below. Enter these strings in the "Tool properties" dialog.
+
Plugin looks for its folders in two places:
  
[[File:cudatext-tools-props.png]]
+
* Folder "clips" in the plugin folder.
 +
* Folder CudaText/data/clips, which is absent by default, for custom user folders.
  
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.
+
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.
  
[[File:cudatext-tools-mainlexertool.png]]
+
== CudaLint ==
  
Notes:
+
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:
  
* 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.
+
* JavaScript is supported with linter based on JSLint tool,
* 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".
+
* HTML is supported with linter based on HTML Tidy tool,
 +
* CSS is supported with linter based on CSSLint tool,
 +
* etc
 +
 
 +
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.
  
=== Tool to compile by GCC ===
+
=== Linters - usage ===
  
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++".
+
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).
  
Properties:
+
Linting can also be run by events:
  
* Name: C - compile
+
* after opening file
* File name: gcc
+
* on saving file
* Shell command: unchecked
+
* after text is changed + pause passed
* Parameters: "{FileNameOnly}" -o "{FileNameNoExt}"
+
 
* Initial folder: {FileDir}
+
Events aren't used by default (to not slowdown usual work). To use events, you must enable them in config.
* Lexers: C,C++
+
Call config by menu item in "Options / Settings-plugins".
* Capture output: Output panel
 
* Encoding: utf_8
 
  
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".
+
=== Linters - Node.js ===
  
* Pattern: (?P<file>[^:]+):(?P<line>\d+):(?P<col>\d+): .+
+
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.
  
=== Tool to run C program ===
+
* Windows: "node.exe" must be in PATH, command "node -v" must work in console.
 +
* Linux: "nodejs" package must be installed, command "nodejs -v" must work in terminal.
  
Tool is for Linux, so "File name" don't have an extension. For Windows, change "File name" field to "{FileNameNoExt}.exe".
+
=== Linters - authoring ===
  
Tool will catch the program output in the Output panel, program text input will not work.
+
To support more lexers, it's a good idea to port linter from SublimeLinter. To port a linter, most you need is:
  
* Name: C - run
+
* 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.
* File name: "./{FileNameNoExt}"
+
* 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.
* Shell command: checked
+
* 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.
* Parameters: (empty)
+
* If linter was using Node.js, take some code to run Node, from cuda_lint_csslint linter.
* Initial folder: {FileDir}
+
 
* Lexers: C,C++
+
=== Linters - per project ===
* Capture output: Output panel
+
 
* Encoding: utf_8
+
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:
* Pattern: (empty)
+
 
 +
linter_css=csslint
 +
 
 +
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".
  
=== Tool to run C program, on Windows, with input in terminal ===
+
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.
  
Tool is for Windows, it allows to run compiled C/C++ program in new console window. Text input will work in this console.
+
=== Linters - method split_match ===
 +
Linters have RegEx property in class, which must find named groups:
  
Example C++ program:
+
* "line": Line index.
 +
* "col": Column index.
 +
* "error": If found then CudaLint will force "error" gutter icon.
 +
* "warning": If found then CudaLint will force "warning" gutter icon.
 +
* "message": Message text.
  
<syntaxhighlight lang="C++">
+
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.
#include <stdio.h>
+
 
int main ()
+
Example from SublimeLinter's linter for "Luau":
{
+
<syntaxhighlight lang="python">
  int c;
+
class Luau(Linter):
  puts ("Enter text. Include a dot ('.') in a sentence to exit:");
+
    cmd = 'luau-analyze --formatter=gnu -'
  do {
+
    regex = r'^stdin:(?P<line>\d+)\.(?P<col>\d+)\-(?P<end_line>\d+)\.(?P<end_col>\d+): (?P<code>\w+): (?P<message>.+)'
    c=getchar();
 
    putchar (c);
 
  } while (c != '.');
 
  return 0;
 
}
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Tool props:
+
Sometimes, finding "error"/"warning" named groups is hard, and class method "split_match" can help here.
* Name: C - run
+
Example from SublimeLinter's linter for "Luau":
* File name: cmd
+
<syntaxhighlight lang="python">
* Shell command: unchecked
+
    def split_match(self, match):
* Parameters: /K "{FileNameNoExt}.exe"
+
        error = super().split_match(match)
** Alternative value: /C "{FileNameNoExt}.exe" && pause
+
        error['error_type'] = 'error' if error['code'].endswith('Error') else 'warning'
* Initial folder: {FileDir}
+
        return error
* Lexers: C,C++
+
</syntaxhighlight>
* Capture output: Ignore
 
* Encoding: utf_8
 
* Pattern: (empty)
 
  
=== Tool to run C program, on Linux, with input in terminal ===
+
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:
 +
<syntaxhighlight lang="python">
 +
    def split_match(self, match):
 +
        matches, line, col, error, warning, message, near = super().split_match(match)
 +
        is_error = matches.group('code').endswith('Error')
 +
        error = is_error
 +
        warning = not is_error
 +
        return matches, line, col, error, warning, message, ''
 +
</syntaxhighlight>
  
Tool is for Linux, it allows to run compiled C/C++ program in new terminal window. Text input will work in this terminal window.
+
CudaLint needs 7 tuple items in split_match() result:
 +
* matches: RegEx match object
 +
* line: Line index
 +
* col: Column index
 +
* error: Error state; if casted to True, line will have "error" icon (red)
 +
* warning: Warning state; if casted to True, line will have "warning" icon (yellow)
 +
* message: Message string
 +
* near: Ignored in CudaLint
  
Example C++ program:
+
Example from CudaLint linter for Java.
 +
We override method because javac lints all referenced files, and we only want errors from the linted file.
 +
<syntaxhighlight lang="python">
 +
    def split_match(self, match):
 +
        if match:
 +
            if match.group('file') != self.filename:
 +
                match = None
 +
        return super().split_match(match)
 +
</syntaxhighlight>
 +
 
 +
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.
 +
<syntaxhighlight lang="python">
 +
    def split_match(self, match):
 +
        match, line, col, error, warning, message, near = super().split_match(match)
 +
        if line is None:
 +
            line = col = 0
 +
        return match, line, col, error, warning, message, near
 +
</syntaxhighlight>
 +
 
 +
Example from CudaLint linter for AutoIt.
 +
Here we modify the message/error/warning.
 +
<syntaxhighlight lang="python">
 +
    def split_match(self, match):
 +
        split_match = super(AutoIt, self).split_match(match)
 +
        match, line, col, error, warning, message, near = split_match
 +
        message = '{} (Col {})'.format(message, col)
 +
 
 +
        if match and match.group('type') == 'error':
 +
            error = 1
 +
            message = 'Error: ' + message
 +
        elif match and match.group('type') == 'warning':
 +
            warning = 1
 +
            message = 'Warning: ' + message
  
<syntaxhighlight lang="C++">
+
        return match, line, col, error, warning, message, ''
#include <stdio.h>
 
int main ()
 
{
 
  int c;
 
  puts ("Enter text. Include a dot ('.') in a sentence to exit:");
 
  do {
 
    c=getchar();
 
    putchar (c);
 
  } while (c != '.');
 
  return 0;
 
}
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Tool props:
+
Example from CudaLint linter for JavaScript using ESLint.
* Name: C - run
+
We override this method to silent warning by .eslintignore settings.
* Variant for xterm:
+
<syntaxhighlight lang="python">
** File name: xterm
+
    def split_match(self, match):
** Parameters: -hold -e "./{FileNameNoExt}"
+
        v1message = 'File ignored because of your .eslintignore file. Use --no-ignore to override.'
* Variant for gnome-terminal:
+
        v2message = 'File ignored because of a matching ignore pattern. Use --no-ignore to override.'
** File name: gnome-terminal
+
 
** Parameters: -- bash -c "./{FileNameNoExt}; read -s -n1 -r -p 'Press any key... '; echo"
+
        match, line, col, error, warning, message, near = super().split_match(match)
* Shell command: unchecked
+
        if message and (message == v1message or message == v2message):
* Initial folder: {FileDir}
+
            return match, None, None, None, None, '', None
* Lexers: C,C++
 
* Capture output: Ignore
 
* Encoding: utf_8
 
* Pattern: (empty)
 
  
=== Tool to compile+run C program ===
+
        return match, line, col, error, warning, message, near
 +
</syntaxhighlight>
  
In the External Tools dialog, press Join button, to join 2 tools created in above steps. Properties of joined tool:
+
Example from CudaLint linter for PowerShell using PSScriptAnalyzer.
 +
We return the match with ` quotes transformed to '.
 +
We supress one message.
 +
<syntaxhighlight lang="python">
 +
    def split_match(self, match):
 +
        match, line, col, error, warning, message, near = super().split_match(match)
  
* Name: C - make+run
+
        if message == 'no PowerShell code found at all':
* Series: C - compile; C - run
+
            match = None
* Lexers: C,C++
+
        else:
 +
            message = message.replace('`', '\'')
  
=== Tool to run current Batch file ===
+
            # If the message contains a complaint about a function
 +
            # and near looks like a function reference, remove the trailing
 +
            # () so it can be found.
 +
            if 'function \'' in message and near and near.endswith('()'):
 +
                near = near[:-2]
  
Tool properties:
+
        return match, line, col, error, warning, message, near
 +
</syntaxhighlight>
  
* Name: Run batch file
+
Example from CudaLint linter for Ruby.
* File name: cmd.exe
+
We override method because unrelated library files can throw errors, and we only want errors from the linted file.
* Shell command: unchecked
+
<syntaxhighlight lang="python">
* Parameters: /c "{FileName}"
+
    def split_match(self, match):
* Initial folder: {FileDir}
+
        if match:
* Lexers: Batch files
+
            if match.group('file') != '-':
* Capture output: Output panel
+
                match = None
* Encoding: the same as file's encoding: e.g. utf_8 or cp1251 (cp1251 is Russian ANSI codepage)
+
        return super(Ruby,self).split_match(match)
 +
</syntaxhighlight>
  
=== Tool to compile by Free Pascal ===
+
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.
 +
<syntaxhighlight lang="python">
 +
    def split_match(self, match):
 +
        match, line, col, error, warning, message, near = super().split_match(match)
 +
        if line is None and message:
 +
            line = 0
 +
            col = 0
 +
        return match, line, col, error, warning, message, near
 +
</syntaxhighlight>
  
This tool is for Free Pascal 3.x on Linux x64.
+
Example from CudaLint linter for Haskell.
 +
We override method to ignore errors reported in imported files.
 +
<syntaxhighlight lang="python">
 +
    def split_match(self, match):
 +
        match, line, col, error, warning, message, near = super().split_match(match)
 +
        match_filename = os.path.basename(match.groupdict()['filename'])
 +
        if not match_filename.startswith('_CudaLint_'):
 +
            return None, None, None, None, None, '', None
 +
        return match, line, col, error, warning, message, near
 +
</syntaxhighlight>
  
Properties:
+
== CudaFormatter ==
 +
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.
  
* Name: FPC - compile
+
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.
* File name:
 
** for FPC installed system-wide: fpc
 
** for FPC installed via fpcupdeluxe: /home/user/fpcupdeluxe/fpcupdeluxe/fpc/bin/x86_64-linux/fpc.sh
 
* Shell command: unchecked
 
* Parameters: {FileNameOnly}
 
* Initial folder: {FileDir}
 
* Lexers: Pascal
 
* Capture output: Output panel
 
* Encoding: utf_8
 
  
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.
+
For example, how to format code in XML?
  
=== Tool to call file-compare utility ===
+
* Use "Plugins / Addon Manager / Install" to install the CudaFormatter, and formatter(s) for XML. Restart CudaText.
 +
* Open XML file (normal or "lite" lexer XML must activate).
 +
* Use "Plugins / CudaFormatter / Formatter (menu)". This will show the menu of actions from appropriate formatter(s) for the XML (normal or "lite") lexer.
  
Tools, which call file-compare utility, to compare 2 files: active files in group-1 and group-2.
+
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.
  
==== WinMerge, KDiff, Kompare====
+
===CudaFormatter commands===
  
* Name: Compare files in G1, G2
+
;Formatter (menu): 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.
* File name: (full name of executable file)
 
* Shell command: unchecked
 
* Parameters: "{FileName_g1}" "{FileName_g2}"
 
* Initial folder: (empty)
 
* Capture output: Ignore
 
  
==== Meld ====
+
;Formatter per-lexer A...D: 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".
  
* Name: Compare files in G1, G2
+
;Formatter cross-lexer 1...4: 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.
* File name: (full name of executable file)
 
* Shell command: unchecked
 
* Parameters: --newtab "{FileName_g1}" "{FileName_g2}"
 
* Initial folder: (empty)
 
* Capture output: Ignore
 
  
==== diff ====
+
;Minify to separate file: 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).
  
* Name: Compare files in G1, G2
+
;Configure on_save: 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.
* File name: diff
 
* Shell command: unchecked
 
* Parameters: -Nau "{FileName_g1}" "{FileName_g2}"
 
* Initial folder: (empty)
 
* Capture output: Copy to new document
 
  
=== Tool to run Python scripts ===
+
;Configure per-lexer labels: 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.
  
* Name: Python3
+
;Configure formatter: For those formatters which have configuration file, command will suggest to open global config file (in the folder "settings" of CudaText).
* File name:
 
** on Windows: full path to "python.exe"
 
** on Unix: python3
 
* Shell command:
 
** on Windows: checked
 
** on Unix: unchecked
 
* Parameters: "{FileNameOnly}"
 
* Initial folder: {FileDir}
 
* Lexers: Python
 
* Capture output: Output panel
 
* Encoding: utf_8
 
* Pattern: \s*File "(?P<file>.+)", line (?P<line>\d+)
 
  
=== Tool to preview HTML file in Chrome ===
+
;Configure formatter (local): 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.
  
* Name: Preview in Chrome
+
===How to run formatter ESLint on saving===
* File name:
+
* Install from Addons Manager: "CudaFormatter"
** on Windows: C:\Program Files\Google\Chrome\Application\chrome.exe
+
* Install from Addons Manager: "formatter: JavaScript_JSON"
* Shell command:
 
** on Windows: unchecked
 
* Parameters: "{FileName}"
 
* Initial folder: (empty)
 
* Lexers: HTML
 
* Capture output: Ignore
 
  
=== Tool to open PHP documentation with given topic ===
+
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?
  
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.
+
* Activate lexer JavaScript in the current document (can be empty).
 +
* Call menu item "Plugins / CudaFormatter / Configure on_save...".
 +
* 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.
  
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.
+
[[File:cudatext-fmt-onsave.png]]
  
Download PHP documentation in .chm format from PHP.net, google for "php_manual_en chm", it is 16M file.
+
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.
 +
 
 +
===How formatter can know filename===
 +
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:
  
Tool properties:
+
from cuda_fmt import fmtconfig
 +
fn = fmtconfig.ed_filename
  
* Name: PHP Help
+
== External Tools ==
* File name: keyhh.exe
 
* Shell command: unchecked
 
* Parameters: -MyHelp -#klink {CurrentWord} "C:\Work\php_manual_en.chm"
 
* Initial folder: (empty)
 
* Lexers: PHP
 
* Save before: Nothing
 
* Capture output: Ignore
 
  
=== Tool to open AutoIt documentation with given topic ===
+
=== Introduction to External Tools ===
  
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.
+
Plugin "External Tools" (ExtTools) can be installed from Addon Manager. It allows to run external programs, catch their output, and then it can:
  
With AutoIt installed, you also have .chm documentation, its path is usually "C:\Program Files (x86)\AutoIt3\AutoIt.chm".
+
* Display this output in the Output or Console panel of CudaText.
 +
* Replace current editor selection with the output.
 +
* Copy this output to a new document.
 +
* Copy this output to Clipboard.
 +
* And more.
  
Tool properties:
+
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.
  
* Name: AutoIt Help
+
[[File:cudatext-tools-menuitem.png]]
* File name: keyhh.exe
 
* Shell command: unchecked
 
* Parameters: -MyHelp -#klink  {CurrentWord} "C:\Program Files (x86)\AutoIt3\AutoIt.chm"
 
* Initial folder: (empty)
 
* Lexers: AutoIt
 
* Save before: Nothing
 
* Capture output: Ignore
 
  
=== Tool to open .chm documentation for all lexers ===
+
Some external tools configs are shown in the Wiki topics below. Enter these strings in the "Tool properties" dialog.
  
See above example about tool for PHP documentation. Create the similar tool
+
[[File:cudatext-tools-props.png]]
  
* File name: keyhh.exe
+
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. 
* Shell command: unchecked
 
* Parameters: -MyHelp -#klink "{CurrentWord}" "{AppDir}\..\Docs\{Lexer}.chm"
 
* Lexers: (empty)
 
  
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.
+
[[File:cudatext-tools-mainlexertool.png]]
  
=== URL for Google search ===
+
Notes:
  
This is URL, not tool. In the External Tools dialog, press URL button, then press Add to add a new URL.
+
* 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.
 +
* 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".
  
* Name: Google find
+
=== Tool to compile by GCC ===
* URL:
 
  
<syntaxhighlight lang="text">
+
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++".
http://google.com/search?q={SelectedText|q}
 
</syntaxhighlight>
 
  
=== Tool to open folder of current file in Windows Explorer ===
+
Properties:
  
Tool properties:
+
* Name: C - compile
 
+
* File name: gcc
* Name: Open cur dir in Explorer
 
* File name: explorer.exe
 
 
* Shell command: unchecked
 
* Shell command: unchecked
* Parameters: {FileDir}
+
* Parameters: "{FileNameOnly}" -o "{FileNameNoExt}"
 
* Initial folder: {FileDir}
 
* Initial folder: {FileDir}
 +
* Lexers: C,C++
 +
* Capture output: Output panel
 +
* Encoding: utf_8
  
=== Tool to go to current file in FreeCommander ===
+
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".
  
* Name: Go to file in FreeCommander
+
* Pattern: (?P<file>[^:]+):(?P<line>\d+):(?P<col>\d+): .+
* File name: path\to\FreeCommander.exe
 
* Shell command: unchecked
 
* Parameters: "/L={FileName}" /C
 
* Initial folder: {FileDir}
 
  
=Runner=
+
=== Tool to run C program ===
Plugin Runner was written as an alternative to External Tools.
 
  
* Runner is more light weight.
+
Tool is for Linux, so "File name" don't have an extension. For Windows, change "File name" field to "{FileNameNoExt}.exe".
* Runner supports Sublime Text 3 build-systems.
+
 
* Runner displays tool output immediately line-by-line as it appears (External Tools can only show the entire ready output).
+
Tool will catch the program output in the Output panel, program text input will not work.
 +
 
 +
* Name: C - run
 +
* File name: "./{FileNameNoExt}"
 +
* Shell command: checked
 +
* Parameters: (empty)
 +
* Initial folder: {FileDir}
 +
* Lexers: C,C++
 +
* Capture output: Output panel
 +
* Encoding: utf_8
 +
* Pattern: (empty)
  
Many build-systems from Sublime Text 3 were packaged and put to add-on collection, search for add-on "Many Build Systems".
+
=== Tool to run C program, on Windows, with input in terminal ===
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.
 
  
See the [https://github.com/halfbrained/cuda_runner/blob/main/readme/readme.txt Runner documentation on GitHub].
+
Tool is for Windows, it allows to run compiled C/C++ program in new console window. Text input will work in this console.
  
Here is the GIF animation which shows reaction of Runner to PHP script running:
+
Example C++ program:
<syntaxhighlight lang="php">
+
 
<?php
+
<syntaxhighlight lang="C++">
for($i=0; $i<10; $i++) {
+
#include <stdio.h>
sleep(1);
+
int main ()
echo "$i is here\n";
+
{
 +
  int c;
 +
  puts ("Enter text. Include a dot ('.') in a sentence to exit:");
 +
  do {
 +
    c=getchar();
 +
    putchar (c);
 +
  } while (c != '.');
 +
  return 0;
 
}
 
}
?>
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
[[File:cudatext-runner-thread.gif]]
+
Tool props:
 
+
* Name: C - run
==Example C++ tool==
+
* File name: cmd
Install the add-on "build-system: C++ using G++".
+
* Shell command: unchecked
It supports C++ lexer using GNU C++ compiler.
+
* Parameters: /K "{FileNameNoExt}.exe"
It works on Linux/macOS out-of-the-box, on Windows you need the command "g++" to be in the system PATH.
+
** Alternative value: /C "{FileNameNoExt}.exe" && pause
 +
* Initial folder: {FileDir}
 +
* Lexers: C,C++
 +
* Capture output: Ignore
 +
* Encoding: utf_8
 +
* Pattern: (empty)
  
This build-system has 2 commands:
+
=== Tool to run C program, on Linux, with input in terminal ===
* compile, then run the compiled binary (default command)
 
* only run the compiled binary (it should be called from "Plugins / Runner / Build with...").
 
  
Example C++ file:
+
Tool is for Linux, it allows to run compiled C/C++ program in new terminal window. Text input will work in this terminal window.
<syntaxhighlight lang="cpp">
 
#include <iostream>
 
  
int main() {
+
Example C++ program:
    std::cout << "Hello World!";
 
    return 0;
 
}
 
</syntaxhighlight>
 
  
Example output in the CudaText Output panel (Linux):
+
<syntaxhighlight lang="C++">
<pre>
+
#include <stdio.h>
-- [16:41:55] Building: C++: new.cpp
+
int main ()
-- Command: g++ -std=c++11 -Wall "/home/user/new.cpp" -o "/home/user/new" && "/home/user/new"
 
-- Working dir: /home/user
 
Hello World!
 
-- Done (0.8s), return code: 0
 
</pre>
 
 
 
==Example PHP tool==
 
How to debug for example PHP file, with Runner.
 
Create file "[CudaText]/data/buildsystems/php.sublime-build" with such text:
 
<syntaxhighlight lang="json">
 
 
{
 
{
   "file_patterns": ["*.php"],
+
   int c;
   "linux": {
+
  puts ("Enter text. Include a dot ('.') in a sentence to exit:");
     "cmd": ["php", "$file"]
+
   do {
   },
+
     c=getchar();
  "windows": {
+
    putchar (c);
    "cmd": ["C:\\PHP_folder\\php-win.exe", "$file"]
+
   } while (c != '.');
   }
+
   return 0;
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Restart CudaText.
+
Tool props:
 +
* Name: C - run
 +
* Variant for xterm:
 +
** File name: xterm
 +
** Parameters: -hold -e "./{FileNameNoExt}"
 +
* Variant for gnome-terminal:
 +
** File name: gnome-terminal
 +
** Parameters: -- bash -c "./{FileNameNoExt}; read -s -n1 -r -p 'Press any key... '; echo"
 +
* Shell command: unchecked
 +
* Initial folder: {FileDir}
 +
* Lexers: C,C++
 +
* Capture output: Ignore
 +
* Encoding: utf_8
 +
* Pattern: (empty)
  
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.
+
=== Tool to compile+run C program ===
  
Example script to test:
+
In the External Tools dialog, press Join button, to join 2 tools created in above steps. Properties of joined tool:
<syntaxhighlight lang="php">
 
<?php
 
for($i=0; $i<10; $i++) {
 
sleep(1);
 
echo "$i is here\n";
 
}
 
?>
 
</syntaxhighlight>
 
  
==Example Python tool==
+
* Name: C - make+run
How to debug for example Python file, with Runner.
+
* Series: C - compile; C - run
Create file "[CudaText]/data/buildsystems/py.sublime-build" with such text:
+
* Lexers: C,C++
<syntaxhighlight lang="json">
 
{
 
  "file_patterns": ["*.py"],
 
  "linux": {
 
    "cmd": ["python3", "$file"],
 
  },
 
  "windows": {
 
    "cmd": ["pythonw.exe", "$file"]
 
  }
 
}
 
</syntaxhighlight>
 
  
Restart CudaText.
+
=== Tool to run current Batch file ===
  
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.
+
Tool properties:
  
Example script to test:
+
* Name: Run batch file
<syntaxhighlight lang="python">
+
* File name: cmd.exe
import sys
+
* Shell command: unchecked
import time
+
* Parameters: /c "{FileName}"
 +
* Initial folder: {FileDir}
 +
* Lexers: Batch files
 +
* Capture output: Output panel
 +
* Encoding: the same as file's encoding: e.g. utf_8 or cp1251 (cp1251 is Russian ANSI codepage)
  
def ForTest():
+
=== Tool to compile by Free Pascal ===
    for i in range(5):
 
        time.sleep(1)
 
        print(str(i) + " is here", flush=True)
 
       
 
if __name__ == '__main__':
 
    ForTest()
 
</syntaxhighlight>
 
  
==Example Free Pascal tool==
+
This tool is for Free Pascal 3.x on Linux x64.
How to compile and run Free Pascal files.
 
Create file "[CudaText]/data/buildsystems/Free Pascal.sublime-build" with such text:
 
<syntaxhighlight lang="json">
 
{
 
  "file_patterns": ["*.pp", "*.pas"],
 
  "file_regex": "(.+?)\\((\\d+),(\\d+)\\)\\s(.+)$",
 
  "working_dir": "$file_path",
 
  "name": "Compile",
 
  "cmd": ["/home/user/fpcupdeluxe/fpcupdeluxe32/fpc/bin/x86_64-linux/fpc.sh", "$file_name"],
 
  "variants": [
 
    {
 
      "name": "Run",
 
      "cmd": ["./$file_base_name"]
 
    }
 
  ]
 
}
 
</syntaxhighlight>
 
  
Restart CudaText.
+
Properties:
  
Here we use full path to FPC, when it is installed by FPCUPdeluxe tool on Linux x64. We use path of "fpc.sh" which is created by FPC installation.
+
* Name: FPC - compile
 
+
* File name:
After opening a Pascal file, call Runner main command "Build", that's it.
+
** for FPC installed system-wide: fpc
The "Build" command example output:
+
** for FPC installed via fpcupdeluxe: /home/user/fpcupdeluxe/fpcupdeluxe/fpc/bin/x86_64-linux/fpc.sh
 
+
* Shell command: unchecked
<pre>
+
* Parameters: {FileNameOnly}
-- [20:07:55] Building: Free Pascal: new.pas
+
* Initial folder: {FileDir}
-- Command: ['/home/user/fpcupdeluxe/fpcupdeluxe32/fpc/bin/x86_64-linux/fpc.sh', 'new.pas']
+
* Lexers: Pascal
-- Working dir: /home/user
+
* Capture output: Output panel
Free Pascal Compiler version 3.2.3-425-gebc55c0f4e-dirty [2021/09/09] for x86_64
+
* Encoding: utf_8
Copyright (c) 1993-2021 by Florian Klaempfl and others
+
 
Target OS: Linux for x86-64
+
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.
Compiling new.pas
 
Linking new
 
3 lines compiled, 0.1 sec
 
-- Done (0.2s), return code: 0
 
</pre>
 
  
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:
+
=== Tool to call file-compare utility ===
  
<pre>
+
Tools, which call file-compare utility, to compare 2 files: active files in group-1 and group-2.
-- [20:09:09] Building: Free Pascal: new.pas
 
-- Command: ['./new']
 
-- Working dir: /home/user
 
Hello world.
 
-- Done (-0.0s), return code: 0
 
</pre>
 
  
=FindInFiles=
+
==== WinMerge, KDiff, Kompare====
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.
 
  
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.
+
* Name: Compare files in G1, G2
 +
* File name: (full name of executable file)
 +
* Shell command: unchecked
 +
* Parameters: "{FileName_g1}" "{FileName_g2}"
 +
* Initial folder: (empty)
 +
* Capture output: Ignore
  
==FiF3 and FiF4: comparison and future==
+
==== Meld ====
CudaText has two plugins to search in files/tabs:
 
  
* FindInFiles v3 (FiF3)
+
* Name: Compare files in G1, G2
* FindInFiles v4 (FiF4)
+
* File name: (full name of executable file)
 +
* Shell command: unchecked
 +
* Parameters: --newtab "{FileName_g1}" "{FileName_g2}"
 +
* Initial folder: (empty)
 +
* Capture output: Ignore
  
Important: FiF3 is almost frozen. Only serious bugs will be fixed. No plans to hide/delete FiF3. FiF4 supersedes FiF3.
+
==== diff ====
  
Detailed comparison.
+
* Name: Compare files in G1, G2
 +
* File name: diff
 +
* Shell command: unchecked
 +
* Parameters: -Nau "{FileName_g1}" "{FileName_g2}"
 +
* Initial folder: (empty)
 +
* Capture output: Copy to new document
  
Common features:
+
=== Tool to run Python scripts ===
  
* 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.
+
* Name: Python3
* Encoding detection. FiF4 allows to set more flexible plan (see submenu "=/Encoding plan").
+
* File name:
* 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''').
+
** on Windows: full path to "python.exe"
* 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.
+
** on Unix: python3
* FiF3 has commands to '''count fragments''' and to show only filenames. FiF4 skips such commands as unnecessary.
+
* Shell command:
* FiF3 can save '''dialog layouts'''. FiF4 saves layout as part of preset.
+
** on Windows: checked
* Like FiF3, FiF4 has the "Replace" functionality.
+
** on Unix: unchecked
* Like FiF3, FiF4 can search '''in project''' folder(s).
+
* Parameters: "{FileNameOnly}"
 +
* Initial folder: {FileDir}
 +
* Lexers: Python
 +
* Capture output: Output panel
 +
* Encoding: utf_8
 +
* Pattern: \s*File "(?P<file>.+)", line (?P<line>\d+)
  
Main new features:
+
=== Tool to preview HTML file in Chrome ===
  
* FiF4 can report the found fragment with its '''around lines''' (see "-?+?" button).
+
* Name: Preview in Chrome
* FiF4 can search '''multi-line fragments''' (see "+" button).
+
* File name:
* FiF4 can search in '''many start folders'''.
+
** on Windows: C:\Program Files\Google\Chrome\Application\chrome.exe
* FiF4 allows to use '''lexer data''' to filter and report fragments (in/out string/comment, lexer path).
+
* Shell command:
* FiF4 allows to show lines in the Results with its '''lexer colors''' from source files.
+
** on Windows: unchecked
* FiF4 allows to use '''macro-variables''' (OS environments, properties of current file/tab and free-set names) in any editable fields .
+
* Parameters: "{FileName}"
* FiF4 has '''statusbar''' to show statistics of the last search: folders/files/fragments/timing.
+
* Initial folder: (empty)
* FiF4 allows to '''reformat Results''' (change tree type and more) without new search.
+
* Lexers: HTML
* FiF4 allows to show '''modification time''' of files in the Results.
+
* Capture output: Ignore
  
=Configure Menu=
+
=== Tool to open PHP documentation with given topic ===
  
Plugin "Configure Menu" (in Addon Manager) allows to change top menu and context menu. Plugin can create file (settings/menu.json) with default menu configuration, which you edit to customize all menus. File has items like:
+
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.
  
,{"cap":"&Save", "cmd":"cmd_FileSave"}
+
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.
  
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.
+
Download PHP documentation in .chm format from PHP.net, google for "php_manual_en chm", it is 16M file.
  
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:
+
Tool properties:
  
,{"cap":"Toggle line comment", "cmd":"module=cuda_comments;cmd=cmt_toggle_line_body;"}
+
* Name: PHP Help
 +
* File name: keyhh.exe
 +
* Shell command: unchecked
 +
* Parameters: -MyHelp -#klink {CurrentWord} "C:\Work\php_manual_en.chm"
 +
* Initial folder: (empty)
 +
* Lexers: PHP
 +
* Save before: Nothing
 +
* Capture output: Ignore
  
Here "cuda_comments" is plugin folder name, and "cmt_toggle_line_body" is Python method from install.inf.
+
=== Tool to open AutoIt documentation with given topic ===
  
You can add items to the CudaText top-menu and/or context-menu, it is different sections in "menu.json".
+
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.
Example screenshot shows how "menu.json" will look with new items for context-menu:
 
  
[[File:cudatext-editing-context-menu.png]]
+
With AutoIt installed, you also have .chm documentation, its path is usually "C:\Program Files (x86)\AutoIt3\AutoIt.chm".
  
=Intext Bookmarks=
+
Tool properties:
  
Plugin allows to place special marks, and to show Goto dialog for its special marks.
+
* Name: AutoIt Help
These are not usual CudaText bookmarks, but text lines, which are recognized only by this plugin.
+
* File name: keyhh.exe
 +
* Shell command: unchecked
 +
* Parameters: -MyHelp -#klink  {CurrentWord} "C:\Program Files (x86)\AutoIt3\AutoIt.chm"
 +
* Initial folder: (empty)
 +
* Lexers: AutoIt
 +
* Save before: Nothing
 +
* Capture output: Ignore
 +
 
 +
=== Tool to open .chm documentation for all lexers ===
  
Plugin adds menu items in "Plugins / In-text Bookmarks":
+
See above example about tool for PHP documentation. Create the similar tool
  
* List for current tab -- show all marks in the current document
+
* File name: keyhh.exe
* List for all tabs -- show all marks in all opened UI-tabs
+
* Shell command: unchecked
* Go to next
+
* Parameters: -MyHelp -#klink "{CurrentWord}" "{AppDir}\..\Docs\{Lexer}.chm"
* Go to previous
+
* Lexers: (empty)
* Add -- add a new mark at caret position
 
  
"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".
+
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.
  
You can customize that special lines, using plugin configuration dialog: menu item "Options / Settings-plugins / In-text Bookmarks". Dialog gives such options:
+
=== Tool for Google search ===
  
* Bookmark signs: NOTE: NB! TODO: todo: todo. FIX:
+
This is URL (special kind of tool). In the External Tools dialog, press the "URL" button, then press "Add" to add a new URL.
* Comment sign: //
 
  
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.
+
* Name: Google find
For files with rich lexers, plugin uses lexer's line-comment prefix.
+
* URL:
  
=Color Text=
+
<syntaxhighlight lang="text">
 +
http://google.com/search?q={SelectedText|q}
 +
</syntaxhighlight>
  
Plugin "Color Text" gives several commands (in the Plugins menu) to add coloring to text ranges.
+
=== Tool to open folder of current file in Windows Explorer ===
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.
 
  
[[File:cudatext-color-text.png]]
+
Tool properties:
  
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.
+
* Name: Open cur dir in Explorer
 +
* File name: explorer.exe
 +
* Shell command: unchecked
 +
* Parameters: {FileDir}
 +
* Initial folder: {FileDir}
  
Not only background color can be changed, but also border color, and font styles (bold, italic, stikeout).
+
=== Tool to go to current file in FreeCommander ===
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:
 
  
* "all_words": Colorize all occurrences of fragment.
+
* Name: Go to file in FreeCommander
* "case_sensitive": Case sensitive search for other occurrences.
+
* File name: path\to\FreeCommander.exe
* "whole_words": Colorize only those occurrences, which are whole words.
+
* Shell command: unchecked
* "show_on_map": Show added colored marks also on micro-map.
+
* Parameters: "/L={FileName}" /C
 +
* Initial folder: {FileDir}
  
=Insert Pics=
+
=Runner=
CudaText gives the plugin API to show pictures between the text lines.
+
Plugin Runner was written as an alternative to External Tools.
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:
 
  
[[File:cudatext-insert-pics.png]]
+
* Runner is more light weight.
 +
* Runner supports Sublime Text 3 build-systems.
 +
* Runner displays tool output immediately line-by-line as it appears (External Tools can only show the entire ready output).
  
* You can use any lexer for files with pictures.
+
Many build-systems from Sublime Text 3 were packaged and put to add-on collection, search for add-on "Many Build Systems".
* You can add the unlimited number of pictures. But only one picture per "gap".
+
Only few build-systems were packaged into own separate packages because they have big EXE/Binary files.
* You can add/delete pictures later, using plugin's commands in menu "Plugins / Insert Pics".
+
Some ST3 plugins have build-systems paired with some Python code - they are not supported.
* When you delete the "helper file" (located in the same folder), all pictures will be lost for plugin.
+
 
 +
See the [https://github.com/halfbrained/cuda_runner/blob/main/readme/readme.txt Runner documentation on GitHub].
  
=Complete From Text=
+
Here is the GIF animation which shows reaction of Runner to PHP script running:
Plugin allows to show auto-completion listbox with words from the current file (or all opened UI-tabs, by option).
+
<syntaxhighlight lang="php">
E.g. if you typed "op" and press Ctrl+Space (default auto-completion hotkey), it may suggest previously mentioned words "operations", "opinion", "option" etc.
+
<?php
Plugin is not smart like "LSP Client" plugin, so expect lot of 'false positives' in its listbox.
+
for($i=0; $i<10; $i++) {
 +
sleep(1);
 +
echo "$i is here\n";
 +
}
 +
?>
 +
</syntaxhighlight>
  
[[File:cudatext-complete-from-text.png]]
+
[[File:cudatext-runner-thread.gif]]
  
In the picture above, one word was taken from C lexer's C.acp file (this is a feature).
+
==Runner limitation for input==
 +
If your Python script contains the input() function:
  
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:
+
<syntaxhighlight lang="python">
 +
s=input('enter text: ')
 +
print('entered:', s)
 +
</syntaxhighlight>
  
* Install the plugin
+
it will run with a runtime error like this:
* Call menu item "Options / Settings-plugins / Complete From Text"
 
* This opens the "plugins.ini" file
 
* Find section "[complete_from_text]", add ",c" (without quotes) to the line "lexers="
 
* Restart CudaText
 
  
Plugin has more options in that "plugins.ini" file:
+
enter text: Traceback (most recent call last):
 +
  File "/home/user/a.py", line 3, in <module>
 +
s=input('enter text: ')
 +
EOFError: EOF when reading a line
  
* 'lexers': comma-separated lexer names, ie for which lexers to work; specify none-lexer as '-'.
+
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.
* 'min_len': minimal word length, words of smaller length will be ignored.
 
* 'max_lines': if document has bigger count of lines, ignore this document.   
 
* 'case_sens': case-sensitive; words starting with 'A' will be ignored when you typed 'a'.
 
* 'no_comments': ignore words inside "syntax comments" (lexer specific).
 
* 'no_strings': ignore words inside "syntax strings" (lexer specific).
 
* 'what_editors': which documents (ie UI tabs) to read to get words. Values:
 
**    0: only current document.
 
**    1: all opened documents.
 
**    2: all opened documents with the same lexer.
 
* 'use_acp': add suggestions from autocomplete files in 'data/autocomplete'
 
* '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.
 
* '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.  
 
  
Plugin supports CudaText option "nonword_chars", so for example words with '$' char are also added to completions, if CudaText option is configured so.
+
==Runner tool for C==
 +
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.
  
=Embedded Editor=
+
This build-system has 2 commands:
 +
* Build: only compiles
 +
* Run: compiles and then runs the binary
  
Plugin "Embedded Editor" shows "included" file in embedded editor - additional editor UI control is
+
Example C file:
shown between the text lines.
+
<syntaxhighlight lang="cpp">
For example, you can open included CSS / JS files while editing the HTML file.
+
#include <stdio.h>
 +
int main(){
 +
  printf("Hello world");
 +
  return 0;
 +
}
 +
</syntaxhighlight>
  
[[File:cudatext-embedded-editor.png]]
+
Example output in the CudaText Output panel (Linux):
 +
<pre>
 +
-- [10:34:08] Building: C via GCC: a.c
 +
-- Command: gcc "/home/user/a.c" -o "/home/user/a" && "/home/user/a"
 +
-- Working dir: /home/user
 +
Hello world
 +
-- Done (0.2s), return code: 0
 +
</pre>
  
It adds menu item to show/hide embedded editor in the current document, for the
+
==Runner tool for C++==
current caret position: "Plugins / Embedded Editor / Toggle".
+
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.
  
By default, plugin searches for the included filename inside double-quotes,
+
This build-system has 2 commands:
surrounding the caret position. This works OK for HTML and many other documents.
+
* compile, then run the compiled binary (default command)
 +
* only run the compiled binary (it should be called from "Plugins / Runner / Build with...").
  
For example, when you have opened file "/folder/file.html", and placed caret
+
Example C++ file:
inside first double-quotes:
+
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="html">
+
#include <iostream>
  <link href="css/style.css" rel="stylesheet" type="text/css"/>
 
</syntaxhighlight>
 
then embedded editor will be opened for file "/folder/css/style.css".
 
  
The search can be configured, though. For example, plugin can be used in Pascal
+
int main() {
files for include-directives:
+
    std::cout << "Hello World!";
<syntaxhighlight lang="pascal">
+
    return 0;
  {$I path/filename.inc}
+
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Plugin has 2 config files, you will see 2 menu items in the  
+
Example output in the CudaText Output panel (Linux):
"Options / Settings-plugins / Embedded Editor".
 
Read more about config files in the readme.txt of plugin.
 
 
 
=Breadcrumbs=
 
 
 
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:
 
 
<pre>
 
<pre>
[ home / user / mydir / myfile.ext ]
+
-- [16:41:55] Building: C++: new.cpp
</pre>
+
-- Command: g++ -std=c++11 -Wall "/home/user/new.cpp" -o "/home/user/new" && "/home/user/new"
It can also show the "~" button for the home directory (by option):
+
-- Working dir: /home/user
<pre>
+
Hello World!
[ ~ / mydir / myfile.ext ]
+
-- Done (0.8s), return code: 0
 
</pre>
 
</pre>
  
[[File:cudatext-breadcrumbs.png]]
+
==Runner tool for PHP==
 +
How to debug for example PHP file, with Runner.
 +
Create file "[CudaText]/data/buildsystems/php.sublime-build" with such text:
 +
<syntaxhighlight lang="json">
 +
{
 +
  "file_patterns": ["*.php"],
 +
  "linux": {
 +
    "cmd": ["php", "$file"]
 +
  },
 +
  "windows": {
 +
    "cmd": ["C:\\PHP_folder\\php-win.exe", "$file"]
 +
  }
 +
}
 +
</syntaxhighlight>
 +
 
 +
Restart CudaText.
  
Clicking on each button shows the popup with file-system listing, showing the
+
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.
folder containing  the clicked item. This popup supports basic tree-view navigation,
 
you can click files there to open them in CudaText.
 
  
Plugin can also show buttons for Code-Tree nodes. This must be enabled first
+
Example script to test:
in the config file - turn on the option "code_navigation".
+
<syntaxhighlight lang="php">
Clicking the buttons from the code-tree shows the same tree-popup but with
+
<?php
a different content - with symbols of the documents. Clicking the nodes
+
for($i=0; $i<10; $i++) {
in the tree-popup scrolls the document to different symbols.
+
sleep(1);
 +
echo "$i is here\n";
 +
}
 +
?>
 +
</syntaxhighlight>
  
=LSP Client=
+
==Runner tool for Python==
 +
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:
 +
* Build
 +
* Syntax Check
  
Plugin "LSP Client" allows to use Microsoft LSP protocol in CudaText with servers for many languages.  
+
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.
It requires that CudaText uses Python 3.6 or newer (otherwise you will see the error messagebox).
 
  
LSP Client gives several commands in the "Plugins / LSP Client", and all these commands work only if server supports them.
+
Example script to test:
Some of LSP commands are:
+
<syntaxhighlight lang="python">
 +
import time
  
* Auto-completion: integrated with CudaText command "Auto-completion menu" (in the Command Palette).
+
for i in range(5):
* Go to definition: integrated with CudaText command "Go to definition" (in the Command Palette, and in the editor context menu).
+
    time.sleep(1)
* Function signature help: integrated with CudaText command "Show function hint" (in the Command Palette).
+
    print(str(i) + " is here", flush=True)
* Hover: shows the tooltip when you hover mouse above identifiers. You need the Ctrl key pressed while you hover.
+
</syntaxhighlight>
  
[[File:cudatext-lsp-hover_.png]]
+
==Runner tool for Free Pascal==
 +
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:
 +
<syntaxhighlight lang="json">
 +
{
 +
  "file_patterns": ["*.pp", "*.pas"],
 +
  "file_regex": "(.+?)\\((\\d+),(\\d+)\\)\\s(.+)$",
 +
  "working_dir": "$file_path",
 +
  "name": "Compile",
 +
  "cmd": ["/home/user/fpcupdeluxe/fpcupdeluxe32/fpc/bin/x86_64-linux/fpc.sh", "$file_name"],
 +
  "variants": [
 +
    {
 +
      "name": "Run",
 +
      "cmd": ["./$file_base_name"]
 +
    }
 +
  ]
 +
}
 +
</syntaxhighlight>
  
* Find references: finds all locations where an identifier (under first caret) is used and shows menu with locations.
+
In this file, you need to adjust the path to "fpc.sh", according to your [[fpcupdeluxe]] folder.
 +
Restart CudaText.
  
[[File:cudatext-lsp-refs.png]]
+
After opening a Pascal file, call Runner main command "Build", that's it.
 +
The "Build" command example output:
  
* Code linting: checks the syntax of code, and places underlines and/or bookmarks on "incorrect lines".
+
<pre>
* Document formatting.
+
-- [20:07:55] Building: Free Pascal: new.pas
 
+
-- Command: ['/home/user/fpcupdeluxe/fpcupdeluxe32/fpc/bin/x86_64-linux/fpc.sh', 'new.pas']
All LSP servers should have a homepage with description of their functions, and installation information.
+
-- Working dir: /home/user
 
+
Free Pascal Compiler version 3.2.3-425-gebc55c0f4e-dirty [2021/09/09] for x86_64
In the server config "lsp_*.json", key "lexers", you need to specify the mapping between CudaText lexer names and LSP language names.
+
Copyright (c) 1993-2021 by Florian Klaempfl and others
For example, while CudaText lexer name is "Bash script", LSP language name is "bash".
+
Target OS: Linux for x86-64
And while CudaText lexer name is "C#", LSP language name is "csharp".
+
Compiling new.pas
 +
Linking new
 +
3 lines compiled, 0.1 sec
 +
-- Done (0.2s), return code: 0
 +
</pre>
 +
 
 +
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:
 +
 
 +
<pre>
 +
-- [20:09:09] Building: Free Pascal: new.pas
 +
-- Command: ['./new']
 +
-- Working dir: /home/user
 +
Hello world.
 +
-- Done (-0.0s), return code: 0
 +
</pre>
 +
 
 +
==Runner tool for Cobol==
 +
In Addons Manager, install the lexer "Cobol".
 +
 
 +
Let's make build-system for GnuCOBOL on Windows.
 +
Install GnuCOBOL, usually [https://www.arnoldtrembley.com/GnuCOBOL.htm from this webpage], to "C:\GnuCOBOL".
 +
You must have file "C:\GnuCOBOL\bin\cobc.exe".
 +
 
 +
Create Batch script "c:\GnuCOBOL\bin\runcobol.cmd" with such content:
 +
<pre>
 +
set Path=c:\gnucobol\bin
 +
set COB_CONFIG_DIR=c:\gnucobol\config
 +
set COB_COPY_DIR=c:\gnucobol\copy
 +
set COB_INCLUDE_PATH=c:\gnucobol\include
 +
set COB_LIB_PATH=c:\gnucobol\lib
 +
cobc -x -std=mf %1
 +
</pre>
  
 +
Create build-system file "[CudaText]\data\buildsystems\cobol.sublime-build":
 
<syntaxhighlight lang="json">
 
<syntaxhighlight lang="json">
 
{
 
{
   "lexers": {
+
   "file_patterns": ["*.cob", "*.cbl", "*.cpy"],
    "C#": "csharp"
+
  "name": "Compile",
   },
+
  "cmd": ["cmd.exe", "/c", "c:\\GnuCOBOL\\bin\\runcobol.cmd", "$file"],
   ...
+
  "working_dir": "$file_path",
 +
   "file_regex": "^([^:]+):([0-9]+):",
 +
   "variants": [
 +
    {
 +
      "name": "Run",
 +
      "cmd": ["$file_path/$file_base_name.exe"]
 +
    }
 +
  ] 
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
LSP Client also has the settings file, use menu item to open it: "Options / Settings-plugins / LSP Client".
+
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).
  
==LSP server for Python==
+
Now running the "Plugins / Runner / Build" can give text in the "Output panel" like this:
Python server has [https://github.com/palantir/python-language-server this homepage] and supports:
+
<pre>
 +
-- [07:49:02] Building: cobol: test.cbl
 +
-- Command: ['cmd.exe', '/c', 'c:\\GnuCOBOL\\bin\\runcobol.cmd', 'C:\\Work\\test.cbl']
 +
-- Working dir: C:\Work
  
* Auto-completion
+
C:\Work>set Path=c:\gnucobol\bin
* Go to definition
+
C:\Work>set COB_CONFIG_DIR=c:\gnucobol\config
* Function signature help
+
C:\Work>set COB_COPY_DIR=c:\gnucobol\copy
* Hover
+
C:\Work>set COB_INCLUDE_PATH=c:\gnucobol\include
* Find references
+
C:\Work>set COB_LIB_PATH=c:\gnucobol\lib
* Code linting
+
C:\Work>cobc -x -std=mf C:\Work\test.cbl
* Document formatting
+
C:\Work\test.cbl:1: error: invalid indicator 'u' at column 7
 +
C:\Work\test.cbl:2: warning: line not terminated by a newline [-Wmissing-newline]
 +
C:\Work\test.cbl:3: warning: PROGRAM-ID header missing [-Wothers]
 +
-- Done (0.3s), return code: 1
 +
</pre>
  
Use "pip" to install the Python LSP server:
+
=FindInFiles=
 +
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.
  
pip install python-language-server
+
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.
 
Server installation adds the command "pyls" which is not in the PATH.
 
You need to write the full path to LSP Client config.
 
Create the file "[CudaText]/settings/lsp_py.json" with text like this:
 
  
<syntaxhighlight lang="json">
+
==How to find/replace in all UI-tabs==
{
+
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:
  "lexers": {
+
 
    "Python": "python"
+
<tabs>
  },
+
{t}
  "cmd_windows": ["C:\\Python_folder\\pyls.exe"],
+
 
  "cmd_macos": ["pyls"],
+
[[File:cudatext-findinfiles-intabs.png]]
  "cmd_unix": ["~/.local/bin/pyls"]
+
 
}
+
And in the "Files" field, enter "*" for all files.
</syntaxhighlight>
+
 
 +
To discover more features of FindInFiles dialog, hover mouse over other labels/buttons.
 +
 
 +
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.  
  
Open some Python script, and call some commands of LSP Client. It will run the server, and it should work.
+
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.
  
==LSP server for CSS/SCSS/LESS==
+
==How to use FindInFiles 4==
 +
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.
  
The CSS (and SCSS, LESS) server is not easy to install, so here is the instruction, from the author of LSP Client:
+
==FiF3 and FiF4: comparison and future==
 +
CudaText has two plugins to search in files/tabs:
  
* Download the repository of VSCode: https://github.com/microsoft/vscode
+
* FindInFiles v3 (FiF3)
* From the repository, get the folder "extensions/css-language-features/server" and enter in it.
+
* FindInFiles v4 (FiF4)
* Replace the file "tsconfig.json" with content:
 
<syntaxhighlight lang="json">
 
{
 
    "compilerOptions": {
 
    "target": "es2018",
 
    "lib": [
 
    "es2018"
 
    ],
 
    "module": "commonjs",
 
    "strict": true,
 
    "alwaysStrict": true,
 
    "noImplicitAny": true,
 
    "noImplicitReturns": true,
 
    "noImplicitOverride": true,
 
    "noUnusedLocals": true,
 
    "noUnusedParameters": true,
 
    "forceConsistentCasingInFileNames": true,
 
   
 
    "outDir": "./out"
 
    },
 
  "files": [
 
      "src/node/cssServerMain.ts"
 
  ]
 
}
 
</syntaxhighlight>
 
  
* Install dependencies and TypeScript. In Terminal:
+
Important: FiF3 is almost frozen. Only serious bugs will be fixed. No plans to hide/delete FiF3. FiF4 supersedes FiF3.
  
npm install
+
Detailed comparison.
npm install -g typescript
 
  
* Compile it. In Terminal:
+
Common features:
 +
 
 +
* 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.
 +
* Encoding detection. FiF4 allows to set more flexible plan (see submenu "=/Encoding plan").
 +
* 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''').
 +
* 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.
 +
* FiF3 has commands to '''count fragments''' and to show only filenames. FiF4 skips such commands as unnecessary.
 +
* FiF3 can save '''dialog layouts'''. FiF4 saves layout as part of preset.
 +
* Like FiF3, FiF4 has the "Replace" functionality.
 +
* Like FiF3, FiF4 can search '''in project''' folder(s).
  
npx tsc
+
Main new features:
  
Server should be compiled. To use the server in LSP Client, create the file "lsp_css.json" with such content:
+
* FiF4 can report the found fragment with its '''around lines''' (see "-?+?" button).
<syntaxhighlight lang="json">
+
* FiF4 can search '''multi-line fragments''' (see "+" button).
{
+
* FiF4 can search in '''many start folders'''.
    "name": "vsc-css",
+
* FiF4 allows to use '''lexer data''' to filter and report fragments (in/out string/comment, lexer path).
    "lexers": {
+
* FiF4 allows to show lines in the Results with its '''lexer colors''' from source files.
    "CSS": "css",
+
* FiF4 allows to use '''macro-variables''' (OS environments, properties of current file/tab and free-set names) in any editable fields .
    "SCSS": "scss",
+
* FiF4 has '''statusbar''' to show statistics of the last search: folders/files/fragments/timing.
    "Sass": "sass",
+
* FiF4 allows to '''reformat Results''' (change tree type and more) without new search.
    "LESS": "less",
+
* FiF4 allows to show '''modification time''' of files in the Results.
    },
+
 
    "cmd_unix": [
+
=Terminal=
        "node",
 
        "path_to_server/server/out/node/cssServerMain.js",
 
        "--stdio"
 
    ]
 
}
 
</syntaxhighlight>
 
  
==LSP server for Nim==
+
There are currently 3 terminal plugins:
 +
* Terminal: simplest plugin.
 +
* Terminal Plus: most feature-rich plugin, but its UI may be too complex for beginners.
 +
* ExTerminal: middle in the feature set, but its UI is very simple.
  
Server from https://github.com/PMunch/nimlsp works good. Config "lsp_nim.json":
+
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:
  
<syntaxhighlight lang="json">
+
<syntaxhighlight lang="python">
{
+
x = int(input('Enter x: '))
    "name": "nim-lsp",
+
w = int(input('Enter w: '))
    "lexers": {
+
print(x*w)
        "Nim": "nim"
 
    },
 
    "cmd_unix": [
 
      "~/.nimble/bin/nimlsp"
 
    ]
 
}
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==LSP server for Rust==
+
Steps:
  
Q: I've successfully configured several language servers with this plugin, but rls ( https://github.com/rust-lang/rls ) seems to be unresponsive. Does this work for anyone else?
+
* Save our script to file ~/myfolder/tt.py
 +
* Install ExTerminal, restart CudaText
 +
* Run ExTerminal by clicking its bottom-bar-icon
 +
* 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.
 +
* In ExTerminal, enter "python3 tt.py"
  
A: Seems to be a rls issue: https://github.com/rust-lang/rls/issues/536 . A workaround is to comment out the line in <cudatext>/py/cuda_lsp/sansio_lsp_client/io_handler.py, replace this:
+
Script should work and show 2 input-prompts.
  
        "Content-Type": f"application/vscode-jsonrpc; charset={encoding}",
+
user@user:~/myfolder$ ls *.py
 +
a.py  test.py  tt.py
 +
user@user:~/myfolder$ python3 tt.py
 +
Enter x: 10
 +
Enter w: 20
 +
200
  
with this
+
How to open ExTerminal in the directory of the current editor file? You can do this:
  
        #"Content-Type": f"application/vscode-jsonrpc; charset={encoding}",
+
* Hover mouse over ExTerminal button in the bottom-bar. It must show tooltip like "ExTerminal 1".
 +
* 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.
 +
* To not produce too much ExTerminal buttons, use "Close terminal" from the popup menu.
  
==LSP server for AutoHotkey==
+
=Configure Menu=
  
* Download the repository of AutoHotkey2: https://github.com/thqby/vscode-autohotkey2-lsp
+
Plugin "Configure Menu" (in Addons Manager) allows to change CudaText menus.
* Extract and enter the directory: "vscode-autohotkey2-lsp-main"
+
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.
* Install dependencies and TypeScript. In Terminal:
+
Plugin can create file (settings/menu.json) with default menu configuration, which you edit to customize all menus. File has items like:
  
npm install
+
<syntaxhighlight lang="json">
npm install -g typescript
+
  ,{"cap":"&Save", "cmd":"cmd_FileSave"}
 +
</syntaxhighlight>
  
* Enter the directory "server", and compile the server. In Terminal:
+
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.
  
npx tsc
+
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:
  
Server should be compiled now. To use the server in LSP Client, create the file "lsp_ahk.json" in the "settings" with such content:
 
 
<syntaxhighlight lang="json">
 
<syntaxhighlight lang="json">
{
+
  ,{"cap":"Toggle line comment", "cmd":"module=cuda_comments;cmd=cmt_toggle_line_body;"}
    "name": "AutoHotkey2",
 
    "lexers": {
 
        "AutoHotkey": "ahk"
 
    },
 
    "cmd_unix": [
 
        "node",
 
        "path_to_server/server/out/server.js",
 
        "--stdio"
 
    ]
 
}
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==LSP server for JavaScript/ReactJS==
+
Here "cuda_comments" is plugin folder name, and "cmt_toggle_line_body" is Python method from install.inf.
  
* In "Addons Manager", install the lexer for ReactJS: "JavaScript Babel".
+
You can add items to the CudaText top-menu and/or context-menu, it is different sections in "menu.json".
* Install TypeScript and the LSP server. In Terminal:
+
Possible root sections in "menu.json" are listed in the API wiki page: [[CudaText_API#menu_proc_-_Menu_id]].
 +
 
 +
Example screenshot shows how "menu.json" will look with new items for context-menu:
 +
 
 +
[[File:cudatext-editing-context-menu.png]]
  
npm install -g typescript typescript-language-server
+
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:
  
To use the server in LSP Client, create a file "lsp_js.json" in the "settings" directory with such content:
 
 
<syntaxhighlight lang="json">
 
<syntaxhighlight lang="json">
{
+
    {"cap": "SomeToolName", "cmd": "module=cuda_exttools;cmd=run;info=174420;"}
    "name": "JavaScript",
+
  ,{"cap": "SomeMacroName", "cmd": "module=cuda_macros;cmd=run;info=87635;"}
    "lexers": {
 
        "JavaScript": "javascript",
 
        "JavaScript Babel": "javascriptreact"
 
    },
 
    "cmd_unix": [
 
        "typescript-language-server",
 
        "--stdio"
 
    ]
 
}
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==LSP servers for C/C++==
+
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":
  
Install one of the servers following the instructions:
 
* clangd: https://clangd.llvm.org/installation.html
 
* ccls: https://github.com/MaskRay/ccls/wiki/Build + https://github.com/MaskRay/ccls/wiki/Install
 
 
To use the server in LSP Client, create a file "lsp_c.json" in the "settings" directory with such content:
 
 
<syntaxhighlight lang="json">
 
<syntaxhighlight lang="json">
 
{
 
{
  "lexers": {
+
    "ver": "20151209",
     "C++": "cpp",
+
     "list": [
    "C": "c"
+
        {
  },
+
            "id": 254653,
  "cmd_unix": [
+
            "nm": "C - compile",
      "clangd-9",
+
            "file": "gcc",
  ],
+
            "ddir": "{FileDir}",
}
+
            "shll": false,
</syntaxhighlight>
+
            "prms": "\"{FileNameOnly}\" -o \"{FileNameNoExt}\"",
 +
            "savs": "N",
 +
            "rslt": "OP",
 +
            "encd": "utf_8",
 +
            "lxrs": "C,C++",
 +
            "pttn": "(?P<file>[\\w\\.\\-]+):(?P<line>\\d+):(?P<col>\\d+):.+",
 +
        },
 +
</syntaxhighlight>
 +
 
 +
=Config Toolbar=
 +
 
 +
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.
 +
 
 +
For example, you installed two plugins:
 +
* Config Toolbar
 +
* Color Text
 +
 
 +
And you want to call command "Apply bold" (from "Color Text") via toolbar. How to add such a button? Picture highlights your steps.
 +
 
 +
[[File:cudatext-config-toolbar.png]]
 +
 
 +
* From the Command Palette, call the item "Config Toolbar: Configure buttons...". Dialog will appear from the plugin.
 +
* In the "Configure toolbar" dialog, press "Add item...", and fill fields of new dialog "Button properties".
 +
** Caption
 +
** Tooltip (optional)
 +
** 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.
 +
** Icon (optional)
  
Replace "clangd-9" with "ccls" if it was chosen.
+
=Intext Bookmarks=
  
==LSP server for Red==
+
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.
  
1) On Linux x64.
+
Plugin adds menu items in "Plugins / In-text Bookmarks":
  
* 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.
+
* List for current tab -- show all marks in the current document
* Install server from https://github.com/bitbegin/redlangserver, put the repo e.g. to ~/redlangserver.
+
* List for all tabs -- show all marks in all opened UI-tabs
* Create file "redlangserver.sh" and put it to some PATH dir. Content:
+
* Go to next
 +
* Go to previous
 +
* Add -- add a new mark at caret position
  
<syntaxhighlight lang="bash">
+
"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".
#!/bin/bash
+
 
red ~/redlangserver/server.red
+
You can customize that special lines, using plugin configuration dialog: menu item "Options / Settings-plugins / In-text Bookmarks". Dialog gives such options:
</syntaxhighlight>
+
 
 
+
* Bookmark signs: NOTE: NB! TODO: todo: todo. FIX:
* Create file (CudaText)/settings/lsp_red.json with content:
+
* Comment sign: //
 
+
 
<syntaxhighlight lang="json">
+
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.
   "lexers": {
+
 
     "Red": "red"
+
=Color Text=
   },
+
 
   "cmd_unix": ["redlangserver.sh"],
+
Plugin "Color Text" gives several commands (in the Plugins menu) to add coloring to text ranges.
   "cmd_windows": ["c:\\red\\red.exe", "--cli", "c:\\red\\redlangserver\\server.red"]
+
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.
 +
 
 +
[[File:cudatext-color-text.png]]
 +
 
 +
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.
 +
 
 +
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:
 +
 
 +
* "all_words": Colorize all occurrences of fragment.
 +
* "case_sensitive": Case sensitive search for other occurrences.
 +
* "whole_words": Colorize only those occurrences, which are whole words.
 +
* "show_on_map": Show added colored marks also on micro-map.
 +
 
 +
=Insert Pics=
 +
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:
 +
 
 +
[[File:cudatext-insert-pics.png]]
 +
 
 +
* You can use any lexer for files with pictures.
 +
* You can add the unlimited number of pictures. But only one picture per "gap".
 +
* You can add/delete pictures later, using plugin's commands in menu "Plugins / Insert Pics".
 +
* When you delete the "helper file" (located in the same folder), all pictures will be lost for plugin.
 +
 
 +
=Complete From Text=
 +
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.
 +
 
 +
[[File:cudatext-complete-from-text.png]]
 +
 
 +
In the picture above, one word was taken from C lexer's C.acp file (this is a feature).
 +
 
 +
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:
 +
 
 +
* Install the plugin
 +
* Call menu item "Options / Settings-plugins / Complete From Text"
 +
* This opens the "plugins.ini" file
 +
* Find section "[complete_from_text]", add ",c" (without quotes) to the line "lexers="
 +
* Restart CudaText
 +
 
 +
Plugin has more options in that "plugins.ini" file:
 +
 
 +
* 'lexers': comma-separated lexer names, ie for which lexers to work; specify none-lexer as '-'.
 +
* 'min_len': minimal word length, words of smaller length will be ignored.
 +
* 'max_lines': if document has bigger count of lines, ignore this document.   
 +
* 'case_sens': case-sensitive; words starting with 'A' will be ignored when you typed 'a'.
 +
* 'no_comments': ignore words inside "syntax comments" (lexer specific).
 +
* 'no_strings': ignore words inside "syntax strings" (lexer specific).
 +
* 'what_editors': which documents (ie UI tabs) to read to get words. Values:
 +
**    0: only current document.
 +
**    1: all opened documents.
 +
**    2: all opened documents with the same lexer.
 +
* 'use_acp': add suggestions from autocomplete files in 'data/autocomplete'
 +
* '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.
 +
* '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.
 +
 
 +
Plugin supports CudaText option "nonword_chars", so for example words with '$' char are also added to completions, if CudaText option is configured so.
 +
 
 +
=Embedded Editor=
 +
 
 +
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.
 +
 
 +
[[File:cudatext-embedded-editor.png]]
 +
 
 +
It adds menu item to show/hide embedded editor in the current document, for the
 +
current caret position: "Plugins / Embedded Editor / Toggle".
 +
 
 +
By default, plugin searches for the included filename inside double-quotes,
 +
surrounding the caret position. This works OK for HTML and many other documents.
 +
 
 +
For example, when you have opened file "/folder/file.html", and placed caret
 +
inside first double-quotes:
 +
<syntaxhighlight lang="html">
 +
  <link href="css/style.css" rel="stylesheet" type="text/css"/>
 +
</syntaxhighlight>
 +
then embedded editor will be opened for file "/folder/css/style.css".
 +
 
 +
The search can be configured, though. For example, plugin can be used in Pascal
 +
files for include-directives:
 +
<syntaxhighlight lang="pascal">
 +
  {$I path/filename.inc}
 +
</syntaxhighlight>
 +
 
 +
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.
 +
 
 +
=Breadcrumbs=
 +
 
 +
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:
 +
<pre>
 +
[ home / user / mydir / myfile.ext ]
 +
</pre>
 +
It can also show the "~" button for the home directory (by option):
 +
<pre>
 +
[ ~ / mydir / myfile.ext ]
 +
</pre>
 +
 
 +
[[File:cudatext-breadcrumbs.png]]
 +
 
 +
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.
 +
 
 +
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.
 +
 
 +
=LSP Client=
 +
 
 +
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).
 +
 
 +
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:
 +
 
 +
* Auto-completion: integrated with CudaText command "Auto-completion menu" (in the Command Palette).
 +
* Go to definition: integrated with CudaText command "Go to definition" (in the Command Palette, and in the editor context menu).
 +
* Function signature help: integrated with CudaText command "Show function hint" (in the Command Palette).
 +
* Hover: shows the tooltip when you hover mouse above identifiers. You need the Ctrl key pressed while you hover.
 +
 
 +
[[File:cudatext-lsp-hover_.png]]
 +
 
 +
* Find references: finds all locations where an identifier (under first caret) is used and shows menu with locations.
 +
 
 +
[[File:cudatext-lsp-refs.png]]
 +
 
 +
* 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.
 +
* Document formatting: formatting of the source code by LSP server. This feature is also implemented in [[#CudaFormatter]] and usually it works better/faster there.
 +
 
 +
All LSP servers should have a homepage with description of their functions, and installation information.
 +
 
 +
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".
 +
 
 +
<syntaxhighlight lang="json">
 +
{
 +
  "lexers": {
 +
    "C#": "csharp"
 +
  },
 +
  ...
 +
}
 +
</syntaxhighlight>
 +
 
 +
LSP Client also has the settings file, use menu item to open it: "Options / Settings-plugins / LSP Client".
 +
 
 +
==LSP server for Python==
 +
Project homepage is https://github.com/python-lsp/python-lsp-server .
 +
Note that this is fork of old, unmaintained, project "PyLS".
 +
Server supports:
 +
 
 +
* Auto-completion
 +
* Go to definition
 +
* Function signature help
 +
* Hover
 +
* Find references
 +
* Code linting
 +
* Document formatting
 +
 
 +
Use "pip" to install the server:
 +
 
 +
pip install python-lsp-server
 +
 +
This will expose the command "pylsp" on your PATH. Confirm that installation succeeded by running:
 +
 
 +
pylsp --help
 +
 +
Create the file "[CudaText]/settings/lsp_py.json" with text like this:
 +
 
 +
<syntaxhighlight lang="json">
 +
{
 +
  "lexers": {
 +
    "Python": "python"
 +
  },
 +
  "cmd_windows": ["pylsp.exe"],
 +
  "cmd_macos": ["pylsp"],
 +
  "cmd_unix": ["pylsp"]
 +
}
 +
</syntaxhighlight>
 +
 
 +
Open some Python script, and call some commands of LSP Client. It will run the server, and it should work.
 +
 
 +
==LSP server for Python, pyright==
 +
 
 +
1. Install the server:
 +
 
 +
pip install pyright
 +
 
 +
* On Windows, add folder of "pyright-langserver.exe" to system PATH.
 +
* On Linux/Unix, get the full path of the program, we will use this path in the next step.
 +
 
 +
which pyright-langserver
 +
 
 +
It outputs on Ubuntu:
 +
 
 +
/home/user/.local/bin/pyright-langserver
 +
 
 +
* 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:
 +
 
 +
/Applications/Python\ 3.10/Install\ Certificates.command
 +
 
 +
2. Create config (CudaText)/settings/lsp_pyright.json:
 +
 
 +
<syntaxhighlight lang="json">
 +
{
 +
  "lexers": {
 +
    "Python": "python"
 +
  },
 +
  "cmd_windows": ["pyright-langserver.exe", "--stdio"],
 +
  "cmd_unix": ["/home/user/.local/bin/pyright-langserver", "--stdio"],
 +
  "cmd_macos": ["/Library/Frameworks/Python.framework/Versions/3.10/bin/pyright-langserver", "--stdio"],
 +
  "log_stderr": true
 +
}
 +
</syntaxhighlight>
 +
 
 +
3. To disable type checking (which may be confusing), add key "settings" to the above config:
 +
 
 +
<syntaxhighlight lang="json">
 +
  "settings": {
 +
    "python.analysis": {
 +
      "typeCheckingMode": "off"
 +
    }
 +
  }
 +
</syntaxhighlight>
 +
 
 +
==LSP server for JavaScript/ReactJS==
 +
 
 +
* Install lexer for ReactJS: "JavaScript Babel", from "Addons Manager".
 +
* Install TypeScript and the LSP server. In Terminal:
 +
 
 +
npm install -g typescript typescript-language-server
 +
 
 +
* Create CudaText LSP config: file "settings/lsp_js.json" with such content:
 +
<syntaxhighlight lang="json">
 +
{
 +
    "name": "JavaScript",
 +
    "lexers": {
 +
        "JavaScript": "javascript",
 +
        "JavaScript Babel": "javascriptreact"
 +
    },
 +
    "cmd_unix": [
 +
        "typescript-language-server",
 +
        "--stdio"
 +
    ],
 +
    "cmd_windows": [
 +
        "typescript-language-server.cmd",
 +
        "--stdio"
 +
    ]
 +
}
 +
</syntaxhighlight>
 +
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.
 +
 
 +
==LSP server for TypeScript==
 +
 
 +
* Install TypeScript lexer from "Addons Manager".
 +
* Install TypeScript and the LSP server. In Terminal:
 +
 
 +
npm install -g typescript typescript-language-server
 +
 
 +
* Create CudaText LSP config: file "settings/lsp_ts.json" with such content:
 +
<syntaxhighlight lang="json">
 +
{
 +
  "lexers": {
 +
    "TypeScript": "ts"
 +
  },
 +
  "cmd_unix": [
 +
    "typescript-language-server",
 +
    "--stdio"
 +
  ],
 +
  "cmd_windows": [
 +
    "typescript-language-server.cmd",
 +
    "--stdio"
 +
  ]
 +
}
 +
</syntaxhighlight>
 +
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.
 +
 
 +
According to https://www.zeusedit.com/lsp/typescript.html, sometimes more complex config file may be needed.
 +
Here it is on Ubuntu:
 +
<syntaxhighlight lang="json">
 +
{
 +
  "lexers": {
 +
    "TypeScript": "ts"
 +
  },
 +
  "cmd_unix": [
 +
    "typescript-language-server",
 +
    "--stdio",
 +
    "--log-level=4",
 +
    "--tsserver-log-verbosity=verbose",
 +
    "--tsserver-path=/usr/local/lib/node_modules/typescript/lib/"
 +
  ],
 +
  "cmd_windows": [
 +
    "typescript-language-server.cmd",
 +
    "--stdio",
 +
    "--log-level=4",
 +
    "--tsserver-log-verbosity=verbose",
 +
    "--tsserver-path=\"%APPDATA%\\npm\\node_modules\\typescript\\lib\\\""
 +
  ]
 +
}
 +
</syntaxhighlight>
 +
 
 +
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".
 +
 
 +
Test the auto-completion on this "test.ts" file (with TypeScript lexer):
 +
 
 +
document.body.g
 +
 
 +
==LSP server for C/C++==
 +
 
 +
Install one of the servers following the instructions:
 +
* clangd: https://clangd.llvm.org/installation.html
 +
** 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.
 +
* ccls: https://github.com/MaskRay/ccls/wiki/Build + https://github.com/MaskRay/ccls/wiki/Install
 +
 
 +
To use the server in LSP Client, create a file "lsp_c.json" in the "settings" directory with such content:
 +
<syntaxhighlight lang="json">
 +
{
 +
  "lexers": {
 +
    "C++": "cpp",
 +
    "C": "c"
 +
  },
 +
  "cmd_unix": [
 +
      "clangd-12",
 +
  ],
 +
  "cmd_windows": [
 +
      "clangd",
 +
  ],
 +
}
 +
</syntaxhighlight>
 +
 
 +
Replace "clangd*" with "ccls" if it was chosen.
 +
 
 +
On Windows: you must add the "bin" directory of mingw64 to the PATH so clangd is in the PATH.
 +
 
 +
==LSP server for C#==
 +
 
 +
First, install C# lexer from "Addons Manager".
 +
 
 +
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.
 +
 
 +
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 .
 +
 
 +
3. Create LSP config file: (CudaText)/settings/lsp_cs.json:
 +
<syntaxhighlight lang="json">
 +
{
 +
  "lexers": {
 +
    "C#": "csharp"
 +
  },
 +
  "cmd_windows": [
 +
    "C:\\OmniSharp\\OmniSharp.exe", "-lsp", "-z"
 +
  ]
 +
}
 +
</syntaxhighlight>
 +
Note that backslashes must be doubled (because of JSON format).
 +
 
 +
4. To test that server works: create a file "test.cs" (with C# lexer active). Call auto-completion after "date.A".
 +
<syntaxhighlight lang="csharp">
 +
using System;
 +
 
 +
public class DateExample
 +
{
 +
public static void Main()
 +
{
 +
DateTime  date;
 +
date.A
 +
}
 +
}
 +
</syntaxhighlight>
 +
 
 +
==LSP server for CSS/SCSS/LESS==
 +
 
 +
The CSS (and SCSS, LESS) server is not easy to install, so here is the instruction, from the author of LSP Client:
 +
 
 +
* Download the repository of VSCode: https://github.com/microsoft/vscode
 +
* From the repository, get the folder "extensions/css-language-features/server" and enter in it.
 +
* Replace the file "tsconfig.json" with content:
 +
<syntaxhighlight lang="json">
 +
{
 +
    "compilerOptions": {
 +
    "target": "es2018",
 +
    "lib": [
 +
    "es2018"
 +
    ],
 +
    "module": "commonjs",
 +
    "strict": true,
 +
    "alwaysStrict": true,
 +
    "noImplicitAny": true,
 +
    "noImplicitReturns": true,
 +
    "noImplicitOverride": true,
 +
    "noUnusedLocals": true,
 +
    "noUnusedParameters": true,
 +
    "forceConsistentCasingInFileNames": true,
 +
   
 +
    "outDir": "./out"
 +
    },
 +
  "files": [
 +
      "src/node/cssServerMain.ts"
 +
  ]
 +
}
 +
</syntaxhighlight>
 +
 
 +
* Install dependencies and TypeScript. In Terminal:
 +
 
 +
npm install
 +
npm install -g typescript
 +
 
 +
* Compile it. In Terminal:
 +
 
 +
npx tsc
 +
 
 +
Server should be compiled.
 +
 
 +
Create config file (CudaText)/settings/lsp_css.json:
 +
<syntaxhighlight lang="json">
 +
{
 +
    "name": "vsc-css",
 +
    "lexers": {
 +
    "CSS": "css",
 +
    "SCSS": "scss",
 +
    "Sass": "sass",
 +
    "LESS": "less",
 +
    },
 +
    "cmd_unix": [
 +
        "node",
 +
        "path_to_server/server/out/node/cssServerMain.js",
 +
        "--stdio"
 +
    ]
 +
}
 +
</syntaxhighlight>
 +
 
 +
==LSP server for HTML==
 +
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:
 +
 
 +
npm install --global vscode-html-ls-bin
 +
 
 +
Make config file (CudaText)/settings/lsp_html.json:
 +
<syntaxhighlight lang="json">
 +
{
 +
    "lexers": {
 +
    "HTML": "html",
 +
    },
 +
    "cmd_windows": ["html-ls.cmd", "--stdio"],
 +
    "cmd_unix": ["html-ls", "--stdio"]
 +
}
 +
</syntaxhighlight>
 +
 
 +
Make sure the script "html-ls" ("html-ls.cmd" on Windows) is in the PATH.
 +
 
 +
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.
 +
 
 +
==LSP server for Java==
 +
'''Part 1. Information for Windows.'''
 +
 
 +
* Install lexer "Java" from Addons Manager.
 +
 
 +
* Install [https://www.oracle.com/java/technologies/downloads/#jdk19-windows Java SE Development Kit 19] or later. If you have usual Java (JRE) then better remove it first. Then run in Console:
 +
 
 +
java -version
 +
 
 +
It must show something like this:
 +
 
 +
java version "19.0.1" 2022-10-18
 +
Java(TM) SE Runtime Environment (build 19.0.1+10-21)
 +
Java HotSpot(TM) 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)
 +
 
 +
* Download package "jdt-language-server-1.9.0-2022*.tar.gz" from [https://download.eclipse.org/jdtls/milestones/?d Eclipse JDT Language Server milestone builds] and extract it to "C:\Java\jdt-language-server".
 +
 
 +
* Create "C:\Java\jLSP.cmd" batch file with the following contents (edit if necessary):
 +
<syntaxhighlight lang="batch">
 +
@echo off
 +
echo.
 +
echo Usage: jLSP.cmd CacheDir
 +
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.
 +
echo.
 +
 
 +
:: language server installation folder (adjust to suit)
 +
set Directory=C:/Java/jdt-language-server
 +
:: language server jar file (update based on version file of jar)
 +
set JarFile=%Directory%/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar
 +
:: language server config folder location
 +
set Config=%Directory%/config_win
 +
 
 +
set CacheDir=%~1
 +
echo Directory: %Directory%
 +
echo  JarFile: %JarFile%
 +
echo    Config: %Config%
 +
echo  CacheDir: %CacheDir%
 +
 
 +
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%
 +
</syntaxhighlight>
 +
 
 +
* Create LSP config file: (CudaText)/settings/lsp_java.json:
 +
<syntaxhighlight lang="json">
 +
{
 +
  "lexers": {
 +
    "Java": "java"
 +
  },
 +
  "cmd_windows": ["C:\\Java\\jLSP.cmd", "./cache_for_proj1"] 
 +
}
 +
</syntaxhighlight>
 +
 
 +
Use testing file "test.java". Place caret on last code line after "System.g" and call auto-completion.
 +
<syntaxhighlight lang="java">
 +
public class Example {
 +
public static void main(String[] args) {
 +
System.g
 +
}
 +
}
 +
</syntaxhighlight>
 +
 
 +
'''Part 2. Information for Linux.'''
 +
 
 +
* Install lexer "Java" from Addons Manager.
 +
 
 +
* Install "Java SE Development Kit" from [https://www.oracle.com/java/technologies/downloads/#jdk19-linux Oracle website] or from OS package manager. If you have usual Java (JRE) then better remove it first.
 +
 
 +
On Ubuntu this command works (2022 year):
 +
 
 +
sudo apt install openjdk-17-jre-headless
 +
 
 +
Then run in Console:
 +
 
 +
java -version
 +
 
 +
It must show something like this:
 +
 
 +
openjdk version "17.0.4" 2022-07-19
 +
OpenJDK Runtime Environment (build 17.0.4+8-Ubuntu-120.04)
 +
OpenJDK 64-Bit Server VM (build 17.0.4+8-Ubuntu-120.04, mixed mode, sharing)
 +
 
 +
* Download package "jdt-language-server-1.9.0-2022*.tar.gz" from [https://download.eclipse.org/jdtls/milestones/?d Eclipse JDT Language Server milestone builds] and extract it to "~\jdt-language-server".
 +
 
 +
* Create "~\jLSP.sh" shell script with the following contents, and make it executable:
 +
<syntaxhighlight lang="bash">
 +
#!/bin/bash
 +
echo
 +
echo Usage: jLSP.sh CacheDir
 +
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.
 +
echo
 +
 
 +
# language server installation folder (adjust to suit)
 +
Directory=~/jdt-language-server
 +
# language server jar file (update based on version file of jar)
 +
JarFile=$Directory/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar
 +
# language server config folder location
 +
Config=$Directory/config_linux
 +
 
 +
CacheDir=$1
 +
echo Directory: $Directory
 +
echo  JarFile: $JarFile
 +
echo    Config: $Config
 +
echo  CacheDir: $CacheDir
 +
 
 +
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
 +
</syntaxhighlight>
 +
 
 +
* Create LSP config file: (CudaText)/settings/lsp_java.json:
 +
<syntaxhighlight lang="json">
 +
{
 +
  "lexers": {
 +
    "Java": "java",
 +
  },
 +
  "cmd_unix": ["~/jLSP.sh", "./cache_for_proj1"],
 +
}
 +
</syntaxhighlight>
 +
 
 +
Use testing file "test.java". Place caret on last code line after "System.g" and call auto-completion.
 +
<syntaxhighlight lang="java">
 +
public class Example {
 +
public static void main(String[] args) {
 +
System.g
 +
}
 +
}
 +
</syntaxhighlight>
 +
 
 +
==LSP server for Nim==
 +
 
 +
Server from https://github.com/PMunch/nimlsp works good.
 +
 
 +
Config file (CudaText)/settings/lsp_nim.json:
 +
 
 +
<syntaxhighlight lang="json">
 +
{
 +
    "name": "nim-lsp",
 +
    "lexers": {
 +
        "Nim": "nim"
 +
    },
 +
    "cmd_unix": [
 +
      "~/.nimble/bin/nimlsp"
 +
    ]
 +
}
 +
</syntaxhighlight>
 +
 
 +
==LSP server for Rust==
 +
 
 +
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
 +
 
 +
Create config (CudaText)/settings/lsp_rust.json:
 +
 
 +
<syntaxhighlight lang="json">
 +
{
 +
  "lexers": {
 +
    "Rust": "rust"
 +
  },
 +
  "cmd_windows": ["rust-analyzer-x86_64-pc-windows-msvc.exe"],
 +
  "cmd_unix": ["rust-analyzer-x86_64-unknown-linux-gnu"]
 +
}
 +
</syntaxhighlight>
 +
 
 +
==LSP server for AutoHotkey==
 +
 
 +
* Download the repository of AutoHotkey2: https://github.com/thqby/vscode-autohotkey2-lsp
 +
* Extract and enter the directory: "vscode-autohotkey2-lsp-main"
 +
* Install dependencies and TypeScript. In Terminal:
 +
 
 +
npm install
 +
npm install -g typescript
 +
 
 +
* Enter the directory "server", and compile the server. In Terminal:
 +
 
 +
npx tsc
 +
 
 +
Server should be compiled now. To use the server in LSP Client, create the file "lsp_ahk.json" in the "settings" with such content:
 +
<syntaxhighlight lang="json">
 +
{
 +
    "name": "AutoHotkey2",
 +
    "lexers": {
 +
        "AutoHotkey": "ahk"
 +
    },
 +
    "cmd_unix": [
 +
        "node",
 +
        "path_to_server/server/out/server.js",
 +
        "--stdio"
 +
    ]
 +
}
 +
</syntaxhighlight>
 +
 
 +
==LSP server for Red==
 +
 
 +
1) On Linux x64.
 +
 
 +
* 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.
 +
* Install server from https://github.com/bitbegin/redlangserver, put the repo e.g. to ~/redlangserver.
 +
* Create file "redlangserver.sh" and put it to some PATH dir. Content:
 +
 
 +
<syntaxhighlight lang="bash">
 +
#!/bin/bash
 +
red ~/redlangserver/server.red
 +
</syntaxhighlight>
 +
 
 +
* Create file (CudaText)/settings/lsp_red.json with content:
 +
 
 +
<syntaxhighlight lang="json">
 +
{
 +
   "lexers": {
 +
     "Red": "red"
 +
   },
 +
   "cmd_unix": ["redlangserver.sh"],
 +
   "cmd_windows": ["c:\\red\\red.exe", "--cli", "c:\\red\\redlangserver\\server.red"]
 +
}
 +
</syntaxhighlight>
 +
 
 +
Server should work now. It gives: mouse hover tooltips (Ctrl + mouse hovering over names), go to definition.
 +
 
 +
2) On Windows 10 x64.
 +
 
 +
* Install Red to "c:\Red". Tested the build from 02-Oct-2021.
 +
* Install server from https://github.com/bitbegin/redlangserver, put the repo to "c:\Red\redlangserver".
 +
* Run once the command "c:\red\red.exe --cli", it will print "Compiling Red console..." with the big pause.
 +
* Create file (CudaText)\settings\lsp_red.json with the same content as for Unix. Adjust path to Red folder, if needed.
 +
 
 +
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).
 +
 
 +
Note: don't create .bat or .cmd file with the "red.exe" calling, because it does not work in LSP Client for some reason.
 +
 
 +
==LSP server for PHP==
 +
 
 +
1. Install PHP, Composer. PHP versions 7.4.3 and 8.1 are OK.
 +
 
 +
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".
 +
 
 +
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.
 +
 
 +
4. Create LSP config (CudaText)/settings/lsp_php.json:
 +
 
 +
<syntaxhighlight lang="json">
 +
{
 +
    "name": "PHP",
 +
    "lexers": {
 +
        "PHP": "php"
 +
    },
 +
    "tcp_port": 12345,
 +
    "cmd_unix": [
 +
      "php",
 +
      "folder_of_server/bin/php-language-server.php",
 +
      "--tcp-server=127.0.0.1:12345"
 +
    ],
 +
    "cmd_windows": [
 +
      "php",
 +
      "D:\\programm\\php\\php-language-server\\bin\\php-language-server.php",
 +
      "--tcp-server=127.0.0.1:12345"
 +
    ]
 +
}
 +
</syntaxhighlight>
 +
 
 +
Server should work now. It gives these features: https://github.com/zobo/php-language-server#features .
 +
 
 +
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.
 +
 
 +
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.
 +
 
 +
==LSP server for Bash==
 +
 
 +
* Install Node.js, see readme here: https://github.com/nodesource/distributions/blob/master/README.md
 +
* Install Bash server, see readme here: https://github.com/bash-lsp/bash-language-server
 +
* Install Shellcheck from https://www.shellcheck.net/ - "We strongly recommend that you install shellcheck to enable linting"
 +
* On Windows, maybe you need to add folder of "bash-language-server.cmd" to system PATH.
 +
* Create file (CudaText)/settings/lsp_bash.json with content:
 +
 
 +
<syntaxhighlight lang="json">
 +
{
 +
    "lexers": {
 +
        "Bash script": "bash"
 +
    },
 +
    "cmd_windows": ["bash-language-server.cmd", "start"],   
 +
    "cmd_unix": ["bash-language-server", "start"]
 +
}
 +
</syntaxhighlight>
 +
 
 +
==LSP server for D==
 +
 
 +
First, install D lexer from "Addons Manager".
 +
 
 +
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.
 +
 
 +
2. Install the LSP server, run from console:
 +
 
 +
dub fetch dls
 +
 
 +
This must show output like
 +
 
 +
C:\D>dub fetch dls
 +
Fetching dls 0.26.2...
 +
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.
 +
 
 +
3. Compile the LSP server, run from console:
 +
 
 +
dub run dls:bootstrap
 +
 
 +
This must show output like
 +
 
 +
C:\D>dub run dls:bootstrap
 +
Building package dls:bootstrap in C:\Users\user\AppData\Local\dub\packages\dls-0.26.2\dls\bootstrap\
 +
Running pre-generate commands for dls:i18n...
 +
Performing "debug" build using C:\D\dmd2\windows\bin64\dmd.exe for x86_64.
 +
dls:protocol 0.26.2: building configuration "library"...
 +
dls:i18n 0.26.2: building configuration "library"...
 +
dls:bootstrap 0.26.2: building configuration "application"...
 +
Linking...
 +
Running ../Users/user/AppData/Local/dub/packages/dls-0.26.2/dls/bootstrap/dls_bootstrap.exe
 +
C:\Users\user\AppData\Local\dub\packages\.bin\dls-latest\dls.exe
 +
 
 +
Copy to clipboard the last printed filename with dls.exe.
 +
 
 +
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).
 +
<syntaxhighlight lang="json">
 +
{
 +
  "lexers": {
 +
    "D": "dlang"
 +
  },
 +
  "cmd_windows": [
 +
    "C:\\Users\\user\\AppData\\Local\\dub\\packages\\.bin\\dls-latest\\dls.exe", "--stdio"
 +
  ]
 +
}
 +
</syntaxhighlight>
 +
 
 +
5. Create test file "test.d" (with lexer D). Test that auto-completion works after "b.":
 +
<syntaxhighlight lang="d">
 +
class A {int a; int a2;}
 +
class B: A {int a3;}
 +
 
 +
void foo(B b)
 +
{
 +
b.
 +
}
 +
</syntaxhighlight>
 +
 
 +
==LSP server for Go==
 +
 
 +
Install lexer Go from "Addons Manager".
 +
 
 +
1. Install Go. Make sure that Go binary is in the system PATH, and GOPATH variable is also set.
 +
 
 +
2. Install the LSP server:
 +
 
 +
go install golang.org/x/tools/gopls@latest
 +
 
 +
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:
 +
 
 +
gopls version
 +
 
 +
It must give output like:
 +
 
 +
golang.org/x/tools/gopls v0.9.5
 +
    golang.org/x/tools/gopls@v0.9.5 h1:F3TO5th6TUg40FHrpxZfMkMlVaaTmByeEvylgVHGH2A=
 +
 
 +
3. Create CudaText LSP config (CudaText)/settings/lsp_go.json:
 +
<syntaxhighlight lang="json">
 +
{
 +
  "lexers": {
 +
    "Go": "go"
 +
  },
 +
  "cmd_unix": [
 +
    "gopls"
 +
  ],
 +
  "cmd_windows": [
 +
    "gopls.exe"
 +
  ]
 +
}
 +
</syntaxhighlight>
 +
 
 +
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":
 +
<syntaxhighlight lang="go">
 +
package aa
 +
import ("fmt")
 +
 
 +
func main() {
 +
  fmt.F
 +
}
 +
</syntaxhighlight>
 +
 
 +
==LSP server for Lua==
 +
 
 +
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).
 +
 
 +
2. Create LSP config (CudaText)/settings/lsp_lua.json:
 +
<syntaxhighlight lang="json">
 +
{
 +
  "lexers": {
 +
    "Lua": "lua"
 +
  },
 +
  "log_stderr": true,
 +
  "cmd_windows": ["D:\\Programs\\lua-lsp\\bin\\lua-language-server.exe"],
 +
  "cmd_unix": ["/path/to/lua-language-server"]
 +
}
 +
</syntaxhighlight>
 +
 
 +
==LSP server for Scala==
 +
 
 +
Install lexer "Scala" from Addons Manager.
 +
Information for Windows.
 +
 
 +
1. Install Coursier: https://get-coursier.io/docs/cli-installation
 +
 
 +
2. Install Metals. Make sure "metals.bat" is in the system PATH.
 +
 
 +
cs install metals
 +
 
 +
3. Create LSP config file (CudaText)/settings/lsp_scala.json:
 +
<syntaxhighlight lang="json">
 +
{
 +
  "lexers": {
 +
    "Scala": "scala"
 +
  },
 +
  "cmd_windows": ["metals.bat"]
 +
}
 +
</syntaxhighlight>
 +
 
 +
Testing file for auto-completion:
 +
 
 +
object Hello extends App {
 +
    println("Hello, world")
 +
}
 +
 
 +
==LSP server for Fortran==
 +
 
 +
Install lexer "Fortran" from Addons Manager.
 +
Steps show how to use server on Linux (Ubuntu 20.04) with Python 3 installed.
 +
 
 +
1. Install the LSP server:
 +
 
 +
pip install fortran-language-server
 +
 
 +
Check that command runs OK:
 +
 
 +
fortls -?
 +
 
 +
And check its full path:
 +
 
 +
which fortls
 +
 
 +
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.
 +
 
 +
2. Create LSP config file: (CudaText)/settings/lsp_fortran.json:
 +
<syntaxhighlight lang="json">
 +
{
 +
  "lexers": {
 +
    "Fortran": "fortran"
 +
  },
 +
  "cmd_unix": [
 +
      "/home/user/.local/bin/fortls"
 +
  ]
 +
}
 +
</syntaxhighlight>
 +
 
 +
3. Make test file "test.for" (with Fortran lexer). Test auto-completion after "CALL myv".
 +
<syntaxhighlight lang="fortran">
 +
PROGRAM myprog
 +
USE test_free, ONLY: scaled_vector
 +
TYPE(scaled_vector) :: myvec
 +
CALL myv
 +
END PROGRAM
 +
</syntaxhighlight>
 +
 
 +
==LSP server for Markdown==
 +
 
 +
1. Get precompiled Marksman LSP server from GitHub: https://github.com/artempyanykh/marksman/releases
 +
 
 +
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.
 +
 
 +
chmod +x marksman-linux
 +
 
 +
3. Create config file (CudaText)/settings/lsp_md.json:
 +
<syntaxhighlight lang="json">
 +
{
 +
  "lexers": {
 +
    "Markdown": "markdown"
 +
  },
 +
  "cmd_windows": ["marksman.exe"],
 +
  "cmd_unix": ["marksman-linux"]
 +
}
 +
</syntaxhighlight>
 +
 
 +
Now auto-completion / goto-definition / hover-tooltip must work on this "test.md" file:
 +
<syntaxhighlight lang="md">
 +
[reference][abcd]
 +
[reference][a123]
 +
 
 +
Some text.
 +
 
 +
[abcd]: url "title"
 +
[a123]: url "title2"
 +
</syntaxhighlight>
 +
 
 +
==LSP server for V==
 +
 
 +
* Install V lexer (from "Addons Manager / Plugins / Install")
 +
* Install V language
 +
* Install v-analyzer binary from https://github.com/v-analyzer/v-analyzer to a folder (that is included in PATH)
 +
* Create "lsp_v.json" in CudaText's "settings" folder with the following content:
 +
<syntaxhighlight lang="json">
 +
{
 +
  "lexers": {
 +
    "V": "v"
 +
  },
 +
  "cmd_windows": ["v-analyzer.exe"],
 +
  "cmd_unix": ["v-analyzer"],
 +
  "cmd_macos": ["v-analyzer"]
 +
}
 +
</syntaxhighlight>
 +
 
 +
==LSP server Vale==
 +
Steps for Windows OS.
 +
 
 +
* Install Vale server. Add path of "vale-ls.exe" to system PATH.
 +
* Create "lsp_vale.json" in CudaText's "settings" folder. Specify empty lexer name.
 +
<syntaxhighlight lang="json">
 +
{
 +
    "lexers": {
 +
        "": ""
 +
    },
 +
   
 +
    "cmd_windows": ["vale-ls.exe"],
 +
    "log_stderr": true,
 +
    "settings": {
 +
        "configPath": ""
 +
    }
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Server should work now. It gives: mouse hover tooltips (Ctrl + mouse hovering over names), go to definition.
+
* You need to put config file to %UserProfile% folder. For example: "C:\Users\john\.vale.ini".
 
+
* Do not forget to run: "vale sync".
2) On Windows 10 x64.
+
* Vale server did not support filenames with spaces on Windows OS. To fix it, update Vale to 0.3.7 or newer.
 
 
* Install Red to "c:\Red". Tested the build from 02-Oct-2021.
 
* Install server from https://github.com/bitbegin/redlangserver, put the repo to "c:\Red\redlangserver".
 
* Run once the command "c:\red\red.exe --cli", it will print "Compiling Red console..." with the big pause.
 
* Create file (CudaText)\settings\lsp_red.json with the same content as for Unix. Adjust path to Red folder, if needed.
 
 
 
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).
 
 
 
Note: don't create .bat or .cmd file with the "red.exe" calling, because it does not work in LSP Client for some reason.  
 
  
 
[[Category:CudaText]]
 
[[Category:CudaText]]

Latest revision as of 18:19, 26 January 2024

Comments

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).

  • Line comments: from some position to the nearest end-of-line. E.g. in C lexer: "//text here", in Python lexer: "# text here".
  • 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 */".
  • Comments for full lines: from newline to another newline, ie comment for several whole lines. Rarely used, e.g. used in PowerShell.

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.

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.

Command "Toggle stream comment" in plugin adds/removes comments of last 2 types: for range, for full lines (plugin chooses needed kind).

Where comment chars are stored:

  • Line comments: in lexer file data/lexlib/*.lcf.
  • Range comments: in additional file data/lexlib/*.cuda-lexmap.

Commenting options

Plugin "Comments" has several options, and it gives the dialog to change them: menu item "Options / Settings-plugins / Comments / Config".

(Line commands) Try to keep text position after (un)commenting

Affects all commands for line-comments.

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:

    code();

will be changed to line with 2 leading spaces:

  //code();

After uncommenting, line will be restored to original, with 4 leading spaces.

(Line "at non-space") If selected few lines, insert comment at maximal common indent

Affects commands:

  • "Toggle line comment, at non-space char"
  • "Add line comment, at non-space char"

With option on, this selected block of lines in C++:

      code1();
    code2();
        code3();

will be changed to:

    //  code1();
    //code2();
    //    code3();

With option off, block will be changed to:

      //code1();
    //code2();
        //code3();

(All) Move caret to next line

Affects commands for line-comments, when they are called without selection.

With option on, caret will be moved 1 line down. This allows to call the command many times repeatedly, to change many lines.

(Line commands) Skip blank lines

Affects commands for line-comments, when they are called without selection.

With option on, and the previous option "Move caret to next line" on, command will skip lines containing only space/tab chars.

"Toggle line comment" detects action by first non-blank line

Affects command "Toggle line comment".

With option on, command detects its action (to comment or to uncomment) by the first non-blank line of the selected multi-line block.

Here is selected block of code, selection is shown by square brackets, first selected line is blank line:

[
 
    //code1();
    code2();
    //code3();
    code4();
]

With option off, block will be changed it to:

[//
//
    //code1();
    //code2();
    //code3();
    //code4();
]

With option on, block will be changed to:

[
 
    code1();
    code2();
    code3();
    code4();
]

Macros

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:

  • Macros...
  • Start/stop recording
  • Playback last recorded macro
  • Export...
  • Import...
  • items for saved macros

cudatext-macro-menu.png

To record a macro:

  • Call menu item "Macros / Start/stop recording", or use dialog "Macros / Macros..." which gives the button for this.
  • Perform some actions in CudaText:
    • built-in commands, plugin commands (invoked by hotkey, by menu, by Command Palette)
    • some mouse actions (clicks/selections, they save/playback relative to caret position)
    • calling of Find/Replace dialog, "Go to" dialog
    • actions in Find/Replace dialog
  • Call menu item "Macros / Start/stop recording" again, plugin will ask for macro name.

During recording, CudaText shows reddish border around the editor field.

cudatext-macro-border.png

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.

To playback macro:

  • Call menu item "Macros / macro_name", the end of this menu lists all available/saved macros.
  • Or call dialog "Macros / Macros...", which allows to run all available macros:
    • running 1 time
    • running specified count of times
    • running in the loop, by options:
      • While text changes
      • Until caret on last line

Macro example

For example, we have text line with HTML tags like this ("|" shows the caret):

....<tag>....|...........</tag>....

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".

So, during macro recording, run these commands:

  • call Find dialog (or focus it with mouse), search for ">" with "Find previous" button
  • right-arrow key (to reset the selection)
  • "markers: drop marker at caret"
  • call Find dialog again (or focus it with mouse), search for "<" with "Find next" button
  • left-arrow key, 2 times (to reset the selection)
  • "markers: select to last marker"
  • "markers: remove all"

Project Manager

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.

Plugin has context menu on its panel, with items:

  • Project file
    • New project
    • Open project
    • Recent projects
    • Save project as...
    • Go to file... - this shows menu with all project files, and then tree-view selection jumps on selected file
    • Project properties... - this shows dialog with current project's options
    • Config... - this shows dialog with global Project Manager options
  • Root nodes - commands for nodes on the project's root level
    • Add folder...
    • Add file...
    • Clear project
    • Remove node
  • Selected file - it's shown only for files
  • Selected directory - it's shown only for folders
  • Refresh - it re-reads state of files/folders from disk

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:

cudatext-project-seldir.png

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.

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.

Project Manager options dialog

"Ignore files"
";"-separated shell wildcards, which are documented here. If file name (without path) matches any of these wildcards, it will not be listed in the treeview.
"Ignore folders"
";"-separated shell wildcards. If folder name matches any of these wildcards, it will not be listed in the treeview.
"Ignore all hidden files/folders"
Additionally don't list all hidden items. On Unix, hidden mean "beginning with dot". On Windows, hidden means having file-system "hidden" attribute.
"Open file after "Go to file" command"
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.
"Use 'preview tab' on item clicking"
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.
"Open files by double-click"
If turned on, only double-click in the treeview will open file for editing, but not the single click.
"On opening file in Git/SVN repo..."
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.
"Suggest to close tabs not belonging to project"
See #Sessions embedded to project.

And options for icons:

"File type icons"
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".
"Toolbar icons"
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".

Preview tab

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.

"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.

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.

"Preview tab" can be dragged to another tab-group, it should work there too.

Switch between projects

1) To switch to different project, Plugin Manager gives the context menu: "Project File / Recent projects / name.cuda-proj".

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.

3) There is also a way to quickly switch between projects:

  • Install plugins: "Config Toolbar", "External Tools" and "Session Manager". Restart CudaText.
  • Set CudaText option "ui_one_instance": true.
  • 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).
  • Add more such tools in the "External Tools", for different projects (and maybe sessions).

cudatext-tools-and-projects.png

  • 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.

cudatext-tools-and-projects-config.png

4)

  • Install plugin "Config Toolbar" (only 1 plugin here, comparing to the previous method).
  • CudaText option "ui_one_instance" can be any.
  • 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.
  • CudaText will use the new command-line which you entered after "exec=".

Sessions embedded to project

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}".

To control sessions, use the "gear" button on the Project Manager toolbar. Several menu items are there:

  • "Project session: name". One or more menu items, one item per each session.
  • "Save session...". Shows text input prompt, to name a session (you will be warned if you use incorrect characters or session already exists).
  • "Delete session". Shows menu to choose which session to delete from the project.
  • "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.
  • "Forget session, close all tabs".

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:

CudaText has opened 3 tab(s) not belonging to the project "name". Close them?
/path/to/file1
/path2/to/file2
*Untitled1

You will see this confirmation when doing:

  • "New project" action (from Project Manager context menu, or from Command Palette)
  • "Save session..." action (from "gear" popup menu, or from Command Palette)

You can disable that option (or press "Cancel" in the confirmation), to save even "not belonging" opened files to embedded session.

How to bind a hotkey to insert a snippet

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.

Let's show how to make a primitive plugin which has 2 primitive commands:

  • Insert snippet "AA" at the caret position (supporting multi-carets).
  • Surround current line with square brackets.

Make a new plugin by calling menu item "Plugins / Make Plugin". Fieds of dialog:

  • "Plugin name": set to "My plugin".
  • "Python module name": set to "my_snippet".
  • "Commands caption>method": set 2 lines:
My snippet>my_snippet
My edit>my_edit

This will generate new plugin with 2 methods in the file "__init__.py": my_snippet and my_edit. Code will be like this:

    def my_snippet(self):
        #
        #
        #
        msg_box(s, MB_OK)
     
    def my_edit(self):
        pass

At the top of the Python file, near "import" operators, add:

import cudatext_cmd as cmds

Now edit methods my_snippet / my_edit:

    def my_snippet(self):
        ''' Insert my snippet '''
        ed.cmd(cmds.cCommand_TextInsert, 'AA')
     
    def my_edit(self):
        ''' Surround line with brackets '''
        x, y, x1, y1 = ed.get_carets()[0]
        s = ed.get_text_line(y)
        s = '[' + s + ']'
        ed.set_text_line(y, s)
        msg_status('Edited!')

All done. Restart CudaText. You must have new menu items:

  • "Plugins / My plugin / My snippet"
  • "Plugins / My plugin / My edit"

In the Command Palette, find these new commands, press F9 to set hotkey for them.

Snippets

To use snippets you need:

  • Plugin "Snippets" (install from Addon Manager)
  • Snippet package for needed lexer (install from Addon Manager)

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...".

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.

Dialog of Snippets plugin:

cudatext snippets menu.png

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#Markers.

Plugin supports two snippets folder, but formats of data are the same, VSCode JSON format:

  • CudaText snippets. These are packages with prefix "snippets_ct" in the Addons Manager. They are installed into folder CudaText/data/snippets_ct.
  • 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.

Snippets from VSCode

Since recent versions, Snippets plugin supports snippets from VSCode editor. It gives menu items in "Plugins / Snippets":

  • "Install VSCode snippets..." - this suggests to install packages with snippets (packages usually contain more functionality, and CudaText plugin will install only snippets).

cudatext-snippets-add-vscode.png

  • "Remove VSCode snippets"
  • "Visit homepage of VSCode snippets..."
  • "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.

Plugin also gives the fully featured snippet editor dialog, in menu item "Add/edit snippets...".

cudatext-snippets-editor.png

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.

Currently most of VSCode/TextMate "macros" are supported in snippets body, but not all. Refer to readme file of the plugin.

Snippets for HTML tags

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:

 <a href="http" title="Title" target="_blank"></a>

These snippets have markers, so Tab key jumps to the next marker. Last marker is usually placed after the entire tag, ie after ">" bracket.

Format of snippet files

Snippets tab-stops

Specify tab-stops in the snippet text like this:

  • ${NN}
  • ${NN:default text}

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.

  • Markers can be listed in any order (e.g. marker 4 can be between 1 and 2).
  • Tab-key first goes to marker 1, 2, 3... and marker 0 is always the last.
  • Markers with the same indexes will place multi-carets.
  • Nested markers (with default text) are allowed, but only with one nesting level, e.g. ${2:text is {$3:here}}.
  • Marker with default text ${NN:...} can specify multi-line default text (character "}" is on another line of snippet).

Snippets macros

Special macros are handled by Snippets plugin in snippet text:

  • ${sel} - Text selected before snippet insertion (if snippet called with Tab key, it's empty string)
  • ${cp} - Current clipboard contents
  • ${cmt_start} - Current lexer's "block comment" start symbols (or empty string)
  • ${cmt_end} - Current lexer's "block comment" end symbols (or empty string)
  • ${cmt_line} - Current lexer's "line comment" symbols (or empty string)
  • ${fname} - File name only, without path
  • ${fpath} - Full file name, with path
  • ${fdir} - Directory of file
  • ${fext} - Extension of file
  • ${psep} - OS path separator: backslash on Windows, slash on Unix
  • ${date:nnnn} - Current date/time formatted by string "nnnn"; see Python docs
  • ${env:nnnn} - Value of OS environment variable "nnnn"
  • ${cmd:nnnn} - Execute shell command "nnnn" and get its output (space-separated arguments are supported, '~' for home-directory is supported on Unix)

The following macros from Sublime Text editor are supported. They can be written as $NAME or as ${NAME}.

  • $TM_SELECTED_TEXT - The currently selected text or the empty string
  • $TM_CURRENT_LINE - The contents of the current line
  • $TM_CURRENT_WORD - The contents of the word under cursor or the empty string
  • $TM_LINE_INDEX - The zero-based line number
  • $TM_LINE_NUMBER - The one-based line number
  • $TM_FILEPATH - The full file path of the current document
  • $TM_DIRECTORY - The directory of the current document
  • $TM_FILENAME - The filename of the current document
  • $TM_FILENAME_BASE - The filename of the current document without its extensions
  • $CLIPBOARD - The contents of your clipboard
  • $WORKSPACE_NAME - The name of the opened workspace or folder
  • $BLOCK_COMMENT_START - Current lexer's "block comment" start symbols (or empty string)
  • $BLOCK_COMMENT_END - Current lexer's "block comment" end symbols (or empty string)
  • $LINE_COMMENT - Current lexer's "line comment" symbols (or empty string)

For inserting the current date and time:

  • $CURRENT_YEAR - The current year
  • $CURRENT_YEAR_SHORT - The current year's last two digits
  • $CURRENT_MONTH - The month as two digits (e.g. '02')
  • $CURRENT_MONTH_NAME - The full name of the month (e.g. 'July')
  • $CURRENT_MONTH_NAME_SHORT - The short name of the month (e.g. 'Jul')
  • $CURRENT_DATE - The day of the month
  • $CURRENT_DAY_NAME - The name of day (e.g. 'Monday')
  • $CURRENT_DAY_NAME_SHORT - The short name of the day (e.g. 'Mon')
  • $CURRENT_HOUR - The current hour in 24-hour clock format
  • $CURRENT_MINUTE - The current minute
  • $CURRENT_SECOND - The current second
  • $CURRENT_SECONDS_UNIX - The number of seconds since the Unix epoch

Snippet Panel

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).

Preinstalled folders:

  • Arrows
  • Currency symbols
  • Greek alphabet (lower)
  • Greek alphabet (upper)
  • HTML - Arrows
  • HTML - Color names
  • HTML - Color names+values
  • HTML - Letters
  • HTML - Math symbols
  • HTML - Special characters
  • Math symbols
  • Quote selection
  • Special characters

Plugin looks for its folders in two places:

  • Folder "clips" in the plugin folder.
  • Folder CudaText/data/clips, which is absent by default, for custom user folders.

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.

CudaLint

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:

  • JavaScript is supported with linter based on JSLint tool,
  • HTML is supported with linter based on HTML Tidy tool,
  • CSS is supported with linter based on CSSLint tool,
  • etc

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.

Linters - usage

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).

Linting can also be run by events:

  • after opening file
  • on saving file
  • after text is changed + pause passed

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".

Linters - Node.js

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.

  • Windows: "node.exe" must be in PATH, command "node -v" must work in console.
  • Linux: "nodejs" package must be installed, command "nodejs -v" must work in terminal.

Linters - authoring

To support more lexers, it's a good idea to port linter from SublimeLinter. To port a linter, most you need is:

  • 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.
  • 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.
  • 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.
  • If linter was using Node.js, take some code to run Node, from cuda_lint_csslint linter.

Linters - per project

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:

linter_css=csslint

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".

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.

Linters - method split_match

Linters have RegEx property in class, which must find named groups:

  • "line": Line index.
  • "col": Column index.
  • "error": If found then CudaLint will force "error" gutter icon.
  • "warning": If found then CudaLint will force "warning" gutter icon.
  • "message": Message text.

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.

Example from SublimeLinter's linter for "Luau":

class Luau(Linter):
    cmd = 'luau-analyze --formatter=gnu -'
    regex = r'^stdin:(?P<line>\d+)\.(?P<col>\d+)\-(?P<end_line>\d+)\.(?P<end_col>\d+): (?P<code>\w+): (?P<message>.+)'

Sometimes, finding "error"/"warning" named groups is hard, and class method "split_match" can help here. Example from SublimeLinter's linter for "Luau":

    def split_match(self, match):
        error = super().split_match(match)
        error['error_type'] = 'error' if error['code'].endswith('Error') else 'warning'
        return error

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:

    def split_match(self, match):
        matches, line, col, error, warning, message, near = super().split_match(match)
        is_error = matches.group('code').endswith('Error')
        error = is_error
        warning = not is_error
        return matches, line, col, error, warning, message, ''

CudaLint needs 7 tuple items in split_match() result:

  • matches: RegEx match object
  • line: Line index
  • col: Column index
  • error: Error state; if casted to True, line will have "error" icon (red)
  • warning: Warning state; if casted to True, line will have "warning" icon (yellow)
  • message: Message string
  • near: Ignored in CudaLint

Example from CudaLint linter for Java. We override method because javac lints all referenced files, and we only want errors from the linted file.

    def split_match(self, match):
        if match:
            if match.group('file') != self.filename:
                match = None
        return super().split_match(match)

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.

    def split_match(self, match):
        match, line, col, error, warning, message, near = super().split_match(match)
        if line is None:
            line = col = 0
        return match, line, col, error, warning, message, near

Example from CudaLint linter for AutoIt. Here we modify the message/error/warning.

    def split_match(self, match):
        split_match = super(AutoIt, self).split_match(match)
        match, line, col, error, warning, message, near = split_match
        message = '{} (Col {})'.format(message, col)

        if match and match.group('type') == 'error':
            error = 1
            message = 'Error: ' + message
        elif match and match.group('type') == 'warning':
            warning = 1
            message = 'Warning: ' + message

        return match, line, col, error, warning, message, ''

Example from CudaLint linter for JavaScript using ESLint. We override this method to silent warning by .eslintignore settings.

    def split_match(self, match):
        v1message = 'File ignored because of your .eslintignore file. Use --no-ignore to override.'
        v2message = 'File ignored because of a matching ignore pattern. Use --no-ignore to override.'

        match, line, col, error, warning, message, near = super().split_match(match)
        if message and (message == v1message or message == v2message):
            return match, None, None, None, None, '', None

        return match, line, col, error, warning, message, near

Example from CudaLint linter for PowerShell using PSScriptAnalyzer. We return the match with ` quotes transformed to '. We supress one message.

    def split_match(self, match):
        match, line, col, error, warning, message, near = super().split_match(match)

        if message == 'no PowerShell code found at all':
            match = None
        else:
            message = message.replace('`', '\'')

            # If the message contains a complaint about a function
            # and near looks like a function reference, remove the trailing
            # () so it can be found.
            if 'function \'' in message and near and near.endswith('()'):
                near = near[:-2]

        return match, line, col, error, warning, message, near

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.

    def split_match(self, match):
        if match:
            if match.group('file') != '-':
                match = None
        return super(Ruby,self).split_match(match)

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.

    def split_match(self, match):
        match, line, col, error, warning, message, near = super().split_match(match)
        if line is None and message:
            line = 0
            col = 0
        return match, line, col, error, warning, message, near

Example from CudaLint linter for Haskell. We override method to ignore errors reported in imported files.

    def split_match(self, match):
        match, line, col, error, warning, message, near = super().split_match(match)
        match_filename = os.path.basename(match.groupdict()['filename'])
        if not match_filename.startswith('_CudaLint_'):
            return None, None, None, None, None, '', None
        return match, line, col, error, warning, message, near

CudaFormatter

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.

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.

For example, how to format code in XML?

  • Use "Plugins / Addon Manager / Install" to install the CudaFormatter, and formatter(s) for XML. Restart CudaText.
  • Open XML file (normal or "lite" lexer XML must activate).
  • Use "Plugins / CudaFormatter / Formatter (menu)". This will show the menu of actions from appropriate formatter(s) for the XML (normal or "lite") lexer.

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.

CudaFormatter commands

Formatter (menu)
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.
Formatter per-lexer A...D
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".
Formatter cross-lexer 1...4
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.
Minify to separate file
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).
Configure on_save
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.
Configure per-lexer labels
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.
Configure formatter
For those formatters which have configuration file, command will suggest to open global config file (in the folder "settings" of CudaText).
Configure formatter (local)
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.

How to run formatter ESLint on saving

  • Install from Addons Manager: "CudaFormatter"
  • Install from Addons Manager: "formatter: JavaScript_JSON"

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?

  • Activate lexer JavaScript in the current document (can be empty).
  • Call menu item "Plugins / CudaFormatter / Configure on_save...".
  • 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.

cudatext-fmt-onsave.png

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.

How formatter can know filename

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:

from cuda_fmt import fmtconfig
fn = fmtconfig.ed_filename

External Tools

Introduction to External Tools

Plugin "External Tools" (ExtTools) can be installed from Addon Manager. It allows to run external programs, catch their output, and then it can:

  • Display this output in the Output or Console panel of CudaText.
  • Replace current editor selection with the output.
  • Copy this output to a new document.
  • Copy this output to Clipboard.
  • And more.

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.

cudatext-tools-menuitem.png

Some external tools configs are shown in the Wiki topics below. Enter these strings in the "Tool properties" dialog.

cudatext-tools-props.png

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.

cudatext-tools-mainlexertool.png

Notes:

  • 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.
  • 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".

Tool to compile by GCC

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++".

Properties:

  • Name: C - compile
  • File name: gcc
  • Shell command: unchecked
  • Parameters: "{FileNameOnly}" -o "{FileNameNoExt}"
  • Initial folder: {FileDir}
  • Lexers: C,C++
  • Capture output: Output panel
  • Encoding: utf_8

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".

  • Pattern: (?P<file>[^:]+):(?P<line>\d+):(?P<col>\d+): .+

Tool to run C program

Tool is for Linux, so "File name" don't have an extension. For Windows, change "File name" field to "{FileNameNoExt}.exe".

Tool will catch the program output in the Output panel, program text input will not work.

  • Name: C - run
  • File name: "./{FileNameNoExt}"
  • Shell command: checked
  • Parameters: (empty)
  • Initial folder: {FileDir}
  • Lexers: C,C++
  • Capture output: Output panel
  • Encoding: utf_8
  • Pattern: (empty)

Tool to run C program, on Windows, with input in terminal

Tool is for Windows, it allows to run compiled C/C++ program in new console window. Text input will work in this console.

Example C++ program:

#include <stdio.h>
int main ()
{
  int c;
  puts ("Enter text. Include a dot ('.') in a sentence to exit:");
  do {
    c=getchar();
    putchar (c);
  } while (c != '.');
  return 0;
}

Tool props:

  • Name: C - run
  • File name: cmd
  • Shell command: unchecked
  • Parameters: /K "{FileNameNoExt}.exe"
    • Alternative value: /C "{FileNameNoExt}.exe" && pause
  • Initial folder: {FileDir}
  • Lexers: C,C++
  • Capture output: Ignore
  • Encoding: utf_8
  • Pattern: (empty)

Tool to run C program, on Linux, with input in terminal

Tool is for Linux, it allows to run compiled C/C++ program in new terminal window. Text input will work in this terminal window.

Example C++ program:

#include <stdio.h>
int main ()
{
  int c;
  puts ("Enter text. Include a dot ('.') in a sentence to exit:");
  do {
    c=getchar();
    putchar (c);
  } while (c != '.');
  return 0;
}

Tool props:

  • Name: C - run
  • Variant for xterm:
    • File name: xterm
    • Parameters: -hold -e "./{FileNameNoExt}"
  • Variant for gnome-terminal:
    • File name: gnome-terminal
    • Parameters: -- bash -c "./{FileNameNoExt}; read -s -n1 -r -p 'Press any key... '; echo"
  • Shell command: unchecked
  • Initial folder: {FileDir}
  • Lexers: C,C++
  • Capture output: Ignore
  • Encoding: utf_8
  • Pattern: (empty)

Tool to compile+run C program

In the External Tools dialog, press Join button, to join 2 tools created in above steps. Properties of joined tool:

  • Name: C - make+run
  • Series: C - compile; C - run
  • Lexers: C,C++

Tool to run current Batch file

Tool properties:

  • Name: Run batch file
  • File name: cmd.exe
  • Shell command: unchecked
  • Parameters: /c "{FileName}"
  • Initial folder: {FileDir}
  • Lexers: Batch files
  • Capture output: Output panel
  • Encoding: the same as file's encoding: e.g. utf_8 or cp1251 (cp1251 is Russian ANSI codepage)

Tool to compile by Free Pascal

This tool is for Free Pascal 3.x on Linux x64.

Properties:

  • Name: FPC - compile
  • File name:
    • for FPC installed system-wide: fpc
    • for FPC installed via fpcupdeluxe: /home/user/fpcupdeluxe/fpcupdeluxe/fpc/bin/x86_64-linux/fpc.sh
  • Shell command: unchecked
  • Parameters: {FileNameOnly}
  • Initial folder: {FileDir}
  • Lexers: Pascal
  • Capture output: Output panel
  • Encoding: utf_8

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.

Tool to call file-compare utility

Tools, which call file-compare utility, to compare 2 files: active files in group-1 and group-2.

WinMerge, KDiff, Kompare

  • Name: Compare files in G1, G2
  • File name: (full name of executable file)
  • Shell command: unchecked
  • Parameters: "{FileName_g1}" "{FileName_g2}"
  • Initial folder: (empty)
  • Capture output: Ignore

Meld

  • Name: Compare files in G1, G2
  • File name: (full name of executable file)
  • Shell command: unchecked
  • Parameters: --newtab "{FileName_g1}" "{FileName_g2}"
  • Initial folder: (empty)
  • Capture output: Ignore

diff

  • Name: Compare files in G1, G2
  • File name: diff
  • Shell command: unchecked
  • Parameters: -Nau "{FileName_g1}" "{FileName_g2}"
  • Initial folder: (empty)
  • Capture output: Copy to new document

Tool to run Python scripts

  • Name: Python3
  • File name:
    • on Windows: full path to "python.exe"
    • on Unix: python3
  • Shell command:
    • on Windows: checked
    • on Unix: unchecked
  • Parameters: "{FileNameOnly}"
  • Initial folder: {FileDir}
  • Lexers: Python
  • Capture output: Output panel
  • Encoding: utf_8
  • Pattern: \s*File "(?P<file>.+)", line (?P<line>\d+)

Tool to preview HTML file in Chrome

  • Name: Preview in Chrome
  • File name:
    • on Windows: C:\Program Files\Google\Chrome\Application\chrome.exe
  • Shell command:
    • on Windows: unchecked
  • Parameters: "{FileName}"
  • Initial folder: (empty)
  • Lexers: HTML
  • Capture output: Ignore

Tool to open PHP documentation with given topic

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.

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.

Download PHP documentation in .chm format from PHP.net, google for "php_manual_en chm", it is 16M file.

Tool properties:

  • Name: PHP Help
  • File name: keyhh.exe
  • Shell command: unchecked
  • Parameters: -MyHelp -#klink {CurrentWord} "C:\Work\php_manual_en.chm"
  • Initial folder: (empty)
  • Lexers: PHP
  • Save before: Nothing
  • Capture output: Ignore

Tool to open AutoIt documentation with given topic

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.

With AutoIt installed, you also have .chm documentation, its path is usually "C:\Program Files (x86)\AutoIt3\AutoIt.chm".

Tool properties:

  • Name: AutoIt Help
  • File name: keyhh.exe
  • Shell command: unchecked
  • Parameters: -MyHelp -#klink {CurrentWord} "C:\Program Files (x86)\AutoIt3\AutoIt.chm"
  • Initial folder: (empty)
  • Lexers: AutoIt
  • Save before: Nothing
  • Capture output: Ignore

Tool to open .chm documentation for all lexers

See above example about tool for PHP documentation. Create the similar tool

  • File name: keyhh.exe
  • Shell command: unchecked
  • Parameters: -MyHelp -#klink "{CurrentWord}" "{AppDir}\..\Docs\{Lexer}.chm"
  • Lexers: (empty)

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.

Tool for Google search

This is URL (special kind of tool). In the External Tools dialog, press the "URL" button, then press "Add" to add a new URL.

  • Name: Google find
  • URL:
http://google.com/search?q={SelectedText|q}

Tool to open folder of current file in Windows Explorer

Tool properties:

  • Name: Open cur dir in Explorer
  • File name: explorer.exe
  • Shell command: unchecked
  • Parameters: {FileDir}
  • Initial folder: {FileDir}

Tool to go to current file in FreeCommander

  • Name: Go to file in FreeCommander
  • File name: path\to\FreeCommander.exe
  • Shell command: unchecked
  • Parameters: "/L={FileName}" /C
  • Initial folder: {FileDir}

Runner

Plugin Runner was written as an alternative to External Tools.

  • Runner is more light weight.
  • Runner supports Sublime Text 3 build-systems.
  • Runner displays tool output immediately line-by-line as it appears (External Tools can only show the entire ready output).

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.

See the Runner documentation on GitHub.

Here is the GIF animation which shows reaction of Runner to PHP script running:

<?php
for($i=0; $i<10; $i++) {
	sleep(1);
	echo "$i is here\n";
}
?>

cudatext-runner-thread.gif

Runner limitation for input

If your Python script contains the input() function:

s=input('enter text: ')
print('entered:', s)

it will run with a runtime error like this:

enter text: Traceback (most recent call last):
  File "/home/user/a.py", line 3, in <module>
	s=input('enter text: ')
EOFError: EOF when reading a line

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.

Runner tool for C

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.

This build-system has 2 commands:

  • Build: only compiles
  • Run: compiles and then runs the binary

Example C file:

#include <stdio.h>
int main(){
  printf("Hello world");
  return 0;
}

Example output in the CudaText Output panel (Linux):

-- [10:34:08] Building: C via GCC: a.c
-- Command: gcc "/home/user/a.c" -o "/home/user/a" && "/home/user/a"
-- Working dir: /home/user
Hello world
-- Done (0.2s), return code: 0

Runner tool for C++

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.

This build-system has 2 commands:

  • compile, then run the compiled binary (default command)
  • only run the compiled binary (it should be called from "Plugins / Runner / Build with...").

Example C++ file:

#include <iostream>

int main() {
    std::cout << "Hello World!";
    return 0;
}

Example output in the CudaText Output panel (Linux):

-- [16:41:55] Building: C++: new.cpp
-- Command: g++ -std=c++11 -Wall "/home/user/new.cpp" -o "/home/user/new" && "/home/user/new"
-- Working dir: /home/user
Hello World!
-- Done (0.8s), return code: 0

Runner tool for PHP

How to debug for example PHP file, with Runner. Create file "[CudaText]/data/buildsystems/php.sublime-build" with such text:

{
  "file_patterns": ["*.php"],
  "linux": {
    "cmd": ["php", "$file"]
  },
  "windows": {
    "cmd": ["C:\\PHP_folder\\php-win.exe", "$file"]
  }
}

Restart CudaText.

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.

Example script to test:

<?php
for($i=0; $i<10; $i++) {
	sleep(1);
	echo "$i is here\n";
}
?>

Runner tool for Python

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:

  • Build
  • Syntax Check

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.

Example script to test:

import time

for i in range(5):
    time.sleep(1)
    print(str(i) + " is here", flush=True)

Runner tool for Free Pascal

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:

{
  "file_patterns": ["*.pp", "*.pas"],
  "file_regex": "(.+?)\\((\\d+),(\\d+)\\)\\s(.+)$",
  "working_dir": "$file_path",
  "name": "Compile",
  "cmd": ["/home/user/fpcupdeluxe/fpcupdeluxe32/fpc/bin/x86_64-linux/fpc.sh", "$file_name"],
  "variants": [
    {
      "name": "Run",
      "cmd": ["./$file_base_name"]
    }
  ]
}

In this file, you need to adjust the path to "fpc.sh", according to your fpcupdeluxe folder. Restart CudaText.

After opening a Pascal file, call Runner main command "Build", that's it. The "Build" command example output:

-- [20:07:55] Building: Free Pascal: new.pas
-- Command: ['/home/user/fpcupdeluxe/fpcupdeluxe32/fpc/bin/x86_64-linux/fpc.sh', 'new.pas']
-- Working dir: /home/user
Free Pascal Compiler version 3.2.3-425-gebc55c0f4e-dirty [2021/09/09] for x86_64
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling new.pas
Linking new
3 lines compiled, 0.1 sec
-- Done (0.2s), return code: 0

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:

-- [20:09:09] Building: Free Pascal: new.pas
-- Command: ['./new']
-- Working dir: /home/user
Hello world.
-- Done (-0.0s), return code: 0

Runner tool for Cobol

In Addons Manager, install the lexer "Cobol".

Let's make build-system for GnuCOBOL on Windows. Install GnuCOBOL, usually from this webpage, to "C:\GnuCOBOL". You must have file "C:\GnuCOBOL\bin\cobc.exe".

Create Batch script "c:\GnuCOBOL\bin\runcobol.cmd" with such content:

set Path=c:\gnucobol\bin
set COB_CONFIG_DIR=c:\gnucobol\config
set COB_COPY_DIR=c:\gnucobol\copy
set COB_INCLUDE_PATH=c:\gnucobol\include
set COB_LIB_PATH=c:\gnucobol\lib
cobc -x -std=mf %1

Create build-system file "[CudaText]\data\buildsystems\cobol.sublime-build":

{
  "file_patterns": ["*.cob", "*.cbl", "*.cpy"],
  "name": "Compile",
  "cmd": ["cmd.exe", "/c", "c:\\GnuCOBOL\\bin\\runcobol.cmd", "$file"],
  "working_dir": "$file_path",
  "file_regex": "^([^:]+):([0-9]+):",
  "variants": [
    {
      "name": "Run",
      "cmd": ["$file_path/$file_base_name.exe"]
    }
  ]  
}

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).

Now running the "Plugins / Runner / Build" can give text in the "Output panel" like this:

-- [07:49:02] Building: cobol: test.cbl
-- Command: ['cmd.exe', '/c', 'c:\\GnuCOBOL\\bin\\runcobol.cmd', 'C:\\Work\\test.cbl']
-- Working dir: C:\Work

C:\Work>set Path=c:\gnucobol\bin 
C:\Work>set COB_CONFIG_DIR=c:\gnucobol\config 
C:\Work>set COB_COPY_DIR=c:\gnucobol\copy 
C:\Work>set COB_INCLUDE_PATH=c:\gnucobol\include 
C:\Work>set COB_LIB_PATH=c:\gnucobol\lib 
C:\Work>cobc -x -std=mf C:\Work\test.cbl 
C:\Work\test.cbl:1: error: invalid indicator 'u' at column 7
C:\Work\test.cbl:2: warning: line not terminated by a newline [-Wmissing-newline]
C:\Work\test.cbl:3: warning: PROGRAM-ID header missing [-Wothers]
-- Done (0.3s), return code: 1

FindInFiles

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.

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.

How to find/replace in all UI-tabs

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:

<tabs>
{t}

cudatext-findinfiles-intabs.png

And in the "Files" field, enter "*" for all files.

To discover more features of FindInFiles dialog, hover mouse over other labels/buttons.

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.

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.

How to use FindInFiles 4

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.

FiF3 and FiF4: comparison and future

CudaText has two plugins to search in files/tabs:

  • FindInFiles v3 (FiF3)
  • FindInFiles v4 (FiF4)

Important: FiF3 is almost frozen. Only serious bugs will be fixed. No plans to hide/delete FiF3. FiF4 supersedes FiF3.

Detailed comparison.

Common features:

  • 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.
  • Encoding detection. FiF4 allows to set more flexible plan (see submenu "=/Encoding plan").
  • 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).
  • 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.
  • FiF3 has commands to count fragments and to show only filenames. FiF4 skips such commands as unnecessary.
  • FiF3 can save dialog layouts. FiF4 saves layout as part of preset.
  • Like FiF3, FiF4 has the "Replace" functionality.
  • Like FiF3, FiF4 can search in project folder(s).

Main new features:

  • FiF4 can report the found fragment with its around lines (see "-?+?" button).
  • FiF4 can search multi-line fragments (see "+" button).
  • FiF4 can search in many start folders.
  • FiF4 allows to use lexer data to filter and report fragments (in/out string/comment, lexer path).
  • FiF4 allows to show lines in the Results with its lexer colors from source files.
  • FiF4 allows to use macro-variables (OS environments, properties of current file/tab and free-set names) in any editable fields .
  • FiF4 has statusbar to show statistics of the last search: folders/files/fragments/timing.
  • FiF4 allows to reformat Results (change tree type and more) without new search.
  • FiF4 allows to show modification time of files in the Results.

Terminal

There are currently 3 terminal plugins:

  • Terminal: simplest plugin.
  • Terminal Plus: most feature-rich plugin, but its UI may be too complex for beginners.
  • ExTerminal: middle in the feature set, but its UI is very simple.

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:

x = int(input('Enter x: '))
w = int(input('Enter w: '))
print(x*w)

Steps:

  • Save our script to file ~/myfolder/tt.py
  • Install ExTerminal, restart CudaText
  • Run ExTerminal by clicking its bottom-bar-icon
  • 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.
  • In ExTerminal, enter "python3 tt.py"

Script should work and show 2 input-prompts.

user@user:~/myfolder$ ls *.py
a.py  test.py  tt.py
user@user:~/myfolder$ python3 tt.py
Enter x: 10
Enter w: 20
200

How to open ExTerminal in the directory of the current editor file? You can do this:

  • Hover mouse over ExTerminal button in the bottom-bar. It must show tooltip like "ExTerminal 1".
  • 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.
  • To not produce too much ExTerminal buttons, use "Close terminal" from the popup menu.

Configure Menu

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:

  ,{"cap":"&Save", "cmd":"cmd_FileSave"}

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.

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:

  ,{"cap":"Toggle line comment", "cmd":"module=cuda_comments;cmd=cmt_toggle_line_body;"}

Here "cuda_comments" is plugin folder name, and "cmt_toggle_line_body" is Python method from install.inf.

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#menu_proc_-_Menu_id.

Example screenshot shows how "menu.json" will look with new items for context-menu:

cudatext-editing-context-menu.png

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:

    {"cap": "SomeToolName", "cmd": "module=cuda_exttools;cmd=run;info=174420;"}
   ,{"cap": "SomeMacroName", "cmd": "module=cuda_macros;cmd=run;info=87635;"}

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":

{
    "ver": "20151209",
    "list": [
        {
            "id": 254653,
            "nm": "C - compile",
            "file": "gcc",
            "ddir": "{FileDir}",
            "shll": false,
            "prms": "\"{FileNameOnly}\" -o \"{FileNameNoExt}\"",
            "savs": "N",
            "rslt": "OP",
            "encd": "utf_8",
            "lxrs": "C,C++",
            "pttn": "(?P<file>[\\w\\.\\-]+):(?P<line>\\d+):(?P<col>\\d+):.+",
        },

Config Toolbar

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.

For example, you installed two plugins:

  • Config Toolbar
  • Color Text

And you want to call command "Apply bold" (from "Color Text") via toolbar. How to add such a button? Picture highlights your steps.

cudatext-config-toolbar.png

  • From the Command Palette, call the item "Config Toolbar: Configure buttons...". Dialog will appear from the plugin.
  • In the "Configure toolbar" dialog, press "Add item...", and fill fields of new dialog "Button properties".
    • Caption
    • Tooltip (optional)
    • 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.
    • Icon (optional)

Intext Bookmarks

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.

Plugin adds menu items in "Plugins / In-text Bookmarks":

  • List for current tab -- show all marks in the current document
  • List for all tabs -- show all marks in all opened UI-tabs
  • Go to next
  • Go to previous
  • Add -- add a new mark at caret position

"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".

You can customize that special lines, using plugin configuration dialog: menu item "Options / Settings-plugins / In-text Bookmarks". Dialog gives such options:

  • Bookmark signs: NOTE: NB! TODO: todo: todo. FIX:
  • Comment sign: //

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.

Color Text

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.

cudatext-color-text.png

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.

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:

  • "all_words": Colorize all occurrences of fragment.
  • "case_sensitive": Case sensitive search for other occurrences.
  • "whole_words": Colorize only those occurrences, which are whole words.
  • "show_on_map": Show added colored marks also on micro-map.

Insert Pics

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:

cudatext-insert-pics.png

  • You can use any lexer for files with pictures.
  • You can add the unlimited number of pictures. But only one picture per "gap".
  • You can add/delete pictures later, using plugin's commands in menu "Plugins / Insert Pics".
  • When you delete the "helper file" (located in the same folder), all pictures will be lost for plugin.

Complete From Text

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.

cudatext-complete-from-text.png

In the picture above, one word was taken from C lexer's C.acp file (this is a feature).

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:

  • Install the plugin
  • Call menu item "Options / Settings-plugins / Complete From Text"
  • This opens the "plugins.ini" file
  • Find section "[complete_from_text]", add ",c" (without quotes) to the line "lexers="
  • Restart CudaText

Plugin has more options in that "plugins.ini" file:

  • 'lexers': comma-separated lexer names, ie for which lexers to work; specify none-lexer as '-'.
  • 'min_len': minimal word length, words of smaller length will be ignored.
  • 'max_lines': if document has bigger count of lines, ignore this document.
  • 'case_sens': case-sensitive; words starting with 'A' will be ignored when you typed 'a'.
  • 'no_comments': ignore words inside "syntax comments" (lexer specific).
  • 'no_strings': ignore words inside "syntax strings" (lexer specific).
  • 'what_editors': which documents (ie UI tabs) to read to get words. Values:
    • 0: only current document.
    • 1: all opened documents.
    • 2: all opened documents with the same lexer.
  • 'use_acp': add suggestions from autocomplete files in 'data/autocomplete'
  • '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.
  • '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.

Plugin supports CudaText option "nonword_chars", so for example words with '$' char are also added to completions, if CudaText option is configured so.

Embedded Editor

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.

cudatext-embedded-editor.png

It adds menu item to show/hide embedded editor in the current document, for the current caret position: "Plugins / Embedded Editor / Toggle".

By default, plugin searches for the included filename inside double-quotes, surrounding the caret position. This works OK for HTML and many other documents.

For example, when you have opened file "/folder/file.html", and placed caret inside first double-quotes:

  <link href="css/style.css" rel="stylesheet" type="text/css"/>

then embedded editor will be opened for file "/folder/css/style.css".

The search can be configured, though. For example, plugin can be used in Pascal files for include-directives:

  {$I path/filename.inc}

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.

Breadcrumbs

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:

[ home / user / mydir / myfile.ext ]

It can also show the "~" button for the home directory (by option):

[ ~ / mydir / myfile.ext ]

cudatext-breadcrumbs.png

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.

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.

LSP Client

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).

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:

  • Auto-completion: integrated with CudaText command "Auto-completion menu" (in the Command Palette).
  • Go to definition: integrated with CudaText command "Go to definition" (in the Command Palette, and in the editor context menu).
  • Function signature help: integrated with CudaText command "Show function hint" (in the Command Palette).
  • Hover: shows the tooltip when you hover mouse above identifiers. You need the Ctrl key pressed while you hover.

cudatext-lsp-hover .png

  • Find references: finds all locations where an identifier (under first caret) is used and shows menu with locations.

cudatext-lsp-refs.png

  • 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.
  • Document formatting: formatting of the source code by LSP server. This feature is also implemented in #CudaFormatter and usually it works better/faster there.

All LSP servers should have a homepage with description of their functions, and installation information.

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".

{
  "lexers": {
    "C#": "csharp"
  },
  ...
}

LSP Client also has the settings file, use menu item to open it: "Options / Settings-plugins / LSP Client".

LSP server for Python

Project homepage is https://github.com/python-lsp/python-lsp-server . Note that this is fork of old, unmaintained, project "PyLS". Server supports:

  • Auto-completion
  • Go to definition
  • Function signature help
  • Hover
  • Find references
  • Code linting
  • Document formatting

Use "pip" to install the server:

pip install python-lsp-server

This will expose the command "pylsp" on your PATH. Confirm that installation succeeded by running:

pylsp --help

Create the file "[CudaText]/settings/lsp_py.json" with text like this:

{
  "lexers": {
    "Python": "python"
  },
  "cmd_windows": ["pylsp.exe"],
  "cmd_macos": ["pylsp"],
  "cmd_unix": ["pylsp"]
}

Open some Python script, and call some commands of LSP Client. It will run the server, and it should work.

LSP server for Python, pyright

1. Install the server:

pip install pyright
  • On Windows, add folder of "pyright-langserver.exe" to system PATH.
  • On Linux/Unix, get the full path of the program, we will use this path in the next step.
which pyright-langserver

It outputs on Ubuntu:

/home/user/.local/bin/pyright-langserver
  • 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:
/Applications/Python\ 3.10/Install\ Certificates.command

2. Create config (CudaText)/settings/lsp_pyright.json:

{
  "lexers": {
    "Python": "python"
  },
  "cmd_windows": ["pyright-langserver.exe", "--stdio"],
  "cmd_unix": ["/home/user/.local/bin/pyright-langserver", "--stdio"],
  "cmd_macos": ["/Library/Frameworks/Python.framework/Versions/3.10/bin/pyright-langserver", "--stdio"],
  "log_stderr": true
}

3. To disable type checking (which may be confusing), add key "settings" to the above config:

  "settings": {
    "python.analysis": {
      "typeCheckingMode": "off"
    }
  }

LSP server for JavaScript/ReactJS

  • Install lexer for ReactJS: "JavaScript Babel", from "Addons Manager".
  • Install TypeScript and the LSP server. In Terminal:
npm install -g typescript typescript-language-server
  • Create CudaText LSP config: file "settings/lsp_js.json" with such content:
{
    "name": "JavaScript",
    "lexers": {
        "JavaScript": "javascript",
        "JavaScript Babel": "javascriptreact"
    },
    "cmd_unix": [
        "typescript-language-server",
        "--stdio"
    ],
    "cmd_windows": [
        "typescript-language-server.cmd",
        "--stdio"
    ]
}

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.

LSP server for TypeScript

  • Install TypeScript lexer from "Addons Manager".
  • Install TypeScript and the LSP server. In Terminal:
npm install -g typescript typescript-language-server
  • Create CudaText LSP config: file "settings/lsp_ts.json" with such content:
{
  "lexers": {
    "TypeScript": "ts"
  },
  "cmd_unix": [
    "typescript-language-server", 
    "--stdio" 
  ],
  "cmd_windows": [
    "typescript-language-server.cmd",
    "--stdio" 
  ]
}

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.

According to https://www.zeusedit.com/lsp/typescript.html, sometimes more complex config file may be needed. Here it is on Ubuntu:

{
  "lexers": {
    "TypeScript": "ts"
  },
  "cmd_unix": [
    "typescript-language-server", 
    "--stdio", 
    "--log-level=4", 
    "--tsserver-log-verbosity=verbose",
    "--tsserver-path=/usr/local/lib/node_modules/typescript/lib/"
  ],
  "cmd_windows": [
    "typescript-language-server.cmd",
    "--stdio", 
    "--log-level=4", 
    "--tsserver-log-verbosity=verbose",
    "--tsserver-path=\"%APPDATA%\\npm\\node_modules\\typescript\\lib\\\""
  ]
}

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".

Test the auto-completion on this "test.ts" file (with TypeScript lexer):

document.body.g

LSP server for C/C++

Install one of the servers following the instructions:

To use the server in LSP Client, create a file "lsp_c.json" in the "settings" directory with such content:

{
  "lexers": {
    "C++": "cpp",
    "C": "c"
  },
  "cmd_unix": [
      "clangd-12",
  ],
  "cmd_windows": [
      "clangd",
  ],
}

Replace "clangd*" with "ccls" if it was chosen.

On Windows: you must add the "bin" directory of mingw64 to the PATH so clangd is in the PATH.

LSP server for C#

First, install C# lexer from "Addons Manager".

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.

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 .

3. Create LSP config file: (CudaText)/settings/lsp_cs.json:

{
  "lexers": {
    "C#": "csharp"
  },
  "cmd_windows": [
    "C:\\OmniSharp\\OmniSharp.exe", "-lsp", "-z"
  ]
}

Note that backslashes must be doubled (because of JSON format).

4. To test that server works: create a file "test.cs" (with C# lexer active). Call auto-completion after "date.A".

using System;

public class DateExample
{
	public static void Main()
	{
		DateTime  date;
		date.A
	}
}

LSP server for CSS/SCSS/LESS

The CSS (and SCSS, LESS) server is not easy to install, so here is the instruction, from the author of LSP Client:

  • Download the repository of VSCode: https://github.com/microsoft/vscode
  • From the repository, get the folder "extensions/css-language-features/server" and enter in it.
  • Replace the file "tsconfig.json" with content:
{
    "compilerOptions": {
	    "target": "es2018",
	    "lib": [
		    "es2018"
	    ],
	    "module": "commonjs",
	    "strict": true,
	    "alwaysStrict": true,
	    "noImplicitAny": true,
	    "noImplicitReturns": true,
	    "noImplicitOverride": true,
	    "noUnusedLocals": true,
	    "noUnusedParameters": true,
	    "forceConsistentCasingInFileNames": true,
	    
	    "outDir": "./out"
    },
  "files": [
      "src/node/cssServerMain.ts"
  ]
}
  • Install dependencies and TypeScript. In Terminal:
npm install
npm install -g typescript
  • Compile it. In Terminal:
npx tsc

Server should be compiled.

Create config file (CudaText)/settings/lsp_css.json:

{
    "name": "vsc-css",
    "lexers": {
    	"CSS": "css",
    	"SCSS": "scss",
    	"Sass": "sass",
    	"LESS": "less",
    },
    "cmd_unix": [
        "node",
        "path_to_server/server/out/node/cssServerMain.js",
        "--stdio"
    ]
}

LSP server for HTML

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:

npm install --global vscode-html-ls-bin

Make config file (CudaText)/settings/lsp_html.json:

{
    "lexers": {
    	"HTML": "html",
    },
    "cmd_windows": ["html-ls.cmd", "--stdio"],
    "cmd_unix": ["html-ls", "--stdio"]
}

Make sure the script "html-ls" ("html-ls.cmd" on Windows) is in the PATH.

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.

LSP server for Java

Part 1. Information for Windows.

  • Install lexer "Java" from Addons Manager.
java -version

It must show something like this:

java version "19.0.1" 2022-10-18
Java(TM) SE Runtime Environment (build 19.0.1+10-21)
Java HotSpot(TM) 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)
  • Create "C:\Java\jLSP.cmd" batch file with the following contents (edit if necessary):
@echo off
echo.
echo Usage: jLSP.cmd CacheDir
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.
echo.

:: language server installation folder (adjust to suit)
set Directory=C:/Java/jdt-language-server
:: language server jar file (update based on version file of jar)
set JarFile=%Directory%/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar
:: language server config folder location
set Config=%Directory%/config_win

set CacheDir=%~1
echo Directory: %Directory%
echo   JarFile: %JarFile%
echo    Config: %Config%
echo  CacheDir: %CacheDir%

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%
  • Create LSP config file: (CudaText)/settings/lsp_java.json:
{
  "lexers": {
    "Java": "java"
  },
  "cmd_windows": ["C:\\Java\\jLSP.cmd", "./cache_for_proj1"]  
}

Use testing file "test.java". Place caret on last code line after "System.g" and call auto-completion.

public class Example {
	public static void main(String[] args) {
		System.g
	}
}

Part 2. Information for Linux.

  • Install lexer "Java" from Addons Manager.
  • Install "Java SE Development Kit" from Oracle website or from OS package manager. If you have usual Java (JRE) then better remove it first.

On Ubuntu this command works (2022 year):

sudo apt install openjdk-17-jre-headless 

Then run in Console:

java -version

It must show something like this:

openjdk version "17.0.4" 2022-07-19
OpenJDK Runtime Environment (build 17.0.4+8-Ubuntu-120.04)
OpenJDK 64-Bit Server VM (build 17.0.4+8-Ubuntu-120.04, mixed mode, sharing)
  • Create "~\jLSP.sh" shell script with the following contents, and make it executable:
#!/bin/bash
echo
echo Usage: jLSP.sh CacheDir
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.
echo

# language server installation folder (adjust to suit)
Directory=~/jdt-language-server
# language server jar file (update based on version file of jar)
JarFile=$Directory/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar
# language server config folder location
Config=$Directory/config_linux

CacheDir=$1
echo Directory: $Directory
echo   JarFile: $JarFile
echo    Config: $Config
echo  CacheDir: $CacheDir

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
  • Create LSP config file: (CudaText)/settings/lsp_java.json:
{
  "lexers": {
    "Java": "java",
  },
  "cmd_unix": ["~/jLSP.sh", "./cache_for_proj1"],
}

Use testing file "test.java". Place caret on last code line after "System.g" and call auto-completion.

public class Example {
	public static void main(String[] args) {
		System.g
	}
}

LSP server for Nim

Server from https://github.com/PMunch/nimlsp works good.

Config file (CudaText)/settings/lsp_nim.json:

{
    "name": "nim-lsp",
    "lexers": {
        "Nim": "nim"
    },
    "cmd_unix": [
      "~/.nimble/bin/nimlsp"
    ]
}

LSP server for Rust

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

Create config (CudaText)/settings/lsp_rust.json:

{
  "lexers": {
    "Rust": "rust"
  },
  "cmd_windows": ["rust-analyzer-x86_64-pc-windows-msvc.exe"],
  "cmd_unix": ["rust-analyzer-x86_64-unknown-linux-gnu"]
}

LSP server for AutoHotkey

npm install
npm install -g typescript
  • Enter the directory "server", and compile the server. In Terminal:
npx tsc

Server should be compiled now. To use the server in LSP Client, create the file "lsp_ahk.json" in the "settings" with such content:

{
    "name": "AutoHotkey2",
    "lexers": {
        "AutoHotkey": "ahk"
    },
    "cmd_unix": [
        "node",
        "path_to_server/server/out/server.js",
        "--stdio"
    ]
}

LSP server for Red

1) On Linux x64.

  • 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.
  • Install server from https://github.com/bitbegin/redlangserver, put the repo e.g. to ~/redlangserver.
  • Create file "redlangserver.sh" and put it to some PATH dir. Content:
#!/bin/bash
red ~/redlangserver/server.red
  • Create file (CudaText)/settings/lsp_red.json with content:
{
  "lexers": {
    "Red": "red"
  },
  "cmd_unix": ["redlangserver.sh"],
  "cmd_windows": ["c:\\red\\red.exe", "--cli", "c:\\red\\redlangserver\\server.red"]
}

Server should work now. It gives: mouse hover tooltips (Ctrl + mouse hovering over names), go to definition.

2) On Windows 10 x64.

  • Install Red to "c:\Red". Tested the build from 02-Oct-2021.
  • Install server from https://github.com/bitbegin/redlangserver, put the repo to "c:\Red\redlangserver".
  • Run once the command "c:\red\red.exe --cli", it will print "Compiling Red console..." with the big pause.
  • Create file (CudaText)\settings\lsp_red.json with the same content as for Unix. Adjust path to Red folder, if needed.

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).

Note: don't create .bat or .cmd file with the "red.exe" calling, because it does not work in LSP Client for some reason.

LSP server for PHP

1. Install PHP, Composer. PHP versions 7.4.3 and 8.1 are OK.

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".

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.

4. Create LSP config (CudaText)/settings/lsp_php.json:

{
    "name": "PHP",
    "lexers": {
        "PHP": "php"
    },
    "tcp_port": 12345,
    "cmd_unix": [
      "php",
      "folder_of_server/bin/php-language-server.php",
      "--tcp-server=127.0.0.1:12345"
    ],
    "cmd_windows": [
      "php",
      "D:\\programm\\php\\php-language-server\\bin\\php-language-server.php",
      "--tcp-server=127.0.0.1:12345"
    ]
}

Server should work now. It gives these features: https://github.com/zobo/php-language-server#features .

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.

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.

LSP server for Bash

{
    "lexers": {
        "Bash script": "bash"
    },
    "cmd_windows": ["bash-language-server.cmd", "start"],    
    "cmd_unix": ["bash-language-server", "start"]
}

LSP server for D

First, install D lexer from "Addons Manager".

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.

2. Install the LSP server, run from console:

dub fetch dls

This must show output like

C:\D>dub fetch dls
Fetching dls 0.26.2...
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.

3. Compile the LSP server, run from console:

dub run dls:bootstrap

This must show output like

C:\D>dub run dls:bootstrap
Building package dls:bootstrap in C:\Users\user\AppData\Local\dub\packages\dls-0.26.2\dls\bootstrap\
Running pre-generate commands for dls:i18n...
Performing "debug" build using C:\D\dmd2\windows\bin64\dmd.exe for x86_64.
dls:protocol 0.26.2: building configuration "library"...
dls:i18n 0.26.2: building configuration "library"...
dls:bootstrap 0.26.2: building configuration "application"...
Linking...
Running ../Users/user/AppData/Local/dub/packages/dls-0.26.2/dls/bootstrap/dls_bootstrap.exe
C:\Users\user\AppData\Local\dub\packages\.bin\dls-latest\dls.exe

Copy to clipboard the last printed filename with dls.exe.

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).

{
  "lexers": {
    "D": "dlang"
  },
  "cmd_windows": [
    "C:\\Users\\user\\AppData\\Local\\dub\\packages\\.bin\\dls-latest\\dls.exe", "--stdio"
  ]
}

5. Create test file "test.d" (with lexer D). Test that auto-completion works after "b.":

class A {int a; int a2;}
class B: A {int a3;}

void foo(B b)
{
 	b.
}

LSP server for Go

Install lexer Go from "Addons Manager".

1. Install Go. Make sure that Go binary is in the system PATH, and GOPATH variable is also set.

2. Install the LSP server:

go install golang.org/x/tools/gopls@latest

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:

gopls version

It must give output like:

golang.org/x/tools/gopls v0.9.5
    golang.org/x/tools/gopls@v0.9.5 h1:F3TO5th6TUg40FHrpxZfMkMlVaaTmByeEvylgVHGH2A=

3. Create CudaText LSP config (CudaText)/settings/lsp_go.json:

{
  "lexers": {
    "Go": "go"
  },
  "cmd_unix": [
    "gopls" 
  ],
  "cmd_windows": [
    "gopls.exe"
  ]
}

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":

package aa
import ("fmt")

func main() {
  fmt.F
}

LSP server for Lua

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).

2. Create LSP config (CudaText)/settings/lsp_lua.json:

{
  "lexers": {
     "Lua": "lua"
  },
  "log_stderr": true,
  "cmd_windows": ["D:\\Programs\\lua-lsp\\bin\\lua-language-server.exe"],
  "cmd_unix": ["/path/to/lua-language-server"]
}

LSP server for Scala

Install lexer "Scala" from Addons Manager. Information for Windows.

1. Install Coursier: https://get-coursier.io/docs/cli-installation

2. Install Metals. Make sure "metals.bat" is in the system PATH.

cs install metals

3. Create LSP config file (CudaText)/settings/lsp_scala.json:

{
  "lexers": {
    "Scala": "scala"
  },
  "cmd_windows": ["metals.bat"]
}

Testing file for auto-completion:

object Hello extends App {
    println("Hello, world")
}

LSP server for Fortran

Install lexer "Fortran" from Addons Manager. Steps show how to use server on Linux (Ubuntu 20.04) with Python 3 installed.

1. Install the LSP server:

pip install fortran-language-server

Check that command runs OK:

fortls -?

And check its full path:

which fortls

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.

2. Create LSP config file: (CudaText)/settings/lsp_fortran.json:

{
  "lexers": {
    "Fortran": "fortran"
  },
  "cmd_unix": [
      "/home/user/.local/bin/fortls" 
  ]
}

3. Make test file "test.for" (with Fortran lexer). Test auto-completion after "CALL myv".

PROGRAM myprog
USE test_free, ONLY: scaled_vector
TYPE(scaled_vector) :: myvec
CALL myv
END PROGRAM

LSP server for Markdown

1. Get precompiled Marksman LSP server from GitHub: https://github.com/artempyanykh/marksman/releases

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.

chmod +x marksman-linux

3. Create config file (CudaText)/settings/lsp_md.json:

{
  "lexers": {
    "Markdown": "markdown"
  },
  "cmd_windows": ["marksman.exe"],
  "cmd_unix": ["marksman-linux"]
}

Now auto-completion / goto-definition / hover-tooltip must work on this "test.md" file:

[reference][abcd]
[reference][a123]

Some text.

[abcd]: url "title"
[a123]: url "title2"

LSP server for V

  • Install V lexer (from "Addons Manager / Plugins / Install")
  • Install V language
  • Install v-analyzer binary from https://github.com/v-analyzer/v-analyzer to a folder (that is included in PATH)
  • Create "lsp_v.json" in CudaText's "settings" folder with the following content:
{
  "lexers": {
    "V": "v"
  },
  "cmd_windows": ["v-analyzer.exe"],
  "cmd_unix": ["v-analyzer"],
  "cmd_macos": ["v-analyzer"]
}

LSP server Vale

Steps for Windows OS.

  • Install Vale server. Add path of "vale-ls.exe" to system PATH.
  • Create "lsp_vale.json" in CudaText's "settings" folder. Specify empty lexer name.
{
    "lexers": {
        "": ""
    },
    
    "cmd_windows": ["vale-ls.exe"],
    "log_stderr": true,
    "settings": {
        "configPath": ""
    }
}
  • You need to put config file to %UserProfile% folder. For example: "C:\Users\john\.vale.ini".
  • Do not forget to run: "vale sync".
  • Vale server did not support filenames with spaces on Windows OS. To fix it, update Vale to 0.3.7 or newer.