1.7.0 • Published 1 year ago

coc-floatinput v1.7.0

Weekly downloads
601
License
MIT
Repository
github
Last release
1 year ago

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

Highlight

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

API

Use coc-floatinput API in other extensions

// 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

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

string input

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

number input

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

confirm

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

{
  "floatinput.status.enabled": true
}

Avoid only floating window error

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

1.7.0

1 year ago

1.6.1

2 years ago

1.6.0

2 years ago

1.5.7

2 years ago

1.5.5

3 years ago

1.5.6

3 years ago

1.5.4

3 years ago

1.5.3

3 years ago

1.5.2

3 years ago

1.5.1

3 years ago

1.5.0

3 years ago

1.4.3

4 years ago

1.4.2

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.2.2

4 years ago

1.3.0

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago