midoBB / nvim-quicktype

Generate types from JSON all inside Neovim
Other
10 stars 1 forks source link

Bug: Parsing issues with `--just_types` #1

Closed zivkovicn closed 5 days ago

zivkovicn commented 5 days ago

Hello,

was testing the plugin, when I try to convert the simple json to go struct, getting:

Error: Option parsing failed: Unknown option: --just_types.

seems that this option is not available anymore https://github.com/glideapps/quicktype/issues/1200

midoBB commented 5 days ago

Hi, the correct option is just-types not just_types. Also do note it's already set by default for Golang and all the languages that support it. For Lua to accept it or any other options that have dashes in the middle you need to wrap option in [ ] So it should be like this

 ["just-types"] = true
zivkovicn commented 5 days ago

Hey, so this is the config:

return {
  "midoBB/nvim-quicktype",
  cmd = "QuickType",
  ft = { "typescript", "python", "java", "go", "rust", "cs", "swift", "elixir", "kotlin", "typescriptreact" },
  config = function()
    require("nvim-quicktype").setup({
      global = {
        debug_dir = "/Users/nikola/debug",
      },
    })
  end,
  keys = {
    {
      "<leader>cg",
      "<Cmd>QuickType<CR>",
      desc = "Generate type",
    },
  },
}

the log:

Executed command:
cat << EoF | quicktype --src-lang json --all-properties-optional --telemetry disable -l go -t test --just_types 2>/Users/nikola/debug/err.log 
{
  "extras": [
    "lazyvim.plugins.extras.coding.copilot",
    "lazyvim.plugins.extras.coding.copilot-chat",
    "lazyvim.plugins.extras.dap.core",
    "lazyvim.plugins.extras.editor.overseer",
    "lazyvim.plugins.extras.lang.cmake",
    "lazyvim.plugins.extras.lang.docker",
    "lazyvim.plugins.extras.lang.go",
    "lazyvim.plugins.extras.lang.json",
    "lazyvim.plugins.extras.lang.markdown",
    "lazyvim.plugins.extras.lang.python",
    "lazyvim.plugins.extras.lang.sql",
    "lazyvim.plugins.extras.lang.tailwind",
    "lazyvim.plugins.extras.lang.terraform",
    "lazyvim.plugins.extras.lang.toml",
    "lazyvim.plugins.extras.lang.typescript",
    "lazyvim.plugins.extras.lang.yaml",
    "lazyvim.plugins.extras.lang.cmake",
    "lazyvim.plugins.extras.test.core",
    "lazyvim.plugins.extras.util.project"
  ],
  "news": {
    "NEWS.md": "6520"
  },
  "version": 6
}

EoF

the error: Error: Option parsing failed: Unknown option: --just_types.

I'm not sure what is appending --just_types, to the command that is executing?

zivkovicn commented 5 days ago

@midoBB ok I've found it https://github.com/midoBB/nvim-quicktype/blob/main/lua/nvim-quicktype.lua#L43C2-L45C9

you will need to change this to just-types 😄 I can open the PR if you like.

midoBB commented 5 days ago

Go ahead. Thanks for catching it!

nidzola commented 5 days ago

here it is: https://github.com/midoBB/nvim-quicktype/pull/2 @midoBB