mason.nvim icon indicating copy to clipboard operation
mason.nvim copied to clipboard

rust-analyzer runs twice when installed by Mason

Open SlartThunder opened this issue 1 year ago • 2 comments

I've searched open issues for similar requests

  • [X] Yes

I've manually reviewed logs to find potential errors

  • [ ] Yes

I've recently downloaded the latest plugin version of mason.nvim

  • [X] Yes

Problem description

(I don't know whether this bug belongs here or into rust-analyzer repo… ) I noticed that when opening .rs files, rust-analyzer was running twice ONLY when this LSP was installed using Mason plugin. That also provoke the cmp to show its contents also duplicated…

Expected behavior

It should run only 1 time

Steps to reproduce

  1. Install rust-analyzer with Mason
  2. Open a .rs file and you will be able to see rust-analyzer running twice

Affected packages

rust-analyzer

Neovim version (>= 0.7)

NVIM v0.10.0 Build type: Release LuaJIT 2.1.1716656478

Operating system/version

macOS 14.4.1

Healthcheck

mason: require("mason.health").check()

mason.nvim ~
- OK mason.nvim version v1.10.0
- OK PATH: prepend
- OK Providers: 
    mason.providers.registry-api
    mason.providers.client
- OK neovim version >= 0.7.0

mason.nvim [Registries] ~
- OK Registry `github.com/mason-org/mason-registry version: 2024-06-17-silly-hand` is installed.

mason.nvim [Core utils] ~
- OK unzip: `UnZip 6.00 of 20 April 2009, by Info-ZIP.  Maintained by C. Spieler.  Send`
- OK wget: `GNU Wget 1.24.5 built on darwin23.2.0.`
- OK curl: `curl 8.7.1 (aarch64-apple-darwin23.4.0) libcurl/8.7.1 (SecureTransport) OpenSSL/3.3.0 zlib/1.2.12 brotli/1.1.0 zstd/1.5.6 libidn2/2.3.7 libssh2/1.11.0 nghttp2/1.61.0 librtmp/2.3 OpenLDAP/2.6.7`
- OK gzip: `Apple gzip 430.100.5`
- OK tar: `bsdtar 3.5.3 - libarchive 3.5.3 zlib/1.2.12 liblzma/5.4.3 bz2lib/1.0.8 `
- OK bash: `GNU bash, version 5.2.26(1)-release (aarch64-apple-darwin23.2.0)`
- OK sh: `Ok`

mason.nvim [Languages] ~
- OK Ruby: `ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin23]`
- WARNING Composer: not available
  - ADVICE:
    - spawn: composer failed with exit code - and signal -. composer is not executable
- WARNING PHP: not available
  - ADVICE:
    - spawn: php failed with exit code - and signal -. php is not executable
- OK cargo: `cargo 1.78.0`
- OK node: `v18.1.0`
- OK RubyGem: `3.0.3.1`
- OK Go: `go version go1.22.3 darwin/arm64`
- WARNING julia: not available
  - ADVICE:
    - spawn: julia failed with exit code - and signal -. julia is not executable
- OK npm: `8.8.0`
- OK luarocks: `/opt/homebrew/bin/luarocks 3.11.0`
- OK python: `Python 3.12.0`
- OK pip: `pip 24.0 from ~/.pyenv/versions/3.12.0/lib/python3.12/site-packages/pip (python 3.12)`
- OK python venv: `Ok`
- OK java: `openjdk version "21.0.3" 2024-04-16`
- OK javac: `javac 21.0.3`

mason.nvim [GitHub] ~
- OK GitHub API rate limit. Used: 16. Remaining: 44. Limit: 60. Reset: Mon Jun 17 20:27:52 2024.
  Install and authenticate via gh-cli to increase rate limit.

Screenshots or recordings

No response

SlartThunder avatar Jun 17 '24 18:06 SlartThunder

I'm noticing the same thing with ts_ls and eslint_d, I get two copies of the language server attached to my buffer, which means I get every completion item offered twice etc.

insidewhy avatar Nov 26 '24 18:11 insidewhy

But for other language servers e.g. terraform, I only get one.

insidewhy avatar Nov 26 '24 18:11 insidewhy

same for gopls, in recent version of nvim/mason

peku-jamf avatar Jun 18 '25 07:06 peku-jamf

FWIW, I had this issue because I setup the lsp capabilities for cmp_nvim_lsp after calling require("mason-lspconfig").setup(), moving the capability setup to happen before the mason setup fixed the problem for me and only one LSP instance gets started.

DemvSteinbrink avatar Aug 06 '25 06:08 DemvSteinbrink

This was caused in my setup by calling mason.setup() more than once:

require("mason").setup() -- require("mason-lspconfig").setup() -- require("lsp.mason")

daviareias avatar Sep 30 '25 09:09 daviareias