mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
feat: updated ts and vtls
This commit is contained in:
parent
1c5312d637
commit
51c8e42d75
1 changed files with 43 additions and 0 deletions
|
|
@ -55,6 +55,11 @@ return {
|
||||||
suggest = {
|
suggest = {
|
||||||
completeFunctionCalls = true,
|
completeFunctionCalls = true,
|
||||||
},
|
},
|
||||||
|
preferences = {
|
||||||
|
removeUnusedImports = true,
|
||||||
|
organizeImportsOnSave = true,
|
||||||
|
includePackageJsonAutoImports = "auto",
|
||||||
|
},
|
||||||
inlayHints = {
|
inlayHints = {
|
||||||
enumMemberValues = { enabled = true },
|
enumMemberValues = { enabled = true },
|
||||||
functionLikeReturnTypes = { enabled = true },
|
functionLikeReturnTypes = { enabled = true },
|
||||||
|
|
@ -64,6 +69,17 @@ return {
|
||||||
variableTypes = { enabled = false },
|
variableTypes = { enabled = false },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
javascript = {
|
||||||
|
updateImportsOnFileMove = { enabled = "always" },
|
||||||
|
suggest = {
|
||||||
|
completeFunctionCalls = true,
|
||||||
|
},
|
||||||
|
preferences = {
|
||||||
|
removeUnusedImports = true,
|
||||||
|
organizeImportsOnSave = true,
|
||||||
|
includePackageJsonAutoImports = "auto",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
keys = {
|
keys = {
|
||||||
{
|
{
|
||||||
|
|
@ -132,6 +148,33 @@ return {
|
||||||
end,
|
end,
|
||||||
vtsls = function(_, opts)
|
vtsls = function(_, opts)
|
||||||
LazyVim.lsp.on_attach(function(client, buffer)
|
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)
|
client.commands["_typescript.moveToFileRefactoring"] = function(command, ctx)
|
||||||
---@type string, string, lsp.Range
|
---@type string, string, lsp.Range
|
||||||
local action, uri, range = unpack(command.arguments)
|
local action, uri, range = unpack(command.arguments)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue