Coder Social home page Coder Social logo

ncm2-tern'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-tern's People

Stargazers

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

Watchers

 avatar  avatar  avatar

ncm2-tern's Issues

打开javacript.jsx格式文件会报错

报错信息:

[ncm2_tern@yarp] Traceback (most recent call last):
[ncm2_tern@yarp] File "/Users/Licht/.vim/plugged/nvim-yarp/pythonx/yarp.py", line 59, in
[ncm2_tern@yarp] module_obj = importlib.import_module(module)
[ncm2_tern@yarp] File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/init.py", line 127, in import_module
[ncm2_tern@yarp] return _bootstrap._gcd_import(name[level:], package, level)
[ncm2_tern@yarp] File "", line 1006, in _gcd_import
[ncm2_tern@yarp] File "", line 983, in _find_and_load
[ncm2_tern@yarp] File "", line 967, in _find_and_load_unlocked
[ncm2_tern@yarp] File "", line 677, in _load_unlocked
[ncm2_tern@yarp] File "", line 728, in exec_module
[ncm2_tern@yarp] File "", line 219, in _call_with_frames_removed
[ncm2_tern@yarp] File "/Users/Licht/.vim/plugged/ncm2-tern/pythonx/ncm2_tern.py", line 171, in
[ncm2_tern@yarp] source = Source(vim)
[ncm2_tern@yarp] File "/Users/Licht/.vim/plugged/ncm2-tern/pythonx/ncm2_tern.py", line 94, in init
[ncm2_tern@yarp] 'split(globpath(&rtp,"node_modules/tern/bin/tern",1),"\n")[0]')
[ncm2_tern@yarp] File "/usr/local/lib/python3.7/site-packages/neovim/api/nvim.py", line 280, in eval
[ncm2_tern@yarp] return self.request('nvim_eval', string, **kwargs)
[ncm2_tern@yarp] File "/usr/local/lib/python3.7/site-packages/neovim/api/nvim.py", line 170, in request
[ncm2_tern@yarp] res = self._session.request(name, *args, **kwargs)
[ncm2_tern@yarp] File "/usr/local/lib/python3.7/site-packages/neovim/msgpack_rpc/session.py", line 100, in request
[ncm2_tern@yarp] raise self.error_wrapper(err)
[ncm2_tern@yarp] neovim.api.nvim.NvimError: b'Vim:E684: list index out of range: 0'
[ncm2_tern@yarp] Job is dead. cmd=['/usr/local/bin/python3', '-u', '/Users/Licht/.vim/plugged/nvim-yarp/pythonx/yarp.py', '/var/folders/v7/1dtcydw51_s1ydkmypx1fggh0000gn/T/nvimqHymaZ/0', 7, 'ncm2_tern']

Job is dead. cmd=['/usr/bin/python3', ...... , '/tmp/nvimL912c5/0', 7, 'ncm2_tern']

[ncm2_tern@yarp] Traceback (most recent call last):
[ncm2_tern@yarp] File "/home/moonmoonc/.vim/plugged/nvim-yarp/pythonx/yarp.py", line 63, in <
module>
[ncm2_tern@yarp] module_obj = importlib.import_module(module)
[ncm2_tern@yarp] File "/usr/lib/python3.6/importlib/init.py", line 126, in import_module
[ncm2_tern@yarp] return _bootstrap._gcd_import(name[level:], package, level)
[ncm2_tern@yarp] File "", line 994, in _gcd_import
[ncm2_tern@yarp] File "", line 971, in _find_and_load
[ncm2_tern@yarp] File "", line 955, in _find_and_load_unlocked
[ncm2_tern@yarp] File "", line 665, in _load_unlocked
[ncm2_tern@yarp] File "", line 678, in exec_module
[ncm2_tern@yarp] File "", line 219, in _call_with_frames_removed

[ncm2_tern@yarp] File "/home/moonmoonc/.vim/plugged/ncm2-tern/pythonx/ncm2_tern.py", line 188
, in
[ncm2_tern@yarp] source = Source(vim)
[ncm2_tern@yarp] File "/home/moonmoonc/.vim/plugged/ncm2-tern/pythonx/ncm2_tern.py", line 104
, in init
[ncm2_tern@yarp] self._tern = Tern(path)
[ncm2_tern@yarp] File "/home/moonmoonc/.vim/plugged/ncm2-tern/pythonx/ncm2_tern.py", line 44,
in init
[ncm2_tern@yarp] "stderr: %s\n") % (stdout_output, stderr_output)
[ncm2_tern@yarp] Exception: Did not get expected output starting tern, got the following:
[ncm2_tern@yarp] stdout:
[ncm2_tern@yarp] stderr: Bad JSON in /home/moonmoonc/.tern-config: Unexpected end of JSON input

[ncm2_tern@yarp] Job is dead. cmd=['/usr/bin/python3', '-u', '/home/moonmoonc/.vim/plugged/nvim-yarp/pythonx/yarp.py', '/tmp/nvimL912c5/0', 7, 'ncm2_tern']

Someone helps me?

add configuration for ternjs queries

It would be nice if we could configure the completions we get back from ternjs like deoplete-ternjs offers: https://github.com/carlitux/deoplete-ternjs#vim-configuration-example. The default ternjs completions can be a tad too noisy. E.g. including keywords like const and function.

I see the options are already being set in the python file https://github.com/ncm2/ncm2-tern/blob/master/pythonx/ncm2_tern.py#L66. If I were pointed in the right direction, I could open a PR for this.

And of course, thank you for the awesome work on ncm2!

ncm2_tern@yarp Job is dead

I have ncm2-tern as part of my dotfiles and I noticed this morning that tern no longer works. I have installed tern via npm globally, I've installed yarp, ncm2, and ncm2-tern, checked to make sure Python was enabled in nvim, confirmed that .tern-config is in my home directory and still I can't get tern to run. Is there an update or something that broke this?

EDIT: I seem to have found the issue. { 'do': 'npm install' } is not firing. Does anyone know why this would be?

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.