SUMMARY When I enable the terraform LSP client (terraform-ls) it goes into a frenzy and tries to scan my whole $HOME directory. Span starts to spin up and the Output tabis spammed with logs like the ones posted below. I wasn't able yet to catch the beginning of that output because even with a `while sleep .1; do killall terraform-ls; done` loop in the background it is just too quick. STEPS TO REPRODUCE 1. Enable Terraform LSP 2. Open a Terraform file OBSERVED RESULT CPU fan starts spinning up, Output window is spammed with logs which indicate that the LSP client tries to scan my .cache directory. EXPECTED RESULT A working LSP client. SOFTWARE/OS VERSIONS Operating System: KDE neon User Edition KDE Plasma Version: 6.4.2 KDE Frameworks Version: 6.15.0 Qt Version: 6.9.0 Kernel Version: 6.11.0-29-generic (64-bit) Graphics Platform: Wayland ADDITIONAL INFORMATION Log excerpt: 2025/07/14 11:42:55 walker.go:217: walking of {file:///home/ me/.cache/go/pkg/mod/cache/download/cloud.google.com/go/networksecurity} finished 2025/07/14 11:42:55 discover.go:26: bus: -> Discover /home/ me/.cache/go/pkg/mod/cache/download/cloud.google.com/go/notebooks 2025/07/14 11:42:55 discover.go:26: bus: -> Discover /home/ me/.cache/go/pkg/mod/cache/download/cloud.google.com/go/notebooks/@v 2025/07/14 11:42:55 walker.go:217: walking of {file:///home/ me/.cache/go/pkg/mod/cache/download/cloud.google.com/go/notebooks/@v} finished 2025/07/14 11:42:55 walker.go:217: walking of {file:///home/ me/.cache/go/pkg/mod/cache/download/cloud.google.com/go/notebooks} finished 2025/07/14 11:42:55 discover.go:26: bus: -> Discover /home/ me/.cache/go/pkg/mod/cache/download/cloud.google.com/go/optimization 2025/07/14 11:42:55 discover.go:26: bus: -> Discover /home/ me/.cache/go/pkg/mod/cache/download/cloud.google.com/go/optimization/@v 2025/07/14 11:42:55 walker.go:217: walking of {file:///home/ me/.cache/go/pkg/mod/cache/download/cloud.google.com/go/optimization/@v} finished 2025/07/14 11:42:55 walker.go:217: walking of {file:///home/ me/.cache/go/pkg/mod/cache/download/cloud.google.com/go/optimization} finished 2025/07/14 11:42:55 discover.go:26: bus: -> Discover /home/ me/.cache/go/pkg/mod/cache/download/cloud.google.com/go/orchestration 2025/07/14 11:42:55 discover.go:26: bus: -> Discover /home/ me/.cache/go/pkg/mod/cache/download/cloud.google.com/go/orchestration/@v 2025/07/14 11:42:55 walker.go:217: walking of {file:///home/ me/.cache/go/pkg/mod/cache/download/cloud.google.com/go/orchestration/@v} finished 2025/07/14 11:42:55 walker.go:217: walking of {file:///home/ me/.cache/go/pkg/mod/cache/download/cloud.google.com/go/orchestration} finished 2025/07/14 11:42:55 discover.go:26: bus: -> Discover /home/ me/.cache/go/pkg/mod/cache/download/cloud.google.com/go/orgpolicy 2025/07/14 11:42:55 discover.go:26: bus: -> Discover /home/ me/.cache/go/pkg/mod/cache/download/cloud.google.com/go/orgpolicy/@v 2025/07/14 11:42:55 walker.go:217: walking of {file:///home/ me/.cache/go/pkg/mod/cache/download/cloud.google.com/go/orgpolicy/@v} finished 2025/07/14 11:42:55 walker.go:217: walking of {file:///home/ me/.cache/go/pkg/mod/cache/download/cloud.google.com/go/orgpolicy} finished 2025/07/14 11:42:55 discover.go:26: bus: -> Discover /home/ me/.cache/go/pkg/mod/cache/download/cloud.google.com/go/osconfig 2025/07/14 11:42:55 discover.go:26: bus: -> Discover /home/ me/.cache/go/pkg/mod/cache/download/cloud.google.com/go/osconfig/@v 2025/07/14 11:42:55 walker.go:217: walking of {file:///home/ me/.cache/go/pkg/mod/cache/download/cloud.google.com/go/osconfig/@v} finished 2025/07/14 11:42:55 walker.go:217: walking of {file:///home/ me/.cache/go/pkg/mod/cache/download/cloud.google.com/go/osconfig} finished 2025/07/14 11:42:55 discover.go:26: bus: -> Discover /home/ me/.cache/go/pkg/mod/cache/download/cloud.google.com/go/oslogin 2025/07/14 11:42:55 discover.go:26: bus: -> Discover /home/ me/.cache/go/pkg/mod/cache/download/cloud.google.com/go/oslogin/@v 2025/07/14 11:42:55 walker.go:217: walking of {file:///home/ me/.cache/go/pkg/mod/cache/download/cloud.google.com/go/oslogin/@v} finished 2025/07/14 11:42:55 walker.go:217: walking of {file:///home/ me/.cache/go/pkg/mod/cache/download/cloud.google.com/go/oslogin} finished 2025/07/14 11:42:55 discover.go:26: bus: -> Discover /home/ me/.cache/go/pkg/mod/cache/download/cloud.google.com/go/phishingprotection 2025/07/14 11:42:55 discover.go:26: bus: -> Discover /home/ me/.cache/go/pkg/mod/cache/download/cloud.google.com/go/phishingprotection/@v 2025/07/14 11:42:55 walker.go:217: walking of {file:///home/ me/.cache/go/pkg/mod/cache/download/cloud.google.com/go/phishingprotection/@v} finished
terraform-ls version: ``` 0.35.0 platform: linux/amd64 go: go1.23.2 compiler: gc ```
There is a slightly modified config available at https://github.com/hashicorp/terraform-ls/blob/main/docs/USAGE.md#kate which includes the ``"rootIndicationFileNames": ["*.tf", "*.tfvars"]` options but that doesn't help either.
What a fascinating Heisenbug: When I start kate as `env QT_LOGGING_RULES=katelspclientplugin=true kate locals.tf` (cf. https://docs.kde.org/stable5/en/kate/kate/kate-application-plugin-lspclient.html) the issue persists. When I start it as `env QT_LOGGING_RULES=katelspclientplugin=true LSPCLIENT_DEBUG=1 kate locals.tf` (I had to dig up that env variable from the source) the issue is gone!
I finally found the output in the journal. And indeed, the rootPath was set to my Home Directory even though the description at https://docs.kde.org/stable5/en/kate/kate/kate-application-plugin-lspclient.html sounds like it should have limited the root to my project folder. I was able to fix this by setting the root explicitly: ``` "terraform": { "command": ["terraform-ls", "serve"], "url": "https://github.com/hashicorp/terraform-ls", "highlightingModeRegex": "^Terraform$", "rootIndicationFileNames": ["*.tf", "*.tfvars"], "root": "%{Project:NativePath}" } ```
Can you paste the full contests of user settings json? The config needs to wrapped in: { "servers": { "terraform": { ... } } } Just like in the builtin settings. Also try to remove rootFileIndicationNames and root. See if the server can work without it.
Too late, I see you fixed it already, however I think: "rootIndicationFileNames": ["*.tf", "*.tfvars"], is wrong. Its a pattern, so I believe it should be: "rootIndicationFilePatterns": [....]
Thinking again, If the server doesn't work correctly, perhaps we should fix the default config that we ship. Can you confirm it doesn't work with default config? And perhaps you would like to open a merge request and fix it? The default config is here: https://invent.kde.org/utilities/kate/-/blob/master/addons/lspclient/settings.json
(In reply to Waqar Ahmed from comment #7) > Thinking again, If the server doesn't work correctly, perhaps we should fix > the default config that we ship. > > Can you confirm it doesn't work with default config? Yes, that's why I raised this issue. I re-read the explanation on https://docs.kde.org/stable5/en/kate/kate/kate-application-plugin-lspclient.html and I think I misunderstood this before. * "root" is only used if given and then the rules as descibed (absolue or relative) apply * "rootIndicationFileNames" only look for files in the *parent* directory which is why it didn't work for me * else it falls back to $HOME as it does here which causes the performance issues I see I haven't tried it yet but I think the best fix for this problem is to set ``` "root": "." ``` to avoid falling back to $HOME. I will rasie a PR for that as suggested.
> * "rootIndicationFileNames" only look for files in the *parent* directory which is why it didn't work for me It looks in all parent directories, it keeps doing `cd ..` till it finds a root indication file. Also it looks for file with exact names. It won't work with `*.tf`. For a pattern, "rootIndicationFilePatterns" should be used
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kate/-/merge_requests/1820
(In reply to Waqar Ahmed from comment #9) > > * "rootIndicationFileNames" only look for files in the *parent* directory which is why it didn't work for me > > It looks in all parent directories, it keeps doing `cd ..` till it finds a > root indication file. Also it looks for file with exact names. It won't work > with `*.tf`. For a pattern, "rootIndicationFilePatterns" should be used Ah, I just copy and pasted the code from https://github.com/hashicorp/terraform-ls/blob/main/docs/USAGE.md#kate -- looks like the "offical" documentation is broken then. I think `"root": "."` is better though since it will use the project directory, ie a bit more context (cf. PR).
> Ah, I just copy and pasted the code from https://github.com/hashicorp/terraform-ls/blob/main/docs/USAGE.md#kate -- looks like the "offical" documentation is broken then. Yep
Thanks for improving Kate
Git commit cb9945e90edc49aee30426eb801f82cb66639458 by Malte Stretz, on behalf of Malte S. Stretz. Committed on 15/07/2025 at 09:06. Pushed by cullmann into branch 'master'. Limit Terraform LSP to project directory The LSP server will scan the root directory recursively so the fallback to $HOME is not a good idea, performance wise. M +1 -0 addons/lspclient/settings.json https://invent.kde.org/utilities/kate/-/commit/cb9945e90edc49aee30426eb801f82cb66639458
Git commit 4c564020b3431447de2602c8eb5a978de68af857 by Christoph Cullmann. Committed on 22/07/2025 at 17:10. Pushed by cullmann into branch 'release/25.08'. Limit Terraform LSP to project directory The LSP server will scan the root directory recursively so the fallback to $HOME is not a good idea, performance wise. (cherry picked from commit cb9945e90edc49aee30426eb801f82cb66639458) Co-authored-by: Malte S. Stretz <mss@apache.org> M +1 -0 addons/lspclient/settings.json https://invent.kde.org/utilities/kate/-/commit/4c564020b3431447de2602c8eb5a978de68af857