Skip to content

Commit

Permalink
feat(pack/typescript): handle neotree rename imports
Browse files Browse the repository at this point in the history
Signed-off-by: taskylizard <[email protected]>
  • Loading branch information
taskylizard authored and mehalter committed Mar 15, 2023
1 parent 6ddffc5 commit cd18f64
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
1 change: 1 addition & 0 deletions lua/astrocommunity/pack/typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ This plugin pack does the following:
- Adds [nvim-dap-vscode-js](https://github.com/mxsdev/nvim-dap-vscode-js) for debugging
- Adds [typescript.nvim](https://github.com/jose-elias-alvarez/typescript.nvim) for language specific tooling
- Adds [package-info.nvim](https://github.com/vuki656/package-info.nvim) for project package management
- Handles file imports on rename or move within neo-tree
36 changes: 35 additions & 1 deletion lua/astrocommunity/pack/typescript/typescript.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
local utils = require "astrocommunity.utils"
local events = require "neo-tree.events"
local function on_file_remove(args)
local ts_clients = vim.lsp.get_active_clients { name = "tsserver" }
for _, ts_client in ipairs(ts_clients) do
ts_client.request("workspace/executeCommand", {
command = "_typescript.applyRenameFile",
arguments = {
{
sourceUri = vim.uri_from_fname(args.source),
targetUri = vim.uri_from_fname(args.destination),
},
},
})
end
end

return {
{
"nvim-treesitter/nvim-treesitter",
Expand Down Expand Up @@ -51,7 +67,10 @@ return {
ft = { "ts", "js", "tsx", "jsx" },
enabled = true,
dependencies = {
{ "mxsdev/nvim-dap-vscode-js", opts = { debugger_cmd = { "js-debug-adapter" }, adapters = { "pwa-node" } } },
{
"mxsdev/nvim-dap-vscode-js",
opts = { debugger_cmd = { "js-debug-adapter" }, adapters = { "pwa-node" } },
},
{ "theHamsta/nvim-dap-virtual-text", config = true },
{ "rcarriga/nvim-dap-ui", config = true },
},
Expand Down Expand Up @@ -108,4 +127,19 @@ return {
},
opts = function() return { server = require("astronvim.utils.lsp").config "tsserver" } end,
},
{
"nvim-neo-tree/neo-tree.nvim",
opts = {
event_handlers = {
{
event = events.FILE_MOVED,
handler = on_file_remove,
},
{
event = events.FILE_RENAMED,
handler = on_file_remove,
},
},
},
},
}

0 comments on commit cd18f64

Please sign in to comment.