WhoIsSethDaniel / goldsmith.nvim

Use Neovim features, such as built-in LSP and tree-sitter, and develop Go code.
MIT License
57 stars 3 forks source link

Safely fallback to default encoding on nil response #56

Closed antoineco closed 2 years ago

antoineco commented 2 years ago

Inside goldsmith.format.organize_imports, get_client_by_id() may return nil for various reasons. When this occurs, the following error is thrown:

E5108: Error executing lua [...] attempt to index global 'client' (a nil value)

To prevent this kind of scenario, I suggest we fall back to 'utf-8' as default encoding when get_client_by_id() returns nil.

WhoIsSethDaniel commented 2 years ago

Looks good. Thank you!