Collections of coc.nvim extensions maintained by @voldikss
voldikss / coc-extensions Goto Github PK
View Code? Open in Web Editor NEW🌸 Collections of coc.nvim extensions maintained by @voldikss
🌸 Collections of coc.nvim extensions maintained by @voldikss
About the default highlight for floating window:
NormalFloat
for NeovimPmenu
for Vim8 (Popup window)Which makes the color of floating window different in Neovim and vim8.
So I think it will be better to make the highlight configurable by user.
Or set the default highlight to CocFloating
since this is a coc plugin.
我用的clash 使用privoxy来让http/https 走socks代理
环境变量代理配置
export HTTP_PROXY="http://127.0.0.1:8118"
export HTTPS_PROXY=$HTTP_PROXY
privoxy配置
forward-socks5t / 127.0.0.1:7890 .
Coc配置
"translator.proxy": "socks5://127.0.0.1:7890",
"translator.engines": [
"google",
"youdao"
],
执行coc-translation翻译,只有Google和bing的翻译引擎不工作(不怎么用bing,但试过了他也没工作),代理确定没有问题,其它程序都能用socks代理,请问我这是哪里没配置好?
大佬,有没有什么方法可以自定义调用的搜索引擎
就是我发现google翻译句子挺棒,但是翻译单词托慢了运行速度。
我想nmap就用bing/youdao,vmap就用google
First, I'd thank you for the translation extension. However, I find the UX could be enhanced in a way. For example, the popup content could be pasted/yanked into the current buffer right away by leveraging the tab button. Also translations database list doesn't save the varying word categories. For example if a word has adjective & adverb & noun translation, only the first category will be saved.
I was also wondering If it's possible to integrate Forvo API for pronunciations (which does have readily available libraries online)
Thanks!
I use this extension with nvim 0.8.0 and vim 9.0, but I can't find any translator's command when using coccommand. also, I map a key for coc-translator-p and it doesn't work. Do I miss something? or this extension doesn't support the high version for nvim or vim?
if (/^zh/.test(targetLang)) host = 'translate.google.com.hk'
#105
测试了一下,最新版本下,coc-translator-data
文件夹下及下层的translation.json
不会自动创建,手动创建后还需要在translation.json
中手动填入[]
,就正常了
https://github.com/Decodetalkers/neocmakelsp is another cmake LS.
TIA!
vmap gr <Plug>(coc-translator-rv)
Select if window active
, press gr
,
Actual Result:
如果窗口活动 window active
Expected Result:
如果窗口活动
大佬,请求添加离线词典文件的支持
例如: mdx, eudic词典文件的支持
大佬你好! 我在安装coc-translator
后尝试使用它, 但是发现插件并没有成功启用, 执行:CocInfo
后得到以下输出:
## versions
vim version: NVIM v0.4.4
node version: v15.3.0
coc.nvim version: 0.0.79-4f517cc785
coc.nvim directory: /home/chen/repos/nvim/plugged/coc.nvim
term: st-256color
platform: linux
## Log of coc.nvim
2020-12-02T17:18:00.522 ERROR (pid:76557) [extensions] - Error on active extension coc-translator: Error: ENOENT: no such file or directory, stat '/home/chen/.config/coc/extensions/coc-translator-data' [Error: ENOENT: no such file or directory, stat '/home/chen/.config/coc/extensions/coc-translator-data'] {
errno: -2,
code: 'ENOENT',
syscall: 'stat',
path: '/home/chen/.config/coc/extensions/coc-translator-data'
}
2020-12-02T17:18:00.539 INFO (pid:76557) [plugin] - coc.nvim 0.0.79-4f517cc785 initialized with node: v15.3.0 after 262ms
于是我尝试建立了coc-tranlator-data
文件夹, 插件恢复了工作, 但是每次翻译得到了以下错误:
[coc.nvim]: Error on notification "doKeymap": ENOENT: no such file or directory, stat '/home/chen/.config/coc/extensions/coc-translator-data/tra
nslation.json'
我不确定我是不是在安装过程中进行了意外的操作, 于是我尝试了重新安装插件, 但问题并未得到解决
Seeing your plugin reminded me of this extension https://addons.mozilla.org/en-US/firefox/addon/rikaichamp/ which I am fond of, basically when you hover over a japanese/chinese word, a popup opens with the meanings/pronunciation of the kanji and the differents words that can be created from the neighboring kanjis.
I would love to have this kind of behavior in vim, i.e., having a popup that translates the kanji (and the compositions with its surrounding) next to the cursor.
It might be out of scope for you but I thought I would mention it anyway. Feel free to close if that's the case.
Hey, this extension is awesome! it would be super useful if we could pass the "toLang" translation from CocCommand. Somehting like
CocCommand translator.popup hello -t fr
That'd be really helpful! Thanks a lot for the great extension.
somtimes the translation take too long and we will want to cancel it. In coc.nvim, the LSP request will be canceled after moving
麻烦看一下吧,感谢感谢
tslint -c tslint.json -p .
可以看到许多警告,或者把 tslint 这些去掉。可以安装 https://github.com/neoclide/coc-tslint-plugin 实时检测。 nvim.pauseNotification()
for (let item of arr) {
let text = item.content[0].padEnd(20) + item.content[1]
nvim.call('append', [0, text], true)
}
nvim.command('syntax match CocTranslatorQuery /\\v^.*\\v%20v/', true)
nvim.command('syntax match CocTranslatorOmit /\\v\\.\\.\\./', true)
nvim.command('syntax match CocTranslatorResult /\\v%21v.*$/', true)
nvim.command('highlight default link CocTranslatorQuery Keyword', true)
nvim.command('highlight default link CocTranslatorResult String', true)
await nvim.resumeNotification()
[coc.nvim] Translation failed: SyntaxError: Unexpected token u in JSON at position 0
如题,Bing接口好像只能翻译单词不能翻译句子,所以翻译句子不会返回结果而且会报错 Translating Error: Bad Response,你加这层校验的目的如果是想验证接口有没有失效的话可能这种方法不是最好的,因为实际上翻译单词Bing这个接口是没问题的,我现在自己的处理方式是:
let BingTransAPI = 'http://cn.bing.com/dict/SerpHoverTrans'
let url = BingTransAPI
url += '?q=' + encodeURIComponent(text)
const resCheckAPI = await request('GET', BingTransAPI, 'text', null, headers)
if (!resCheckAPI) {
showMessage(`${this.name} Translating Error: Bad Response`, 'error')
return result
}
const res = await request('GET', url, 'text', null, headers)
if (!res) {
return result
}
很丑陋所以没有提PR,每次翻译都要多一次请求(主页是有结果返回的,所以用来校验),我也不会这个语言,能优化一下这一块吗?
[coc.nvim]: Error on "doKeymap": o.window.getSelectedRange is not a function
?
It works well when translate any single word, but fails to translate most sentences.
Example.
error information: [coc.nvim] Translating failed: TypeError: Cannot read properties of undefined (reading 'map')
error information: [coc.nvim] Translating failed: TypeError: Cannot read properties of undefined (reading 'map')
error information: [coc.nvim] Translating failed: TypeError: Cannot read properties of undefined (reading 'map')
你好
form google
, youdao
and haici
.no error output
error information: [coc.nvim] Translating failed: TypeError: Cannot read properties of undefined (reading 'map')
This is the configuration.
"translator.proxy": "socks://127.0.0.1:10024",
"translator.toLang": "zh_CN",
"translator.engines": ["google", "bing", "youdao", "haici"],
"translator.window.maxHeight": 40,
No error occurred before last update.
老哥,感谢你做的插件,我遇到一个 bug
但我使用 popup 模式的时候 "nmap k (coc-translator-p)",
就会出现 "[coc.nvim] error: error on notification 'doKeymap': TypeError: Cannot read property 'uri' of undefined"
echo 模式没有问题
我的 coc 设置为
"translator.toLang": "zh",
"translator.engines": ["bing", "google"]
大佬您好,请问为何在Visual模式下选中一个句子,会一直显示translating而不出结果呢? 我尝试了Visual模式下选中一个单词,则可以很快出结果。。。我甚至又安装测试了您的另一个插件voldikss/vim-translator
,翻译句子也是没有问题的。。。
以下是我的一些设置:
" popup
nmap <Leader>t <Plug>(coc-translator-p)
vmap <Leader>t <Plug>(coc-translator-pv)
" echo
nmap <Leader>e <Plug>(coc-translator-e)
vmap <Leader>e <Plug>(coc-translator-ev)
"translator.toLang": "zh",
"translator.engines": [
"youdao",
"google",
"haici"
],
"translator.enableHover": false,
"translator.maxsize": 5000,
"translator.window.maxWidth": 999,
"translator.window.maxHeight": 999,
[coc.nvim] error on notification "doKeymap": this.engines is not iterable
# map call
[coc.nvim] Command error: this.engines is not iterable
# command call
This warning appears wherever coc-translator is called, including :CocCommand translator.popup/echo/replace hello
and nmap
define in init.vim.
My system environment:
OS: WSL2-ArchWSL (Arch Linux on WSL2)
vim version: NVIM v0.4.4
node version: v15.3.0
coc.nvim version: 0.0.79-3658eda4fa
coc-translator: Current version 1.5.0 is up to date.
My init.vim:
" Translating current text in popup (CocCommand translator.*)
nmap ;t <Plug>(coc-translator-p)
vmap ;t <Plug>(coc-translator-pv)
My coc.nvim configuration:
"translator.engines": {
"type": "array",
"default": [
"bing",
"google",
"youdao",
"haici"
]
},
Some logs:
2020-11-28T01:41:45.082 INFO (pid:10578) [services] - registered service "highlight"
2020-11-28T01:41:45.128 INFO (pid:10578) [language-client-index] - highlight started with 10591
2020-11-28T01:41:45.150 INFO (pid:10578) [plugin] - coc.nvim 0.0.79-3658eda4fa initialized with node: v15.3.0 after 205ms
2020-11-28T01:41:49.183 ERROR (pid:10578) [attach] - Notification error: doKeymap [ 'translator-p' ] TypeError: this.engines is not iterable
at Translator.<anonymous> (/home/hrand/.cache/nvim/coc/extensions/node_modules/coc-translator/lib/index.js:523:34)
at Generator.next (<anonymous>)
at /home/hrand/.cache/nvim/coc/extensions/node_modules/coc-translator/lib/index.js:257:71
at new Promise (<anonymous>)
at __awaiter (/home/hrand/.cache/nvim/coc/extensions/node_modules/coc-translator/lib/index.js:253:12)
at Translator.translate (/home/hrand/.cache/nvim/coc/extensions/node_modules/coc-translator/lib/index.js:509:16)
at Helper.<anonymous> (/home/hrand/.cache/nvim/coc/extensions/node_modules/coc-translator/lib/index.js:180:49)
at Generator.next (<anonymous>)
at fulfilled (/home/hrand/.cache/nvim/coc/extensions/node_modules/coc-translator/lib/index.js:96:58)
at processTicksAndRejections (node:internal/process/task_queues:93:5)
2020-11-28T01:42:57.325 ERROR (pid:10578) [commands] - TypeError: this.engines is not iterable
at Translator.<anonymous> (/home/hrand/.cache/nvim/coc/extensions/node_modules/coc-translator/lib/index.js:523:34)
at Generator.next (<anonymous>)
at /home/hrand/.cache/nvim/coc/extensions/node_modules/coc-translator/lib/index.js:257:71
at new Promise (<anonymous>)
at __awaiter (/home/hrand/.cache/nvim/coc/extensions/node_modules/coc-translator/lib/index.js:253:12)
at Translator.translate (/home/hrand/.cache/nvim/coc/extensions/node_modules/coc-translator/lib/index.js:509:16)
at Helper.<anonymous> (/home/hrand/.cache/nvim/coc/extensions/node_modules/coc-translator/lib/index.js:192:49)
at Generator.next (<anonymous>)
at /home/hrand/.cache/nvim/coc/extensions/node_modules/coc-translator/lib/index.js:99:71
at new Promise (<anonymous>)
Does there exist support for more engines? Such as some programs running in user's machine like translate-shell, sdcv, ydcv also can translate words. Where, some of them use dictionary so don't need network, which may be useful for some situation where network is not available.
Thanks.
no such file or directory , the bug occurs in version 1.7.0 again.
Every time use coc-translator,
[coc.nvim] Translating failed: Error: timeout of 5000ms exceeded
However, the network seems to to be connected; other programs using external translating engine, like ydcv, can work normally.
Any possible reason to result in this problem? Thanks.
hello,
feature for adding reverse command between target_lang and source_lang.
Other question : can we target a specific language in a command line EX : "coccomand translator.echo "fr""
Every time the translator popup window appears, it will create a "[Scratch]" buffer.
After the popup window is closed, the "[Scratch]" buffer will not be removed.
Also the next time the translator popup window appears, the previous "[Scratch]" buffer will not be reused. Instead it will create a new one.
After using coc-translator multiple times, there will be full of useless "[Scratch]" buffers in the buffer list.
I tried to call coc-translator via the mapping nmap <Leader>te <Plug>(coc-translator-p)
on some japanese text but it gives me:
## versions
vim version: NVIM v0.4.0-dev
node version: v10.16.0
coc.nvim version: 0.0.72-22daa03a7d
term: xterm-termite
platform: linux
## Messages
"content/dechets.md" 28L, 1022C
[coc.nvim] error: error on notification 'doKeymap': TypeError: Cannot read property 'index' of null
## Output channel: snippets
My coc config is :
"translator.toLang": "fr",
// "bing", "ciba",
"translator.engines": [ "google"],
// history size
"translator.maxsize": 5000,
系统代理:
export http_proxy=127.0.0.1:7890
export https_proxy=127.0.0.1:7890
export socks_proxy=127.0.0.1:7891
当我使用系统代理时进行翻译功能会报告如下错误,我尝试了所有类型的translator.engines
都无法正常工作:
[coc.nvim]: UnhandledRejection: TypeError: Cannot read properties of undefined (reading 'length')
我能够确认我的系统代理是正常的,因为我使用下方命令请求返回了正确的结果:
curl "http://dict.youdao.com/fsearch?client=deskdict&keyfrom=chrome.extension&q=hello&pos=-1&doctype=xml&xmlVersion=3.2&dogVersion=1.0&vendor=unknown&appVer=3.1.17.4208"
这可能是翻译请求失败引起的,但我无法确认具体的原因,之前翻译功能是正常的,但是最近可能发生了arch的滚动更新或者coc插件的更新导致了这个问题,当然如果我执行以下命令取消系统代理,翻译功能依然能够正确工作:
unset http_proxy
unset https_proxy
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.