Giter Site home page Giter Site logo

nvim-lsp-file-operations's People

Contributors

antosha417 avatar cseickel avatar jellis206 avatar kallestruik avatar luckasranarison avatar mehalter avatar mikehaertl avatar susliko avatar trard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nvim-lsp-file-operations's Issues

Document how to setup extended clientCapabilities

I'm not sure if I missed anything, but for me the default setup is not enough, because nvim will not include the corresponding capabilities in the LSP initialize request.

So for nvim-lspconfig I had to add something like this to my config:

local lspconfig = require'lspconfig'
local util = lspconfig.util

-- Set global defaults for all servers
util.default_config = vim.tbl_extend(
  'force',
  util.default_config,
  {
    capabilities = vim.tbl_deep_extend(
      "force",
      vim.lsp.protocol.make_client_capabilities(),

      -- support added by lsp-file-operations
      {
        workspace = {
          fileOperations = {
            willRename = true,
            didRename = true,
            willCreate = true,
            didCreate = true,
            willDelete = true,
            didDelete = true,
          }
        }
      }
    )
  }
)

Shouldn't this be mentioned in the README?

Plugin doesn't work on Windows atleast with tsserver

Tried same min config on Ubuntu Wsl on same project and plugin works perfectly but on Windows it doesn't make any changes while renaming/moving files etc. Server is attached correctly, renaming works fine on Windows with jose-elias-alvarez/typescript.nvim plugin.

Expected behaviour: imports update.
Current behaviour: no changes.

This is my one file config:

-- Plugin manager loading
local lazypath = vim.fn.stdpath("data") .. "/lazy/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",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

-- Plugins setup
require("lazy").setup({
  -- Min lsp config with tsserver
  {
    "neovim/nvim-lspconfig",
    config = function()
      require("lspconfig").tsserver.setup({})
    end,
  },
  -- nvim-lsp-file-operations min config
  {
    "antosha417/nvim-lsp-file-operations",
    dependencies = {
      "nvim-lua/plenary.nvim",
      {
        "nvim-tree/nvim-tree.lua",
        version = "*",
        config = function()
          require("nvim-tree").setup({})
        end,
      },
    },
    config = function()
      require("lsp-file-operations").setup({
        debug = true,
      })
    end,
  },
}, {})

Those are logs while renaming file:

[DEBUG 13 / 05 / 2023 22: 39: 56] ...im - lsp - file - operations / lua / lsp - file - operations / utils.lua: 50: Matching name C: \Programming\React\project\src\Components\NewName.js to pattern[\/].*\.\(ts\|js\|jsx\|tsx\|mjs\|mts\|cjs\|cts\)$
[DEBUG 13 / 05 / 2023 22: 39: 56] ...im - lsp - file - operations / lua / lsp - file - operations / utils.lua: 66: Path did match the filter C: \Programming\React\project\src\Components\NewName.js {
  pattern = {
    glob = "**/*.{ts,js,jsx,tsx,mjs,mts,cjs,cts}",
    matches = "file"
  },
    scheme = "file"
}
[DEBUG 13 / 05 / 2023 22: 39: 56] ...-file - operations / lua / lsp - file - operations / will - rename.lua: 7: going to get workspace edit
[DEBUG 13 / 05 / 2023 22: 39: 56] ...-file - operations / lua / lsp - file - operations / will - rename.lua: 16: Sending workspace / willRenameFiles request {
  files = { {
    newUri = "file://C:\\Programming\\React\\project\\src\\Components\\Message.js",
      oldUri = "file://C:\\Programming\\React\\project\\src\\Components\\NewName.js"
  }
}
}
[DEBUG 13 / 05 / 2023 22: 39: 56] ...-file - operations / lua / lsp - file - operations / will - rename.lua: 19: Got workspace / willRenameFiles response {
  result = {
    changes = vim.empty_dict()
  }
}
[DEBUG 13 / 05 / 2023 22: 39: 56] ...-file - operations / lua / lsp - file - operations / will - rename.lua: 32: going to apply workspace edit {
  changes = vim.empty_dict()
}

Logs while moving to subfolder:

