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

bug(picker): lsp_symbols reverts options set with opt_local / setlocal #1524

Open
4 tasks done
LonelyMusicDisc opened this issue Mar 7, 2025 · 4 comments · May be fixed by #1525
Open
4 tasks done

bug(picker): lsp_symbols reverts options set with opt_local / setlocal #1524

LonelyMusicDisc opened this issue Mar 7, 2025 · 4 comments · May be fixed by #1525
Labels
bug Something isn't working

Comments

@LonelyMusicDisc
Copy link

Did you check docs and existing issues?

  • I have read all the snacks.nvim docs
  • I have updated the plugin to the latest version before submitting this issue
  • I have searched the existing issues of snacks.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

0.10.2

Operating system/version

Fedora 40 (Linux)

Describe the bug

When using lsp_symbols with line numbers turned off buffer-wise (setlocal nonumber norelativenumber), lsp_symbols reverts turns line numbers back on. I imagine this happens with other buffer-local visual options.

Steps To Reproduce

  1. Open file with lsp support (lua)
  2. Do :setlocal nonumber norelativenumber
  3. Run picker.lsp_symbols by any means like :lua Snacks.picker.lsp_symbols

Expected Behavior

Picker opens without changing options of unrelated buffer(s).

Repro

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

require("lazy.minit").repro({
  spec = {
    { "folke/snacks.nvim", opts = {} },
    {
      "neovim/nvim-lspconfig",
      config = function()
        require("lspconfig").lua_ls.setup({})
      end,
    },
  },
})
@LonelyMusicDisc LonelyMusicDisc added the bug Something isn't working label Mar 7, 2025
@dpetka2001
Copy link
Contributor

You have to explicitly define the local window options you want in your snacks configuration. lsp_symbols only shows numbers in the preview window, so you can do the following to disable them

return {
  "folke/snacks.nvim",
  opts = {
    picker = {
      sources = {
        lsp_symbols = {
          win = {
            preview = {
              wo = {
                relativenumber = false,
                number = false,
              },
            },
          },
        },
      },
    },
  },
}

@LonelyMusicDisc
Copy link
Author

I'm not talking about the preview, it's the buffer I called it from that has its options changed. I'll try to illustrate it with screenshots.

Before calling lsp_symbols: Neovim screenshot

after calling it: Neovim screenshot 2

@dpetka2001
Copy link
Contributor

Ok I see what you mean now. I misunderstood your first comment.

@dpetka2001
Copy link
Contributor

dpetka2001 commented Mar 7, 2025

I believe it's this line here. I believe it should be scope = "local". Or maybe it could be left just an empty table as the help from vim.api.nvim_get_option_value mentions

Gets the value of an option. The behavior of this function matches that of
:set: the local value of an option is returned if it exists; otherwise,
the global value is returned. Local values always correspond to the current
buffer or window, unless "buf" or "win" is set in {opts}.

PS: I believe scope = "local" would be more prudent, since Snacks.util.wo sets local options either way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants