nvimdev / guard.nvim

async fast minimalist plugin make format easy in neovim
MIT License
448 stars 24 forks source link

how to config eslint fromat javascript file #7

Closed WingDust closed 1 year ago

WingDust commented 1 year ago
  {
    "nvimdev/guard.nvim",
    config = function()
      -- code
      local ft = require("guard.filetype")
      ---- use stylua to format lua files and no linter
      ft("lua"):fmt({
        cmd = "stylua",
        args = { "-" },
        stdin = true,
        ignore_error = true,
      })
      ft("javascript"):fmt({
        cmd = "eslint",
        args = { "--fix" },

        -- args = { "--fix", vim.api.nvim_buf_get_name(0) },
        fname = true,
        -- fname = vim.api.nvim_buf_get_name(0),
      })

      require("guard").setup({
        -- the only option for the setup function
        fmt_on_save = true,
      })
    end,
  },

not work

guard: require("guard.health").check()

- ERROR Failed to run healthcheck for "guard" plugin. Exception:
  function health#check, line 25
  Vim(eval):E5108: Error executing lua ...i/.local/share/nvim/lazy/guard.nvim/lua/guard/health.lua:56: attempt to call field 'start' (a nil value)
  stack traceback:
  ...i/.local/share/nvim/lazy/guard.nvim/lua/guard/health.lua:56: in function 'check'
  [string "luaeval()"]:1: in main chunk
WingDust commented 1 year ago

@glepnir anther problem how to config eslint fix javascript file,

glepnir commented 1 year ago

suggest use lspconfig eslint lsp