Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null ls not started with command tab new #171

Open
3 of 5 tasks
Gitfz810 opened this issue Aug 2, 2024 · 3 comments
Open
3 of 5 tasks

Null ls not started with command tab new #171

Gitfz810 opened this issue Aug 2, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@Gitfz810
Copy link
Contributor

Gitfz810 commented Aug 2, 2024

FAQ

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

Issues

  • 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

  • I have read and followed the instructions above and understand that my issue will be closed if I did not provide the required information.
@Gitfz810 Gitfz810 added the bug Something isn't working label Aug 2, 2024
@mochaaP
Copy link
Member

mochaaP commented Aug 2, 2024

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.

@Gitfz810
Copy link
Contributor Author

Gitfz810 commented Aug 2, 2024

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.

@apgrc
Copy link
Contributor

apgrc commented Aug 25, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants