https://github.com/gw31415/deepl.vim
Vim functions to wrap the DeepL API.
https://github.com/gw31415/deepl.vim
deepl vim
Last synced: 10 months ago
JSON representation
Vim functions to wrap the DeepL API.
- Host: GitHub
- URL: https://github.com/gw31415/deepl.vim
- Owner: gw31415
- License: zlib
- Created: 2022-09-07T12:42:19.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-09-09T06:50:41.000Z (almost 4 years ago)
- Last Synced: 2025-05-25T09:41:03.138Z (about 1 year ago)
- Topics: deepl, vim
- Language: Vim Script
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DeepL.vim
Provides functions to wrap the [DeepL API](https://www.deepl.com/en/docs-api/).
This plugin provides only simple functions. If you need commands, see
[gw31415/deepl-commands.nvim](https://github.com/gw31415/deepl-commands.nvim).
## Installation
### 1. Installation of this plugin
[Plug.vim](https://github.com/junegunn/vim-plug)
```vim
Plug 'gw31415/deepl.vim'
```
[dein.vim](https://github.com/Shougo/dein.vim)
```vim
call dein#add('gw31415/deepl.vim')
```
[packer.nvim](https://github.com/wbthomason/packer.nvim)
```lua
use 'gw31415/deepl.vim'
```
### 2. Configuration of Auth Key
```vim
let g:deepl_auth_key = '{Your auth key of DeepL API}'
```
## Example
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.
```vim
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(, , '')
```
## Related Projects
- [deepl-commands.nvim](https://github.com/gw31415/deepl-commands.nvim): Provides the DeepL command using this deepl.vim plugin.