diff --git a/lua/elixir/credo/init.lua b/lua/elixir/credo/init.lua index 92dae4c8..0ee3b3e9 100644 --- a/lua/elixir/credo/init.lua +++ b/lua/elixir/credo/init.lua @@ -24,20 +24,22 @@ function M.setup(opts) file = nil end - local cmd - if type(opts.port) == "number" then - cmd = vim.lsp.rpc.connect("127.0.0.1", opts.port) - else - cmd = { opts.cmd, "--stdio" } - end + if file then + local cmd + if type(opts.port) == "number" then + cmd = vim.lsp.rpc.connect("127.0.0.1", opts.port) + else + cmd = { opts.cmd, "--stdio" } + end - vim.lsp.start { - name = "Credo", - cmd = cmd, - settings = {}, - root_dir = vim.fs.dirname(file), - on_attach = opts.on_attach or function() end, - } + vim.lsp.start { + name = "Credo", + cmd = cmd, + settings = {}, + root_dir = vim.fs.dirname(file), + on_attach = opts.on_attach or function() end, + } + end end, }) end