voldikss / coc-extensions

🌸 Collections of coc.nvim extensions maintained by @voldikss
122 stars 6 forks source link

error on notification 'doKeymap': #9

Closed teto closed 5 years ago

teto commented 5 years ago

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, 
teto commented 5 years ago

how does the engine work ? I've tried to call the mapping on a visual range but it returns No range allowed. Would be nice to support it :)

voldikss commented 5 years ago

Thank you for testing this plugin! I have run into that problem before. But I tested it just now and found it was gone. Could you upgrade coc/coc-translator to the lastest version and test again?

voldikss commented 5 years ago

As a coc's extension, its keymap was defined here https://github.com/voldikss/coc-translator/blob/e3c667d3150cefc3b6017ced91671003dbf958b0/src/index.ts#L19-L33

The engine classes was wrote in the translator.ts file. But currently I can't figure out how to define a visual keymap and make it workable. So I added it into the TODO

teto commented 5 years ago

I was already using the latest coc-translator. I've bumped coc-nvim runtime (still using 0.72 for th binary though) but still gets the error :s

voldikss commented 5 years ago

Hmmm, sorry I still can not reproduce this issue. It's weird somehow

teto commented 5 years ago

no pb this kind of issue tends to go away with time, after several package updates; I will wait :)

btw I work with several different languages so I would like to specify the target/origin language when mapping. I feel like it's impossible right now ?

voldikss commented 5 years ago

btw I work with several different languages so I would like to specify the target/origin language when mapping.

Hi @teto If you want to create various keymaps according to the languages, you can use vim-translate-me, which is developed using VimL. I just refine its command and make it easy to pass target language argument.

e.g.

nmap <silent>    <Leader>tf   :TranslateW -e bing google -l fr<CR>
nmap <silent>    <Leader>tj   :TranslateW -e bing google -l ja<CR>
teto commented 5 years ago

haha I used to use that one but I liked the idea of displaying the translation in floating windows, hence I switched to this one (as I already used the excellent coc)

voldikss commented 5 years ago

That plugin also display the translation in floating windows(for nvim) or popup(for vim81). Moreover, viml is easier to handle some stuff such as keymap.

Yes, coc is super sexy.

perfectspr commented 5 years ago

got the same issue when nmap <Leader>t <Plug>(coc-translator-p) got below issue when nmap <Leader>e <Plug>(coc-translator-e)

[coc.nvim] error: error on notification 'doKeymap': TypeError: Cannot read property 'query' of undefined

voldikss commented 5 years ago

@perfectspr Could you give me the text under the cursor(so that I can reproduce that issue)?

teto commented 5 years ago

still present (just ran on 店) CocInfo

## versions

vim version: NVIM v0.4.0-dev
node version: v10.16.0
coc.nvim version: 0.0.73-56825890dc
term: xterm-termite
platform: linux

## Messages
"content/nixos_testing_infra.md" 55L, 1613C
"content/restauration.md" 38L, 1166C
1 modification ; avant #1 ; il y a 1 seconde
"content/restauration.md" 38 lines --28%--
[coc.nvim] error: error on notification 'doKeymap': TypeError: Cannot read property 'index' of null
## Output channel: snippets
voldikss commented 5 years ago

@teto I just located the bug and fixed it. I wasn't aware that you use Japanese before....

teto commented 5 years ago

thanks ! it works. One strange thing is that google seems to return a character that can't be displayed ? This is the content of the floating window when trying to translate the kanji 店

           @ 店内 @

--------- google ---------
🌀 À l'intérieur du magasin

the block/square on the last line is: '🌀' U+1F300 Dec:127744 CYCLONE &#x1F300; /\%U1f300 "\U1f300". Shouldn't it display the same kanji ? or is that a network error ?

voldikss commented 5 years ago

I will check it for you

teto commented 5 years ago

so github displays correctly the cyclon codepoint (but in my terminal, it was the glyph for unknown glyph). Anyway strange to use a cyclon instead of 店内.

voldikss commented 5 years ago

Sorry I didn't figure out what the real problem is. Do you mean cyclon isn't displayed correctly or the translation text À l'intérieur du magasin is invalid? Could you take a screenshot for that?

teto commented 5 years ago

The translation is correct, I just find it weird that my term is asked to display 'cyclon' instead of the kanji it was asked to translate: coc-translator

voldikss commented 5 years ago

Hmmm I am not aware that emoji may not be displayed correctly in some terminal. :neckbeard: