potamides / pantran.nvim

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

config default_enging not effected #9

Closed Mr-LLLLL closed 1 year ago

Mr-LLLLL commented 1 year ago

when i remap:

{
        default_engine = "google",
        controls= {
            mappings = {
                edit = {
                    n = {
                        ["q"] = package.loaded.pantran.ui.close,
                    },
                },             
            }
        },
}

I test sometimes, if this map include "package.loaded.pantran.ui", then will be reset default_enging to Argos

Mr-LLLLL commented 1 year ago

i found some config not effected, example

{
        default_engine = "google",
        engines = {
            google = {
                default_source = "auto",
                default_target = "zh-CN",
                fallback = {
                    default_source = "auto",
                    default_target = "zh-CN",
                }
            },
        }
}

i test sometimes, this is caused by call local pantran_actions = require("pantran.ui.actions") before, this bug same as above

Mr-LLLLL commented 1 year ago

os version: ubuntu 21.10 neovim version: 0.8.1

potamides commented 1 year ago

Try the following instead, it should work:

{
  default_engine = "google",
  controls= {
      mappings = {
          edit = {
              n = {
                  ["q"] = require("pantran.ui.actions").close,
              },
          },
      }
  },
}
potamides commented 1 year ago

The README uses package.loaded but this cannot work, I'll update it. Thanks for bringing this to my attention.

Mr-LLLLL commented 1 year ago

thank for your anwser, but i test ["q"] = require("pantran.ui.actions").close, it not work

    local pantran_actions = require("pantran.ui.actions")
    require("pantran").setup {
        default_engine = "google",
        engines = {
            google = {
                default_source = "auto",
                default_target = "zh-CN",
                fallback = {
                    default_source = "auto",
                    default_target = "zh-CN",
                }
            },
        },
        controls = {
            mappings = {
                edit = {
                    n = { ["q"] = pantran_actions.close}
                   }
            }
        },
    }
Mr-LLLLL commented 1 year ago

i found call require("pantran.ui.actions") before, other config not work

potamides commented 1 year ago

Please try the latest commit, it should fix your problem!