nvim-lsp-file-operations icon indicating copy to clipboard operation
nvim-lsp-file-operations copied to clipboard

Expose a lua API or ex commands for renaming without nvim-tree?

Open IndianBoy42 opened this issue 2 years ago • 7 comments

IndianBoy42 avatar May 24 '23 12:05 IndianBoy42

Also came here for this. I don't use a file tree plugin at all and installing one just for the LSP renaming operation feels a bit bad

chrisgrieser avatar May 24 '23 12:05 chrisgrieser

Yeah, I totally agree. Would be a great addition to the plugin. @IndianBoy42 how would you like the api to look like?

I think for now you can just call this function before moving the files around. https://github.com/antosha417/nvim-lsp-file-operations/blob/master/lua/lsp-file-operations/will-rename.lua#L23-L38

require('lsp-file-operations.will-rename').callback({old_name: "path/to/file", new_name: "new/path/to/file"})

antosha417 avatar May 24 '23 15:05 antosha417

for the API, something like these seems fine to me?

require('lsp-file-operations').rename({ old_name = "foo", new_name = "bar"})

edit: old_name should be optional, defaulting to the current file

chrisgrieser avatar May 24 '23 15:05 chrisgrieser

@chrisgrieser, do you want it to actually move the files? after calling callback

There should also be a way of specifying which callback you want to call. Right now we have only will-rename but lsp spec supports others. Like did-rename. Or should we call all of them?

antosha417 avatar May 30 '23 12:05 antosha417

I don't have a lot of time to work on this for now. You can try it in your local config and open a pr if you want. I'll happily merge it

antosha417 avatar May 30 '23 12:05 antosha417

@chrisgrieser are you planning to integrate this into genghis wink wink ? :)

bugabinga avatar Sep 22 '23 10:09 bugabinga

@bugabinga No, but I'll gladly accept a PR if someone would wink wink :)

chrisgrieser avatar Sep 22 '23 11:09 chrisgrieser