[DEBUG 13/05/2023 22:40:29] ...im-lsp-file-operations/lua/lsp-file-operations/utils.lua:50: Matching name C:\Programming\React\project\src\Components\subfolder\Message.js to pattern [\/].*\.\(ts\|js\|jsx\|tsx\|mjs\|mts\|cjs\|cts\)$
[DEBUG 13/05/2023 22:40:29] ...im-lsp-file-operations/lua/lsp-file-operations/utils.lua:66: Path did match the filter C:\Programming\React\project\src\Components\subfolder\Message.js {
  pattern = {
    glob = "**/*.{ts,js,jsx,tsx,mjs,mts,cjs,cts}",
    matches = "file"
  },
  scheme = "file"
}
[DEBUG 13/05/2023 22:40:29] ...-file-operations/lua/lsp-file-operations/will-rename.lua:7: going to get workspace edit
[DEBUG 13/05/2023 22:40:29] ...-file-operations/lua/lsp-file-operations/will-rename.lua:16: Sending workspace/willRenameFiles request {
  files = { {
    newUri = "file://C:\\Programming\\React\\project\\src\\Components\\Message.js",
    oldUri = "file://C:\\Programming\\React\\project\\src\\Components\\subfolder\\Message.js"
    } }
}
[DEBUG 13/05/2023 22:40:29] ...-file-operations/lua/lsp-file-operations/will-rename.lua:19: Got workspace/willRenameFiles response {
  result = {
    changes = vim.empty_dict()
  }
}
[DEBUG 13/05/2023 22:40:29] ...-file-operations/lua/lsp-file-operations/will-rename.lua:32: going to apply workspace edit {
  changes = vim.empty_dict()
}

Maybe Windows paths cause problems.

Probably plugin doesn't work with .ts and .tsx files

Hi, I am using LunarVim, I have installed typescript-language-server. Also typescript and tsx from treesitter. I installed and setup lsp-file-operations. When I rename the filename (.ts or .tsx) through nvim-tree only the filename is changed. No imports are updated. Do you have any ideas about what is wrong?

Error for WillRenameNode event

Hey!
When renaming a dart file, I get the error below:

Handler for event WillRenameNode errored. nvim-lsp-file-operations/lua/lsp-file-operations/utils.lua:27: attempt to call method 'new' (a nil value)

My dart lsp is setup and it does support willRenameFiles request.

Feature request: support async LSP file operations

Thank you for your work on this plugin, it has been working very well for me with nvim-tree so far!

I'm not sure how difficult this would be to support, however I think it would be a killer feature to support asynchronous LSP file operations. Currently, when renaming a file (especially in a larger codebase) it may take several seconds to complete the LSP file operation.
Since this is happening synchronously, it blocks the UI for several seconds until the action is completed.

Opening up this ticket here to at least start a conversation of the feasibility of supporting async LSP file operations in order to unblock the UI until the file operations are completed. Ideally once complete, it would have nvim-tree/neo-tree refresh with updated files.

Lazy Load Plugin

Thanks for this fantastic plugin! I noticed that, copying the setup (using Lazy as a package manager) in the README, the plugin never loaded. I've "solved" the issue by adding lazy = false but ideally it would load on the correct event. Could you suggest the appropriate event to ensure the plugin is loaded only when necessary for renaming/moving (cutting and pasting) the file in nvim-tree? Thanks

Plugin causing nvim to (silently) exit with status 134

I'm using nvim 0.9.4 on macOS 14.1.1 and I've noticed enabling this plugin causes nvim to exit with an error status:

$ nvim
$ echo $?
134

This happens consistently when the plugin is enabled, even just loading vim and immediately quitting is sufficient. There is no error message or log that I can see, but it causes issues with programs using EDITOR and then expecting a zero status from saving and quitting.

I enabled the debug log for nvim-lsp-file-operations but all it shows is:

[DEBUG Sat Dec  2 22:30:53 2023] /Users/me/.local/share/LazyVim/lazy/nvim-lsp-file-operations/lua/lsp-file-operations.lua:27: Setting up neo-tree integration
[DEBUG Sat Dec  2 22:30:53 2023] /Users/me/.local/share/LazyVim/lazy/nvim-lsp-file-operations/lua/lsp-file-operations.lua:56: Neo-tree integration setup complete
[DEBUG Sat Dec  2 22:32:17 2023] /Users/me/.local/share/LazyVim/lazy/nvim-lsp-file-operations/lua/lsp-file-operations.lua:27: Setting up neo-tree integration
[DEBUG Sat Dec  2 22:32:17 2023] /Users/me/.local/share/LazyVim/lazy/nvim-lsp-file-operations/lua/lsp-file-operations.lua:56: Neo-tree integration setup complete

Any thoughts on how to proceed debugging? Thanks

Save files after applying workspace edit

Neovim does dot save the files after applying workspace edit. Because of that we need to manually save files to stop seeing errors after refactoring.
Wolud be great to have an option to automatically save edited files. Or to put them in quckfix list. Or something like that.

not working after installing fd-find

