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

Call vim.lsp.util.jump_to_location to jump to an unloaded buffer, where the buffer name is not shortened #29457

Closed
gh-liu opened this issue Jun 23, 2024 · 3 comments

Comments

@gh-liu
Copy link

gh-liu commented Jun 23, 2024

Problem

Call the jump_to_location function to jump to an unloaded buffer, where the buffer name is not shortened, it is the full path of the file, this could be quite verbose and hard to read in the result of :buffers command.

Steps to reproduce

  1. open a project in nvim with lsp started
  2. call vim.lsp.buf.definition() on a symbol which defined in other file that no loaded
  3. see the result in the :buffers command

Expected behavior

The bufname is shortened.

Neovim version (nvim -v)

v0.11.0-dev-298+gd82efeccc

Vim (not Nvim) behaves the same?

vim has no lsp

Operating system/version

macos

Terminal name/version

kitty

$TERM environment variable

xterm-color256

Installation

build from repo

@gh-liu gh-liu added the bug issues reporting wrong behavior label Jun 23, 2024
@github-actions github-actions bot added the lsp label Jun 23, 2024
@glepnir
Copy link
Member

glepnir commented Jun 23, 2024

because uri_to_bufnr use full path . if you want use relative path i think you can modified in your local . this is not bug.

vim.uri_to_bufnr = function(uri)
  local fname = vim.uri_to_fname(uri)
  fname = vim.fn.fnamemodify(fname, ':p:.')
  return vim.fn.bufadd(fname)
end

@glepnir glepnir closed this as completed Jun 23, 2024
@glepnir glepnir removed bug issues reporting wrong behavior lsp labels Jun 23, 2024
@gh-liu
Copy link
Author

gh-liu commented Jun 23, 2024

because uri_to_bufnr use full path . if you want use relative path i think you can modified in your local . this is not bug.

vim.uri_to_bufnr = function(uri)
  local fname = vim.uri_to_fname(uri)
  fname = vim.fn.fnamemodify(fname, ':p:.')
  return vim.fn.bufadd(fname)
end

Thanks, but I have tried the code and it doesn't work.

@glepnir
Copy link
Member

glepnir commented Jun 23, 2024

just a simply code you may also need check fname include the root of cwd. then modify it and make sure the override before you call vim.lsp.buf.definition()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants