Terraform lsp.log going crazy

Hi

I have noticed that my lsp.log from neovim is going crazy every time I use terraformls lsp server.

I have attached image just for reference as logs contain paths which I was not comfortable to expose.

my setup is simple.

I use
nvim version: NVIM v0.9.0-dev-1343-gbcd25b200-dirty
with mason plugin for installing LSP servers.

terraform-ls version
0.29.3
platform: darwin/arm64
go: go1.19.1
compiler: gc

I have also noticed when I open the terraform file it actually takes few seconds for LSP server to start working.

I am not sure what else I can provide but if you need anything else please let me know.

Hi @lanox,

Just to make sure it’s clear what you’re referring to, when you say it’s “going crazy” do you just mean that there are more events being written to the file than you expected, or is it writing something specific in there that is concerning to you?

What you’ve shown here seems to just be the normal log output of the language server, which the program is writing to stderr. The language server does have a -log-file option to its serve command which can send that information to a specific file, overriding the default behavior of writing to stderr. If you don’t care to see the logs at all then I suppose you could send them to /dev/null or similar, so that they’ll be discarded entirely.

If you haven’t already then I would suggest reporting the performance concern in the terraform-ls GitHub repository.

Hi @apparentlymart

Thanks for your response, yes when I said going crazy I was referring that it writes thousands of lines and they all seem to be reported as [ERROR] so I ultimately thought that there is something wrong as I am experiencing very slow performance with LSP server in neovim. It takes about 5-10 seconds before autocomplete starts to work.

Out of curiosity why is it creating those events under [ERROR]?

Hi @lanox,

I’m not familiar with this Neovim LSP integration you are using, but as far as I can tell from the messaging it seems to be your Neovim plugin that is deciding to classify them as error events, not the language server.

The language server is writing its logs to the “stderr” standard file handle, and so I suppose it is reasonable for the LSP plugin to treat any data written to that as being an error, but the language server itself doesn’t distinguish between different log levels so not everything it writes to its logs is being classified as an error by that plugin.

There isn’t any standard filehandle for logging in Unix, so terraform-ls uses stderr for that because there isn’t any obviously better place without explicit configuration. (The language server protocol can use stdout as the primary communication channel with the client, so that isn’t an option here.)

Interesting, to be honest, you could be right.

I am using this plugin:

Mason Nvim

And this is the list of plug-ins as its calls to be installed

Terraform-ls

There isn’t much to it at all, to be honest.

Do you think it’s worth asking under neovim? Or mason package?