0

I'm new into vim and I'm trying to configure null-ls to format files, I think I'm missing something, since whenever I try to run the command :NullLsInfo to see if I've got a formatter configured, it says that I don't have a buffer source attached.

Here's the NullLsInfos' result for a .vue file, which should support prettier builtin source:

And here's my null-ls.lua file content, which is correctly sourced in init.vim

null_ls = require("null-ls")
null_ls.setup({
  sources = {
    null_ls.builtins.formatting.shfmt,
    null_ls.builtins.formatting.phpcbf,
    null_ls.builtins.formatting.prettier.with({
        filetypes = { "html", "json", "yaml", "markdown", "vue" },
    }),
  },
})

Obviously, when I try to format the document using :lua vim.lsp.buf.formatting_sync(nil, 2000), nothing happens.

I tried running the command echo executable("prettier") returns true.

What am I missing?

Edit

I just discovered this, when I try to open a file, I get this error enter image description here don't ask me how I discovered this just now

1 Answers1

0

What I imagine is happening is that you tried to configure setup twice, first on installation and another on said file, the setup from installation has priority. Just erase or configure correct there. Can't confirm, since you didn't post your installation code.

Also, for good practice, add a 'local' before null_ls

local null_ls = require("null-ls")
  • With installation file you mean the "init.vim"? because the only thing i have there about null-ls is: `Plug 'jose-elias-alvarez/null-ls.nvim'` and `source $HOME/.config/nvim/plug-config/null-ls.lua`, and if I try to remove the first part vim throws me an error saying it can't find null-ls. – Lorenzo_inirapmoC Jul 05 '23 at 10:41
  • I misjudged your "new into vim". Your installation seems fine. Just to make sure, did you install plenary? – Victor Reial Jul 05 '23 at 13:08
  • Yep, with `Plug 'nvim-lua/plenary.nvim'`, I just edited with a new error I just noticed – Lorenzo_inirapmoC Jul 05 '23 at 15:18