potamides / pantran.nvim

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

[ask] how to setup plugin using lazy #20

Open muhfaris opened 11 months ago

muhfaris commented 11 months ago

hi @potamides can you explain to me how to setup this plugin using lazy.nvim my config below, is not work properly.

return {
  "potamides/pantran.nvim",
  keys = {
    { "<leader>ttx", desc = "translate text" },
  },
  config = function()
    require("pantran").setup {
      -- Default engine to use for translation. To list valid engine names run
      -- `:lua =vim.tbl_keys(require("pantran.engines"))`.
      default_engine = "google",
      -- Configuration for individual engines goes here.
      engines = {
        yandex = {
          -- Default languages can be defined on a per engine basis. In this case
          -- `:lua require("pantran.async").run(function()
          -- vim.pretty_print(require("pantran.engines").yandex:languages()) end)`
          -- can be used to list available language identifiers.
          default_source = "auto",
          default_target = "en",
        },
      },
      controls = {
        mappings = {
          edit = {
            n = {
              -- Use this table to add additional mappings for the normal mode in
              -- the translation window. Either strings or function references are
              -- supported.
              ["j"] = "gj",
              ["k"] = "gk",
            },
            i = {
              -- Similar table but for insert mode. Using 'false' disables
              -- existing keybindings.
              ["<C-y>"] = true,
              ["<C-a>"] = require("pantran.ui.actions").yank_close_translation,
            },
          },
          -- Keybindings here are used in the selection window.
          select = {
            n = {
              -- ...
            },
          },
        },
      },
    }
  end,
}

thanks

potamides commented 10 months ago

Hi @muhfaris, I don't use lazy.nvim, but maybe I can still help you. Could you please describe your specific problem in more detail?

muhfaris commented 10 months ago

thanks @potamides for reply I try open the dialog with the command <leader>ttx, but nothing happen

souk4711 commented 10 months ago
return {
  {
    "potamides/pantran.nvim",
    config = function ()
      local pantran = require('pantran')
      pantran.setup({})

      local opts = {noremap = true, silent = true, expr = true}
      vim.keymap.set("n", "<Leader>tr", pantran.motion_translate, opts)
      vim.keymap.set("n", "<leader>trr", function() return pantran.motion_translate() .. "_" end, opts)
      vim.keymap.set("x", "<leader>tr", pantran.motion_translate, opts)
    end,
  },
}
orhnk commented 9 months ago
  {
    "potamides/pantran.nvim",

    keys = {
        {
            "<leader>tr",
            function()
                require("pantran").motion_translate()
            end,
            mode = {"n", "v"},
            desc = "Translate",
        },
    },

    opts = {},

    config = function (_, opts)
      require('pantran').setup(opts)
    end,
  },
muhfaris commented 9 months ago

it's still not work for me

orhnk commented 9 months ago

Is this the first plugin you are installing?

Because It works in my setup (Fairly modified)

(e.g) do you have a snippet like so?

require("lazy").setup {
   -- PLUGINS HERE
}
eerison commented 7 months ago
  {
    "potamides/pantran.nvim",

    keys = {
        {
            "<leader>tr",
            function()
                require("pantran").motion_translate()
            end,
            mode = {"n", "v"},
            desc = "Translate",
        },
    },

    opts = {},

    config = function (_, opts)
      require('pantran').setup(opts)
    end,
  },

Usually lazyvim configs works for astrovim I just need to add return on first line.

I could see the command <leader>tr but nothing happen :(, any idea why?

eerison commented 7 months ago

Ok just to point out, I used this config and it worked, I didn't added line by line to check what was missing, But it worked for AstroVim ;)

https://github.com/potamides/pantran.nvim/issues/17#issuecomment-1636822777

eerison commented 7 months ago
return {
  {
    "potamides/pantran.nvim",
    config = function ()
      local pantran = require('pantran')
      pantran.setup({})

      local opts = {noremap = true, silent = true, expr = true}
      vim.keymap.set("n", "<Leader>tr", pantran.motion_translate, opts)
      vim.keymap.set("n", "<leader>trr", function() return pantran.motion_translate() .. "_" end, opts)
      vim.keymap.set("x", "<leader>tr", pantran.motion_translate, opts)
    end,
  },
}

It also works but you need to select the text ;)