Socket
Socket
Sign inDemoInstall

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.7.0 to 0.7.1

src/WannaBeStatusBarItem.ts

16

lib/index.js

@@ -6,9 +6,7 @@ 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});const e=require("vscode-languageserver-protocol");var t,o,s,n,i;!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={}));
},{}],"ODYs":[function(require,module,exports) {
"use strict";var t=this&&this.__awaiter||function(t,e,s,r){return new(s||(s=Promise))(function(i,n){function o(t){try{c(r.next(t))}catch(e){n(e)}}function h(t){try{c(r.throw(t))}catch(e){n(e)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof s?e:new s(function(t){t(e)})).then(o,h)}c((r=r.apply(t,e||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0});const e=require("coc.nvim");class s{constructor(){this.frames=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],this._text="",this.counter=0,this.interval=setInterval(()=>{this.showProgress()},1e3)}createStatusBarItem(t){this._text=t;let e={update:t=>{this._text=t},dispose:()=>{clearInterval(this.interval)}};return this.showProgress(),e}getText(){void 0===this.frames[this.counter]&&(this.counter=0);const t=""!==this._text.trim()?this._text+this.frames[this.counter]:this._text;return this.counter++,t}showProgress(){return t(this,void 0,void 0,function*(){let t=this.getText();e.workspace.showMessage(t)})}}exports.default=s;
"use strict";Object.defineProperty(exports,"__esModule",{value:!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={}));
},{}],"UnXq":[function(require,module,exports) {
"use strict";var e=this&&this.__awaiter||function(e,n,o,t){return new(o||(o=Promise))(function(r,i){function s(e){try{c(t.next(e))}catch(n){i(n)}}function a(e){try{c(t.throw(e))}catch(n){i(n)}}function c(e){var n;e.done?r(e.value):(n=e.value,n instanceof o?n:new o(function(e){e(n)})).then(s,a)}c((t=t.apply(e,n||[])).next())})},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var o in e)Object.hasOwnProperty.call(e,o)&&(n[o]=e[o]);return n.default=e,n};Object.defineProperty(exports,"__esModule",{value:!0});const t=require("./commands"),r=require("coc.nvim"),i=n(require("./ProgressItem")),s=require("metals-languageclient"),a=o(require("metals-languageclient"));function c(e){const n=(new i.default).createStatusBarItem("Preparing Metals");return s.downloadProgress({download:e,onProgress:n.update,onError:n.dispose,onComplete:n.dispose})}function u(){return e(this,void 0,void 0,function*(){const e=r.workspace.getConfiguration("metals");a.checkServerVersion({config:e,updateConfig:({configSection:n,latestServerVersion:o})=>{e.update(n,o,!0)},onOutdated:({message:e,upgradeChoice:n,openSettingsChoice:o,dismissChoice:i,upgrade:s})=>{r.workspace.showQuickpick([n,o,i],e).then(e=>{0===e?s():1===e&&r.workspace.nvim.command(t.Commands.OPEN_COC_CONFIG,!0)})}})})}function d(){const e=r.workspace.documents.find(e=>e.uri.endsWith("info"));e?r.workspace.nvim.command(`bd ${e.bufnr}`):r.workspace.nvim.command(t.Commands.OPEN_LOGS)}function m(e){return new Promise(n=>{setTimeout(n,e)})}function p(){a.detectLaunchConfigurationChanges(r.workspace,({message:e,reloadWindowChoice:n,dismissChoice:o})=>r.workspace.showQuickpick([n,o],e).then(e=>{0===e&&r.workspace.nvim.command(t.Commands.RESTART_COC,!0)}))}exports.trackDownloadProgress=c,exports.checkServerVersion=u,exports.toggleLogs=d,exports.wait=m,exports.detectLaunchConfigurationChanges=p;
},{"./commands":"eojW","./ProgressItem":"ODYs"}],"OBPZ":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=require("coc.nvim");class i{fillInitializeParams(i){i.capabilities.experimental||(i.capabilities.experimental={}),i.capabilities.experimental.debuggingProvider=!1,i.capabilities.experimental.decorationProvider=e.workspace.isNvim,i.capabilities.experimental.quickPickProvider=!0,i.capabilities.experimental.inputBoxProvider=!0,i.capabilities.experimental.didFocusProvider=!0,i.capabilities.experimental.slowTaskProvider=!1,i.capabilities.experimental.executeClientCommandProvider=!0,i.capabilities.experimental.doctorProvider="json",i.capabilities.experimental.statusBarProvider="show-message"}fillClientCapabilities(){}initialize(e){e.experimental&&(this.debuggingProvider=e.experimental.debuggingProvider,this.decorationProvider=e.experimental.decorationProvider,this.quickPickProvider=e.experimental.quickPickProvider,this.inputBoxProvider=e.experimental.inputBoxProvider,this.didFocusProvider=e.experimental.didFocusProvider,this.slowTaskProvider=e.experimental.slowTaskProvider,this.executeClientCommandProvider=e.experimental.executeClientCommandProvider,this.doctorProvider=e.experimental.doctorProvider,this.statusBarProvider=e.experimental.statusBarProvider)}}exports.MetalsFeatures=i;
"use strict";var e=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))(function(r,i){function s(e){try{c(t.next(e))}catch(o){i(o)}}function a(e){try{c(t.throw(e))}catch(o){i(o)}}function c(e){var o;e.done?r(e.value):(o=e.value,o instanceof n?o:new n(function(e){e(o)})).then(s,a)}c((t=t.apply(e,o||[])).next())})},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var o={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(o[n]=e[n]);return o.default=e,o};Object.defineProperty(exports,"__esModule",{value:!0});const n=require("./commands"),t=require("coc.nvim"),r=require("metals-languageclient"),i=o(require("metals-languageclient"));function s(e,o,n){return r.downloadProgress({download:o,onProgress:o=>{n.text=e,n.show()},onError:n.dispose,onComplete:n.dispose})}function a(){return e(this,void 0,void 0,function*(){const e=t.workspace.getConfiguration("metals");i.checkServerVersion({config:e,updateConfig:({configSection:o,latestServerVersion:n})=>{e.update(o,n,!0)},onOutdated:({message:e,upgradeChoice:o,openSettingsChoice:r,dismissChoice:i,upgrade:s})=>{t.workspace.showQuickpick([o,r,i],e).then(e=>{0===e?s():1===e&&t.workspace.nvim.command(n.Commands.OPEN_COC_CONFIG,!0)})}})})}function c(){const e=t.workspace.documents.find(e=>e.uri.endsWith("info"));e?t.workspace.nvim.command(`bd ${e.bufnr}`):t.workspace.nvim.command(n.Commands.OPEN_LOGS)}function u(e){return new Promise(o=>{setTimeout(o,e)})}function d(){i.detectLaunchConfigurationChanges(t.workspace,({message:e,reloadWindowChoice:o,dismissChoice:r})=>t.workspace.showQuickpick([o,r],e).then(e=>{0===e&&t.workspace.nvim.command(n.Commands.RESTART_COC,!0)}),["statusBarEnabled","bloopVersion"])}exports.trackDownloadProgress=s,exports.checkServerVersion=a,exports.toggleLogs=c,exports.wait=u,exports.detectLaunchConfigurationChanges=d;
},{"./commands":"eojW"}],"OBPZ":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=require("coc.nvim");class i{constructor(e){this.statusBarEnabled=void 0!==e&&e}fillInitializeParams(i){i.capabilities.experimental||(i.capabilities.experimental={}),i.capabilities.experimental.debuggingProvider=!1,i.capabilities.experimental.decorationProvider=e.workspace.isNvim,i.capabilities.experimental.quickPickProvider=!0,i.capabilities.experimental.inputBoxProvider=!0,i.capabilities.experimental.didFocusProvider=!0,i.capabilities.experimental.slowTaskProvider=!1,i.capabilities.experimental.executeClientCommandProvider=!0,i.capabilities.experimental.doctorProvider="json",i.capabilities.experimental.statusBarProvider=this.statusBarEnabled?"on":"show-message"}fillClientCapabilities(){}initialize(e){e.experimental&&(this.debuggingProvider=e.experimental.debuggingProvider,this.decorationProvider=e.experimental.decorationProvider,this.quickPickProvider=e.experimental.quickPickProvider,this.inputBoxProvider=e.experimental.inputBoxProvider,this.didFocusProvider=e.experimental.didFocusProvider,this.slowTaskProvider=e.experimental.slowTaskProvider,this.executeClientCommandProvider=e.experimental.executeClientCommandProvider,this.doctorProvider=e.experimental.doctorProvider,this.statusBarProvider=e.experimental.statusBarProvider)}}exports.MetalsFeatures=i;
},{}],"p29A":[function(require,module,exports) {

@@ -28,4 +26,6 @@ "use strict";var e=this&&this.__awaiter||function(e,t,o,n){return new(o||(o=Promise))(function(r,a){function i(e){try{s(n.next(e))}catch(t){a(t)}}function c(e){try{s(n.throw(e))}catch(t){a(t)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(i,c)}s((n=n.apply(e,t||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0});const t=require("coc.nvim");class o{constructor(e){this.currentDecorations=[],this.decorationNameSpace=t.workspace.createNameSpace("worksheetDecorations"),this.floatFactory=e}setDecorations(o){return e(this,void 0,void 0,function*(){const e=t.workspace.getDocument(o.uri),{buffer:n}=e;n.clearNamespace(this.decorationNameSpace),this.currentDecorations=[],o.options.forEach(e=>{var t,o,r,a;this.currentDecorations.push(e),n.setVirtualText(this.decorationNameSpace,e.range.end.line,[[null!==(a=null===(r=null===(o=null===(t=e.renderOptions)||void 0===t?void 0:t.after)||void 0===o?void 0:o.contentText)||void 0===r?void 0:r.replace("//","‣"))&&void 0!==a?a:"","test"]])})})}showHover(){return e(this,void 0,void 0,function*(){const{position:e}=yield t.workspace.getCurrentState(),o=this.currentDecorations.find(t=>t.range.end.line===e.line);o&&"string"!=typeof o.hoverMessage&&o.hoverMessage&&(yield this.floatFactory.create([{content:o.hoverMessage.value,filetype:o.hoverMessage.language}],!0,0))})}clearDecorations(e){const o=t.workspace.getDocument(e),{buffer:n}=o;n.clearNamespace(this.decorationNameSpace),this.currentDecorations=[]}}exports.default=o;

"use strict";var e=this&&this.__awaiter||function(e,i,t,s){return new(t||(t=Promise))(function(r,o){function n(e){try{d(s.next(e))}catch(i){o(i)}}function a(e){try{d(s.throw(e))}catch(i){o(i)}}function d(e){var i;e.done?r(e.value):(i=e.value,i instanceof t?i:new t(function(e){e(i)})).then(n,a)}d((s=s.apply(e,i||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0});const i=require("vscode-languageserver-protocol"),t=require("coc.nvim");class s{constructor(e){this._client=e,this.requestType=new i.RequestType("metals/treeView"),this.treeViewChildrenParamsType=new i.RequestType("metals/treeViewChildren"),this.treeViewRevealType=new i.RequestType("metals/treeViewReveal"),this.treeViewDidChangeType=new i.NotificationType("metals/treeViewDidChange"),this.treeViewVisibilityChangedType=new i.NotificationType("metals/treeViewVisibilityDidChange"),this.treeViewNodeCollapseChangedType=new i.NotificationType("metals/treeViewNodeCollapseDidChange"),this.providerEmitter=new i.Emitter,this.viewUpdaters=new Map,this.mbGotoCommandDisposable=void 0}get messages(){return this.requestType}fillClientCapabilities(e){null==e.experimental&&(e.experimental={}),e.experimental.treeViewProvider=!0}initialize(s){if(!s.experimental.treeViewProvider)return;const r=this._client;r.onNotification(this.treeViewDidChangeType,e=>{e.nodes.forEach(e=>{const t=e.viewId,s=this.viewUpdaters.get(t);if(void 0===s){const e=new i.Emitter,s={viewId:t,updatedNodes:e.event,loadNodeChildren:e=>{const i=r.sendRequest(this.treeViewChildrenParamsType,{viewId:t,nodeUri:e}).then(e=>e.nodes);return Promise.resolve(i)},loadParentInfo:(e,i)=>{const t={line:i.line+1,character:i.character},s={textDocument:{uri:e.uri},position:t};return Promise.resolve(r.sendRequest(this.treeViewRevealType,s))},sendTreeViewVisibilityNotification:e=>{r.sendNotification(this.treeViewVisibilityChangedType,{viewId:t,visible:e})},sendTreeNodeVisibilityNotification:(e,i)=>{r.sendNotification(this.treeViewNodeCollapseChangedType,{viewId:t,nodeUri:e,collapsed:i})}};this.providerEmitter.fire(s),this.viewUpdaters.set(t,e)}else s.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 r.sendRequest(i.ExecuteCommandRequest.type,e).then(void 0,e=>{r.logFailedRequest(i.ExecuteCommandRequest.type,e)})}),null,!0)}providerEvents(){return this.providerEmitter.event}register(e,i){}unregister(e){}dispose(){this.providerEmitter.dispose(),this.viewUpdaters.forEach(e=>e.dispose()),void 0!==this.mbGotoCommandDisposable&&this.mbGotoCommandDisposable.dispose()}}exports.TreeViewFeature=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.__awaiter||function(e,t,o,a){return new(o||(o=Promise))(function(n,r){function s(e){try{c(a.next(e))}catch(t){r(t)}}function i(e){try{c(a.throw(e))}catch(t){r(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((a=a.apply(e,t||[])).next())})},t=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o in e)Object.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t.default=e,t};Object.defineProperty(exports,"__esModule",{value:!0});const a=require("./commands"),n=require("./embeddedDoctor"),r=require("metals-languageclient"),s=require("./metalsProtocol"),i=require("./utils"),c=require("coc.nvim"),u=require("vscode-languageserver-protocol"),l=require("./MetalsFeatures"),d=t(require("./decoration")),m=require("./tvp/controller"),p=require("./tvp/feature"),v=require("./tvp/treeviews"),g=o(require("path"));function h(t){return e(this,void 0,void 0,function*(){i.detectLaunchConfigurationChanges(),yield i.checkServerVersion(),r.getJavaHome(c.workspace.getConfiguration("metals").get("javaHome")).then(e=>w(t,e),()=>{c.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&&c.workspace.nvim.command(a.Commands.OPEN_COC_CONFIG,!0)})})})}function w(e,t){var o,n,s;const u=r.checkDottyIde(null===(o=c.workspace.workspaceFolder)||void 0===o?void 0:o.uri);if(u.enabled)return void c.workspace.showMessage("Metals will not start since Dotty is enabled for this workspace. "+`To enable Metals, remove the file ${u.path} and run ':CocCommand metals.restartServer'`,"warning");const l=c.workspace.getConfiguration("metals"),d=l.get("serverVersion"),m=l.inspect("serverVersion").defaultValue,p=d||m,v=null!==(n=l.get("serverProperties"))&&void 0!==n?n:[],g=l.get("customRepositories "),h=r.getJavaConfig({workspaceRoot:null===(s=c.workspace.workspaceFolder)||void 0===s?void 0:s.uri,javaHome:t,customRepositories:g,extensionPath:e.extensionPath}),w=r.fetchMetals({serverVersion:p,serverProperties:v,javaConfig:h});i.trackDownloadProgress(w).then(t=>{f(e,t,v,h)},()=>{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 p===m?"Failed to download Metals, make sure you have an internet connection and "+`the Java Home '${t}' 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 '${p}' is correct and the Java Home '${t}' is valid. `+"You can configure the Metals version and Java Home in the settings."+e})();c.workspace.showPrompt(`${e}\n Open Settings?`).then(e=>{e&&c.workspace.nvim.command(a.Commands.OPEN_COC_CONFIG,!0)})})}function f(t,o,a,h){const w=r.getServerOptions({metalsClasspath:o,serverProperties:a,javaConfig:h,clientName:"coc-metals"}),f={documentSelector:[{scheme:"file",language:"scala"}],synchronize:{configurationSection:"metals"},revealOutputChannelOn:c.RevealOutputChannelOn.Never},k=new c.LanguageClient("metals","Metals",w,f),y=new l.MetalsFeatures,C=new p.TreeViewFeature(k);k.registerFeature(y),k.registerFeature(C);const b=new c.FloatFactory(c.workspace.nvim,c.workspace.env,!1,100,100,!0),M=new d.default(b),q=new v.TreeViewsManager(c.workspace.nvim,t.logger),O=new m.TreeViewController(C,q);function P(e,o){t.subscriptions.push(c.commands.registerCommand(e,o))}t.subscriptions.push(C,q,O),P("metals.restartServer",r.restartServer(k,c.workspace)),t.subscriptions.push(k.start()),k.onReady().then(o=>{c.workspace.showMessage("Metals is ready!");["build-import","build-connect","sources-scan","doctor-run","compile-cascade","compile-cancel"].forEach(t=>{P("metals."+t,()=>e(this,void 0,void 0,function*(){c.workspace.showMessage("metals"+t),k.sendRequest(u.ExecuteCommandRequest.type,{command:t})}))}),P("metals.logs-toggle",()=>{i.toggleLogs()}),y.decorationProvider&&t.subscriptions.push(c.workspace.registerKeymap(["n"],"metals-expand-decoration",()=>{M.showHover()},{sync:!1})),P("metals.new-scala-file",()=>e(this,void 0,void 0,function*(){const e=(yield c.workspace.document).uri,t=g.dirname(e);k.sendRequest(u.ExecuteCommandRequest.type,{command:"new-scala-file",arguments:[t]})})),k.onNotification(s.ExecuteClientCommand.type,t=>e(this,void 0,void 0,function*(){switch(t.command){case"metals-goto-location":const e=t.arguments&&t.arguments[0];e&&(yield q.prepareWindowForGoto(),yield i.wait(10),yield c.workspace.jumpTo(e.uri,e.range.start));break;case"metals-doctor-run":const o=t.arguments&&t.arguments[0];n.makeVimDoctor(JSON.parse(o));break;case"metals-doctor-reload":c.workspace.nvim.call("coc#util#has_preview").then(e=>{if(e>0){const e=t.arguments&&t.arguments[0];n.makeVimDoctor(JSON.parse(e))}});break;case"metals-diagnostics-focus":c.workspace.nvim.command("CocList diagnostics");break;case"metals-logs-toggle":i.toggleLogs();break;default:c.workspace.showMessage(`Recieved unknown command: ${t.command}`)}})),c.events.on("BufWinEnter",e=>{const t=c.workspace.documents.find(t=>t.bufnr===e);t&&"scala"===t.filetype&&k.sendNotification(s.MetalsDidFocus.type,t.uri)}),k.onRequest(s.MetalsInputBox.type,t=>e(this,void 0,void 0,function*(){const e=yield c.workspace.callAsync("input",[`${t.prompt}: `,t.value?t.value:""]);return""===e.trim()?{cancelled:!0}:{value:e}})),k.onRequest(s.MetalsQuickPick.type,(e,t)=>c.workspace.showQuickpick(e.items.map(e=>e.label),e.placeHolder).then(t=>-1===t?{cancelled:!0}:{itemId:e.items[t].id})),y.decorationProvider&&(k.onNotification(s.DecorationsRangesDidChange.type,e=>{c.workspace.uri&&c.workspace.uri===e.uri&&M.setDecorations(e)}),c.events.on("BufWinLeave",e=>{const t=c.workspace.documents.find(t=>t.bufnr===e);t&&t.uri.endsWith(".worksheet.sc")&&M.clearDecorations(e)}))})}exports.activate=h;
},{"./commands":"eojW","./embeddedDoctor":"BTOZ","./metalsProtocol":"z7J4","./utils":"UnXq","./MetalsFeatures":"OBPZ","./decoration":"p29A","./tvp/controller":"bAI2","./tvp/feature":"Y104","./tvp/treeviews":"GgEX"}]},{},["QCba"], null)
"use strict";var e=this&&this.__awaiter||function(e,t,o,a){return new(o||(o=Promise))(function(r,n){function s(e){try{c(a.next(e))}catch(t){n(t)}}function i(e){try{c(a.throw(e))}catch(t){n(t)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(s,i)}c((a=a.apply(e,t||[])).next())})},t=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o in e)Object.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t.default=e,t};Object.defineProperty(exports,"__esModule",{value:!0});const a=require("./commands"),r=require("./embeddedDoctor"),n=require("metals-languageclient"),s=require("./metalsProtocol"),i=require("./utils"),c=require("coc.nvim"),u=require("vscode-languageserver-protocol"),l=require("./MetalsFeatures"),d=t(require("./decoration")),m=require("./tvp/controller"),p=require("./tvp/feature"),v=require("./tvp/treeviews"),g=o(require("path")),h=t(require("./WannaBeStatusBarItem"));function w(t){return e(this,void 0,void 0,function*(){i.detectLaunchConfigurationChanges(),yield i.checkServerVersion(),n.getJavaHome(c.workspace.getConfiguration("metals").get("javaHome")).then(e=>f(t,e),()=>{c.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&&c.workspace.nvim.command(a.Commands.OPEN_COC_CONFIG,!0)})})})}function f(e,t){var o,r,s;const u=n.checkDottyIde(null===(o=c.workspace.workspaceFolder)||void 0===o?void 0:o.uri);if(u.enabled)return void c.workspace.showMessage("Metals will not start since Dotty is enabled for this workspace. "+`To enable Metals, remove the file ${u.path} and run ':CocCommand metals.restartServer'`,"warning");const l=c.workspace.getConfiguration("metals"),d=l.get("serverVersion"),m=l.inspect("serverVersion").defaultValue,p=d||m,v=null!==(r=l.get("serverProperties"))&&void 0!==r?r:[],g=l.get("customRepositories "),w=n.getJavaConfig({workspaceRoot:null===(s=c.workspace.workspaceFolder)||void 0===s?void 0:s.uri,javaHome:t,customRepositories:g,extensionPath:e.extensionPath}),f=n.fetchMetals({serverVersion:p,serverProperties:v,javaConfig:w}),y=l.get("statusBarEnabled"),C=y?c.workspace.createStatusBarItem(0,{progress:!0}):new h.default(0,!0,"Preparing Metals"),b=`Downloading Metals v${p}`;i.trackDownloadProgress(b,f,C).then(t=>{k(e,t,v,w,C,y)},()=>{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 p===m?"Failed to download Metals, make sure you have an internet connection and "+`the Java Home '${t}' 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 '${p}' is correct and the Java Home '${t}' is valid. `+"You can configure the Metals version and Java Home in the settings."+e})();c.workspace.showPrompt(`${e}\n Open Settings?`).then(e=>{e&&c.workspace.nvim.command(a.Commands.OPEN_COC_CONFIG,!0)})})}function k(t,o,a,h,w,f){const k=n.getServerOptions({metalsClasspath:o,serverProperties:a,javaConfig:h,clientName:"coc-metals"}),y={documentSelector:[{scheme:"file",language:"scala"}],synchronize:{configurationSection:"metals"},revealOutputChannelOn:c.RevealOutputChannelOn.Never},C=new c.LanguageClient("metals","Metals",k,y),b=new l.MetalsFeatures(f),M=new p.TreeViewFeature(C);C.registerFeature(b),C.registerFeature(M);const q=new c.FloatFactory(c.workspace.nvim,c.workspace.env,!1,100,100,!0),P=new d.default(q),O=new v.TreeViewsManager(c.workspace.nvim,t.logger),x=new m.TreeViewController(M,O);function S(e,o){t.subscriptions.push(c.commands.registerCommand(e,o))}t.subscriptions.push(M,O,x),S("metals.restartServer",n.restartServer(C,c.workspace)),t.subscriptions.push(C.start()),C.onReady().then(o=>{w.isProgress=!1,w.text="Metals is Ready!",w.show();if(["build-import","build-connect","build-restart","sources-scan","doctor-run","compile-cascade","compile-cancel"].forEach(t=>{S("metals."+t,()=>e(this,void 0,void 0,function*(){c.workspace.showMessage("metals"+t),C.sendRequest(u.ExecuteCommandRequest.type,{command:t})}))}),S("metals.logs-toggle",()=>{i.toggleLogs()}),b.decorationProvider&&t.subscriptions.push(c.workspace.registerKeymap(["n"],"metals-expand-decoration",()=>{P.showHover()},{sync:!1})),S("metals.new-scala-file",()=>e(this,void 0,void 0,function*(){const e=(yield c.workspace.document).uri,t=g.dirname(e);C.sendRequest(u.ExecuteCommandRequest.type,{command:"new-scala-file",arguments:[t]})})),C.onNotification(s.ExecuteClientCommand.type,t=>e(this,void 0,void 0,function*(){switch(t.command){case"metals-goto-location":const e=t.arguments&&t.arguments[0];e&&(yield O.prepareWindowForGoto(),yield i.wait(10),yield c.workspace.jumpTo(e.uri,e.range.start));break;case"metals-doctor-run":const o=t.arguments&&t.arguments[0];r.makeVimDoctor(JSON.parse(o));break;case"metals-doctor-reload":c.workspace.nvim.call("coc#util#has_preview").then(e=>{if(e>0){const e=t.arguments&&t.arguments[0];r.makeVimDoctor(JSON.parse(e))}});break;case"metals-diagnostics-focus":c.workspace.nvim.command("CocList diagnostics");break;case"metals-logs-toggle":i.toggleLogs();break;default:c.workspace.showMessage(`Recieved unknown command: ${t.command}`)}})),c.events.on("BufWinEnter",e=>{const t=c.workspace.documents.find(t=>t.bufnr===e);t&&"scala"===t.filetype&&C.sendNotification(s.MetalsDidFocus.type,t.uri)}),C.onRequest(s.MetalsInputBox.type,t=>e(this,void 0,void 0,function*(){const e=yield c.workspace.callAsync("input",[`${t.prompt}: `,t.value?t.value:""]);return""===e.trim()?{cancelled:!0}:{value:e}})),C.onRequest(s.MetalsQuickPick.type,(e,t)=>c.workspace.showQuickpick(e.items.map(e=>e.label),e.placeHolder).then(t=>-1===t?{cancelled:!0}:{itemId:e.items[t].id})),f){const e=c.workspace.createStatusBarItem(0);C.onNotification(s.MetalsStatus.type,t=>{e.text=t.text,t.show?e.show():t.hide&&e.hide()})}b.decorationProvider&&(C.onNotification(s.DecorationsRangesDidChange.type,e=>{c.workspace.uri&&c.workspace.uri===e.uri&&P.setDecorations(e)}),c.events.on("BufWinLeave",e=>{const t=c.workspace.documents.find(t=>t.bufnr===e);t&&t.uri.endsWith(".worksheet.sc")&&P.clearDecorations(e)}))})}exports.activate=w;
},{"./commands":"eojW","./embeddedDoctor":"BTOZ","./metalsProtocol":"z7J4","./utils":"UnXq","./MetalsFeatures":"OBPZ","./decoration":"p29A","./tvp/controller":"bAI2","./tvp/feature":"Y104","./tvp/treeviews":"GgEX","./WannaBeStatusBarItem":"n7Rg"}]},{},["QCba"], null)
{
"name": "coc-metals",
"version": "0.7.0",
"version": "0.7.1",
"description": "coc.nvim extension for Metals, the Scala language server",

@@ -108,2 +108,10 @@ "keywords": [

},
"metals.bloopVersion": {
"type": "string",
"markdownDescription": "This version will be used for the Bloop build tool plugin, for any supported build tool, while importing in Metals as well as for running the embedded server"
},
"metals.bloopSbtAlreadyInstalled": {
"type": "boolean",
"markdownDescription": "If true, Metals will not generate a `project/metals.sbt` file under the assumption that sbt-bloop is already manually installed in the sbt build. Build import will fail with a 'not valid command bloopInstall' error in case Bloop is not manually installed in the build when using this option."
},
"metals.customRepositories": {

@@ -117,2 +125,7 @@ "type": "array",

},
"metals.statusBarEnabled": {
"type": "boolean",
"default": false,
"markdownDescription": "Turn on usage of the statusBar integration.\n\nNote: You need to ensure you are adding something like `%{coc#status()}` in order to display it, or use a plugin with status integration."
},
"metals.treeviews.initialWidth": {

@@ -229,2 +242,7 @@ "type": "number",

{
"command": "metals.build-restart",
"category": "Metals",
"title": "Restart Bloop server"
},
{
"command": "metals.sources-scan",

@@ -277,3 +295,3 @@ "category": "Metals",

"devDependencies": {
"@types/node": "^13.7.6",
"@types/node": "^13.7.7",
"npm-run-all": "^4.1.5",

@@ -284,7 +302,7 @@ "parcel-bundler": "^1.12.4",

"ts-loader": "^6.0.3",
"typescript": "3.8.2"
"typescript": "3.8.3"
},
"dependencies": {
"coc.nvim": "0.0.74",
"metals-languageclient": "0.1.19",
"coc.nvim": "0.0.75",
"metals-languageclient": "0.1.20",
"promisify-child-process": "^3.1.3",

@@ -291,0 +309,0 @@ "vscode-languageserver-protocol": "3.15.0-next.6"

@@ -234,2 +234,3 @@

- `metals.build-connect`
- `metails.build-restart`
- `metals.sources-scan`

@@ -274,2 +275,5 @@ - `metals.compile-cascade`

`metals.customRepositories` | Optional list of custom resolvers passed to Coursier when fetching metals dependencies. For documentation on accepted values see the [Coursier documentation](https://get-coursier.io/docs/other-repositories). The extension will pass these to Coursier using the COURSIER_REPOSITORIES environment variable after joining the custom repositories with a pipe character (|).
`metals.bloopVersion` | This version will be used for the Bloop build tool plugin, for any supported build tool,while importing in Metals as well as for running the embedded server
`metals.bloopSbtAlreadyInstalled` | If true, Metals will not generate a `project/metals.sbt` file under the assumption that sbt-bloop is already manually installed in the sbt build. Build import will fail with a 'not valid command bloopInstall' error in case Bloop is not manually installed in the build when using this option.
`metals.statusBarEnabled` | Turn on usage of the statusBar integration. Note: You need to ensure you are adding something like `%{coc#status()}` in order to display it, or use a plugin that includes a status integration.
`metals.treeviews.toggleNode` | Expand / Collapse tree node (default `<CR>`)

@@ -311,30 +315,40 @@ `metals.treeviews.initialWidth` | Initial Tree Views panels (default `40`)

It's recommended to use a statusline integration with `coc-metals` in order to
allow messages to be displayed in your status line rather than as a message. This
will allow for a better experience with as you can continue to get status
information while entering a command or responding to a prompt. However, we
realize that not everyone by default will have this setup, and since the user
needs to see messages about the status of their build, the following is
defaulted to false.
```json
"metals.statusBarEnabled": true
```
Again, it's recommended to make this active, and use a statusline plugin, or
manually add the coc status information into your statusline.
`coc.nvim` has multiple ways to integrate with various statusline plugins. You can find instructions
for each of them located [here](https://github.com/neoclide/coc.nvim/wiki/Statusline-integration).
Two noteworthy things that they add are the ability to see diagnostic information in the current
buffer...
If you're unsure of what to use, [vim-airline](https://github.com/vim-airline/vim-airline) is a
great minimal choice that will work out of the box.
With [vim-airline](https://github.com/vim-airline/vim-airline), you'll notice two noteworthy,
things. The first will be that you'll have diagnostic information on the far
right of your screen.
![Diagnostic statusline](https://i.imgur.com/7uNYTYl.png)
... and also progress information for longer standing processes.
You'll also have metals status information in your status bar.
![Progress item](https://i.imgur.com/AAWZ4o4.png)
![Status bar info](https://i.imgur.com/eCAgrCn.png)
If you don't use a statusline integration, but would still like to see this information, the easiest
way is to add the following to your `.vimrc`.
Without a statusline integration, you'll get messages like you see below.
```vim
set statusline^=%{coc#status()}
```
The `coc#status()` function will display both status and diagnostic information. However, if you are
using an integration like I am in the photos that display your diagnostic information in the far
right, but you'd like to see the status information in the middle, you can make a small function to
just grab that information, and use it in your statusline. This is what I use for lightline to
display only the status information in the middle of the statusline (`section_c`).
![No status line](https://i.imgur.com/XF7A1BJ.png)
If you don't use a statusline plugin, but would still like to see this information, the easiest
way is to make sure you have the following in your `.vimrc`.
```vim
function! CocExtensionStatus() abort
return get(g:, 'coc_status', '')
endfunction
let g:airline_section_c = '%f%{CocExtensionStatus()}'
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
```

@@ -341,0 +355,0 @@

@@ -19,3 +19,4 @@ import { Commands } from "./commands";

PublishDecorationsParams,
MetalsQuickPickParams
MetalsQuickPickParams,
MetalsStatus
} from "./metalsProtocol";

@@ -37,3 +38,4 @@ import {

events,
FloatFactory
FloatFactory,
StatusBarItem
} from "coc.nvim";

@@ -51,2 +53,3 @@ import {

import * as path from "path";
import WannaBeStatusBarItem from "./WannaBeStatusBarItem";

@@ -109,5 +112,19 @@ export async function activate(context: ExtensionContext) {

trackDownloadProgress(fetchProcess).then(
const statusBarEnabled = config.get<boolean>("statusBarEnabled");
const progress: StatusBarItem = statusBarEnabled
? workspace.createStatusBarItem(0, { progress: true })
: new WannaBeStatusBarItem(0, true, "Preparing Metals");
const title = `Downloading Metals v${serverVersion}`;
trackDownloadProgress(title, fetchProcess, progress).then(
classpath => {
launchMetals(context, classpath, serverProperties, javaConfig);
launchMetals(
context,
classpath,
serverProperties,
javaConfig,
progress,
statusBarEnabled
);
},

@@ -145,3 +162,5 @@ () => {

serverProperties: string[],
javaConfig: JavaConfig
javaConfig: JavaConfig,
progress: StatusBarItem,
statusBarEnabled: boolean | undefined
) {

@@ -170,3 +189,3 @@ const serverOptions = getServerOptions({

const features = new MetalsFeatures();
const features = new MetalsFeatures(statusBarEnabled);
const treeViewFeature = new TreeViewFeature(client);

@@ -184,4 +203,4 @@ client.registerFeature(features);

);
const decorationProvider = new DecorationProvider(floatFactory);
const treeViewsManager = new TreeViewsManager(workspace.nvim, context.logger);

@@ -207,3 +226,5 @@ const treeViewController = new TreeViewController(

client.onReady().then(_ => {
workspace.showMessage("Metals is ready!");
progress.isProgress = false;
progress.text = "Metals is Ready!";
progress.show();

@@ -213,2 +234,3 @@ const commands = [

"build-connect",
"build-restart",
"sources-scan",

@@ -330,2 +352,14 @@ "doctor-run",

if (statusBarEnabled) {
const statusItem = workspace.createStatusBarItem(0);
client.onNotification(MetalsStatus.type, params => {
statusItem.text = params.text;
if (params.show) {
statusItem.show();
} else if (params.hide) {
statusItem.hide();
}
});
}
if (features.decorationProvider) {

@@ -332,0 +366,0 @@ client.onNotification(

@@ -18,2 +18,12 @@ import {

export class MetalsFeatures implements StaticFeature {
private statusBarEnabled: boolean;
constructor(statusBarEnabled: boolean | undefined) {
if (statusBarEnabled !== undefined) {
this.statusBarEnabled = statusBarEnabled;
} else {
this.statusBarEnabled = false;
}
}
debuggingProvider?: DebuggingProvider;

@@ -43,4 +53,6 @@ decorationProvider?: DecorationProvider;

(params.capabilities.experimental as any).doctorProvider = "json";
(params.capabilities.experimental as any).statusBarProvider =
"show-message";
(params.capabilities.experimental as any).statusBarProvider = this
.statusBarEnabled
? "on"
: "show-message";
}

@@ -47,0 +59,0 @@ fillClientCapabilities(): void {}

@@ -93,1 +93,15 @@ import {

}
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;
}
import { Commands } from "./commands";
import { workspace } from "coc.nvim";
import { workspace, StatusBarItem } from "coc.nvim";
import { ChildProcessPromise } from "promisify-child-process";
import ProgressItem from "./ProgressItem";
import { downloadProgress } from "metals-languageclient";

@@ -10,8 +9,12 @@ import * as metalsLanguageClient from "metals-languageclient";

export function trackDownloadProgress(
download: ChildProcessPromise
title: string,
download: ChildProcessPromise,
progress: StatusBarItem
): Promise<string> {
const progress = new ProgressItem().createStatusBarItem("Preparing Metals");
return downloadProgress({
download,
onProgress: progress.update,
onProgress: _ => {
progress.text = title;
progress.show();
},
onError: progress.dispose,

@@ -80,4 +83,5 @@ onComplete: progress.dispose

});
}
},
["statusBarEnabled", "bloopVersion"]
);
}
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