Giter Site home page Giter Site logo

float-preview.nvim's Introduction

Introduction

NCM2, formerly known as nvim-completion-manager, is a slim, fast and hackable completion framework for neovim.

Main features:

  1. Fast and asynchronous completion support, with vimscript friendly API.
  2. Smart on files with different languages, for example, css/javascript completion in html style/script tag.
  3. Function parameter expansion support using ncm2-snippet plugins.
  4. Language server protocol plugin integration.

Read our wiki page for a list of extensions and programming languages support for NCM2.

peek 2018-07-17 18-15

View demo vimrc at #19

Requirements

  • :echo has("nvim-0.2.2") prints 1. Older versions has not been tested
  • :echo has("python3") prints 1. This is usually set by python3 -m pip install pynvim in shell and let g:python3_host_prog=/path/to/python/executable/ in vimrc.
  • Plugin nvim-yarp

For vim8 user, read the nvim-yarp README. Note that vim8 support is simply a bonus. It's not the goal of NCM2.

Install

    " assuming you're using vim-plug: https://github.com/junegunn/vim-plug
    Plug 'ncm2/ncm2'
    Plug 'roxma/nvim-yarp'

    " enable ncm2 for all buffers
    autocmd BufEnter * call ncm2#enable_for_buffer()

    " IMPORTANT: :help Ncm2PopupOpen for more information
    set completeopt=noinsert,menuone,noselect

    " NOTE: you need to install completion sources to get completions. Check
    " our wiki page for a list of sources: https://github.com/ncm2/ncm2/wiki
    Plug 'ncm2/ncm2-bufword'
    Plug 'ncm2/ncm2-path'

Optional Vimrc Tips

    " suppress the annoying 'match x of y', 'The only match' and 'Pattern not
    " found' messages
    set shortmess+=c

    " CTRL-C doesn't trigger the InsertLeave autocmd . map to <ESC> instead.
    inoremap <c-c> <ESC>

    " When the <Enter> key is pressed while the popup menu is visible, it only
    " hides the menu. Use this mapping to close the menu and also start a new
    " line.
    inoremap <expr> <CR> (pumvisible() ? "\<c-y>\<cr>" : "\<CR>")

    " Use <TAB> to select the popup menu:
    inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
    inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"

    " wrap existing omnifunc
    " Note that omnifunc does not run in background and may probably block the
    " editor. If you don't want to be blocked by omnifunc too often, you could
    " add 180ms delay before the omni wrapper:
    "  'on_complete': ['ncm2#on_complete#delay', 180,
    "               \ 'ncm2#on_complete#omni', 'csscomplete#CompleteCSS'],
    au User Ncm2Plugin call ncm2#register_source({
            \ 'name' : 'css',
            \ 'priority': 9,
            \ 'subscope_enable': 1,
            \ 'scope': ['css','scss'],
            \ 'mark': 'css',
            \ 'word_pattern': '[\w\-]+',
            \ 'complete_pattern': ':\s*',
            \ 'on_complete': ['ncm2#on_complete#omni', 'csscomplete#CompleteCSS'],
            \ })

How Do I write Ncm2 Source?

One important step is to understand how and when completion gets triggered. Read :help ncm2#register_source carefully, or :help ncm2#register_source-example for quick start.

In case you don't know what tool you should use for async support. Here are some options available:

Debugging

Refer to the debugging section of nvim-yarp

float-preview.nvim's People

Contributors

alok avatar ikalnytskyi avatar p00f avatar resolritter avatar roxma avatar shatur avatar subnut avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

float-preview.nvim's Issues

Close preview after timeout

Hi!
First, thank you for great plugin!

Sorry if this question is not directly related, but more generic one. I would like to setup popup so it would close after some timeout. I think, that this may solve problem, when I do not remember function params.

For now I am closing it manually:
imap <leader>a <ESC>:call float_preview#close()<CR>a

neovim always prompt "Save change to "Untitled"

minimal vimrc:

let g:buf = nvim_create_buf(0, 1)
call nvim_buf_set_lines(g:buf, 0, -1, 0, [])
call nvim_buf_set_option(g:buf, 'syntax', 'OFF')
set confirm

first three line are from your plugin:float-preview.nvim

reproduce step

nvim -u minimal_vimrc file_do_not_exist

then

:q 

or

:q! 

neovim will prompt "Save change to "Untitled"

But with following minimal vimrc

set confirm

neovim exit without any promt

Syntax highlight preview window

Thanks for this plugin! I'm integrating it with Nvim-R and I would like to syntax highlight the preview window, such as in the image below:

floatpreview

I had to do a small change in autoload/float_preview.vim to get the above screenshot. I replaced the line 85 with:

        if exists('b:float_syntax')
            call nvim_buf_set_option(s:buf, 'syntax', b:float_syntax)
        else
            call nvim_buf_set_option(s:buf, 'syntax', 'OFF')
        endif

Could you, please, support either a buffer variable as in the example above or a global variable, perhaps a dictionary with the format {'filetype': 'syntaxname'}?

Unknown function `nvim_create_buf`

I installed it by Vim Plug and got this error

Error detected while processing function <SNR>33_init:
line    6:
E117: Unknown function: nvim_create_buf
E15: Invalid expression: nvim_create_buf(0, 1)
line    7:
E121: Undefined variable: s:buf
E116: Invalid arguments for function nvim_buf_set_lines
line    8:
E121: Undefined variable: s:buf
E116: Invalid arguments for function nvim_buf_set_option
Press ENTER or type command to continue

My Neovim version is 0.3.1,
I also tried in version 0.3.4

Truncated text in floating preview

I have the plugin installed, but the text is very truncated for some reason, and in addition, there is a ~ character at the bottom of the preview window for some reason. I'm using the plugin with Deoplete and LanguageClient-NeoVim.

Here is my config:

" Don't dock the preview window to the bottom of the window
let g:float_preview#docked = 0

Screen Shot 2019-10-31 at 2 29 28 PM

preview split and float-preview both appear

Hi,

Thank you for this plugin.
If I add preview to completeopt I see the floating window fine but a preview window split also appears at the bottom.
Is there some autocmd or other setting I can use to prevent the bottom, right previewwindow split to appear ?

thx,
-m

How to navigate floating popup?

Sometimes the definition is longer than what fits the window.
Is there any keybinding for scrolling the text in the window up/down?

Ultisnip support

Hi,
first of all thank you for this awesome plugin. Just a request, when I was using coc used to get apreview for ultisnips.
Now I'm using deoplete, and for floating windows, float-preview is suggested.
But ultisnips are not providing any snippets.

Problems with installation

nvim v.0.3.7

I've following plugins installed:

Plug 'ncm2/ncm2'
Plug 'ncm2/float-preview.nvim'

While opening vim, it's giving me following error:

Error detected while processing ~/.vim/plugged/float-preview.nvim/plugin/float_preview.vim:
line 14:
E216: No such group or event: CompleteChanged * call float_preview#_menu_popup_changed()
Press ENTER or type command to continue

I think it will be nice to have some instructions how to install it.

Thanks.

Place preview window above cursor line

Not sure if this is possible, but add option to place preview window above cursor line. Or even better on the opposite side of cursor line than completion menu.

Change preview for print() function

On pycharm the preview is loaded when you are in the middle of parenthesis, like this:

print("|")

but both in deoplete-jedi and float-preview-nvim it appears just after print, like this:

print|

I did not figure out a way of sharing the image here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.