feat: updated ts and vtls

This commit is contained in:
Kemboi Elvis 2025-06-04 12:26:08 +03:00
parent 1c5312d637
commit 51c8e42d75

View file

@ -55,6 +55,11 @@ return {
suggest = {
completeFunctionCalls = true,
},
preferences = {
removeUnusedImports = true,
organizeImportsOnSave = true,
includePackageJsonAutoImports = "auto",
},
inlayHints = {
enumMemberValues = { enabled = true },
functionLikeReturnTypes = { enabled = true },
@ -64,6 +69,17 @@ return {
variableTypes = { enabled = false },
},
},
javascript = {
updateImportsOnFileMove = { enabled = "always" },
suggest = {
completeFunctionCalls = true,
},
preferences = {
removeUnusedImports = true,
organizeImportsOnSave = true,
includePackageJsonAutoImports = "auto",
},
},
},
keys = {
{
@ -132,6 +148,33 @@ return {
end,
vtsls = function(_, opts)
LazyVim.lsp.on_attach(function(client, buffer)
-- Auto-organize imports and remove unused on save
if client.name == "vtsls" then
local ts_group = vim.api.nvim_create_augroup("TypeScriptAutoFix", { clear = true })
vim.api.nvim_create_autocmd("BufWritePre", {
group = ts_group,
buffer = buffer,
callback = function()
-- Remove unused imports
vim.lsp.buf.code_action({
apply = true,
filter = function(action)
return action.kind == "source.removeUnused.ts"
end,
})
-- Organize imports
vim.lsp.buf.code_action({
apply = true,
filter = function(action)
return action.kind == "source.organizeImports"
end,
})
end,
})
end
client.commands["_typescript.moveToFileRefactoring"] = function(command, ctx)
---@type string, string, lsp.Range
local action, uri, range = unpack(command.arguments)