feat: improve vim extension user experience (#71)
* chore: checkin dist file for vim extension * use getbufline * do not invoke tabby if file type is unknown * update readme * Update README.md * Update README.md * Update README.md * Update tabby.vimadd-more-languages
parent
d5f5bed4b9
commit
2c3fee4f4f
|
|
@ -1,33 +1,20 @@
|
||||||
# How to Use This VIM Plugin
|
# Tabby VIM extension
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
1. VIM 9.0+ with `+job` and `+textprop` features enabled. NeoVIM is not supported at the moment.
|
1. VIM 9.0+ with `+job` and `+textprop` features enabled. NeoVIM is not supported at the moment.
|
||||||
2. Node.js 16.0+, with `yarn` or `npm` installed.
|
2. Node.js 16.0+.
|
||||||
|
|
||||||
## Setup
|
## Getting started
|
||||||
|
|
||||||
1. Build node scripts in `node_scripts/` directory. Use `yarn` as example. You can also use `npm` instead.
|
### Plug
|
||||||
```bash
|
```
|
||||||
cd node_scripts
|
; Make sure that the filetype plugin has been enabled.
|
||||||
yarn && yarn build
|
filetype plugin on
|
||||||
cd ..
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Copy this directory to your VIM plugin directory.
|
Plug 'TabbyML/tabby', {'rtp': 'clients/vim'}
|
||||||
```bash
|
let g:tabby_server_url = 'http://127.0.0.1:5000'
|
||||||
cp -r . ~/.vim/pack/plugins/start/tabby.vim
|
```
|
||||||
```
|
|
||||||
|
|
||||||
3. (Optional) Set Tabby server URL in your `vimrc` file. If you do not set a URL, the default value is `http://127.0.0.1:5000`.
|
|
||||||
```vim
|
|
||||||
let g:tabby_server_url = 'http://127.0.0.1:5000'
|
|
||||||
```
|
|
||||||
|
|
||||||
4. (Optional) Turn on `filetype` plugin for better compatibility.
|
|
||||||
```vim
|
|
||||||
filetype plugin on
|
|
||||||
```
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -156,11 +156,16 @@ function! s:GetCompletion(id)
|
||||||
if !tabby#Running()
|
if !tabby#Running()
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
let l:language = s:GetLanguage()
|
||||||
|
if l:language == 'unknown'
|
||||||
|
return
|
||||||
|
endif
|
||||||
call ch_sendexpr(s:tabby, #{
|
call ch_sendexpr(s:tabby, #{
|
||||||
\ func: 'getCompletion',
|
\ func: 'getCompletion',
|
||||||
\ args: [#{
|
\ args: [#{
|
||||||
\ prompt: s:GetPrompt(),
|
\ prompt: s:GetPrompt(),
|
||||||
\ language: s:GetLanguage(),
|
\ language: l:language,
|
||||||
\ }],
|
\ }],
|
||||||
\ }, #{
|
\ }, #{
|
||||||
\ callback: function('s:HandleCompletion', [a:id]),
|
\ callback: function('s:HandleCompletion', [a:id]),
|
||||||
|
|
@ -305,7 +310,7 @@ function! tabby#Accept(fallback)
|
||||||
let s:text_to_insert = lines[0]
|
let s:text_to_insert = lines[0]
|
||||||
let insertion = "\<C-R>\<C-O>=tabby#ComsumeInsertion()\<CR>"
|
let insertion = "\<C-R>\<C-O>=tabby#ComsumeInsertion()\<CR>"
|
||||||
else
|
else
|
||||||
let current_line = getbufoneline('%', line('.'))
|
let current_line = getbufline('%', line('.'), line('.'))[0]
|
||||||
let suffix_chars_to_replace = len(current_line) - col('.') + 1
|
let suffix_chars_to_replace = len(current_line) - col('.') + 1
|
||||||
let s:text_to_insert = join(lines, "\n")
|
let s:text_to_insert = join(lines, "\n")
|
||||||
let insertion = repeat("\<Del>", suffix_chars_to_replace) . "\<C-R>\<C-O>=tabby#ComsumeInsertion()\<CR>"
|
let insertion = repeat("\<Del>", suffix_chars_to_replace) . "\<C-R>\<C-O>=tabby#ComsumeInsertion()\<CR>"
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1 @@
|
||||||
node_modules
|
node_modules
|
||||||
dist
|
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,13 @@
|
||||||
|
/*!
|
||||||
|
* mime-db
|
||||||
|
* Copyright(c) 2014 Jonathan Ong
|
||||||
|
* Copyright(c) 2015-2022 Douglas Christopher Wilson
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* mime-types
|
||||||
|
* Copyright(c) 2014 Jonathan Ong
|
||||||
|
* Copyright(c) 2015 Douglas Christopher Wilson
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
Loading…
Reference in New Issue