typescript-tools.nvim
typescript-tools.nvim copied to clipboard
Restarting tsserver breaks "TSToolsRemoveUnusedImports"
I use this autocmd which works really well. However when I restart the tsserver and then save the file the autocmd breaks.
This is the autocmd:
-- Remove unused import on save
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = "*.ts*",
command = ":TSToolsRemoveUnusedImports sync",
})
This is the error:
Error detected while processing BufWritePre Autocommands for "*.ts*":
Error executing Lua callback: .../lazy/typescript-tools.nvim/lua/typescript-tools/api.lua:60: attempt to index local 'res' (a nil value)
stack traceback:
.../lazy/typescript-tools.nvim/lua/typescript-tools/api.lua:60: in function 'organize_imports_mode'
.../lazy/typescript-tools.nvim/lua/typescript-tools/api.lua:78: in function 'remove_unused_imports'
...script-tools.nvim/lua/typescript-tools/user_commands.lua:36: in function 'fn'
Restarting neovim fixes this issue, but it would be nice not to have to restart neovim every time I want to restart the lsp.