Closed fillipe-gsm closed 2 years ago
Hello! It seems like lspconfig is unable to find a root directory (:h lspconfig-root-dir
). The root dir pattern for terraformls happens to be .terraform, .git
. Have you tried editing a terraform file inside a git repository?
Hi, sorry for the late reply!
I was actually following the Quickstart tutorial from HashiCorp, so there was no git repository.
I ended up finishing the code with no autocomplete and run terraform init
. After that, when I opened the file again, the server was properly running! It seems it really needs a .terraform
folder created from 'terraform init`.
I tried creating other projects. I noticed that simply running terraform init
on an empty configuration file is not enough for the server to start. I had to write a minimal configuration first, run terraform init
, and then the autocomplete begins to work.
I am not sure I am just convoluting the whole process, but it seems there is no issue with the plugin.
Thanks for the reply!
Had the exact same issue, ended up copying the terraformls binary to my path, also had to do this for stylua.
I do have both .git and .terraform in my project and no dice until I copied that file over.
Another thing and it's completely unrelated is that the official hashicorp lsp server is quite poor in features so i grabbed the alternative, renamed it to match what lsp installer has configured and now I get completions and overall a better experience. Should that server be also added to the list?
Hey @mvaldes14 try pulling the latest version, this should've been fixed in #630!
Excellent, yep that fixes the problem. thank you very much @williamboman !
Problem description
I installed the terraform language server with the usual
LspInstall terraformls
. The installation succeeds. However, when I open any file with the.tf
extension I get no autocomplete.When checking for
LspInfo
, I see the "Unable to find executable. Please check your path and ensure the server is installed".I tried uninstalling and installing it again, updating the plugin, and even renaming the executable file, with no luck.
If I go to my
$HOME/.local/share/nvim/lsp_servers/terraform
path I see the following structure:I know I can run the executable with
./terraform-ls serve
, so there may be some configuration I am not aware.Neovim version (>= 0.6)
NVIM v0.6.1 Build type: Release LuaJIT 2.1.0-beta3 Compiled by builduser
Features: +acl +iconv +tui See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/usr/share/nvim"
Run :checkhealth for more info
Operating system/version
Linux fillipe-loggi 5.15.28-1-MANJARO #1 SMP PREEMPT Fri Mar 11 14:12:57 UTC 2022 x86_64 GNU/Linux
I've recently downloaded the latest plugin version of both nvim-lsp-installer and nvim-lspconfig
Affected language servers
terraform-ls
Steps to reproduce
-- Use a loop to conveniently call 'setup' on multiple servers and -- map buffer local keybindings when the language server attaches lsp_installer.on_server_ready(function(server) -- Specify the default options which we'll use to setup all servers local opts = { on_attach = on_attach, capabilities = capabilities, flags = { -- This will be the default in neovim 0.7+ debounce_text_changes = 150, }, }
end)
Healthcheck
Screenshots or recordings
No response