diff --git a/autoload/copilot/android_shim.js b/autoload/copilot/android_shim.js new file mode 100644 index 0000000..46f4c49 --- /dev/null +++ b/autoload/copilot/android_shim.js @@ -0,0 +1,14 @@ +const Module = require('module'); +const originalRequire = Module.prototype.require; + +Module.prototype.require = function(path) { + // Intercept the specific failing module + if (path.includes('vscode-policy-watcher')) { + return { + createWatcher: () => ({ + dispose: () => {} + }) + }; + } + return originalRequire.apply(this, arguments); +}; diff --git a/autoload/copilot/client.vim b/autoload/copilot/client.vim index 75d683e..b8e1011 100644 --- a/autoload/copilot/client.vim +++ b/autoload/copilot/client.vim @@ -540,6 +540,14 @@ function! s:Command() abort return [[], [], 'Node.js executable `' . get(node, 0, '') . "' not found"] endif endif + " --- START ANDROID WORKAROUND --- + if has('android') + let shim = s:root . '/autoload/copilot/android_shim.js' + if filereadable(shim) + let node += ['--require', shim] + endif + endif + " --- END ANDROID WORKAROUND --- return [node, script, ''] endfunction