Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sidlatau/dart-lsp-refactorings.nvim
https://github.com/sidlatau/dart-lsp-refactorings.nvim
Last synced: 28 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/sidlatau/dart-lsp-refactorings.nvim
- Owner: sidlatau
- License: mit
- Created: 2022-11-20T11:16:28.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-25T15:50:18.000Z (over 1 year ago)
- Last Synced: 2023-03-02T04:35:35.598Z (over 1 year ago)
- Language: Lua
- Size: 19.5 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dart-lsp-refactorings.nvim
[Dart language server](https://github.com/dart-lang/sdk/blob/main/pkg/analysis_server/tool/lsp_spec/README.md) has setting to `renameFilesWithClasses` and to update imports `updateImportsOnRename` after files was renamed. But now imports are not updated. LSP server support `workspace/willRenameFiles` client request to get import changes. But Neovim LSP does not have support for this request. This plugin modifies `lsp.buf.rename` function to call `workspace/willRenameFiles` request before file rename and apply these changes after rename is done.
## Installation
Using `packer.nvim`
```lua
use {'sidlatau/dart-lsp-refactorings.nvim' }
```## Usage
```lua
require("dart-lsp-refactorings").rename()```
Call this function when you want rename class or anything else. If file will be renamed too, this function will update imports.
---
```lua
require("dart-lsp-refactorings").on_rename_file({
source = "/source_file_path.dart",
destination = "/destination_file_path.dart",
callback = function()
-- function to be called to finish file rename
end
})
```Hook function that get import changes and applies these changes before file rename.
Example of using with [neo-tree](https://github.com/nvim-neo-tree/neo-tree.nvim)```lua
neo_tree.setup {
...
event_handlers = {
{
event = "before_file_rename",
handler = function(args)
local ok, refact = pcall(require, "dart-lsp-refactorings")
if ok then
refact.on_rename_file(args)
return { handled = true }
end
end,
},
{
event = "before_file_move",
handler = function(args)
local ok, refact = pcall(require, "dart-lsp-refactorings")
if ok then
refact.on_rename_file(args)
return { handled = true }
end
end,
},
},
}
```