Provides functions to wrap the DeepL API.
This plugin provides only simple functions. If you need commands, see gw31415/deepl-commands.nvim.
Plug 'gw31415/deepl.vim'
call dein#add('gw31415/deepl.vim')
use 'gw31415/deepl.vim'
let g:deepl_auth_key = '{Your auth key of DeepL API}'
In the example below, the command :{range}DeepL
is created that translates
the selected lines and adds the translation just below the selection. If the
command called with a exclamation mark ( :{range}DeepL!
), the lines will be
replaced with the translation.
fu! s:deepl(l1, l2, bang) abort
let in = join(getline(a:l1, a:l2), "\n")
try
let out = split(deepl#translate(in, 'EN'), "\n")
catch
echoh ErrorMsg | ec v:exception | echoh None
retu
endt
if a:bang == ''
cal append(a:l2, out)
el
cal setline(a:l1, out)
en
endfu
com! -range -bang DeepL cal s:deepl(<line1>, <line2>, '<bang>')
- deepl-commands.nvim: Provides the DeepL command using this deepl.vim plugin.