# coc-floatinput

> Floating input for coc.nvim

Latest version **1.7.0** (published 2023-01-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install coc-floatinput
pnpm add coc-floatinput
yarn add coc-floatinput
bun add coc-floatinput
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.7.0 |
| Published | 2023-01-13 |
| First published | 2020-08-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 76.6 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 36 |
| Author | Weirong Xu |
| Maintainers | raidou1 |
| Keywords | coc.nvim, neovim, floatwin, floatinput |

## Links

- npm: https://www.npmjs.com/package/coc-floatinput
- Repository: git@github.com:weirongxu/coc-floatinput
- npm.io page: https://npm.io/package/coc-floatinput

## Dependencies (2)

- [esbuild](https://npm.io/package/esbuild.md) ^0.16.17
- [coc-helper](https://npm.io/package/coc-helper.md) ^0.16.0

## Recent versions

- 1.7.0 (latest) — 2023-01-13
- 1.6.1 — 2022-05-09
- 1.6.0 — 2022-01-17
- 1.5.7 — 2022-01-17
- 1.5.6 — 2021-08-09
- 1.5.5 — 2021-08-09
- 1.5.4 — 2021-05-13
- 1.5.3 — 2021-01-12
- 1.5.2 — 2020-12-19
- 1.5.1 — 2020-12-05
- 1.5.0 — 2020-11-09
- 1.4.3 — 2020-10-29
- 1.4.2 — 2020-10-25
- 1.4.1 — 2020-10-25
- 1.4.0 — 2020-10-14
- … 11 more at https://npm.io/package/coc-floatinput/versions

## 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 <silent> <Leader>: <Plug>(coc-floatinput-command)`

`nmap <silent> <Leader>c: <Plug>(coc-floatinput-coc-command)`

`nmap <silent> <Leader>rn <Plug>(coc-floatinput-rename)`

### Screenshots

<img src="https://user-images.githubusercontent.com/1709861/90628904-03ab2e80-e251-11ea-97c7-5eec56b7821f.png" width="400">
<img src="https://user-images.githubusercontent.com/1709861/90628942-13c30e00-e251-11ea-81af-683363ae5370.png" width="400">

## 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<FloatInputType>
      | 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',
});
```

<img src="https://user-images.githubusercontent.com/1709861/96014948-8cbd9b00-0e79-11eb-8409-fbc31a0fcc76.png" width="300">

#### number input

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

<img src="https://user-images.githubusercontent.com/1709861/96015085-bd9dd000-0e79-11eb-979d-b89480554fb2.png" width="300">

#### confirm

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

<img src="https://user-images.githubusercontent.com/1709861/96015199-defebc00-0e79-11eb-9a9c-18288fd34718.png" width="300">

## 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 <SID>quit_pre()
endif
```

## License

MIT

---

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

---
_Source: https://npm.io/package/coc-floatinput · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
