Skip to content

Commit

Permalink
feat: add translate plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
adoyle-h committed Nov 17, 2022
1 parent cf46197 commit 89815e3
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 17 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ All-in-one neovim configuration framework implemented with Lua. It is highly fle
- Notebook: [zk](lua/one/plugins/zk.lua)
- Live Command: [live-command](https://github.com/smjonas/live-command.nvim)
- Color Highlighter: [nvim-colorizer](lua/one/plugins/colors/inline.lua)
- Translation: [translate.nvim](lua/one/plugins/translate.lua)
- [Games](lua/one/plugins/funny.lua)

</details>
Expand Down Expand Up @@ -525,8 +526,8 @@ Any comments and suggestions are always welcome.

**Before open an issue/discussion/PR, You should search related [issue][]/[discussion][]/[PR][] first** for avoiding to create duplicated links.

- For new feature request, open an [discussion][], describe your demand concisely and clearly.
- For new feature submit, open an [PR][], describe your demand and design concisely and clearly.
- For new feature request, open a [discussion][], describe your demand concisely and clearly.
- For new feature submit, open a [PR][], describe your demand and design concisely and clearly.
- For bug report, open an [issue][], describe the bug concisely and clearly.
- For bug fix, open a [PR][], concisely and clearly describe what you fixed.
- For question and suggestion, open a [discussion][].
Expand Down
1 change: 1 addition & 0 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Click [./README.md](./README.md) to read English documents.
- 笔记本: [zk](lua/one/plugins/zk.lua)
- 实时命令: [live-command](https://github.com/smjonas/live-command.nvim)
- 颜色着色: [nvim-colorizer](lua/one/plugins/colors/inline.lua)
- 翻译: [translate.nvim](lua/one/plugins/translate.lua)
- [游戏](lua/one/plugins/funny.lua)

</details>
Expand Down
1 change: 1 addition & 0 deletions doc/keymaps.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Press `<space>k` to see all keymaps in nvim.
- `<M-I>` = Decrement word under cursor
- `<leader>so` = Toggle scrolloff
- `<leader>sp` = Toggle spell-checking
- `<M-t>` = Translate text under cursor (support selection). You can also use `:Translate <lang>`. See [translate plugin](../lua/one/plugins/translate.lua).

## Edit and Write

Expand Down
16 changes: 1 addition & 15 deletions lua/one/plugins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ return function(Plug, Load, config)
Load 'js'
Load 'crontab'
Load 'live-cmd'
Load 'translate'

Plug {
'tyru/capture.vim',
Expand All @@ -80,20 +81,5 @@ return function(Plug, Load, config)
Plug { 'mechatroner/rainbow_csv', desc = 'For .csv file', ft = 'csv' }
Plug 'rohanorton/lua-gf.nvim'

------ Default disabled plugins ------
-- User can enable them on demand
-- Load 'profiling'
-- Load 'zk'
-- Load 'node'
-- Load 'curl'
-- Load 'funny'
-- Load 'latex'
-- Load 'calendar'
-- Load 'todo'
-- Load 'zen'
-- Load 'mark'
-- Load 'bookmark'
--------------------------------------

Plug 'ryanoasis/vim-devicons' -- Devicons for old vimscript plugins. It should be put at last!!
end
30 changes: 30 additions & 0 deletions lua/one/plugins/translate.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
return {
'uga-rosa/translate.nvim',

keymaps = function(config)
return {
{ { 'n', 'x' }, '<M-t>', string.format(':Translate %s<CR>', config.translate.targetLang) },
}
end,

config = function(config)
require('translate').setup(config.translate)
end,

defaultConfig = {
'translate',
{
targetLang = 'en', -- 'en', 'zh-CN', 'zh-TW'. See the completion list when typing `:Translate `.
default = {
-- (default) 'google': It uses Google Translate. It needs curl installed.
-- 'translate_shell':
-- It needs [trans](https://github.com/soimort/translate-shell) command installed.
-- And it's recommended to set a [config](https://github.com/soimort/translate-shell/wiki/Configuration) file.
-- 'deepl_pro' or 'deepl_free':
-- You need the authorization key for DeepL API Pro/Free.
-- It needs curl installed.
command = 'google',
},
},
},
}

0 comments on commit 89815e3

Please sign in to comment.