Giter Site home page Giter Site logo

ncm2-racer'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

ncm2-racer's People

Contributors

liuchengxu avatar roxma avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

megalithic

ncm2-racer's Issues

no completion if used with vim-plug on-demand loading

If ncm2-racer is loaded on-demand with vim-plug, completion does not work:

Plug 'ncm2/ncm2-racer', { 'for': 'rust' }

This may be true for other ncm2 plugins.

Suggested fix would be to document this in the Installation section of the README, since it's surprising. I can provide provide a minimal example if this isn't expected behavior.

Thanks for all your work on ncm2!

subprocess is not defined

After installed this plugin, i encountered NameError: 'subprocess' is not defined. message. So i googled this message and solved this issue by adding some line to ncm2.py.

ncm2.py:

...
import subprocess # <= this line
from subprocess import Popen
...

...and compilation works perfectly.
Is this correct solution? Here is my init.vim file.

init.vim:

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" vim-plug
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
call plug#begin('~/appdata/local/nvim/plugged')
" theme
Plug 'nanotech/jellybeans.vim'

" utilities
Plug 'scrooloose/nerdtree'

" ncm2
Plug 'ncm2/ncm2'
Plug 'roxma/nvim-yarp'
"Plug 'autozimu/LanguageClient-neovim', {
	"\ 'branch': 'next',
	"\ 'do': 'bash install.sh'
	"\}

Plug 'ncm2/ncm2-bufword'
Plug 'ncm2/ncm2-path'

" languages
" Plug 'fatih/vim-go'
Plug 'racer-rust/racer'
Plug 'ncm2/ncm2-racer'
call plug#end()

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" outlooks
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set number
colorscheme jellybeans
" set guifont=D2Coding:h12

set tabstop=4
set shiftwidth=4

"let g:LanguageClient_serverCommands = {
			"\'rust': ['rustup', 'run', 'nightly', 'rls']
			"\}

autocmd BufEnter * call ncm2#enable_for_buffer() " enable ncm2 for all buffers
set completeopt=noinsert,menuone,noselect

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.