nvimtools / none-ls.nvim

null-ls.nvim reloaded / Use Neovim as a language server to inject LSP diagnostics, code actions, and more via Lua.
The Unlicense
2.39k stars 69 forks source link

🐛fix(client): we dont want to attach a source if its command is not executable. #124

Closed Zeioth closed 2 months ago

Zeioth commented 3 months ago

(for sources which command is different than nil).

Problem

A explicitly registered external source will be attached even if the source command is not actually executable. This create several unwanted scenarios:

This is inconsistent with the behavior of builtins, which will only attach if the executable is available. This inconsistent behavior is likely to be a regression.

Example

The next formatter appear attached even though we uninstalled it and rebooted neovim (bottom right of the image). screenshot_2024-05-10_18-49-50_149890376

Trying to run the formatter will of cause an error. screenshot_2024-05-10_18-51-58_029003400

Solution

Zeioth commented 3 months ago

closes https://github.com/nvimtools/none-ls.nvim/issues/90

mochaaP commented 3 months ago

Correct me if I'm wrong: seems https://github.com/nvimtools/none-ls.nvim/blob/f5632db2491fbe02b54f1a321a98548a8ba2bd15/lua/null-ls/sources.lua?plain=1#L101-L107 already handled this (generator._failed)?

Zeioth commented 3 months ago

Ok I just discovered the next:

none-ls architecture

mason-null-ls

This provokes mason-null-ls is not able to find external sources.

Possible solution A

Fixing the issue in mason-null-ls.

Pros: Fixes the issue. Everything keep working the same.

Possible solution B

Fixing the issue in none-ls (as in this PR).

Pros: It fixes the issue. Cons: It won't inform to users if the executable is not present anymore. It will just not load the source.

Zeioth commented 3 months ago

For now I'm gonna try to implement the solution in mason-null-ls. but I'm keeping the PR open.

Zeioth commented 3 months ago

I've implemented a plugin to load internal and external sources intelligently when using mason: https://github.com/Zeioth/none-ls-autoload.nvim

But I would still consider merging this PR, so we don't register things we know for a fact are not going to work when trying to run them.

Zeioth commented 2 months ago

Because the tests are not passing, and we already have the plugin to solve this. Let's close the PR.