nvimdev / nvimdev/lspsaga.nvim

Duplicated peek_definition when css_variables is attached

Open
#1,534 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Lua
Stars
3.8k
Forks
308
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

When LSP css_variables is attached we get duplicated peek_definition.

Image
Steps to reproduce

Minimal:

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require "plugins.extra.lazyGlobals"

require("lazy.minit").repro({
  spec = {
    -- add any other plugins here

    -- noice
    {
      "folke/noice.nvim",
      opts = {},
      dependencies = {
        "MunifTanjim/nui.nvim",
        "rcarriga/nvim-notify",
      },
    },

    -- LSP
    {
      {
        "williamboman/mason.nvim",
        opts = {},
      },
      {
        "williamboman/mason-lspconfig.nvim",
        config = function ()
          require("mason-lspconfig").setup {
            ensure_installed = { "cssls", "css_variables" },
          }
        end
      },
      {
        "neovim/nvim-lspconfig",
        dependencies = {
          "williamboman/mason-lspconfig.nvim",
        },
        config = function ()

          local lspconfig = require("lspconfig")

          -- List of LSP servers
          local servers = { "cssls", "css_variables" }

          -- Mapping of LSP names to their actual executable commands
          local server_executables = {
            cssls = "vscode-css-language-server",
            css_variables = "css-variables-language-server",
          }

          -- Function to check if an LSP executable exists
          local function is_executable(server)
            local cmd = server_executables[server] or server
            return vim.fn.executable(cmd) == 1
          end

          -- Setup LSPs only if installed
          for _, server in ipairs(servers) do
            if is_executable(server) then
              lspconfig[server].setup({})
            else
              vim.notify(server .. " LSP is not installed", vim.log.levels.WARN)
            end
          end

        end
      },
    },

    -- lspsaga
    {
      "glepnir/lspsaga.nvim",
      dependencies = {
        { "nvim-treesitter/nvim-treesitter" },
      },
      opts = {}
    },

  },
})

Sample CSS:

:root {
  --white: #ffffff;
  --shadow-1: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

nav {
  background: var(--white);
  box-shadow: var(--shadow-1);
}
  1. nvim -u "minimal" foo.css
  2. Over any of the two variables run: Lspsaga peek_definition
Expected behavior

Exptected to see only 1 pop-up (as it happens when that LSP is not active).

Maybe the issue relies on the LSP itself but is there a way to avoid Lspsaga triggering this duplicated pop-up?

Neovim version (nvim -v)

v0.11.0-dev-1517+ga37784ad83

lspsaga commit

778d56f

Terminal name/version

iterm2 3.5.11

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Lspsaga peek_definition entry point and reproduce the issue using the minimal configuration with both cssls and css_variables attached. Compare the LSP responses for a CSS variable against the single-server case, then verify that running Lspsaga peek_definition produces one popup rather than duplicated popups.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.