From 6ace4db082370c3f7a2de4220d5174caec2c5ea6 Mon Sep 17 00:00:00 2001 From: William Boman Date: Fri, 21 May 2021 18:52:45 +0200 Subject: add nvim-tree.lua adapter --- README.md | 14 +++++++++++++- lua/nvim-lsp-installer/adapters/nvim-tree.lua | 17 +++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 lua/nvim-lsp-installer/adapters/nvim-tree.lua diff --git a/README.md b/README.md index 24fe7fc8..e6235f74 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ end The `tsserver` language server comes with the following extras: -- `rename_file(old, new)` Tells the language server that a file was renamed. Useful when refactoring. +- `rename_file(old, new)` Tells the language server that a file was renamed. Useful when refactoring. Refer to the [adapters section](#adapters) to find plugin integrations that automatically executes this for you. Usage: @@ -113,6 +113,18 @@ require'nvim-lsp-installer.extras.tsserver'.rename_file(old, new) require'nvim-lsp-installer.extras.tsserver'.organize_imports(bufname) ``` +## Adapters + +### [kyazdani42/nvim-tree.lua](https://github.com/kyazdani42/nvim-tree.lua) + +```lua +require'nvim-lsp-installer.adapters.nvim-tree'.connect() +``` + +Supported capabilities: + + - `_typescript.applyRenameFile`. Automatically executes the rename file client request when renaming a node. + ## Logo Illustrations in the logo are derived from [@Kaligule](https://schauderbasis.de/)'s "Robots" collection. diff --git a/lua/nvim-lsp-installer/adapters/nvim-tree.lua b/lua/nvim-lsp-installer/adapters/nvim-tree.lua new file mode 100644 index 00000000..ec240ac1 --- /dev/null +++ b/lua/nvim-lsp-installer/adapters/nvim-tree.lua @@ -0,0 +1,17 @@ +local M = {} + +local tsserverExtras = require("nvim-lsp-installer.extras.tsserver") + +function M.connect() + local ok, events = pcall(require, "nvim-tree.events") + if not ok then + return vim.api.nvim_err_writeln("Unable to import nvim-tree module when connecting nvim-lsp-installer adapter.") + end + + events.on_node_renamed(function (payload) + -- TODO: not do this when renaming folders + tsserverExtras.rename_file(payload.old_name, payload.new_name) + end) +end + +return M -- cgit v1.2.3-70-g09d2