potamides / pantran.nvim

Use your favorite machine translation engines without having to leave your favorite editor.
MIT License
289 stars 2 forks source link

Setting default_source and default_target does not work. #17

Closed atishdhu closed 1 year ago

atishdhu commented 1 year ago

My config

I want to set default engine to google and its default_source to english and default_target to french. I have the following config in plugins.lua:

{
    "potamides/pantran.nvim",
    event = "VimEnter",
    config = function()
      require("pantran").setup({
        default_engine = "google",
        engines = {
          google = {
            default_source = "auto",
            default_target = "fr"
          },
        },
      })
    end
  },

I also tried with:

{
    "potamides/pantran.nvim",
    event = "VimEnter",
    config = function()
      require("pantran").setup({
        default_engine = "google",
        engines = {
          google = {
            config = {
              default_source = "auto",
              default_target = "fr"
            }
          },
        },
      })
    end
  },

Expectation

Source is auto and target is french when i execute :Pantran.

Actual Result

Source is auto and target is english when i execute :Pantran.

potamides commented 1 year ago

You are probably using the fallback endpoint, so you need to use the following configuration keys. On a side note, this seems to be a reoccurring point of confusion, so this should be documented better.

atishdhu commented 1 year ago

I updated the config and it works now, thank you.

{
    "potamides/pantran.nvim",
    event = "VimEnter",
    config = function()
      require("pantran").setup({
        default_engine = "google",
        engines = {
          google = {
            fallback = {
              default_source = "auto",
              default_target = "fr"
            }
          },
        },
      })
    end
  },