最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

eslint - problem with eslint_d in neovim (none-ls) - Stack Overflow

programmeradmin1浏览0评论

I am having a problem with eslint_d in Neovim, where it only seems to work with json, whenever I open a Javascript or Typescript file, I get an error in the very first line even if the file is empty:

failed to decode json: Expected value but found invalid token at character 1

The linter doesn't seem to work as well, for example code like this won't generate an error or a warning:

"use strict";
a = 10; // should trigger an error: 'x' is not defined

Here's my current none-ls configuration:

return {
    "nvimtools/none-ls.nvim",
    dependencies = {
        "nvimtools/none-ls-extras.nvim",
    },
    config = function()
        local null_ls = require("null-ls")
        null_ls.setup({
            sources = {
                require("none-ls.diagnostics.eslint_d"),
                null_ls.builtins.formatting.stylua,
                null_ls.builtins.formatting.prettier,
                null_ls.builtins.formatting.black,
                null_ls.builtins.formatting.isort,
                null_ls.builtins.formatting.clang_format,
                null_ls.builtins.formatting.google_java_format,
                null_ls.builtins.diagnostics.checkstyle,
                null_ls.builtins.diagnostics.cppcheck,
                null_ls.builtins.diagnostics.stylelint,
            },
        })
        vim.keymap.set("n", "<leader>gf", vim.lsp.buf.format, {})
    end,
}

I have looked everywhere for a solution but couldn't find anything, i also tried switching to oxlint and biome by installing them through Mason and modifying the configuration like this:

return {
    "nvimtools/none-ls.nvim",
    dependencies = {
        "nvimtools/none-ls-extras.nvim",
    },
    config = function()
        local null_ls = require("null-ls")
        null_ls.setup({
            sources = {
                null_ls.builtins.diagnostics.oxlint,
                -- or
                null_ls.builtins.diagnostics.biome  

                null_ls.builtins.formatting.stylua,
                null_ls.builtins.formatting.prettier,
                null_ls.builtins.formatting.black,
                null_ls.builtins.formatting.isort,
                null_ls.builtins.formatting.clang_format,
                null_ls.builtins.formatting.google_java_format,
                null_ls.builtins.diagnostics.checkstyle,
                null_ls.builtins.diagnostics.cppcheck,
                null_ls.builtins.diagnostics.stylelint,
            },
        })
        vim.keymap.set("n", "<leader>gf", vim.lsp.buf.format, {})
    end,
}

but both didn't work for some reason, and i kept getting an error:

[null-ls] failed to load builtin oxlint for method diagnostics; please check your config

Does anyone know what the problem with eslint_d is? or how can i switch to oxlint or biome instead? Thanks a lot!

I am having a problem with eslint_d in Neovim, where it only seems to work with json, whenever I open a Javascript or Typescript file, I get an error in the very first line even if the file is empty:

failed to decode json: Expected value but found invalid token at character 1

The linter doesn't seem to work as well, for example code like this won't generate an error or a warning:

"use strict";
a = 10; // should trigger an error: 'x' is not defined

Here's my current none-ls configuration:

return {
    "nvimtools/none-ls.nvim",
    dependencies = {
        "nvimtools/none-ls-extras.nvim",
    },
    config = function()
        local null_ls = require("null-ls")
        null_ls.setup({
            sources = {
                require("none-ls.diagnostics.eslint_d"),
                null_ls.builtins.formatting.stylua,
                null_ls.builtins.formatting.prettier,
                null_ls.builtins.formatting.black,
                null_ls.builtins.formatting.isort,
                null_ls.builtins.formatting.clang_format,
                null_ls.builtins.formatting.google_java_format,
                null_ls.builtins.diagnostics.checkstyle,
                null_ls.builtins.diagnostics.cppcheck,
                null_ls.builtins.diagnostics.stylelint,
            },
        })
        vim.keymap.set("n", "<leader>gf", vim.lsp.buf.format, {})
    end,
}

I have looked everywhere for a solution but couldn't find anything, i also tried switching to oxlint and biome by installing them through Mason and modifying the configuration like this:

return {
    "nvimtools/none-ls.nvim",
    dependencies = {
        "nvimtools/none-ls-extras.nvim",
    },
    config = function()
        local null_ls = require("null-ls")
        null_ls.setup({
            sources = {
                null_ls.builtins.diagnostics.oxlint,
                -- or
                null_ls.builtins.diagnostics.biome  

                null_ls.builtins.formatting.stylua,
                null_ls.builtins.formatting.prettier,
                null_ls.builtins.formatting.black,
                null_ls.builtins.formatting.isort,
                null_ls.builtins.formatting.clang_format,
                null_ls.builtins.formatting.google_java_format,
                null_ls.builtins.diagnostics.checkstyle,
                null_ls.builtins.diagnostics.cppcheck,
                null_ls.builtins.diagnostics.stylelint,
            },
        })
        vim.keymap.set("n", "<leader>gf", vim.lsp.buf.format, {})
    end,
}

but both didn't work for some reason, and i kept getting an error:

[null-ls] failed to load builtin oxlint for method diagnostics; please check your config

Does anyone know what the problem with eslint_d is? or how can i switch to oxlint or biome instead? Thanks a lot!

Share Improve this question edited Jan 30 at 9:48 lcheylus 2,4531 gold badge19 silver badges34 bronze badges asked Jan 29 at 23:43 Death ScytheDeath Scythe 131 silver badge4 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

I know nothing about none-ls, but since you asked about how to setup biome or oxlint:

Both biome and oxlint can be use as language servers, so you can set them with lspconfig, check kickstart.nvim as an example. They will also work as formatters without needing an additional formatting plugin.

Basically you install lspconfig, and mason; and set the servers like this and pass the capabilities, on_attach, settings, etc. to the setup table:

require("lspconfig").biome.setup({
    on_attach = ...,
    capabilities = ...,
    settings = ...,
})

I really recommend you to check kickstart.nvim for a better example.

Funnily enough, you can do the same with eslint by installing eslint_lsp provided you want to stick with eslint, so in the end none-ls becomes irrelevant.

发布评论

评论列表(0)

  1. 暂无评论