Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[d-default behaves differently from explicit mapping #28909

Closed
xudyang1 opened this issue May 22, 2024 · 1 comment
Closed

[d-default behaves differently from explicit mapping #28909

xudyang1 opened this issue May 22, 2024 · 1 comment
Labels
closed:wontfix current behavior is by design, and change is not desired

Comments

@xudyang1
Copy link

xudyang1 commented May 22, 2024

Problem

since v0.10.0, [d and ]d are mapped to vim.diagnostic.goto_next() and vim.diagnostic.goto_prev(). The default behavior of [d and ]d only moves the cursor to the diagnostics.

Explicitly mapping [d and ]d, vim.keymap.set("n", "[d", vim.diagnostic.goto_prev), moves the cursor AND opens the floating diagnostic window.

Steps to reproduce

Tested with and without explicit keymap:

minimal.lua:

local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath })
end
vim.opt.runtimepath:prepend(lazypath)

local plugins = {
  {
    "neovim/nvim-lspconfig",
    event = { "BufReadPost", "BufNewFile" },
    dependencies = {
      {
        "williamboman/mason.nvim",
        opts = {
          -- custom ensure_installed
          ensure_installed = {
            -- lua_ls
            "lua-language-server",
          },
        },
        config = function(_, opts)
          require("mason").setup(opts)
          local mr = require("mason-registry")
          local function ensure_installed()
            for _, tool in pairs(opts.ensure_installed) do
              local p = mr.get_package(tool)
              if not p:is_installed() then
                p:install()
              end
            end
          end

          mr.refresh(ensure_installed)
        end,
      },
    },
    config = function()
      require("lspconfig").lua_ls.setup({})
    end,
  },
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

-- comment / uncomment the following keymaps
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev)
vim.keymap.set("n", "]d", vim.diagnostic.goto_next)

Expected behavior

The default behavior open the floating diagnostic window.

Neovim version (nvim -v)

0.10.0

Vim (not Nvim) behaves the same?

not available in vim

Operating system/version

WSL ubuntu 22.04

Terminal name/version

windows terminal 1.21.1272.0

$TERM environment variable

xterm-256color

Installation

appimage

@xudyang1 xudyang1 added the bug issues reporting wrong behavior label May 22, 2024
@wookayin
Copy link
Member

wookayin commented May 22, 2024

It is by design that floating window is disabled by default. See #16230.

]d and [d are mapped to:

vim.diagnostic.goto_next({ float = false })
vim.diagnostic.goto_prev({ float = false })

respectively. You should use your own custom mapping if you wish floating window is also opened.

@wookayin wookayin closed this as not planned Won't fix, can't repro, duplicate, stale May 22, 2024
@wookayin wookayin added closed:wontfix current behavior is by design, and change is not desired and removed bug issues reporting wrong behavior labels May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed:wontfix current behavior is by design, and change is not desired
Projects
None yet
Development

No branches or pull requests

2 participants