Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

coc-metals

Package Overview
Dependencies
Maintainers
4
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coc-metals - npm Package Compare versions

Comparing version 0.9.1 to 0.9.2

8

lib/index.js

@@ -8,3 +8,3 @@ parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"eojW":[function(require,module,exports) {

},{"./commands":"eojW"}],"z7J4":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MetalsStatus=exports.MetalsQuickPick=exports.MetalsDidFocus=exports.DecorationsRangesDidChange=exports.MetalsInputBox=exports.ExecuteClientCommand=void 0;const e=require("vscode-languageserver-protocol");var t,o,s,n,i,a;!function(t){t.type=new e.NotificationType("metals/executeClientCommand")}(t=exports.ExecuteClientCommand||(exports.ExecuteClientCommand={})),function(t){t.type=new e.RequestType("metals/inputBox")}(o=exports.MetalsInputBox||(exports.MetalsInputBox={})),function(t){t.type=new e.NotificationType("metals/publishDecorations")}(s=exports.DecorationsRangesDidChange||(exports.DecorationsRangesDidChange={})),function(t){t.type=new e.NotificationType("metals/didFocusTextDocument")}(n=exports.MetalsDidFocus||(exports.MetalsDidFocus={})),function(t){t.type=new e.RequestType("metals/quickPick")}(i=exports.MetalsQuickPick||(exports.MetalsQuickPick={})),function(t){t.type=new e.NotificationType("metals/status")}(a=exports.MetalsStatus||(exports.MetalsStatus={}));
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DecorationsRangesDidChange=void 0;const e=require("vscode-languageserver-protocol");var o;!function(o){o.type=new e.NotificationType("metals/publishDecorations")}(o=exports.DecorationsRangesDidChange||(exports.DecorationsRangesDidChange={}));
},{}],"Iw8s":[function(require,module,exports) {

@@ -21,11 +21,11 @@ "use strict";var t=this&&this.__awaiter||function(t,e,n,o){return new(n||(n=Promise))(function(r,c){function u(t){try{s(o.next(t))}catch(e){c(e)}}function i(t){try{s(o.throw(t))}catch(e){c(e)}}function s(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(u,i)}s((o=o.apply(t,e||[])).next())})};function e(e,n){const o=(r,c)=>t(this,void 0,void 0,function*(){if(c<e.length){const t=yield n(e[c],c,e);return o(r.concat(t),c+1)}return r});return o([],0)}function n(t,e){const n=t.length,o=new Map;for(let r=0;r<n;r++){const n=t[r],c=e(n);let u=o.get(c);void 0===u&&(u=[],o.set(c,u)),u.push(n)}return o}Object.defineProperty(exports,"__esModule",{value:!0}),exports.groupBy=exports.sequence=void 0,exports.sequence=e,exports.groupBy=n;

},{"./model":"Vq4m","./treeviews":"GgEX"}],"Y104":[function(require,module,exports) {
"use strict";var e=this&&this.__awaiter||function(e,t,i,s){return new(i||(i=Promise))(function(o,r){function n(e){try{d(s.next(e))}catch(t){r(t)}}function a(e){try{d(s.throw(e))}catch(t){r(t)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(n,a)}d((s=s.apply(e,t||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.TreeViewFeature=void 0;const t=require("coc.nvim"),i=require("metals-languageclient"),s=require("vscode-languageserver-protocol");class o{constructor(e){this._client=e,this.requestType=new s.RequestType("metals/treeView"),this.providerEmitter=new s.Emitter,this.viewUpdaters=new Map,this.mbGotoCommandDisposable=void 0}get messages(){return this.requestType}fillClientCapabilities(){}initialize(){const o=this._client;o.onNotification(i.MetalsTreeViewDidChange.type,e=>{e.nodes.forEach(e=>{const t=e.viewId,r=this.viewUpdaters.get(t);if(void 0===r){const e=new s.Emitter,r={viewId:t,updatedNodes:e.event,loadNodeChildren:e=>{const s=o.sendRequest(i.MetalsTreeViewChildren.type,{viewId:t,nodeUri:e}).then(e=>e.nodes);return Promise.resolve(s)},loadParentInfo:(e,t)=>{const s={line:t.line+1,character:t.character},r={textDocument:{uri:e.uri},position:s};return Promise.resolve(o.sendRequest(i.MetalsTreeViewReveal.type,r))},sendTreeViewVisibilityNotification:e=>{o.sendNotification(i.MetalsTreeViewVisibilityDidChange.type,{viewId:t,visible:e})},sendTreeNodeVisibilityNotification:(e,s)=>{o.sendNotification(i.MetalsTreeViewNodeCollapseDidChange.type,{viewId:t,nodeUri:e,collapsed:s})}};this.providerEmitter.fire(r),this.viewUpdaters.set(t,e)}else r.fire(e)})}),this.mbGotoCommandDisposable=t.commands.registerCommand("metals.goto",(...t)=>e(this,void 0,void 0,function*(){let e={command:"metals.goto",arguments:t};return o.sendRequest(s.ExecuteCommandRequest.type,e).then(void 0,e=>{o.logFailedRequest(s.ExecuteCommandRequest.type,e)})}),null,!0)}providerEvents(){return this.providerEmitter.event}register(e,t){}unregister(e){}dispose(){this.providerEmitter.dispose(),this.viewUpdaters.forEach(e=>e.dispose()),void 0!==this.mbGotoCommandDisposable&&this.mbGotoCommandDisposable.dispose()}}exports.TreeViewFeature=o;
"use strict";var e=this&&this.__awaiter||function(e,t,i,s){return new(i||(i=Promise))(function(o,r){function n(e){try{d(s.next(e))}catch(t){r(t)}}function a(e){try{d(s.throw(e))}catch(t){r(t)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(n,a)}d((s=s.apply(e,t||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.TreeViewFeature=void 0;const t=require("coc.nvim"),i=require("metals-languageclient"),s=require("vscode-languageserver-protocol");class o{constructor(e){this._client=e,this.requestType=new s.RequestType("metals/treeView"),this.providerEmitter=new s.Emitter,this.viewUpdaters=new Map,this.mbGotoCommandDisposable=void 0}get messages(){return this.requestType}fillClientCapabilities(){}initialize(){const o=this._client;o.onNotification(i.MetalsTreeViewDidChange.type,e=>{e.nodes.forEach(e=>{const t=e.viewId,r=this.viewUpdaters.get(t);if(void 0===r){const e=new s.Emitter,r={viewId:t,updatedNodes:e.event,loadNodeChildren:e=>{const s=o.sendRequest(i.MetalsTreeViewChildren.type,{viewId:t,nodeUri:e}).then(e=>e.nodes);return Promise.resolve(s)},loadParentInfo:(e,t)=>{const s={line:t.line+1,character:t.character},r={textDocument:{uri:e.uri},position:s};return Promise.resolve(o.sendRequest(i.MetalsTreeViewReveal.type,r))},sendTreeViewVisibilityNotification:e=>{o.sendNotification(i.MetalsTreeViewVisibilityDidChange.type,{viewId:t,visible:e})},sendTreeNodeVisibilityNotification:(e,s)=>{o.sendNotification(i.MetalsTreeViewNodeCollapseDidChange.type,{viewId:t,nodeUri:e,collapsed:s})}};this.providerEmitter.fire(r),this.viewUpdaters.set(t,e)}else r.fire(e)})}),this.mbGotoCommandDisposable=t.commands.registerCommand(`metals.${i.ServerCommands.Goto}`,(...t)=>e(this,void 0,void 0,function*(){let e={command:i.ServerCommands.Goto,arguments:t};return o.sendRequest(s.ExecuteCommandRequest.type,e).then(void 0,e=>{o.logFailedRequest(s.ExecuteCommandRequest.type,e)})}),null,!0)}providerEvents(){return this.providerEmitter.event}register(e,t){}unregister(e){}dispose(){this.providerEmitter.dispose(),this.viewUpdaters.forEach(e=>e.dispose()),void 0!==this.mbGotoCommandDisposable&&this.mbGotoCommandDisposable.dispose()}}exports.TreeViewFeature=o;
},{}],"UnXq":[function(require,module,exports) {
"use strict";var e=this&&this.__createBinding||(Object.create?function(e,o,t,n){void 0===n&&(n=t),Object.defineProperty(e,n,{enumerable:!0,get:function(){return o[t]}})}:function(e,o,t,n){void 0===n&&(n=t),e[n]=o[t]}),o=this&&this.__setModuleDefault||(Object.create?function(e,o){Object.defineProperty(e,"default",{enumerable:!0,value:o})}:function(e,o){e.default=o}),t=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var n={};if(null!=t)for(var r in t)"default"!==r&&Object.hasOwnProperty.call(t,r)&&e(n,t,r);return o(n,t),n};Object.defineProperty(exports,"__esModule",{value:!0}),exports.detectLaunchConfigurationChanges=exports.wait=exports.toggleLogs=exports.checkServerVersion=exports.trackDownloadProgress=void 0;const n=require("coc.nvim"),r=t(require("metals-languageclient")),s=require("metals-languageclient"),i=require("./commands");function a(e,o,t){return s.downloadProgress({download:o,onProgress:o=>{t.text=e,t.show()},onError:t.dispose,onComplete:t.dispose})}function c(e){r.checkServerVersion({config:e,updateConfig:({configSection:o,latestServerVersion:t})=>{e.update(o,t,!0)},onOutdated:({message:e,upgradeChoice:o,openSettingsChoice:t,dismissChoice:r,upgrade:s})=>{n.workspace.showQuickpick([o,t,r],e).then(e=>{0===e?s():1===e&&n.workspace.nvim.command(i.Commands.OPEN_COC_CONFIG,!0)})}})}function u(){const e=n.workspace.documents.find(e=>"output:/metals"==e.uri);e?n.workspace.nvim.command(`bd ${e.bufnr}`):n.workspace.nvim.command(i.Commands.OPEN_LOGS)}function d(e){return new Promise(o=>{setTimeout(o,e)})}function p(){r.detectLaunchConfigurationChanges(n.workspace,({message:e,reloadWindowChoice:o,dismissChoice:t})=>n.workspace.showQuickpick([o,t],e).then(e=>{0===e&&n.workspace.nvim.command(i.Commands.RESTART_COC,!0)}),["statusBarEnabled","bloopVersion","enable"])}exports.trackDownloadProgress=a,exports.checkServerVersion=c,exports.toggleLogs=u,exports.wait=d,exports.detectLaunchConfigurationChanges=p;
},{"./commands":"eojW"}],"OSfr":[function(require,module,exports) {
"use strict";var t=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))(function(s,o){function r(t){try{c(n.next(t))}catch(e){o(e)}}function a(t){try{c(n.throw(t))}catch(e){o(e)}}function c(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,a)}c((n=n.apply(t,e||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.DebuggingFeature=void 0;const e=require("vscode-languageserver-protocol"),i=require("coc.nvim");class n{constructor(t,e){this._nvim=t,this._client=e}fillInitializeParams(){}fillClientCapabilities(){}initialize(){const n=(i,...n)=>t(this,void 0,void 0,function*(){let i={command:"debug-adapter-start",arguments:n};return this._client.sendRequest(e.ExecuteCommandRequest.type,i).then(e=>t(this,void 0,void 0,function*(){const t=e.uri.lastIndexOf(":");if(-1!==t){const i=parseInt(e.uri.substr(t+1));yield this._nvim.call("vimspector#LaunchWithSettings",[{configuration:"coc-metals",port:i}])}}),t=>{this._client.logFailedRequest(e.ExecuteCommandRequest.type,t)})});i.commands.registerCommand("metals-run-session-start",n.bind(this,!1),null,!0),i.commands.registerCommand("metals-debug-session-start",n.bind(this,!0),null,!0)}}exports.DebuggingFeature=n;
"use strict";var e=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))(function(s,o){function r(e){try{u(i.next(e))}catch(t){o(t)}}function a(e){try{u(i.throw(e))}catch(t){o(t)}}function u(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(r,a)}u((i=i.apply(e,t||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.DebuggingFeature=void 0;const t=require("vscode-languageserver-protocol"),n=require("coc.nvim"),i=require("metals-languageclient");class s{constructor(e,t){this._nvim=e,this._client=t}fillInitializeParams(){}fillClientCapabilities(){}initialize(){const s=(n,...s)=>e(this,void 0,void 0,function*(){let n={command:i.ServerCommands.DebugAdapterStart,arguments:s};return this._client.sendRequest(t.ExecuteCommandRequest.type,n).then(t=>e(this,void 0,void 0,function*(){const e=t.uri.lastIndexOf(":");if(-1!==e){const n=parseInt(t.uri.substr(e+1));yield this._nvim.call("vimspector#LaunchWithSettings",[{configuration:"coc-metals",port:n}])}}),e=>{this._client.logFailedRequest(t.ExecuteCommandRequest.type,e)})});n.commands.registerCommand(i.ClientCommands.StartRunSession,s.bind(this,!1),null,!0),n.commands.registerCommand(i.ClientCommands.StartDebugSession,s.bind(this,!0),null,!0)}}exports.DebuggingFeature=s;
},{}],"n7Rg":[function(require,module,exports) {
"use strict";var t=this&&this.__awaiter||function(t,s,e,i){return new(e||(e=Promise))(function(r,h){function o(t){try{c(i.next(t))}catch(s){h(s)}}function n(t){try{c(i.throw(t))}catch(s){h(s)}}function c(t){var s;t.done?r(t.value):(s=t.value,s instanceof e?s:new e(function(t){t(s)})).then(o,n)}c((i=i.apply(t,s||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0});const s=require("coc.nvim");class e{constructor(t,s,e){this.frames=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],this.counter=0,this.isProgress=!1,this.text="",this.priority=0,this.hide=(()=>this.dispose()),this.show=(()=>this.showText()),this.dispose=(()=>clearInterval(this.interval)),this.update=(t=>this.text=t),this.priority=t,this.isProgress=s,this.text=e,this.interval=setInterval(()=>{this.showText()},1e3)}getText(){let t;return void 0===this.frames[this.counter]&&(this.counter=0),this.isProgress&&""!==this.text.trim()?(t=this.text+this.frames[this.counter],this.counter++):t=this.text,t}showText(){return t(this,void 0,void 0,function*(){s.workspace.showMessage(this.getText())})}}exports.default=e;
},{}],"QCba":[function(require,module,exports) {
"use strict";var e=this&&this.__createBinding||(Object.create?function(e,t,o,r){void 0===r&&(r=o),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[o]}})}:function(e,t,o,r){void 0===r&&(r=o),e[r]=t[o]}),t=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(o){if(o&&o.__esModule)return o;var r={};if(null!=o)for(var a in o)"default"!==a&&Object.hasOwnProperty.call(o,a)&&e(r,o,a);return t(r,o),r},r=this&&this.__awaiter||function(e,t,o,r){return new(o||(o=Promise))(function(a,n){function i(e){try{c(r.next(e))}catch(t){n(t)}}function s(e){try{c(r.throw(e))}catch(t){n(t)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(i,s)}c((r=r.apply(e,t||[])).next())})},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.activate=void 0;const n=require("coc.nvim"),i=require("metals-languageclient"),s=o(require("path")),c=require("vscode-languageserver-protocol"),u=require("./commands"),d=a(require("./decoration")),l=require("./embeddedDoctor"),m=require("./metalsProtocol"),p=require("./tvp/controller"),v=require("./tvp/feature"),g=require("./tvp/treeviews"),h=require("./utils"),w=require("./DebuggingFeature"),f=a(require("./WannaBeStatusBarItem"));function k(e){return r(this,void 0,void 0,function*(){const t=n.workspace.getConfiguration("metals");t.get("enable")&&(h.detectLaunchConfigurationChanges(),h.checkServerVersion(t),i.getJavaHome(t.get("javaHome")).then(o=>y(t,e,o),()=>{n.workspace.showQuickpick(["Open Settings","Ignore for now"],"Unable to find a Java 8 or Java 11 installation on this computer. To fix this problem, update the 'Java Home' setting to point to a Java 8 or Java 11 home directory").then(e=>{0===e&&n.workspace.nvim.command(u.Commands.OPEN_COC_CONFIG,!0)})}))})}function y(e,t,o){var r,a;const s=i.checkDottyIde(null===(r=n.workspace.workspaceFolder)||void 0===r?void 0:r.uri);if(s.enabled)return void n.workspace.showMessage("Metals will not start since Dotty is enabled for this workspace. "+`To enable Metals, remove the file ${s.path} and run ':CocCommand metals.restartServer'`,"warning");const c=e.get("serverVersion"),d=e.inspect("serverVersion").defaultValue,l=c||d,m=e.get("serverProperties"),p=e.get("customRepositories"),v=i.getJavaConfig({workspaceRoot:null===(a=n.workspace.workspaceFolder)||void 0===a?void 0:a.uri,javaHome:o,customRepositories:p,extensionPath:t.extensionPath}),g=i.fetchMetals({serverVersion:l,serverProperties:m,javaConfig:v}),w=e.get("statusBarEnabled"),k=w?n.workspace.createStatusBarItem(0,{progress:!0}):new f.default(0,!0,"Preparing Metals"),y=`Downloading Metals v${l}`;h.trackDownloadProgress(y,g,k).then(e=>{b(t,e,m,v,k,w)},()=>{const e=(()=>{const e="See https://scalaeta.org/metals/docs/editors/vscode.html#http-proxy for instructions if you are using an HTTP proxy.";return l===d?"Failed to download Metals, make sure you have an internet connection and "+`the Java Home '${o}' is valid. You can configure the Java Home in the settings.`+e:"Failed to download Metals, make sure you have an internet connection, "+`the Metals version '${l}' is correct and the Java Home '${o}' is valid. `+"You can configure the Metals version and Java Home in the settings."+e})();n.workspace.showPrompt(`${e}\n Open Settings?`).then(e=>{e&&n.workspace.nvim.command(u.Commands.OPEN_COC_CONFIG,!0)})})}function b(e,t,o,a,u,f){return r(this,void 0,void 0,function*(){const k=i.getServerOptions({metalsClasspath:t,serverProperties:o,javaConfig:a,clientName:"coc-metals"}),y={compilerOptions:{completionCommand:"editor.action.triggerSuggest",isCompletionItemResolve:!1,overrideDefFormat:"unicode",parameterHintsCommand:"editor.action.triggerParameterHints"},debuggingProvider:n.workspace.isNvim&&1===(yield n.workspace.nvim.getVar("loaded_vimpector")),decorationProvider:n.workspace.isNvim,didFocusProvider:!0,doctorProvider:"json",executeClientCommandProvider:!0,inputBoxProvider:!0,quickPickProvider:!0,slowTaskProvider:!0,statusBarProvider:f?"on":"show-message",treeViewProvider:!0},b={documentSelector:[{scheme:"file",language:"scala"}],synchronize:{configurationSection:"metals"},revealOutputChannelOn:n.RevealOutputChannelOn.Never,initializationOptions:y},C=new n.LanguageClient("metals","Metals",k,b),P=new v.TreeViewFeature(C);if(C.registerFeature(P),b.initializationOptions.debuggingProvider){const e=new w.DebuggingFeature(n.workspace.nvim,C);C.registerFeature(e)}const q=new n.FloatFactory(n.workspace.nvim,n.workspace.env,!1,100,100,!0),O=new d.default(q),M=new g.TreeViewsManager(n.workspace.nvim,e.logger),x=new p.TreeViewController(P,M);function _(t,o){e.subscriptions.push(n.commands.registerCommand(t,o))}e.subscriptions.push(P,M,x),_("metals.restartServer",i.restartServer(C,n.workspace)),e.subscriptions.push(C.start()),C.onReady().then(t=>{u.isProgress=!1,u.text="Metals is Ready!",u.show();if(["build-import","build-connect","build-restart","sources-scan","doctor-run","compile-cascade","compile-cancel","compile-clean","ammonite-start","ammonite-stop","new-scala-project","reset-choice"].forEach(e=>{_("metals."+e,()=>r(this,void 0,void 0,function*(){n.workspace.showMessage("metals"+e),C.sendRequest(c.ExecuteCommandRequest.type,{command:e})}))}),_("metals.logs-toggle",()=>{h.toggleLogs()}),n.workspace.isNvim&&e.subscriptions.push(n.workspace.registerKeymap(["n"],"metals-expand-decoration",()=>{O.showHover()},{sync:!1})),_("metals.new-scala-file",()=>r(this,void 0,void 0,function*(){const e=(yield n.workspace.document).uri,t=s.dirname(e);C.sendRequest(c.ExecuteCommandRequest.type,{command:"new-scala-file",arguments:[t]})})),_("metals.go-to-super-method",()=>r(this,void 0,void 0,function*(){const e=yield n.workspace.document,t=yield n.workspace.getCursorPosition();C.sendRequest(c.ExecuteCommandRequest.type,{command:"goto-super-method",arguments:[{document:e.uri,position:t}]})})),_("metals.super-method-hierarchy",()=>r(this,void 0,void 0,function*(){const e=yield n.workspace.document,t=yield n.workspace.getCursorPosition();C.sendRequest(c.ExecuteCommandRequest.type,{command:"super-method-hierarchy",arguments:[{document:e.uri,position:t}]})})),C.onNotification(m.ExecuteClientCommand.type,e=>r(this,void 0,void 0,function*(){switch(e.command){case"metals-goto-location":const t=e.arguments&&e.arguments[0];t&&(yield M.prepareWindowForGoto(),yield h.wait(10),yield n.workspace.jumpTo(t.uri,t.range.start));break;case"metals-doctor-run":const o=e.arguments&&e.arguments[0];l.makeVimDoctor(JSON.parse(o));break;case"metals-doctor-reload":n.workspace.nvim.call("coc#util#has_preview").then(t=>{if(t>0){const t=e.arguments&&e.arguments[0];l.makeVimDoctor(JSON.parse(t))}});break;case"metals-diagnostics-focus":n.workspace.nvim.command("CocList diagnostics");break;case"metals-logs-toggle":h.toggleLogs();break;case"metals-model-refresh":n.events.fire("BufEnter",[n.workspace.bufnr]);break;default:n.workspace.showMessage(`Recieved unknown command: ${e.command}`)}})),n.events.on("BufWinEnter",e=>{const t=n.workspace.documents.find(t=>t.bufnr===e);t&&"scala"===t.filetype&&C.sendNotification(m.MetalsDidFocus.type,t.uri)}),C.onRequest(m.MetalsInputBox.type,e=>r(this,void 0,void 0,function*(){const t=yield n.workspace.callAsync("input",[`${e.prompt}: `,e.value?e.value:""]);return""===t.trim()?{cancelled:!0}:{value:t}})),C.onRequest(m.MetalsQuickPick.type,(e,t)=>n.workspace.showQuickpick(e.items.map(e=>e.label),e.placeHolder).then(t=>-1===t?{cancelled:!0}:{itemId:e.items[t].id})),f){const e=n.workspace.createStatusBarItem(0);C.onNotification(m.MetalsStatus.type,t=>{e.text=t.text,t.show?e.show():t.hide&&e.hide()})}n.workspace.isNvim&&(C.onNotification(m.DecorationsRangesDidChange.type,e=>{n.workspace.uri&&n.workspace.uri===e.uri&&O.setDecorations(e)}),n.events.on("BufWinLeave",e=>{const t=n.workspace.documents.find(t=>t.bufnr===e);t&&t.uri.endsWith(".worksheet.sc")&&O.clearDecorations(e)}))})})}exports.activate=k;
"use strict";var e=this&&this.__createBinding||(Object.create?function(e,t,o,r){void 0===r&&(r=o),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[o]}})}:function(e,t,o,r){void 0===r&&(r=o),e[r]=t[o]}),t=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(o){if(o&&o.__esModule)return o;var r={};if(null!=o)for(var n in o)"default"!==n&&Object.hasOwnProperty.call(o,n)&&e(r,o,n);return t(r,o),r},r=this&&this.__awaiter||function(e,t,o,r){return new(o||(o=Promise))(function(n,a){function s(e){try{c(r.next(e))}catch(t){a(t)}}function i(e){try{c(r.throw(e))}catch(t){a(t)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(s,i)}c((r=r.apply(e,t||[])).next())})},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.activate=void 0;const a=require("coc.nvim"),s=require("metals-languageclient"),i=o(require("path")),c=require("vscode-languageserver-protocol"),u=require("./commands"),m=n(require("./decoration")),d=require("./embeddedDoctor"),l=require("./metalsProtocol"),p=require("./tvp/controller"),v=require("./tvp/feature"),g=require("./tvp/treeviews"),h=require("./utils"),w=require("./DebuggingFeature"),f=n(require("./WannaBeStatusBarItem"));function C(e){return r(this,void 0,void 0,function*(){const t=a.workspace.getConfiguration("metals");t.get("enable")&&(h.detectLaunchConfigurationChanges(),h.checkServerVersion(t),s.getJavaHome(t.get("javaHome")).then(o=>k(t,e,o),()=>{a.workspace.showQuickpick(["Open Settings","Ignore for now"],"Unable to find a Java 8 or Java 11 installation on this computer. To fix this problem, update the 'Java Home' setting to point to a Java 8 or Java 11 home directory").then(e=>{0===e&&a.workspace.nvim.command(u.Commands.OPEN_COC_CONFIG,!0)})}))})}function k(e,t,o){var r,n;const i=s.checkDottyIde(null===(r=a.workspace.workspaceFolder)||void 0===r?void 0:r.uri);if(i.enabled)return void a.workspace.showMessage("Metals will not start since Dotty is enabled for this workspace. "+`To enable Metals, remove the file ${i.path} and run ':CocCommand metals.restartServer'`,"warning");const c=e.get("serverVersion"),m=e.inspect("serverVersion").defaultValue,d=c||m,l=e.get("serverProperties"),p=e.get("customRepositories"),v=s.getJavaConfig({workspaceRoot:null===(n=a.workspace.workspaceFolder)||void 0===n?void 0:n.uri,javaHome:o,customRepositories:p,extensionPath:t.extensionPath}),g=s.fetchMetals({serverVersion:d,serverProperties:l,javaConfig:v}),w=e.get("statusBarEnabled"),C=w?a.workspace.createStatusBarItem(0,{progress:!0}):new f.default(0,!0,"Preparing Metals"),k=`Downloading Metals v${d}`;h.trackDownloadProgress(k,g,C).then(e=>{S(t,e,l,v,C,w)},()=>{const e=(()=>{const e="See https://scalaeta.org/metals/docs/editors/vscode.html#http-proxy for instructions if you are using an HTTP proxy.";return d===m?"Failed to download Metals, make sure you have an internet connection and "+`the Java Home '${o}' is valid. You can configure the Java Home in the settings.`+e:"Failed to download Metals, make sure you have an internet connection, "+`the Metals version '${d}' is correct and the Java Home '${o}' is valid. `+"You can configure the Metals version and Java Home in the settings."+e})();a.workspace.showPrompt(`${e}\n Open Settings?`).then(e=>{e&&a.workspace.nvim.command(u.Commands.OPEN_COC_CONFIG,!0)})})}function S(e,t,o,n,u,f){return r(this,void 0,void 0,function*(){const C=s.getServerOptions({metalsClasspath:t,serverProperties:o,javaConfig:n,clientName:"coc-metals"}),k={compilerOptions:{completionCommand:"editor.action.triggerSuggest",isCompletionItemResolve:!1,overrideDefFormat:"unicode",parameterHintsCommand:"editor.action.triggerParameterHints"},debuggingProvider:a.workspace.isNvim&&1===(yield a.workspace.nvim.getVar("loaded_vimpector")),decorationProvider:a.workspace.isNvim,didFocusProvider:!0,doctorProvider:"json",executeClientCommandProvider:!0,inputBoxProvider:!0,quickPickProvider:!0,slowTaskProvider:!0,statusBarProvider:f?"on":"show-message",treeViewProvider:!0},S={documentSelector:[{scheme:"file",language:"scala"}],synchronize:{configurationSection:"metals"},revealOutputChannelOn:a.RevealOutputChannelOn.Never,initializationOptions:k},y=new a.LanguageClient("metals","Metals",C,S),P=new v.TreeViewFeature(y);if(y.registerFeature(P),S.initializationOptions.debuggingProvider){const e=new w.DebuggingFeature(a.workspace.nvim,y);y.registerFeature(e)}const b=new a.FloatFactory(a.workspace.nvim,a.workspace.env,!1,100,100,!0),M=new m.default(b),q=new g.TreeViewsManager(a.workspace.nvim,e.logger),O=new p.TreeViewController(P,q);function R(t,o){e.subscriptions.push(a.commands.registerCommand(t,o))}e.subscriptions.push(P,q,O),R("metals.restartServer",s.restartServer(y,a.workspace)),e.subscriptions.push(y.start()),y.onReady().then(t=>{if(u.isProgress=!1,u.text="Metals is Ready!",u.show(),[s.ServerCommands.BuildImport,s.ServerCommands.BuildConnect,s.ServerCommands.BuildRestart,s.ServerCommands.SourcesScan,s.ServerCommands.DoctorRun,s.ServerCommands.CascadeCompile,s.ServerCommands.CancelCompilation,s.ServerCommands.CleanCompile,s.ServerCommands.AmmoniteStart,s.ServerCommands.AmmoniteStop,s.ServerCommands.NewScalaProject,s.ServerCommands.ResetChoice].forEach(e=>{R("metals."+e,()=>r(this,void 0,void 0,function*(){a.workspace.showMessage("metals"+e),y.sendRequest(c.ExecuteCommandRequest.type,{command:e})}))}),R("metals.logs-toggle",()=>{h.toggleLogs()}),a.workspace.isNvim&&e.subscriptions.push(a.workspace.registerKeymap(["n"],"metals-expand-decoration",()=>{M.showHover()},{sync:!1})),R(`metals.${s.ServerCommands.NewScalaFile}`,()=>r(this,void 0,void 0,function*(){const e=(yield a.workspace.document).uri,t=i.dirname(e);y.sendRequest(c.ExecuteCommandRequest.type,{command:s.ServerCommands.NewScalaFile,arguments:[t]})})),R(`metals.${s.ServerCommands.GotoSuperMethod}`,()=>r(this,void 0,void 0,function*(){const e=yield a.workspace.document,t=yield a.workspace.getCursorPosition();y.sendRequest(c.ExecuteCommandRequest.type,{command:s.ServerCommands.GotoSuperMethod,arguments:[{document:e.uri,position:t}]})})),R(`metals.${s.ServerCommands.SuperMethodHierarchy}`,()=>r(this,void 0,void 0,function*(){const e=yield a.workspace.document,t=yield a.workspace.getCursorPosition();y.sendRequest(c.ExecuteCommandRequest.type,{command:s.ServerCommands.SuperMethodHierarchy,arguments:[{document:e.uri,position:t}]})})),y.onNotification(s.ExecuteClientCommand.type,e=>r(this,void 0,void 0,function*(){switch(e.command){case s.ClientCommands.GotoLocation:const t=e.arguments&&e.arguments[0];t&&(yield q.prepareWindowForGoto(),yield h.wait(10),yield a.workspace.jumpTo(t.uri,t.range.start));break;case s.ClientCommands.RunDoctor:const o=e.arguments&&e.arguments[0];d.makeVimDoctor(JSON.parse(o));break;case s.ClientCommands.ReloadDoctor:a.workspace.nvim.call("coc#util#has_preview").then(t=>{if(t>0){const t=e.arguments&&e.arguments[0];d.makeVimDoctor(JSON.parse(t))}});break;case s.ClientCommands.FocusDiagnostics:a.workspace.nvim.command("CocList diagnostics");break;case s.ClientCommands.ToggleLogs:h.toggleLogs();break;case s.ClientCommands.RefreshModel:a.events.fire("BufEnter",[a.workspace.bufnr]);break;default:a.workspace.showMessage(`Recieved unknown command: ${e.command}`)}})),a.events.on("BufWinEnter",e=>{const t=a.workspace.documents.find(t=>t.bufnr===e);t&&"scala"===t.filetype&&y.sendNotification(s.MetalsDidFocus.type,t.uri)}),y.onRequest(s.MetalsInputBox.type,e=>a.workspace.callAsync("input",[`${e.prompt}: `,e.value?e.value:""]).then(s.MetalsInputBox.handleInput)),y.onRequest(s.MetalsQuickPick.type,(e,t)=>a.workspace.showQuickpick(e.items.map(e=>e.label),e.placeHolder).then(t=>-1===t?{cancelled:!0}:{itemId:e.items[t].id})),f){const e=a.workspace.createStatusBarItem(0);y.onNotification(s.MetalsStatus.type,t=>{e.text=t.text,t.show?e.show():t.hide&&e.hide()})}a.workspace.isNvim&&(y.onNotification(l.DecorationsRangesDidChange.type,e=>{a.workspace.uri&&a.workspace.uri===e.uri&&M.setDecorations(e)}),a.events.on("BufWinLeave",e=>{const t=a.workspace.documents.find(t=>t.bufnr===e);t&&t.uri.endsWith(".worksheet.sc")&&M.clearDecorations(e)}))})})}exports.activate=C;
},{"./commands":"eojW","./decoration":"p29A","./embeddedDoctor":"BTOZ","./metalsProtocol":"z7J4","./tvp/controller":"bAI2","./tvp/feature":"Y104","./tvp/treeviews":"GgEX","./utils":"UnXq","./DebuggingFeature":"OSfr","./WannaBeStatusBarItem":"n7Rg"}]},{},["QCba"], null)
{
"name": "coc-metals",
"version": "0.9.1",
"version": "0.9.2",
"description": "coc.nvim extension for Metals, the Scala language server",

@@ -29,3 +29,3 @@ "keywords": [

"engines": {
"coc": ">=0.0.66"
"coc": "^0.0.78"
},

@@ -77,3 +77,3 @@ "main": "lib/index.js",

"type": "string",
"default": "0.9.2",
"default": "0.9.3",
"markdownDescription": "The version of the Metals server artifact. Requires reloading the window.\n\n**Change only if you know what you're doing**"

@@ -350,3 +350,3 @@ },

"devDependencies": {
"@types/node": "14.0.23",
"@types/node": "14.6.0",
"npm-run-all": "4.1.5",

@@ -356,8 +356,8 @@ "parcel-bundler": "1.12.4",

"rimraf": "3.0.2",
"ts-loader": "8.0.1",
"typescript": "3.9.6"
"ts-loader": "8.0.2",
"typescript": "3.9.7"
},
"dependencies": {
"coc.nvim": "0.0.77",
"metals-languageclient": "0.2.8",
"metals-languageclient": "0.3.0",
"promisify-child-process": "4.1.1",

@@ -364,0 +364,0 @@ "vscode-languageserver-protocol": "3.15.3"

@@ -7,2 +7,3 @@ import { BaseLanguageClient, StaticFeature, Neovim } from "coc.nvim";

import { commands } from "coc.nvim";
import { ClientCommands, ServerCommands } from "metals-languageclient";

@@ -24,3 +25,3 @@ interface DebugAdapterStartResponse {

let params: ExecuteCommandParams = {
command: "debug-adapter-start",
command: ServerCommands.DebugAdapterStart,
arguments: args,

@@ -45,3 +46,3 @@ };

commands.registerCommand(
"metals-run-session-start",
ClientCommands.StartRunSession,
debugHandler.bind(this, false),

@@ -52,3 +53,3 @@ null,

commands.registerCommand(
"metals-debug-session-start",
ClientCommands.StartDebugSession,
debugHandler.bind(this, true),

@@ -55,0 +56,0 @@ null,

@@ -22,2 +22,11 @@ import {

MetalsInitializationOptions,
ClientCommands,
ServerCommands,
MetalsStatus,
ExecuteClientCommand,
MetalsDidFocus,
MetalsInputBox,
InputBoxOptions,
MetalsQuickPick,
MetalsQuickPickParams,
} from "metals-languageclient";

@@ -34,11 +43,4 @@ import * as path from "path";

DecorationsRangesDidChange,
ExecuteClientCommand,
MetalsDidFocus,
MetalsInputBox,
MetalsQuickPick,
MetalsQuickPickParams,
MetalsStatus,
PublishDecorationsParams,
} from "./metalsProtocol";
import { InputBoxOptions } from "./portedProtocol";
import { TreeViewController } from "./tvp/controller";

@@ -260,14 +262,14 @@ import { TreeViewFeature } from "./tvp/feature";

const commands = [
"build-import",
"build-connect",
"build-restart",
"sources-scan",
"doctor-run",
"compile-cascade",
"compile-cancel",
"compile-clean",
"ammonite-start",
"ammonite-stop",
"new-scala-project",
"reset-choice",
ServerCommands.BuildImport,
ServerCommands.BuildConnect,
ServerCommands.BuildRestart,
ServerCommands.SourcesScan,
ServerCommands.DoctorRun,
ServerCommands.CascadeCompile,
ServerCommands.CancelCompilation,
ServerCommands.CleanCompile,
ServerCommands.AmmoniteStart,
ServerCommands.AmmoniteStop,
ServerCommands.NewScalaProject,
ServerCommands.ResetChoice,
];

@@ -299,3 +301,3 @@

registerCommand("metals.new-scala-file", async () => {
registerCommand(`metals.${ServerCommands.NewScalaFile}`, async () => {
const currentDoc = await workspace.document;

@@ -306,3 +308,3 @@ const currentPath = currentDoc.uri;

client.sendRequest(ExecuteCommandRequest.type, {
command: "new-scala-file",
command: ServerCommands.NewScalaFile,
arguments: [parentDir],

@@ -312,3 +314,3 @@ });

registerCommand("metals.go-to-super-method", async () => {
registerCommand(`metals.${ServerCommands.GotoSuperMethod}`, async () => {
const currentDoc = await workspace.document;

@@ -318,3 +320,3 @@ const position = await workspace.getCursorPosition();

client.sendRequest(ExecuteCommandRequest.type, {
command: "goto-super-method",
command: ServerCommands.GotoSuperMethod,
arguments: [

@@ -329,20 +331,23 @@ {

registerCommand("metals.super-method-hierarchy", async () => {
const currentDoc = await workspace.document;
const position = await workspace.getCursorPosition();
registerCommand(
`metals.${ServerCommands.SuperMethodHierarchy}`,
async () => {
const currentDoc = await workspace.document;
const position = await workspace.getCursorPosition();
client.sendRequest(ExecuteCommandRequest.type, {
command: "super-method-hierarchy",
arguments: [
{
document: currentDoc.uri,
position,
},
],
});
});
client.sendRequest(ExecuteCommandRequest.type, {
command: ServerCommands.SuperMethodHierarchy,
arguments: [
{
document: currentDoc.uri,
position,
},
],
});
}
);
client.onNotification(ExecuteClientCommand.type, async (params) => {
switch (params.command) {
case "metals-goto-location":
case ClientCommands.GotoLocation:
const location =

@@ -358,7 +363,7 @@ params.arguments && (params.arguments[0] as Location);

break;
case "metals-doctor-run":
case ClientCommands.RunDoctor:
const doctorJson: string = params.arguments && params.arguments[0];
makeVimDoctor(JSON.parse(doctorJson));
break;
case "metals-doctor-reload":
case ClientCommands.ReloadDoctor:
workspace.nvim.call("coc#util#has_preview").then((preview) => {

@@ -372,9 +377,9 @@ if (preview > 0) {

break;
case "metals-diagnostics-focus":
case ClientCommands.FocusDiagnostics:
workspace.nvim.command("CocList diagnostics");
break;
case "metals-logs-toggle":
case ClientCommands.ToggleLogs:
toggleLogs();
break;
case "metals-model-refresh":
case ClientCommands.RefreshModel:
// CodeLensManager from coc.nvim reloads codeLens on this event

@@ -399,12 +404,9 @@ events.fire("BufEnter", [workspace.bufnr]);

client.onRequest(MetalsInputBox.type, async (options: InputBoxOptions) => {
const response = await workspace.callAsync<string>("input", [
`${options.prompt}: `,
options.value ? options.value : "",
]);
if (response.trim() === "") {
return { cancelled: true };
} else {
return { value: response };
}
client.onRequest(MetalsInputBox.type, (options: InputBoxOptions) => {
return workspace
.callAsync<string>("input", [
`${options.prompt}: `,
options.value ? options.value : "",
])
.then(MetalsInputBox.handleInput);
});

@@ -411,0 +413,0 @@

@@ -1,46 +0,8 @@

import {
ExecuteCommandParams,
NotificationType,
RequestType,
} from "vscode-languageserver-protocol";
import { DecorationOptions, InputBoxOptions } from "./portedProtocol";
import { NotificationType } from "vscode-languageserver-protocol";
import { DecorationOptions } from "./portedProtocol";
export namespace ExecuteClientCommand {
export const type = new NotificationType<ExecuteCommandParams, void>(
"metals/executeClientCommand"
);
}
export namespace MetalsInputBox {
export const type = new RequestType<
InputBoxOptions,
MetalsInputBoxResult,
void,
void
>("metals/inputBox");
}
export interface MetalsSlowTaskParams {
message: string;
quietLogs?: boolean;
secondsElapsed?: number;
}
export interface MetalsSlowTaskResult {
cancel: boolean;
}
export interface MetalsStatusParams {
text: string;
show?: boolean;
hide?: boolean;
tooltip?: string;
command?: string;
}
export interface MetalsInputBoxResult {
value?: string;
cancelled?: boolean;
}
/**
* As much as I'd like to move the decoration protocol over to the shared
* library it's too intertwined with VS Code.
*/
export interface PublishDecorationsParams {

@@ -56,51 +18,1 @@ uri: string;

}
export namespace MetalsDidFocus {
export const type = new NotificationType<string, void>(
"metals/didFocusTextDocument"
);
}
export namespace MetalsQuickPick {
export const type = new RequestType<
MetalsQuickPickParams,
MetalsQuickPickResult,
void,
void
>("metals/quickPick");
}
export interface MetalsQuickPickParams {
items: MetalsQuickPickItem[];
matchOnDescription?: boolean;
matchOnDetail?: boolean;
placeHolder?: string;
ignoreFocusOut?: boolean;
}
export interface MetalsQuickPickResult {
itemId?: string;
cancelled?: boolean;
}
export interface MetalsQuickPickItem {
id: string;
label: string;
description?: string;
detail?: string;
alwaysShow?: boolean;
}
export namespace MetalsStatus {
export const type = new NotificationType<MetalsStatusParams, void>(
"metals/status"
);
}
export interface MetalsStatusParams {
text: string;
show?: boolean;
hide?: boolean;
tooltip?: string;
command?: string;
}

@@ -11,43 +11,2 @@ import { Range, MarkupContent } from "vscode-languageserver-protocol";

export interface InputBoxOptions {
/** * The value to prefill in the input box. */
value?: string;
/** * Selection of the prefilled [`value`](#InputBoxOptions.value). Defined as tuple of two number where the * first is the inclusive start index and the second the exclusive end index. When `undefined` the whole * word will be selected, when empty (start equals end) only the cursor will be set, * otherwise the defined range will be selected. */ valueSelection?: [
number,
number
];
/**
* The text to display underneath the input box.
*/
prompt?: string;
/**
* An optional string to show as place holder in the input box to guide the user what to type.
*/
placeHolder?: string;
/**
* Set to `true` to show a password prompt that will not show the typed value.
*/
password?: boolean;
/**
* Set to `true` to keep the input box open when focus moves to another part of the editor or to another window.
*/
ignoreFocusOut?: boolean;
/**
* An optional function that will be called to validate input and to give a hint
* to the user.
*
* @param value The current value of the input box.
* @return A human readable string which is presented as diagnostic message.
* Return `undefined`, `null`, or the empty string when 'value' is valid.
*/
validateInput?(
value: string
): string | undefined | null | Thenable<string | undefined | null>;
}
/**

@@ -54,0 +13,0 @@ * Represents options for a specific decoration in a [decoration set](#TextEditorDecorationType).

@@ -16,2 +16,3 @@ import {

MetalsTreeViewVisibilityDidChange,
ServerCommands,
} from "metals-languageclient";

@@ -121,6 +122,6 @@ import {

this.mbGotoCommandDisposable = commands.registerCommand(
"metals.goto",
`metals.${ServerCommands.Goto}`,
async (...args: any[]) => {
let params: ExecuteCommandParams = {
command: "metals.goto",
command: ServerCommands.Goto,
arguments: args,

@@ -127,0 +128,0 @@ };

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc