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

extension rename is not working #146

Open
kryshac opened this issue Mar 3, 2024 · 6 comments
Open

extension rename is not working #146

kryshac opened this issue Mar 3, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@kryshac
Copy link

kryshac commented Mar 3, 2024

Describe the bug
after I installed the extension, rename from lsp (angularls) no longer works, I receive this message:
Language server couldn't provide rename result

System information

  • OS: linux
  • Neovim version: NVIM v0.9.5
  • Dressing config:
{
  'stevearc/dressing.nvim',
  opts = {
    input = {
      insert_only = false,
      relative = 'editor',
    },
  },
}

To Reproduce
Steps to reproduce the behavior:

2024-03-03.20-43-52.mp4

if you need some logs tell me which ones.
Thanks

@kryshac kryshac added the bug Something isn't working label Mar 3, 2024
@kryshac kryshac changed the title after i install extension rename is not working extension rename is not working Mar 3, 2024
@stevearc
Copy link
Owner

I notice that after you close the rename dialog your cursor has moved to the beginning of the line, which would cause the LSP client to not know what variable to rename (it looks for the one under the cursor). Can you reproduce this cursor-jumping behavior with a minimal example? An easy way to do this would be to make a file with this contents

-- test.lua
vim.ui.input({}, function() end)

edit it and then run :source.

It would also help if you can do this with a minimal init.lua to eliminate confounding factors from your other plugins.

-- save as repro.lua
-- run with nvim -u repro.lua
-- DO NOT change the paths
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "runtime", "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",
		"--single-branch",
		"https://github.com/folke/lazy.nvim.git",
		lazypath,
	})
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
	"folke/tokyonight.nvim",
	{
		"stevearc/dressing.nvim",
		config = function()
			require("dressing").setup({})
		end,
	},
}

require("lazy").setup(plugins, {
	root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")

@stevearc stevearc added the question Further information is requested label Mar 18, 2024
@kryshac
Copy link
Author

kryshac commented Mar 18, 2024

if I do this, the cursor stays where it should be

@github-actions github-actions bot removed the question Further information is requested label Mar 18, 2024
@kryshac
Copy link
Author

kryshac commented Mar 18, 2024

what I noticed is that it renames the position where the cursor was last time in insert mode:

2024-03-19.00-53-22.remuxed.mp4

@dk949
Copy link

dk949 commented May 21, 2024

FWIW I had a similar issue because I have the following in my init.lua:

vim.api.nvim_create_autocmd("BufWritePre", {
    pattern = "*",
    command = [[mkview]],
})
vim.api.nvim_create_autocmd("BufEnter", {
    pattern = "*",
    command = [[silent! loadview]],
})

So the code buffer got reset to the last saved view when returning from the input window. The band-aid solution was to just add a vim.cmd[[mkview]] to my rename shortcut.

This may be entirely irrelevant to your case, but the behaviour is very similar.

@kryshac
Copy link
Author

kryshac commented May 21, 2024

@dk949 you're right. If I deactivate the 'Save View for Fold' feature, the plugin issue is resolved.

I have this

-- auto save fold view after exit a file
vim.api.nvim_create_autocmd({ 'BufLeave', 'BufWinLeave', 'InsertLeave' }, {
  pattern = { '*.*' },
  desc = 'save view (folds), when closing file',
  command = 'mkview',
})

-- auto load fold view after enter a file
vim.api.nvim_create_autocmd({ 'BufRead', 'BufWinEnter', 'BufEnter' }, {
  pattern = { '*.*' },
  desc = 'load view (folds), when opening file',
  command = 'silent! loadview',
})

but if I don't use dressing.nvim then there is no conflict with `mkview'

@dk949
Copy link

dk949 commented May 21, 2024

but if I don't use dressing.nvim then there is no conflict with `mkview'

It's because the default implementation does not open a new window, it just puts you in command mode, so when the input dialog is closed there is no BufEnter event and the loadview command isn't executed.

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

No branches or pull requests

3 participants