Code Monkey home page Code Monkey logo

nvim-metals's Introduction

nvim-metals logo

nvim-metals

nvim-metals is a Lua plugin built to provide a better experience while using Metals, the Scala Language Server, with Neovim's built-in LSP support.1 You can see all the available features here.

link to discord link to help docs

Prerequisites

  • Before you get started you need to ensure that you are using the latest nvim v.0.10.x or newer. If you're still on v0.9.x then you'll want to target the v0.9.x tag.
  • Ensure Coursier is installed locally.2
  • Ensure that you have all the LSP mappings for the core functionality you want setup.3
  • Ensure plenary.nvim is installed.4
  • Subscribe to this discussion which will notify you of any breaking changes.
  • Unfamiliar with Lua and Neovim? Check out the great :h lua-guide.

Getting started

NOTE: This plugin works without needing to install neovim/nvim-lspconfig. If you have it installed for other languages, that's not a problem, but make sure you do not have Metals configured through nvim-lspconfig while using this plugin.1

Absolute minimal example using Lazy.nvim

{
  "scalameta/nvim-metals",
  dependencies = {
    "nvim-lua/plenary.nvim",
  },
  ft = { "scala", "sbt", "java" },
  opts = function()
    local metals_config = require("metals").bare_config()
    metals_config.on_attach = function(client, bufnr)
      -- your on_attach function
    end

    return metals_config
  end,
  config = function(self, metals_config)
    local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true })
    vim.api.nvim_create_autocmd("FileType", {
      pattern = self.ft,
      callback = function()
        require("metals").initialize_or_attach(metals_config)
      end,
      group = nvim_metals_group,
    })
  end
}

NOTE: The above assumes you have your own attach function that sets up all your LSP mappings. It also doesn't make use of any configuration. You'll likely want a more involved setup than this, so check out the full minimal example configuration link below.

Settings and Commands

To view all of the available commands, check out :help metals-commands in the help docs. Similarly, to see the available configuration settings check out :help metals-settings.

Integrations

To see the full details on the available configurations, checkout out :help metals-integrations. The currently available integrations are:

Footnotes

  1. If you're familiar with nvim and LSP you'll probably know of nvim-lspconfig which also has a Metals configuration. Note that this is a very minimal version with no specific Metals commands and no Metals extensions. You can see more info on this here. DO NOT try to use Metals both with nvim-lspconfig and with nvim-metals as stuff will not work right. 2

  2. nvim-metals uses Coursier to download and update Metals. NOTE: On Windows, you should run coursier or cs.exe once from the command line as this is how it will install itself. Once this is done you should add C:\Users\YOURNAME\AppData\Coursier\data\bin to your path. To verify that it is properly installed you can run cs --help from a new shell.

  3. By default methods for things like goto definition, find references, etc are there, but not automatically mapped. You can find a minimal example configuration here.

  4. You're more than likely already relying on for other plugins. However, make sure to also have this installed as Metals uses it for things like Jobs, popups, and paths.

nvim-metals's People

Contributors

ckipp01 avatar eugenemedvediev avatar dependabot[bot] avatar antosha417 avatar landerlo avatar suliatis avatar rochala avatar btrachey avatar alfabetacain avatar jl102 avatar caenrique avatar susliko avatar ghostbuster91 avatar timokau avatar lenguyenthanh avatar softinio avatar octavz avatar bloznelis avatar lcharles avatar kluen avatar jsatk avatar asdas91 avatar ex0ns avatar ayhon avatar tymcauley avatar vanhtuan0409 avatar trmckay avatar otherjl0 avatar mpasa avatar johan1a avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.