-
Notifications
You must be signed in to change notification settings - Fork 1
/
extension.js
57 lines (47 loc) · 2.66 KB
/
extension.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const vscode = require('vscode');
const path = require('path');
const os = require('os');
const fs = require('fs');
function setNeovimPath() {
// Construct the dynamic path
const homeDirectory = os.homedir();
const nvimPathLinux = path.join(homeDirectory, '.vscode/extensions/yeferyv.retronvim-0.1.1/bin/linux-x64/nvim');
const nvimPathMacOS = path.join(homeDirectory, '.vscode/extensions/yeferyv.retronvim-0.1.1/bin/darwin-x64/nvim-macos-x86_64/bin/nvim');
const nvimPathWindows = path.join(homeDirectory, '.vscode/extensions/yeferyv.retronvim-0.1.1/bin/win32-x64/nvim-win64/bin/nvim.exe');
const nvimPathWindowsRoot = path.join(homeDirectory, '.vscode/extensions/yeferyv.retronvim-0.1.1');
const nvimPathWindowsRootX64 = path.join(homeDirectory, '.vscode/extensions/yeferyv.retronvim-0.1.1-win32-x64');
// create symlink if installing from marketplace on Windows 10/11
if (os.platform() == "win32" && fs.existsSync(nvimPathWindowsRootX64)) {
fs.symlinkSync(nvimPathWindowsRootX64, nvimPathWindowsRoot)
}
// Access the configuration for 'vscode-neovim'
const config = vscode.workspace.getConfiguration();
// Update the 'neovimExecutablePaths.linux' setting
config.update('vscode-neovim.neovimExecutablePaths.linux', nvimPathLinux, vscode.ConfigurationTarget.Global)
.then(() => {
vscode.window.showInformationMessage(`Neovim path set to: ${nvimPath}`);
}, (err) => {
vscode.window.showErrorMessage(`Failed to set Neovim path: ${err}`);
});
config.update('vscode-neovim.neovimExecutablePaths.darwin', nvimPathMacOS, vscode.ConfigurationTarget.Global)
.then(() => {
vscode.window.showInformationMessage(`Neovim path set to: ${nvimPath}`);
}, (err) => {
vscode.window.showErrorMessage(`Failed to set Neovim path: ${err}`);
});
config.update('vscode-neovim.neovimExecutablePaths.win32', nvimPathWindows, vscode.ConfigurationTarget.Global)
.then(() => {
vscode.window.showInformationMessage(`Neovim path set to: ${nvimPath}`);
}, (err) => {
vscode.window.showErrorMessage(`Failed to set Neovim path: ${err}`);
});
// config.update("telemetry.telemetryLevel", "off", vscode.ConfigurationTarget.Global)
// config.update('window.titleBarStyle', "custom", vscode.ConfigurationTarget.Global)
config.update("security.workspace.trust.untrustedFiles", "open", vscode.ConfigurationTarget.Global)
config.update('window.customMenuBarAltFocus', false, vscode.ConfigurationTarget.Global) // Windows's alt sometimes conflicts with whichkey
}
// You can call this function in your extension's activate function or based on certain events
function activate(context) {
setNeovimPath();
}
exports.activate = activate;