Skip to content

dartls not found in mason-registry #527

@taham8875

Description

@taham8875

Hi there

I'm setting up Neovim with nvim-lspconfig, and I'm getting an issue when trying to enable the Dart language server (dartls). When I start Neovim, I get the following error:

.../share/nvim/lazy/mason.nvim/lua/mason-registry/init.lua:80: Cannot find package "dartls"

Here's what I’ve done so far:

  • I’m using mason.nvim and mason-lspconfig.nvim to manage language servers.
  • I have not manually installed dartls but expected it to be installed automatically as part of my setup.
  • I checked the Mason package registry and couldn’t find a dartls package listed (so this is the problem, Mason can not recognize that something called dartls exists).

I am using kickstart, take a look here at their setup, I added dartls as it is the one that can be found after running :help lspconfig-all:

https://github.com/nvim-lua/kickstart.nvim/blob/e947649cb0ee5ac3c75593288df04d4f58359106/init.lua#L671

So any suggestions on how to make this run

Note: For me, I realized that I can manually setup dart lsp to work without need to use mason-lspconfig by using this code:

require("lspconfig").dartls.setup({
	cmd = { "path/to/dart", "language-server", "--protocol=lsp" },
	filetypes = { "dart" },
	init_options = {
		closinglabels = true,
		flutteroutline = true,
		onlyanalyzeprojectswithopenfiles = true,
		outline = true,
		suggestfromunimportedlibraries = true,
	},
	-- root_dir = root_pattern("pubspec.yaml"),
	settings = {
		dart = {
			completefunctioncalls = true,
			showtodos = true,
		},
	},
	on_attach = function(client, bufnr)
	end,
})

But I am making this issue for future users how want to use mason-lspconfig without manually doing this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions