Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/weirongxu/coc-floatinput
- Owner: weirongxu
- License: mit
- Created: 2020-07-31T12:55:31.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-06-07T06:55:06.000Z (over 1 year ago)
- Last Synced: 2024-10-09T14:50:57.273Z (about 1 month ago)
- Topics: coc-nvim, floatwin, neovim
- Language: TypeScript
- Homepage:
- Size: 615 KB
- Stars: 35
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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'])
endfunctionfunction! 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
endfunctionautocmd QuitPre * call quit_pre()
endif
```## License
MIT
---
> This extension is created by [create-coc-extension](https://github.com/fannheyward/create-coc-extension)