{"id":13479088,"url":"https://github.com/scalameta/coc-metals","last_synced_at":"2025-03-27T09:30:38.093Z","repository":{"id":36468248,"uuid":"224037257","full_name":"scalameta/coc-metals","owner":"scalameta","description":"Deprecated in favor of scalameta/nvim-metals","archived":true,"fork":false,"pushed_at":"2022-06-22T20:14:09.000Z","size":1572,"stargazers_count":166,"open_issues_count":14,"forks_count":24,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-03-19T07:05:43.335Z","etag":null,"topics":["language-server-client","lsp","metals","neovim","scala","tooling","vim"],"latest_commit_sha":null,"homepage":"http://scalameta.org/metals/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scalameta.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-25T20:40:30.000Z","updated_at":"2024-11-29T05:03:42.000Z","dependencies_parsed_at":"2022-09-17T12:01:01.421Z","dependency_job_id":null,"html_url":"https://github.com/scalameta/coc-metals","commit_stats":null,"previous_names":[],"tags_count":48,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalameta%2Fcoc-metals","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalameta%2Fcoc-metals/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalameta%2Fcoc-metals/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalameta%2Fcoc-metals/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scalameta","download_url":"https://codeload.github.com/scalameta/coc-metals/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245817317,"owners_count":20677264,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["language-server-client","lsp","metals","neovim","scala","tooling","vim"],"created_at":"2024-07-31T16:02:09.106Z","updated_at":"2025-03-27T09:30:37.762Z","avatar_url":"https://github.com/scalameta.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","Deprecated"],"sub_categories":[],"readme":"# coc-metals (Deprecated in favor of [nvim-metals](https://github.com/scalameta/nvim-metals)).\n\n**NOTE**: `coc-metals` is now deprecated with last supported Metals version\nbeing 0.11.2. The official recommendation for Metals support in Vim is to use\n[Neovim](https://neovim.io/) and\n[nvim-metals](https://github.com/scalameta/nvim-metals). You can see the full\ncontext for this dececision\n[here](https://github.com/scalameta/coc-metals/issues/460) and you can find\nup-to-date instructins on Vim/Neovim support on the [Metals\nwebste](https://scalameta.org/metals/docs/editors/vim/). If you're a\n`coc-metals` user and would like to see continued support, I will still accept\nprs and provide guidance so feel free to reach out.\n\n\n![coc-metals](https://i.imgur.com/zofu4VI.png)\n![npm](https://img.shields.io/npm/v/coc-metals?style=flat-square)\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ce92ac.svg?style=flat-square)](https://github.com/prettier/prettier)\n[![Gitter](https://img.shields.io/gitter/room/scalameta/metals-vim?style=flat-square)](https://gitter.im/scalameta/metals-vim)\n\n`coc-metals` is the recommended `coc.nvim` extension for\n[Metals](https://scalameta.org/metals/), the Scala language server. `coc-metals`\noffers automated Metals installation, easy configuration, Metals-specific\ncommands, an embedded doctor, implementation of the decoration protocol, and\nmany other small features.\n\n***NOTE: The readme is up-to-date with the main branch, so not all features\nwill be available if you're using the latest stable release. The [vim\npage](https://scalameta.org/metals/docs/editors/vim.html) on the Metals site is\nsynced with the latest stable release***\n\n## Table of Contents\n  - [Requirements](#requirements)\n  - [Installing coc-metals](#installing-coc-metals)\n  - [Importing a build](#importing-a-build)\n    - [Custom sbt launcher](#custom-sbt-launcher)\n    - [Speeding up import](#speeding-up-import)\n    - [Importing changes](#importing-changes)\n  - [Configure Java version](#configure-java-version)\n  - [Using latest Metals SNAPSHOT](#using-latest-metals-snapshot)\n  - [List all workspace compile errors](#list-all-workspace-compile-errors)\n  - [Run doctor](#run-doctor)\n  - [Worksheets](#worksheets)\n  - [Tree View Protocol](#tree-view-protocol)\n  - [Goto Super Method](#goto-super-method)\n  - [All Available Commands](#all-available-commands)\n  - [Show document symbols](#show-document-symbols)\n  - [Available Configuration Options](#available-configuration-options)\n  - [Enable on type formatting for multiline string formatting](#enable-on-type-formatting-for-multiline-string-formatting)\n  - [Shut down the language server](#shut-down-the-language-server)\n  - [Statusline integration](#statusline-integration)\n  - [Formatting on save](#formatting-on-save)\n  - [Analyzing Stacktraces](#analyzing-stacktraces)\n  - [Debugging](#debugging)\n  - [Gitignore](#gitignore)\n  - [Troubleshooting](#troubleshooting)\n  - [Contributing](#contributing)\n  - [Theme](#theme)\n\n### Requirements\n\n***`coc-metals` works with both [Vim](https://www.vim.org/) and\n[Neovim](https://neovim.io/), but we recommend neovim for a smoother experience\nand extra features such as the decoration protocol.***\n\n- [coc.nvim](https://github.com/neoclide/coc.nvim) - There are detailed\n    instructions in their repo on how to get set up and running quickly.\n- Java 8 or 11 provided by OpenJDK or Oracle. Eclipse OpenJ9 is not supported,\n    please make sure the JAVA_HOME environment variable points to a valid Java 8 or\n    11 installation.\n- Node \u003e= 10 in order for coc.nvim to work correctly.\n- ***`coc.nvim` doesn't come with a default mapping for LSP commands, so you\n    need to configure this in order for any of the commands to work. You can find\n    an example configuration and instructions [here](coc-mappings.vim)***\n\n### Installing coc-metals\n\nOnce you have `coc.nvim` installed, you can then install Metals a few different\nways, but the easiest is by running.\n\n```vim\n:CocInstall coc-metals\n```\n\nIf you install this way and are using the latest stable of coc.nvim, then daily\nyour extensions will get checked to see if they are up to date. However, this is\nchanging and has already changed in main. So in that case, you'll need to\nissue the `:CocUpdate` to update your extensions. If you install with this\nmethod youc an also see the version of your extensions by doing a `:CocList\nextensions`.\n\nIf you'd like to use the latest changes on main, but manage it using a plugin\nmanager to download the extension, then if you are using\n[`vim-plug`](https://github.com/junegunn/vim-plug) for example, enter the\nfollowing into where you manage your plugins:\n\n```vim\nPlug 'scalameta/coc-metals', {'do': 'yarn install --frozen-lockfile'}\n```\n\nThen, issue a `:PlugInstall` to install the extension, and regularly a\n`:PlugUpdate` to update it and pull in the latest changes.\n\n*** Keep in mind that if you are installing directly from the repo via\n`:CocInstall` with the repository url or through a plugin manager, remove\n`coc-metals` with `:CocUninstall coc-metals` before you add it in with one of\nthe other methods to not conflict with one another.\n\n### Importing a build\n\nThe first time you open Metals in a new workspace it prompts you to import the\nbuild. Click \"Import build\" to start the installation step.\n\n![Build Import](https://i.imgur.com/1EyQPTC.png)\n\n- \"Not now\" disables this prompt for 2 minutes.\n- \"Don't show again\" disables this prompt indefinitely. If you'd like to get\n    this choice again, execute the `metals.reset-choice` command which will\n    interactively allow you to reset choices that you've made for various\n    things.\n- Use tail -f .metals/metals.log to watch the build import progress.\n- Behind the scenes, Metals uses Bloop to import sbt builds, but you don't need\n    Bloop installed on your machine to run this step.\n\nOnce the import step completes, compilation starts for your open *.scala files.\n\nOnce the sources have compiled successfully, you can navigate the codebase with\ngoto definition.\n\n#### Custom sbt launcher\n\nBy default, Metals runs an embedded sbt-launch.jar launcher that respects\n.sbtopts and .jvmopts.  However, the environment variables SBT_OPTS and\nJAVA_OPTS are not respected.\n\nUpdate the metals.sbtScript setting to use a custom sbt script instead of the\ndefault Metals launcher if you need further customizations like reading\nenvironment variables.\n\n![sbt-launcher](https://i.imgur.com/meciPTg.png)\n\n#### Speeding up import\n\nThe \"Import build\" step can take a long time, especially the first time you run\nit in a new build.  The exact time depends on the complexity of the build and if\nlibrary dependencies need to be downloaded. For example, this step can take\neverything from 10 seconds in small cached builds up to 10-15 minutes in large\nuncached builds.\n\nConsult the Bloop documentation to learn how to speed up build import.\n\n#### Importing changes\n\nWhen you change build.sbt or sources under project/, you will be prompted to\nre-import the build.\n\n![Build Re-Import](https://i.imgur.com/iocTVb6.png)\n\n### Configure Java version\nThe `coc-metals` extension uses by default the `JAVA_HOME` environment variable\n(via [`find-java-home`](https://www.npmjs.com/package/find-java-home)) to locate\nthe `java` executable.\n\n![No Java Home](https://i.imgur.com/clDfPMk.png)\n\nIf no `JAVA_HOME` is detected you can then Open Settings by following the\ninstructions or do it at a later time by using `:CocConfig` or `:CocConfigLocal`\nwhich will open up your configuration where you can manually enter your\nJAVA_HOME location.\n\n![java-home](https://i.imgur.com/wK07Vju.png)\n\n`coc.nvim` uses [jsonc](https://code.visualstudio.com/docs/languages/json) as\na configuration file format. It's basically json with comment support.\n\nIn order to get comment highlighting, please add:\n\n```vim\nautocmd FileType json syntax match Comment +\\/\\/.\\+$+\n```\n\n### Using latest Metals SNAPSHOT\n\nUpdate the \"Server Version\" setting to try out the latest pending Metals\nfeatures.\n\nAfter updating the version, you'll be triggered to reload the window.\nThis will be necessary before the new version will be downloaded and used.\n\n![Update Metals Version](https://i.imgur.com/VUCdQvi.png)\n\n\n### List all workspace compile errors\n\nTo list all compilation errors and warnings in the workspace, run the following\ncommand.\n\n```vim\n:CocList diagnostics\n```\n\nOr use the default recommended mapping `\u003cspace\u003e a`.\n\nThis is helpful to see compilation errors in different files from your current\nopen buffer.\n\n![Diagnostics](https://i.imgur.com/cer22HW.png)\n\nIf you'd like to get all of the workspace diagnostics in your statusBar since by\ndefault you will only see the diagnostics for the buffer, you can find a section\n[here in the wiki](https://github.com/scalameta/coc-metals/wiki/Commonly-Asked-Questions#how-do-i-get-all-the-workspace-diagnostics-like-leader-a-gives-me-instead-of-just-the-local-buffer)\nexplaing how to do it.\n\n### Run doctor\n\nTo troubleshoot problems with your build workspace, open your coc commands by either\nusing `:CocCommand` or the recommend mapping `\u003cspace\u003e c`. This will open your command\nwindow allowing you to search for `metals.doctor-run` command.\n\n![Run Doctor Command](https://i.imgur.com/QaqhxF7.png)\n\nThis command opens an embedded doctor in your preview window. If you're not familiar with\nhaving multiple windows, you can use `\u003cC-w\u003e + w` to jump into it.\n\n![Embedded Doctor](https://i.imgur.com/mgnRXse.png)\n\n### Worksheets\n\nMetals allows users to create a `*.worksheet.sc` file and see evaluations right\nin their file. In Vim, this is done using comments that are inserted which will\nallow you to hover on them to expand. In Neovim, this is done using Neovim's\n[virtual text](https://neovim.io/doc/user/api.html#nvim_buf_set_virtual_text())\nto implement Metal's [Decoration\nProtocol](https://scalameta.org/metals/docs/editors/decoration-protocol.html).\nIf using Neovim, make sure to have the following line included in your `.vimrc`\nalong with your `coc.nvim` mappings.  Also keep in mind that the worksheet needs\nto be created inside of your project to have access to your dependencies etc. If\nyou create them in the root of your project for example, your worksheet will\nonly have access to the standard lib.\n\n```vim\nnmap \u003cLeader\u003ews \u003cPlug\u003e(coc-metals-expand-decoration)\n```\nThen, when on the line that you'd like to expand the decoration to get the hover\ninformation, execute a `\u003cleader\u003ews` in order to see the expanded text for that\nline.\n\n![Decorations with worksheets](https://i.imgur.com/Bt6DMtH.png)\n\n**NOTE** Keep in mind that you can also directly import dependencies is your\nworksheet just like you would in an Ammonite script. This is a great way to try\nsomething out without changing your build definition.\n\n### Tree View Protocol\n\n![Tree View Protocol](https://i.imgur.com/GvcU9Mu.gif)\n\ncoc-metals has a built-in implementation of the [Tree View\nProtocol](https://scalameta.org/metals/docs/editors/tree-view-protocol.html).\nIf you have the [recommended mappings](coc-mappings.vim) copied, you'll notice\nthat in the bottom you'll have some TVP related settings. You can start by\nopening the TVP panel by using the default `\u003cspace\u003e t`. Once open, you'll see\nthere are three parts to the panel. The first being the `MetalsCompile` window\nwhere you can see ongoing compilations, the second is the `MetalsPackages`\nwindow where you are able to see a tree view of all your packages, and finally\nthe `metalsBuild` window where you have build related commands.\n\nYou are able to trigger the commands while being on top of the option you are\nattempting to trigger and pressing `r`. You can change this default in the\nsettings. You can find all the relevant TVP settings below in the [Available\nConfiguration Options](#available-configuration-options).\n\n### Goto Super Method\n\nDepending on whether you're using Vim or Neovim, you'll have a slightly\ndifferent behavior with this feature. If you're using Neovim, you'll want to\nensure that you have `codeLens.enable` set to `true` in your Coc Config since\nyou'll be able to quickly see via code lenses which members are overridden.\nThen, you'll be able to simply trigger a code lens action on the line of the\nmember that is overridden. The default mapping for this is `\u003cleader\u003e cl`.\n\nIf you're using Vim, you'll still have access to this functionality, but you'll\nhave to infer which members are overridden and utilize the\n`metals.goto-super-method` command.\n\nThere is also a `metals.super-method-hierarchy` command which will show you the\nentire hierarchy of the overridden method.\n\n![Goto super method](https://i.imgur.com/TkjolXq.png)\n\nIf you don't utilize this feature you can disable it by setting\n`metals.superMethodLensesEnabled` to `false`.\n\n### All Available Commands\n\nYou can see a list of all the available Metals server commands on the [Metals\nWebsite](https://scalameta.org/metals/docs/editors/new-editor.html#metals-server-commands).\n\nYou can also view these by toggling the `CocList commands`, which is `\u003cspace\u003ec`\nwith the default mappings.\n\n### Show document symbols\n\nRun `:CocList outline` to show a symbol outline for the current file or use the\ndefault mapping `\u003cspace\u003e o`.\n\n![Document Symbols](https://i.imgur.com/gEhAXV4.png)\n\n\n### Available Configuration Options\n\nThe following configuration options are currently available. The easiest way to\nset these configurations is to enter `:CocConfig` or `:CocLocalConfig` to set\nyour global or local configuration settings respectively.\n\nIf you'd like to get autocompletion help for the configuration values you can\ninstall [coc-json](https://github.com/neoclide/coc-json).\n\n\n   Configuration Option                         |      Description\n----------------------------                    |---------------------------\n`metals.enable`                                 | Enable the coc-metals extension (default true)\n`metals.serverVersion`                          | The version of the Metals server artifact. Requires reloading the window.\n`metals.serverProperties`                       | Optional list of properties to pass along to the Metals server. By default, the environment variable `JAVA_OPTS` and `.jvmopts` file are respected.\n`metals.ammoniteJvmProperties`                  | Optional list of JVM properties to pass along to the Ammonite server. Each property needs to be a separate item. Example: `-Xmx1G` or `-Xms100M`\n`metals.javaHome`                               | Optional path to the Java home directory. Requires reloading the window. Defaults to the most recent Java 8 version computed by the `locate-java-home` npm package.\n`metals.sbtScript`                              | Optional absolute path to an `sbt` executable to use for running `sbt bloopInstall`. By default, Metals uses `java -jar sbt-launch.jar` with an embedded launcher while respecting `.jvmopts` and `.sbtopts`. Update this setting if your `sbt` script requires more customizations like using environment variables.\n`metals.millScript`                             | Optional absolute path to a `mill` executable to use for running `mill mill.contrib.Bloop/install`. By default, Metals uses an embedded `millw` script while respecting `.mill-version` file. Update this setting if your `mill` script requires more customizations.\n`metals.mavenScript`                            | Optional absolute path to a `mvn` executable to use for running `mvn ch.epfl.scala:maven-bloop_2.10:\u003cbloop_version\u003e:bloopInstall`. By default, Metals uses an embedded `mvnw` script. Update this setting if your `mvn` script requires more customizations.\n`metals.gradleScript`                           | Optional absolute path to a `gradle` executable to use for running `gradle bloopInstall`. By default, Metals uses an embedded `gradlew` script. Update this setting if your `gradle` script requires more customizations.\n`metals.scalafmtConfigPath`                     | Optional custom path to the .scalafmt.conf file. Should be an absolute path and use forward slashes `/` for file separators (even on Windows).\n`metals.scalafixConfigPath`                     | Optional custom path to the .scalafix.conf file. Should be an absolute path and use forward slashes `/` for file separators (even on Windows).\n`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 (|).\n`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\n`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.\n`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.\n`metals.superMethodLensesEnabled`               | Enable/disable goto super method code lens (default is true)\n`metals.enableStripMarginOnTypeFormatting`      | When enabled, if you press the return key from the first line of a multiline string containing a pipe, it will automatically add `.stripMargin.` (default is true)\n`metals.excludedPackages`                       | List of packages you'd like to be left out of completions, symbol searches, and code actions. Ex. `akka.actor.typed.javadsl` will ensure nothing in the `javadsl` package gets recommended to you. You can find the list of default exclusions [here on the Metals website](https://scalameta.org/metals/docs/editors/new-editor.html#excluded-packages). If you need to remove one of the defaults, you can simply include it and preface it with `--`.\n`metals.showInferredType`                       | When this option is enabled, each method that has infered types have those types displayed as extra info in the hover window.\n`metals.showImplicitArguments`                  | When this option is enabled, each method that has implicit arguments have those aruments displayed as extra info in the hover window.\n`metals.showImplicitConversionsAndClasses`      | When this option is enabled, each implicit method and class is displayed as extra info in the hover window.\n`metals.treeviews.toggleNode`                   | Expand / Collapse tree node (default `\u003cCR\u003e`)\n`metals.treeviews.initialWidth`                 | Initial Tree Views panels (default `40`)\n`metals.treeviews.initialViews`                 | Initial views that the Tree View Panel Displays. Don't mess with this unless you know what you're doing.\n`metals.treeviews.gotoLastChild`                | Go to the last child Node (defalt `J`)\n`metals.treeviews.gotoParentNode`               | Go to parent Node (default `p`)\n`metals.treeviews.gotoFirstChild`               | Go to first child Node (default `K`)\n`metals.treeviews.executeCommand`               | Execute command for node (default `r`)\n`metals.treeviews.gotoPrevSibling`              | Go to prev sibling (default `\u003cC-k\u003e`)\n`metals.treeviews.gotoNextSibling`              | Go to next sibling (default `\u003cC-j\u003e`)\n`metals.treeviews.forceChildrenReload`          | Force the reloading of the children of this node. May be useful when the wrong result is cached and tree contains invalid data. (default `f`)\n`metals.treeviews.executeCommandAndOpenTab`     | Execute command and open node under cursor in tab (if node is class, trait and so on) (default `t`)\n`metals.treeviews.executeCommandAndOpenSplit`   | Execute command and open node under cursor in horizontal split (if node is class, trait and so on) (default `s`)\n`metals.treeviews.executeCommandAndOpenVSplit`  | Execute command and open node under cursor in horizontal split (if node is class, trait and so on) (default `v`)\n\n### Enable on type formatting for multiline string formatting\n\n![on-type](https://i.imgur.com/astTOKu.gif)\n\nTo properly support different multiline string formatting options like adding\n`|` in your multiline string we use the `onTypeFormatting` LSP functionality. To\nenable the functionality you need to enable `coc.preferences.formatOnType`\nsetting.\n\n![coc-preferences-formatOnType](https://i.imgur.com/RWPHt2q.png)\n\n### Shut down the language server\n\nThe Metals server is shutdown when you exit vim as you normally would.\n\n```vim\n:wq\n```\n\nThis step clean ups resources that are used by the server.\n\n### Statusline integration\n\nIt's recommended to use a statusline integration with `coc-metals` in order to\nallow messages to be displayed in your status line rather than as a message.\nThis will allow for a better experience as you can continue to get status\ninformation while entering a command or responding to a prompt. However, we\nrealize that not everyone by default will have this setup, and since the user\nneeds to see messages about the status of their build, the following is\ndefaulted to false.\n\n```json\n\"metals.statusBarEnabled\": true\n```\n\nAgain, it's recommended to make this active, and use a statusline plugin, or\nmanually add the coc status information into your statusline. `coc.nvim` has\nmultiple ways to integrate with various statusline plugins. You can find\ninstructions for each of them located\n[here](https://github.com/neoclide/coc.nvim/wiki/Statusline-integration).  If\nyou're unsure of what to use,\n[vim-airline](https://github.com/vim-airline/vim-airline) is a great minimal\nchoice that will work out of the box.\n\nWith [vim-airline](https://github.com/vim-airline/vim-airline), you'll notice\ntwo noteworthy things. The first will be that you'll have diagnostic\ninformation on the far right of your screen.\n\n![Diagnostic statusline](https://i.imgur.com/7uNYTYl.png)\n\nYou'll also have metals status information in your status bar.\n\n![Status bar info](https://i.imgur.com/eCAgrCn.png)\n\nWithout a statusline integration, you'll get messages like you see below.\n\n![No status line](https://i.imgur.com/XF7A1BJ.png)\n\nIf you don't use a statusline plugin, but would still like to see this\ninformation, the easiest way is to make sure you have the following in your\n`.vimrc`.\n\n```vim\nset statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}\n```\n\n### Formatting on save\n\nIf you'd like to have `:w` format using Metals + Scalafmt, then make sure you\nhave the following in your `:CocConfig`.\n\n```json\n\"coc.preferences.formatOnSaveFiletypes\": [\"scala\"]\n```\n### Analyzing Stacktraces\n\n![analyze-stacktrace](https://i.imgur.com/tQjiAG2.gif)\n\nNOTE: Only available in [Neovim](https://neovim.io/) since this needs virtual\ntext.\n\nTo utilize the [analyze\nstacktrace](https://scalameta.org/metals/docs/editors/new-editor.html#analyze-stacktrace)\ncommand you'll want to copy your your stacktrace to your register. Once copied,\nsimply execute the `metals.analyze-stacktrace` command. This should create a\n`.metals/stacktrace.scala` file which will have code lenses which will allow you\nto jump to the part of your codebase listed in the stacktrace. Keep in mind that\nin order to utilize this feature you'll want to make sure you have\n`\"codeLens.enable\": true` in your config.\n\n### Debugging\n\ncoc-metals provides easy integration with the great\n[vimspector](https://github.com/puremourning/vimspector) plugin that allows  you\nto run a Debug Adapter Server and debug your application with minimum manual\nsteps.\n\n#### Requirements:\n- *This is only currently available for Neovim +0.4.3 for now until the\n  the `launch.json` Metals expects can be mapped to match the `.vimspector.json`\n  file that vimspector uses. For now, you'll need to trigger the `run` or `debug`\n  with code lenses provided by Neovim.\n\n- [vimspector](https://github.com/puremourning/vimspector) plugin - Basically you just\n  need to add vimspector into vim's runtimepath, for example, if you are using vim-plug then\n  add this line in .vimrc\n\n```vim\nPlug 'puremourning/vimspector'\n```\n#### Configuration:\n\n- Set `codeLens.enable` to `true` in your `:CocConfig`\n- Setup your [Vimspector Mappings](https://github.com/puremourning/vimspector#mappings)\n\nThe [vimspector documentation](https://github.com/puremourning/vimspector) is\nquite robust, so please make sure to read through it.\n\nThere are multiple ways to have you base configuration for vimspector to work\nwith Metals. You can either set this up globally to work with all of your Scala\nprojects or for an individual  project.\n\n_Global Example:_\n\nPut your `coc-metals.json` file in the following directory:\n`/path/to/vimspector/configurations/{os}/scala` (where `os` is `linux`, `macos`\nor `windows`) with following content:\n\n```json\n{\n  \"configurations\": {\n    \"coc-metals\": {\n      \"adapter\": {\n        \"port\": \"${port}\",\n        \"variables\": {\n        }\n      },\n      \"configuration\": {\n        \"request\": \"launch\"\n      },\n      \"breakpoints\": {\n        \"exception\": {\n          \"caught\": \"N\",\n          \"uncaught\": \"N\"\n        }\n      }\n    }\n  }\n}\n```\n\nYou can also just place the same contents above in the root of your local\nproject in a `.vimspector.json` file, and it will work the same way.\n\nWith these configuration parameters the codeLens 'run' and 'debug' appear\nagainst runnable classes (applications or tests) of your project. Then, you will\nbe able to trigger these codeLens actions (default mapping is `\u003cleader\u003e cl`) and\nstart Debug Adapter Server. Once Debug Adapter Server is started coc-metals will\ntransfer necessary information to vimspector to activate debugging.\n\nFor now both actions 'run' and 'debug' start vimspector in debug mode. This may\nbe improved in next versions.\n\n### Gitignore\n\nThe Metals server places logs and other files in the .metals/ directory. The\nBloop compile server places logs and compilation artifacts in the .bloop\ndirectory. A Bloop plugin that generates Bloop configuration is added in the\nproject/metals.sbt file. If you are editing Ammonite scripts, you'll also see an\n.ammonite directory created for Ammonite. It's recommended to ignore these\ndirectories and file from version control systems like git.\n\n```git\n# ~/.gitignore\n.metals/\n.bloop/\nproject/metals.sbt\n.ammonite/\n```\n\n### Troubleshooting\n\nIf you have any questions or issues with coc-metals, please submit an\n[issue](https://github.com/scalameta/coc-metals/issues) in this repo if it\npertains to the extension. If the issues is general to Metals, please submit it\nin the [Metals issue repo](https://github.com/scalameta/metals/issues). If you\nhave any feature requests, we also have a feature request [issue\nrepo](https://github.com/scalameta/metals-feature-requests). There is also a\nsection in the wiki for [Commonly Asked\nQuestions](https://github.com/scalameta/coc-metals/wiki/Commonly-Asked-Questions).\nFee free to peruse that to potentially find an answer you may be looking for.\n\n### Contributing\n\nIf you're interested in contributing, please visit the\n[CONTRIBUTING](CONTRIBUTING.md) guide for help on getting started.\n\n### Theme\n\nThe screen shots are in [Neovim](https://neovim.io/). The theme is\n[onedark](https://github.com/joshdick/onedark.vim).  The status bar is\n[vim-airline](https://github.com/vim-airline/vim-airline), and all being ran in\n[iTerm2](https://iterm2.com/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscalameta%2Fcoc-metals","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscalameta%2Fcoc-metals","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscalameta%2Fcoc-metals/lists"}