Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ask] how to setup plugin using lazy #20

Open
muhfaris opened this issue Aug 15, 2023 · 9 comments
Open

[ask] how to setup plugin using lazy #20

muhfaris opened this issue Aug 15, 2023 · 9 comments

Comments

@muhfaris
Copy link

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
Copy link
Owner

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
Copy link
Author

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

@souk4711
Copy link

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
Copy link

orhnk commented Sep 18, 2023

  {
    "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
Copy link
Author

it's still not work for me

@orhnk
Copy link

orhnk commented Sep 23, 2023

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
Copy link

eerison commented Nov 26, 2023

  {
    "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
Copy link

eerison commented Nov 26, 2023

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 ;)

#17 (comment)

@eerison
Copy link

eerison commented Nov 26, 2023

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 ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants