Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/weirongxu/coc-floatinput

Floating input for coc.nvim
https://github.com/weirongxu/coc-floatinput

coc-nvim floatwin neovim

Last synced: about 1 month ago
JSON representation

Floating input for coc.nvim

Awesome Lists containing this project

README

        

# coc-floatinput

Floating input for coc.nvim

**Note**: Vim popupwin doesn't support the focus feature, So this extension only works on neovim

## Install

`:CocInstall coc-floatinput`

## Keymaps

`nmap : (coc-floatinput-command)`

`nmap c: (coc-floatinput-coc-command)`

~~`nmap rn (coc-floatinput-rename)` removed, see https://github.com/weirongxu/coc-floatinput/issues/21~~

### Screenshots


## Highlight

```vim
autocmd ColorScheme *
\ hi CocHelperNormalFloatBorder guifg=#dddddd guibg=#575B54
\ | hi CocHelperNormalFloat guibg=#575B54
```

## API

Use coc-floatinput API in other extensions

```typescript
// Get coc-floatinput API

// input FloatInputType only
import type { FloatInputType } from 'coc-floatinput';

import { extensions } from 'coc.nvim';

let floatInputExt: FloatInputType | undefined;

async function getFloatInputApi() {
if (!floatInputExt) {
floatInputExt = extensions.all.find((e) => e.id === 'coc-floatinput') as
| Extension
| undefined;
}
return floatInputExt?.exports;
}
```

### FloatingUI

```typescript
// Get FloatingUI
async function getFloatUI() {
return (await getFloatInputApi())?.FloatingUI;
}
```

#### string input

```typescript
const FloatUI = await getFloatUI();
await FloatUI?.stringInput({
prompt: 'Input your string',
defaultValue: 'default string',
});
```

#### number input

```typescript
const FloatUI = await getFloatUI();
await FloatUI?.numberInput({
prompt: 'Input your number',
defaultValue: 1,
});
```

#### confirm

```typescript
const FloatUI = await getFloatUI();
await FloatUI?.confirm({
prompt: 'Are you sure',
values: ['yes', 'no', 'skip'],
defaultValue: 'yes',
});
```

## Status window

Enable floatinput status window.

coc-settings.json

```json
{
"floatinput.status.enabled": true
}
```

Avoid `only floating window` error

```vim
if has('nvim')
function! s:is_float(winnr)
let winid = win_getid(a:winnr)
return !empty(nvim_win_get_config(winid)['relative'])
endfunction

function! s:quit_pre()
let cur_nr = winnr()
if s:is_float(cur_nr)
return
endif
let last_nr = winnr('$')
for nr in range(last_nr, 1, -1)
if s:is_float(nr)
continue
endif
if nr == 1
only
else
break
endif
endfor
endfunction

autocmd QuitPre * call quit_pre()
endif
```

## License

MIT

---

> This extension is created by [create-coc-extension](https://github.com/fannheyward/create-coc-extension)