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.
This commit is contained in:
Radvil 2024-06-12 22:30:39 +08:00
parent 2fd07da9a8
commit f365fe5270

View file

@ -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 = {
{
"<leader>cr",
function()
vim.lsp.buf.rename(nil, {
filter = function(client)
return client.name == "angularls"
end,
})
end,
desc = "Rename",
},
},
},
},
},
},