diagnosticls-configs-nvim icon indicating copy to clipboard operation
diagnosticls-configs-nvim copied to clipboard

Fix global fallback in fs.lua

Open LukasDoesDev opened this issue 3 years ago • 4 comments

I'd suggest doing the following in fs.lua.

  if vim.fn.filereadable(binpath) == 0 then
-   add_checkhealth_error(name)
+   return ''
  end
    if local_binpath == '' then
      return get_global_exec(name)
    end
+   add_checkhealth_error(name)

    return local_binpath

The reason for this is that you probably want to check the PATH if there is no ~/node_modules for example. I have many Node-based linters and formatters installed globally through my system package manager and they're in /usr/bin instead of ./node_modules/.bin and patching the files as described made everything work. This will likely fix system/user global NPM packages too.

Please give me thoughts on this idea.

LukasDoesDev avatar Jun 07 '22 19:06 LukasDoesDev

Thanks for pointing this out!

I'll have to take a look at it in the weekend, but from a quick look you're right in that it doesn't point to the right executable.

From what I see I think we can keep the add_checkhealth_error(name) where it is but add the empty string return after that, the fallback check will then be done in the global search logic get_global_exec.

creativenull avatar Jun 09 '22 23:06 creativenull

From what I see I think we can keep the add_checkhealth_error(name) where it is but add the empty string return after that, the fallback check will then be done in the global search logic get_global_exec.

I was thinking that the problem with that approach is that the health error will be added even if the global executable exists.

LukasDoesDev avatar Jun 09 '22 23:06 LukasDoesDev

Ah I see, maybe we don't need to error for local bin checks then? And only error when both local and global check fails.

creativenull avatar Jun 10 '22 00:06 creativenull

Can you try out PR #31 and see if that resolves the issue?

creativenull avatar Jun 12 '22 21:06 creativenull

I think that does it

LukasDoesDev avatar Aug 14 '22 17:08 LukasDoesDev

Can you add an option to globally disable local contexts?

LukasDoesDev avatar Aug 14 '22 17:08 LukasDoesDev

Hmmm at this point I'd rather keep it as is, since it was my initial intention to pick up the tools from the local context before it would try and search one globally.

For now you can just mention a global context following the Advanced Setup

creativenull avatar Aug 14 '22 23:08 creativenull