Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restarting tsserver breaks "TSToolsRemoveUnusedImports" #268

Closed
redsuperbat opened this issue May 17, 2024 · 3 comments
Closed

Restarting tsserver breaks "TSToolsRemoveUnusedImports" #268

redsuperbat opened this issue May 17, 2024 · 3 comments

Comments

@redsuperbat
Copy link

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.

@KostkaBrukowa
Copy link
Collaborator

Hmm... is this still an issue? I've tried this with my config and nothig breaks. And how do you restart tsserver? With :LspRestart?

@KostkaBrukowa
Copy link
Collaborator

Or if you are using nightly this might help: #275

@redsuperbat
Copy link
Author

Hi!
Thanks for looking into it, yes I was using nightly. However I switched from it since it was messing up my workflow :)
Seems like you found the issue, great! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants