none-ls.nvim icon indicating copy to clipboard operation
none-ls.nvim copied to clipboard

Null ls not started with command `tab new`

Open wiserfz opened this issue 1 year ago • 3 comments

FAQ

  • [X] I have checked the FAQ and it didn't resolve my problem.

Issues

  • [X] I have checked existing issues and there are no issues with the same problem.

Neovim Version

NVIM v0.10.0 Build type: Release LuaJIT 2.1.1716656478

Dev Version?

  • [ ] I am using a stable Neovim release version, or if I am using a dev version of Neovim I have confirmed that my issue is reproducible on a stable version.

Operating System

Darwin wisers-MacBook-Pro.local 22.3.0 Darwin Kernel Version 22.3.0

Minimal Config

return {
  "nvimtools/none-ls.nvim",
  dependencies = {
    "nvimtools/none-ls-extras.nvim",
  },
  lazy = true,
  event = { "BufReadPre", "BufNewFile" },
  config = function()
    local null_ls = require("null-ls")

    -- custom setup
    null_ls.setup({
      border = "single",
      sources = {
        require("none-ls.formatting.jq"), -- json formatter
      },
      -- configure format on save
      on_attach = function(current_client, bufnr)
        if current_client.supports_method("textDocument/formatting") then
          vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
          vim.api.nvim_create_autocmd("BufWritePre", {
            group = augroup,
            buffer = bufnr,
            callback = function()
              vim.lsp.buf.format({ async = false })
            end,
          })
        end
      end,
    })
  end,
}

Steps to Reproduce

  1. nvim
  2. :tab new
  3. :set filetype=json
  4. :NullLsInfo

Reproducibility Check

  • [ ] I confirm that my minimal config is based on the minimal_init.lua template and that my issue is reproducible by running nvim --clean -u minimal_init.lua and following the steps above.

Expected Behavior

:NullLsInfo

image

Actual Behavior

:NullLsInfo

image

Debug Log

No debug log because of null ls is not started.

image

Help

No

Implementation Help

No response

Requirements

  • [X] I have read and followed the instructions above and understand that my issue will be closed if I did not provide the required information.

wiserfz avatar Aug 02 '24 06:08 wiserfz

In this case, filetype is only set after null-ls initialized, you have to manually start the sources.

I consider this not an issue? I'm open to discussing.

mochaaP avatar Aug 02 '24 06:08 mochaaP

In this case, filetype is only set after null-ls initialized, you have to manually start the sources.

I don't know when and how null-ls initialized, but lsp server is started after set filetype.

PS: If null-ls's sources could be attached manually, please tell me, thx.

wiserfz avatar Aug 02 '24 07:08 wiserfz

You could could force it to start by starting the buffer with a file name, even if it does not exist yet

:tabnew tmp-file.json

apgrc avatar Aug 25 '24 11:08 apgrc