nvim-lsp-file-operations
is a Neovim plugin that adds support for file operations using built-in LSP support. This plugin works by subscribing to events emitted by nvim-tree, neo-tree and triptych. But other integrations are possible.
Full implementation of all workspace.fileOperations
in the current lsp spec:
If you have usecases for any other operations please open an issue.
use { "antosha417/nvim-lsp-file-operations", requires = { "nvim-lua/plenary.nvim", -- Uncomment whichever supported plugin(s) you use -- "nvim-tree/nvim-tree.lua", -- "nvim-neo-tree/neo-tree.nvim", -- "simonmclean/triptych.nvim" }, config = function() require("lsp-file-operations").setup() end, }
Note that the config function will let you skip the setup step.
return { { "antosha417/nvim-lsp-file-operations", dependencies = { "nvim-lua/plenary.nvim", -- Uncomment whichever supported plugin(s) you use -- "nvim-tree/nvim-tree.lua", -- "nvim-neo-tree/neo-tree.nvim", -- "simonmclean/triptych.nvim" }, config = function() require("lsp-file-operations").setup() end, }, }
Please note that the order that the plugins load in is important, neo-tree must load before nvim-lsp-file-operations for it to work, so nvim-lsp-file-operations depends on neo-tree and not the other way around.
require("lsp-file-operations").setup()
This is equivalent to:
require("lsp-file-operations").setup { -- used to see debug logs in file `vim.fn.stdpath("cache") .. lsp-file-operations.log` debug = false, -- select which file operations to enable operations = { willRenameFiles = true, didRenameFiles = true, willCreateFiles = true, didCreateFiles = true, willDeleteFiles = true, didDeleteFiles = true, }, -- how long to wait (in milliseconds) for file rename information before cancelling timeout_ms = 10000, }
Some LSP servers also expect to be informed about the extended client capabilities. If you use nvim-lspconfig you can configure the default client capabilities that will be sent to all servers like this:
local lspconfig = require'lspconfig' -- Set global defaults for all servers lspconfig.util.default_config = vim.tbl_extend( 'force', lspconfig.util.default_config, { capabilities = vim.tbl_deep_extend( "force", vim.lsp.protocol.make_client_capabilities(), -- returns configured operations if setup() was already called -- or default operations if not require'lsp-file-operations'.default_capabilities(), ) } )
PRs are always welcome.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4