jay-babu / mason-null-ls.nvim

GNU Affero General Public License v3.0
540 stars 22 forks source link

Add support for external sources (currently we only support builtins) #106

Open Zeioth opened 2 months ago

Zeioth commented 2 months ago

Problem

Example

  {
    "nvimtools/none-ls.nvim",
    dependencies = {
      "jay-babu/mason-null-ls.nvim",
      "nvimtools/none-ls-extras.nvim",
    },
    event = "VeryLazy",
    opts = function()
      return {
        -- None-ls-extra sources
        sources = {
          require("none-ls.formatting.reformat_gherkin")   -- This is how we access a external sources (such as `none-ls-extras.nvim`)
          --require("null-ls").builtins.formatting.asmfmt  -- This is how we would normally access a builtin.
        },
        -- Attach the user lsp mappings to every none-ls client.
        on_attach = utils_lsp.apply_user_lsp_mappings
      }
    end
  },

Expected behavior

mason-null-ls should also detect sources from

jay-babu commented 2 months ago

If I loop over everything registered in none-ls.ACTION.SOURCE, it should suffice? Will need to add de-duplication logic such that sources in both do not overlap

jay-babu commented 2 months ago

I am out of town for the next 2 weeks, if you have time to test this out before then, that would be great. If not, I will take a stab at it when I am back

Zeioth commented 2 months ago

That solution would achieve for external sources what we currently achieve for builtins right? Yes I had the same in mind.

I've tried

print(vim.inspect(require("none-ls.formatting")))

The problem is none-ls doesn't seem to be exposing it and it is not possible to iterate it. I'm gonna see if I can find a solution for that.

Enjoy your trip Jay. Let's see if I can manage some kind of PR.

EDIT: I just noticed none-ls.formatting is just the root directory name of none-ls-extras.nvim, so formatting would be just the directory containing all the sources.

Knowing that we would just have to iterate and require all files in every directory.

EDIT 2: Another challenge I've found is there are several repositories with external sources, and each repository has a different project structure.

Maybe we could:

As you mentioned above we should:

Related:

Zeioth commented 1 month ago

I'd say it's done. You can check the fork here: https://github.com/Zeioth/none-ls-autoload.nvim

Please feel free to take it as reference and grab anything you want.

github-actions[bot] commented 1 month ago

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

github-actions[bot] commented 1 month ago

This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a supported version of Electron please open a new issue and include instructions for reproducing the issue.

jay-babu commented 2 weeks ago

I'd say it's done. You can check the fork here: https://github.com/Zeioth/none-ls-autoload.nvim

Please feel free to take it as reference and grab anything you want.

I would like to incorporate this into here. I just haven't been following anything none-ls has been doing. I've also switched using conform.nvim and nvim-lint which are so much nicer and faster hence I don't have an urge to figure out how this works. I looked at your repo and it just seems like one function to look copy over?

Zeioth commented 2 weeks ago

@jay-babu Yeah its just basically the function https://github.com/Zeioth/none-ls-autoload.nvim/blob/7b6358f1f03d95297d737c6ff141895845bc847c/lua/none-ls-autoload/utils.lua#L24 and the point we call it https://github.com/Zeioth/none-ls-autoload.nvim/blob/7b6358f1f03d95297d737c6ff141895845bc847c/lua/none-ls-autoload/utils.lua#L103

Also in case you are interested there is a project like mason-null for conform in case you'd like to contribute: https://github.com/frostplexx/mason-bridge.nvim

github-actions[bot] commented 13 hours ago

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!