i'm not sure but I occurring this problem after sync the lazy.nvim, because previous day I can do the rename and moving file stuff, hopefully you can help me resolve this issue. your plugin really help me.

[email protected]
lazy as package manager

what I do is just copy (x) and paste (p) file into nested folder

here's the debug log:

[DEBUG Tue 21 Mar 2023 10:02:23 AM WIB] ...im-lsp-file-operations/lua/lsp-file-operations/utils.lua:66: Path did match the filter /home/nandafirmans/Development/dataon/fe-micro-standard/src/lib/components/other/date-time-picker/DateTimePickerMobileCarousel.js {
  pattern = {
    glob = "**/*.{ts,js,jsx,tsx,mjs,mts,cjs,cts}",
    matches = "file"
  },
  scheme = "file"
}
[DEBUG Tue 21 Mar 2023 10:02:23 AM WIB] ...-file-operations/lua/lsp-file-operations/will-rename.lua:7: going to get workspace edit
[DEBUG Tue 21 Mar 2023 10:02:23 AM WIB] ...-file-operations/lua/lsp-file-operations/will-rename.lua:16: Sending workspace/willRenameFiles request {
  files = { {
      newUri = "file:///home/nandafirmans/Development/dataon/fe-micro-standard/src/lib/components/other/date-time-picker/context/DateTimePickerMobileCarousel.js",
      oldUri = "file:///home/nandafirmans/Development/dataon/fe-micro-standard/src/lib/components/other/date-time-picker/DateTimePickerMobileCarousel.js"
    } }
}
[DEBUG Tue 21 Mar 2023 10:02:48 AM WIB] ...-file-operations/lua/lsp-file-operations/will-rename.lua:19: Got workspace/willRenameFiles response nil```

Not working with tsserver?

After setting this up and trying to rename a TypeScript file, nothing happens and the debug also doesn't do anything when renaming. The plugin seems to be properly setup because there is an initial debug saying "Setting up nvim-tree integration"

Has tsserver support yet to be added?

Integration with Oil.nvim

I personally don't use neotree/nvim-tree but rather Oil.nvim
I would love to see support for that plugin because that's the main plugin I use for file operations like renaming/moving/deleting

This will only work if you open the file you want to rename in tsserver

my config:

  {
    "antosha417/nvim-lsp-file-operations",
    dependencies = {
      "nvim-lua/plenary.nvim",
      "nvim-neo-tree/neo-tree.nvim",
    },
    config = function()
      require("lsp-file-operations").setup({ debug = false })
    end,
  },

If I change the file name directly on the file tree, it won't work.

If I open this file and then modify it it works fine.

New integration from yazi.nvim ๐Ÿ‘‹๐Ÿป

Hi! I am working with a neovim plugin for a terminal file manager. I added support for renaming and deleting files using your implementation (love it).

I was wondering if you could skim over my implementation here mikavilpas/yazi.nvim#190

  • should I do some kind of initialization logic? It seems like currently this plugin integrates with nvim-tree and neo-tree entirely based on their events, which is pretty clever
  • are you fine with me importing your internal modules (lsp-file-operations.did-rename etc.)? Or should this be done some other way? I am not sure if you consider them a part of your stable, public API.

Also, I asked for your plugin to be packaged into luarocks here nvim-neorocks/nurr#14 so that I can depend on it from my continuous integration test suite.

Debug output is not helpful

I'm trying to make this work and it is not, I enabled debug and all it shows are the following:

[DEBUG Tue Nov 21 23:52:50 2023] /Users/slu/.local/share/nvim/lazy/nvim-lsp-file-operations/lua/lsp-file-operations.lua:27: Setting up neo-tree integration
[DEBUG Tue Nov 21 23:52:50 2023] /Users/slu/.local/share/nvim/lazy/nvim-lsp-file-operations/lua/lsp-file-operations.lua:56: Neo-tree integration setup complete

We should at least have an output of some kind when neotree sends some event.

`setup` Error When No Arguments

require("lsp-file-operations").setup()
Error detected while processing /home/alex/.dotfiles/config/nvim/init.lua:
E5113: Error while calling lua chunk: vim/shared.lua:0: after the second argument: expected table, got nil
stack traceback:
        [C]: in function 'error'
        vim/shared.lua: in function 'validate'
        vim/shared.lua: in function 'tbl_deep_extend'
        ...art/nvim-lsp-file-operations/lua/lsp-file-operations.lua:11: in function 'setup'

Might want to null check the argument, something like

opts = vim.tbl_deep_extend("force", default_config, opts or {})

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.