From f365fe5270fb4ef0628217136149d1741caa6338 Mon Sep 17 00:00:00 2001 From: Radvil Date: Wed, 12 Jun 2024 22:30:39 +0800 Subject: [PATCH] feat(angular): Better rename override Since the keys provided only applied on server attached, so I assumed this is safe (cmiiw). And with this renaming using angularls will behave much similar to vscode. Following some results I tested: - rename variable in `xxx.component.ts` >> `xxx.component.html` will also reflect - rename variable in `xxx.component.html` >> `xxx.component.ts` will also reflect - rename variable component in `xxx.component.ts` >> inline view template will also relfected & vise versa But please note that this will disable the html capabilities of renaming (similar to vscode), so renaming html element name won't work. --- lua/lazyvim/plugins/extras/lang/angular.lua | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/angular.lua b/lua/lazyvim/plugins/extras/lang/angular.lua index 3e2b455b..e1db3b50 100644 --- a/lua/lazyvim/plugins/extras/lang/angular.lua +++ b/lua/lazyvim/plugins/extras/lang/angular.lua @@ -37,12 +37,20 @@ return { root_dir = function(root_dir) return require("lspconfig.util").root_pattern(unpack(angular_root_pattern))(root_dir) end, - angularls = function() - LazyVim.lsp.on_attach(function(client) - --HACK: disable angular renaming capability due to duplicate rename popping up - client.server_capabilities.renameProvider = false - end, "angularls") - end, + keys = { + { + "cr", + function() + vim.lsp.buf.rename(nil, { + filter = function(client) + return client.name == "angularls" + end, + }) + end, + desc = "Rename", + }, + }, + }, }, }, },