Giter Club home page Giter Club logo

coc-extensions's Introduction

@voldikss/coc-extensions

Collections of coc.nvim extensions maintained by @voldikss

publish

coc-extensions's People

Contributors

freed-wu avatar pacmanzou avatar voldikss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

coc-extensions's Issues

Set the floating window highlight to 'CocFloating'?

About the default highlight for floating window:

  • NormalFloat for Neovim
  • Pmenu 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.

socks proxy not working

我用的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代理,请问我这是哪里没配置好?

UX and support for pronunciation

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!

Does this extension support nvim 0.8.0?

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?

Error: ENOENT: no such file or directory, stat '/home/chen/.config/coc/extensions/coc-translator-data

大佬你好! 我在安装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'

我不确定我是不是在安装过程中进行了意外的操作, 于是我尝试了重新安装插件, 但问题并未得到解决

Moonshot: rikaichan

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.

Feat: Pass to translation in command

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.

几个建议

  • 许多 promise 没有处理,执行 tslint -c tslint.json -p . 可以看到许多警告,或者把 tslint 这些去掉。可以安装 https://github.com/neoclide/coc-tslint-plugin 实时检测。
  • 多个连续的 vim 请求最好使用 call_atomic 机制,例如:
  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()
  • 最好能支持多个引擎同时查询。

Bing接口有点问题

如题,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,每次翻译都要多一次请求(主页是有结果返回的,所以用来校验),我也不会这个语言,能优化一下这一块吗?

Error occurs when translate sentences

It works well when translate any single word, but fails to translate most sentences.

Example.

  1. hello world -> youdao:你好世界

error information: [coc.nvim] Translating failed: TypeError: Cannot read properties of undefined (reading 'map')

  1. hello David-> hello David

error information: [coc.nvim] Translating failed: TypeError: Cannot read properties of undefined (reading 'map')

  1. David-> youdao:n. 大卫;戴维(男子名),haici:戴维(男子名)

error information: [coc.nvim] Translating failed: TypeError: Cannot read properties of undefined (reading 'map')

  1. hello->same results 你好 form google, youdao and haici.

no error output

  1. any long sentence

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.

Get error with coc-translator-p

老哥,感谢你做的插件,我遇到一个 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"]

key mapping not work

image

添加key mapping 以后 ,按下以后没有翻译,而是在第一行输入了一些错误的字

no work when translate sentence in V mode...

大佬您好,请问为何在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,

error: this.engines is not iterable

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

Support for more engines

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.

coc-translator always timeout

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.

After setting translator.engines , it does not work

由于国内google访问不了,所以设置翻译引擎,在coc-settings.json中设置了 "translator.engines" = ["bing","youdao","haici"], 如下图所示,
image
但是仍报错google无法访问的错误
image

Translator popup will produce lots of useless "[Scratch]" buffers

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.

  • neovim v0.4.3
  • MacOS

error on notification 'doKeymap':

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, 

[coc.nvim]: UnhandledRejection: TypeError: Cannot read properties of undefined (reading 'length')

系统代理:

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.