Skip to content

Instantly share code, notes, and snippets.

@mlabrkic
Last active December 21, 2022 09:08
Show Gist options
  • Save mlabrkic/aa68e9e86a1322aa121cdebde4499882 to your computer and use it in GitHub Desktop.
Save mlabrkic/aa68e9e86a1322aa121cdebde4499882 to your computer and use it in GitHub Desktop.
"Multi Commander" script: Choose the Neovim configuration (stable config or test config), http://multicommander.com/
Choose the Neovim configuration: stable config or test config
------------------------------------------------------------
What to do? Where to install Neovim?
------------------------------
Install Neovim in a folder C:\UTILS\Neovim\
1. Download:
https://github.com/neovim/neovim/wiki/Installing-Neovim#install-from-download
Latest stable release
Assets 12:
nvim-win64.zip
2. Install (Windows):
https://github.com/neovim/neovim/wiki/Installing-Neovim
Unzip the package (nvim-win64.zip).
Run nvim-qt.exe
C:\UTILS\Neovim\bin\nvim-qt.exe
Create a stable configuration!
------------------------------
1)
First, rename the folders (stable config):
C:\Users\username\AppData\Local\nvim\
C:\Users\username\AppData\Local\nvim-data\
to
C:\Users\username\AppData\Local\nvim1\
C:\Users\username\AppData\Local\nvim-data1\
Note: C:\Users\username\AppData\ , it is a hidden folder
You can insert a blank Neovim-stable-config.txt file into both folders (for labeling purposes).
------------------------------
2)
Second:
Run nvim-qt.exe
Create a test configuration
Then, rename the folders (test config):
C:\Users\username\AppData\Local\nvim\
C:\Users\username\AppData\Local\nvim-data\
to
C:\Users\username\AppData\Local\nvim2\
C:\Users\username\AppData\Local\nvim-data2\
------------------------------------------------------------
for example
I am currently using a test configuration:
C:\Users\<username>\AppData\Local\
nvim (Symlink to folder nvim2)
nvim1
nvim2
nvim-data (Symlink to folder nvim-data2)
nvim-data1
nvim-data2
############################################################
INSTRUCTIONS
------------------------------------------------------------
Create a symlink:
------------------------------
Windows Command shell
MKLINK
https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/mklink
An A-Z Index of Windows CMD commands:
https://ss64.com/nt/mklink.html
MKLINK [[/D] | [/H] | [/J]] LinkName Target
/D Create a Directory symbolic link. (default is file)
By default, only Administrators can create symbolic links.
------------------------------
CreateLink
http://multicommander.com/docs/customcommands_list#mc.utils.createlink
MC.Utils.CreateLink
LNKTYPE 1 = Hardlink, 2 = Junction, 3 = Symlink, 4 = Shortcut
------------------------------------------------------------
http://forum.multicommander.com/forum/index.php/topic,1345.msg4769.html#msg4769
To create Symlinks you must be admin.
You can add "ASADMIN" and you will get a UAC dialog, or you can start MC as admin.
LNKTYPE 3 = Symlink
MC.Utils.CreateLink ASADMIN LNKTYPE=3 LNKSRC="<new source folder>" LNKTRG="<existing target folder>"
<new source folder> Must not exists.
<existing target folder> It exists.
UAC dialog is shown and MCAdmin (Admin helper Process) is starts
SymLink folder is created and points to existing target folder
------------------------------------------------------------
http://forum.multicommander.com/forum/index.php/topic,2036.msg7804.html#msg7804
Contributor: pncdaspropagandas
Go To Link Target v2
------------------------------------------------------------
Docs:
------------------------------------------------------------
http://multicommander.com/docs/
"Search the Online Documentation" (it is better than pdf)
------------------------------
http://multicommander.com/docs/multiscript/functions/filesystem
http://multicommander.com/docs/multiscript/functions/misc
http://multicommander.com/docs/customcommands_list
http://multicommander.com/docs/customcommands_list#mc.utils.createlink
MultiScript Language Syntax:
http://multicommander.com/docs/multiscript/languagesyntax
------------------------------------------------------------
FileExists
http://multicommander.com/docs/multiscript/functions/filesystem#fileexists
<num> FileExists( <str> path );
Return value: 1 if the path exists and is a file, 2 if the path exists and is a folder,
0 if the path does not exist
Example:
@var $res = FileExists( "C:\\temp\\MyFile.txt" );
@var $symlink_exists = FileExists($source_folder);
------------------------------
DeleteFile
http://multicommander.com/docs/multiscript/functions/filesystem#deletefile
Delete a single file using the Multi Commander virtual filesystem.
<num> DeleteFile( <str> filename, <arr> options );
@var $options[] = {"NOPROGRESS", "NODIALOG", "SILENT", "RECYLE"};
DeleteFile( $filename, $options );
------------------------------
AskText
<num> AskText( <str> label, <str> inputText, <num> option );
http://multicommander.com/docs/multiscript/functions/misc#asktext
@var $answer = AskText("Type 1 for a stable Neovim version, or 2 for test version.", "1", 0);
------------------------------
MessageBox
<num> MessageBox( <str> caption, <str> text, <num> options );
http://multicommander.com/docs/multiscript/functions/misc#messagebox
MessageBox("You have selected a stable Neovim configuration!", "nvim1 - stable", 0);
------------------------------
IF - Condition
http://multicommander.com/docs/multiscript/languagesyntax#if_condition
------------------------------------------------------------
http://multicommander.com/docs/multiscript/functions/string
------------------------------
http://forum.multicommander.com/forum/index.php/topic,1929.msg7356.html#msg7356
Administrator: Mathias (Author)
comparing with == can be tricky..
http://multicommander.com/docs/multiscript/functions/string#operator__
Compare two strings (case-sensitive).
Return Value: 1 if the string are the same, and 0 if the are different.
Example:
@var $str1 = "ABCDEF";
@var $str2 = "ABCDEF";
@var $val = $Str1 == $Str2;
// $val == 1
Also if both of the variables are not of string types,
then automatic conversion comes into play that can create havoc.
So because of that it is better to use StrIsEqual / StrIsEqualNoCase if you doing plain string compare
------------------------------
http://multicommander.com/docs/multiscript/functions/string#strisequalnocase
Check whether two strings are Equal, ignoring case differences.
<num> StrIsEqualNoCase(<str> string1, <str> string2);
Return Value: A value of 1 if string1 is equal to string2, 0 if the strings are not identical (ignoring case)
------------------------------------------------------------
############################################################
// "Multi Commander" script:
// MC_Choose_the_Neovim_CONFIG, F12
// Choose the Neovim configuration: stable config or test config
// ------------------------------------------------------------
// Ask user for Neovim configuration:
@var $answer = AskText("Type 1 for a stable Neovim config, or 2 for test config.", "1", 0);
// If user canceled, abort
if ( $answer == 0 )
{
break;
}
// ------------------------------------------------------------
// Check if the Symlink folder exists:
@var $env = TranslateEnvString("%USERPROFILE%");
@var $source_folder = $env ^ "AppData\\Local\\nvim\\";
@var $source_folder_data = $env ^ "AppData\\Local\\nvim-data\\";
@var $symlink_exists = FileExists($source_folder);
// Return value: 1 if the path exists and is a file, 2 if the path exists and is a folder,
// 0 if the path does not exist
// ------------------------------
// Delete Symlinks:
// @var $options[] = {"NOPROGRESS", "NODIALOG", "SILENT", "RECYLE"};
@var $options[] = {"NOPROGRESS", "NODIALOG", "SILENT"};
if($symlink_exists == 2)
{
DeleteFile( $source_folder, $options );
DeleteFile( $source_folder_data, $options );
}
// ------------------------------------------------------------
@var $target_folder;
@var $target_folder_data;
if($answer == 1)
{
// stable config
$target_folder = $env ^ "AppData\\Local\\nvim1\\";
MC.Utils.CreateLink ASADMIN LNKTYPE=3 LNKSRC={$source_folder} LNKTRG={$target_folder}
$target_folder_data = $env ^ "AppData\\Local\\nvim-data1\\";
MC.Utils.CreateLink ASADMIN LNKTYPE=3 LNKSRC={$source_folder_data} LNKTRG={$target_folder_data}
MessageBox("You have selected a stable Neovim configuration!", "nvim1 - stable", 0);
}
else if($answer == 2)
{
// test config
$target_folder = $env ^ "AppData\\Local\\nvim2\\";
MC.Utils.CreateLink ASADMIN LNKTYPE=3 LNKSRC={$source_folder} LNKTRG={$target_folder}
$target_folder_data = $env ^ "AppData\\Local\\nvim-data2\\";
MC.Utils.CreateLink ASADMIN LNKTYPE=3 LNKSRC={$source_folder_data} LNKTRG={$target_folder_data}
MessageBox("You have selected a test Neovim configuration!", "nvim2 - test", 0);
}
else
{
//
}
@mlabrkic
Copy link
Author

Before using this script, you should make a backup of the Neovim config folder.

Be sure to "exit" Neovim, and only then run this script!
As I remember, Neovim config folder was deleted a couple of times...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment