9fans / acme-lsp

Language Server Protocol tools for the acme text editor
MIT License
193 stars 25 forks source link

feature: force ignore directory, or respect underscore convention? #35

Closed mpl closed 3 years ago

mpl commented 4 years ago

Hi,

In an existing github project where I contribute (https://github.com/containous/yaegi), they have a "_test" directory at the root, containing .go files, each of them being a main package. I know they're not supposed to have more than one main in a directory, but on the other hand, since the directory starts with an underscore, it is ignored by the go tool ('go test ./...' at the root runs fine), as I think is the convention.

The reason I'm bringing this up, is because it seems acme-lsp chokes on that structure. If I add the project with L ws+, most things work fine with the L commands. However, as soon as I open in acme one of the files in the _test dir, acme-lsp seems to enter an infinite loop and burning CPU, spewing errors in /LSP/Diagnostics forever.

So don't you think acme-lsp should ignore any file or directory starting with an underscore, as the go tool does? Or if not, could we have a configuration option that tells it to ignore a specific directory? If not, can you think of any other work-around I could use?

I was thinking that in the meantime maybe I could add build tags to all of the files in the _test directory, but I'm not sure that would do the trick, I haven't tried yet.

fhs commented 4 years ago

As workaround, you can choose to not send those files to acme-lsp:

acme-lsp -server '^[^_]+/[^/]+\.go$:gopls' 

Check you don't have any old configuration with -showconfig:

$ acme-lsp -server '^[^_]+/[^/]+\.go$:gopls' -showconfig
[Servers]
  [Servers._userCmdServer0]
    Command = ["gopls"]
...
[[FilenameHandlers]]
  Pattern = "^[^_]+/[^/]+\\.go$"
  ServerKey = "_userCmdServer0"

The regexp is not ideal because it will also exclude other directories with underscore in them.

I need to investigate why acme-lsp is getting into infinite loop. I wasn't able to reproduce the issue on vscode.

mpl commented 4 years ago

As workaround, you can choose to not send those files to acme-lsp:

acme-lsp -server '^[^_]+/[^/]+\.go$:gopls' 

Cool, thanks, I'll try it out tomorrow.

Check you don't have any old configuration with -showconfig:

$ acme-lsp -server '^[^_]+/[^/]+\.go$:gopls' -showconfig
[Servers]
  [Servers._userCmdServer0]
    Command = ["gopls"]
...
[[FilenameHandlers]]
  Pattern = "^[^_]+/[^/]+\\.go$"
  ServerKey = "_userCmdServer0"

The regexp is not ideal because it will also exclude other directories with underscore in them.

yeah, fair enough. It should be fine for my use-case and my daily work though, so I can definitely live with that in the meantime.

I need to investigate why acme-lsp is getting into infinite loop. I wasn't able to reproduce the issue on vscode.

mpl commented 4 years ago

the exclusion regex seems to do the trick for now, thanks!

fhs commented 4 years ago

It's actually not a infinite loop I originally thought. It's just really slow because it redraws the whole window after each new diagnostic. I think I can make it fast for few hundred diagnostics, but it's going to be a challenge for 1000+ diagnostics. So, I've opened a gopls issue: https://github.com/golang/go/issues/39563

mpl commented 4 years ago

It's actually not a infinite loop I originally thought. It's just really slow because it redraws the whole window after each new diagnostic. I think I can make it fast for few hundred diagnostics, but it's going to be a challenge for 1000+ diagnostics. So, I've opened a gopls issue: golang/go#39563

Ah ok, good to know. I must admit I probably only left acme-lsp to run for a minute tops, as the CPU usage was making my laptop noisy, so I never saw it actually stop spewing diagnostics.

fhs commented 3 years ago

I think the issue was fixed on gopls v0.5.0, which was released last month. Closing.