Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A more feature rich vimrc example, and a demo gif #19

Closed
roxma opened this issue Jul 13, 2018 · 17 comments
Closed

A more feature rich vimrc example, and a demo gif #19

roxma opened this issue Jul 13, 2018 · 17 comments

Comments

@roxma
Copy link
Member

roxma commented Jul 13, 2018

peek 2018-07-17 18-15

Vimrc for demo:

Make sure you do understand what it is doing before copying config. Comment if you have any question

execute 'source ' . $WORKSPACE_DIR . '/plug.vim'

call plug#begin($WORKSPACE_DIR)
    Plug 'ncm2/ncm2'
    Plug 'roxma/nvim-yarp'

    autocmd BufEnter * call ncm2#enable_for_buffer()
    set completeopt=noinsert,menuone,noselect
    set shortmess+=c

    inoremap <c-c> <ESC>

    inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
    inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"

    Plug 'ncm2/ncm2-match-highlight'

    Plug 'ncm2/ncm2-ultisnips'
    Plug 'SirVer/ultisnips'
    Plug 'honza/vim-snippets'

    inoremap <silent> <expr> <CR> ((pumvisible() && empty(v:completed_item)) ?  "\<c-y>\<cr>" : (!empty(v:completed_item) ? ncm2_ultisnips#expand_or("", 'n') : "\<CR>" ))

    " c-j c-k for moving in snippet
    imap <expr> <c-u> ncm2_ultisnips#expand_or("\<Plug>(ultisnips_expand)", 'm')
    smap <c-u> <Plug>(ultisnips_expand)
    let g:UltiSnipsExpandTrigger		= "<Plug>(ultisnips_expand)"
    let g:UltiSnipsJumpForwardTrigger	= "<c-j>"
    let g:UltiSnipsJumpBackwardTrigger	= "<c-k>"
    let g:UltiSnipsRemoveSelectModeMappings = 0

    Plug 'ncm2/ncm2-html-subscope'
    Plug 'ncm2/ncm2-markdown-subscope'
    Plug 'ncm2/ncm2-bufword'
    Plug 'ncm2/ncm2-jedi'
    Plug 'ncm2/ncm2-pyclang'
    Plug 'ncm2/ncm2-tern'
    Plug 'ncm2/ncm2-cssomni'

    Plug 'autozimu/LanguageClient-neovim', {
        \ 'branch': 'next',
        \ 'do': 'bash install.sh',
        \ }
    let g:LanguageClient_serverCommands = {
                \ 'vue': ['vls'],
                \ 'rust': ['rls'],
                \ }

    " read
    " https://github.com/autozimu/LanguageClient-neovim/pull/514#issuecomment-404463033
    " for contents of settings.json for vue-language-server
    let g:LanguageClient_settingsPath = $WORKSPACE_DIR . '/.vim/settings.json'
    let g:LanguageClient_completionPreferTextEdit = 1
    autocmd BufNewFile,BufRead *.vue set filetype=vue
    autocmd filetype vue LanguageClientStart

    " the suddennly popup of diagnostics sign is kind of annoying
    let g:LanguageClient_diagnosticsSignsMax = 0

    " " for debugging LanguageClient-neovim
    " set noshowmode
    " inoremap <silent> <c-q> <esc>:<c-u>q!<cr>
    " let g:LanguageClient_loggingFile = '/tmp/lc.log'
    " let g:LanguageClient_loggingLevel = 'DEBUG'

    " markdown syntax highlight, theme
    Plug 'morhetz/gruvbox'
    Plug 'plasticboy/vim-markdown', {'for': 'markdown'}
call plug#end()

set background=dark
colorscheme gruvbox
set number
set relativenumber
@roxma roxma changed the title [TODO] A more feature rich vimrc, and a demo gif? [TODO] A more feature rich vimrc example, and a demo gif? Jul 13, 2018
@roxma roxma changed the title [TODO] A more feature rich vimrc example, and a demo gif? A more feature rich vimrc example, and a demo gif Jul 17, 2018
@roxma roxma closed this as completed Jul 17, 2018
@neur1n

This comment has been minimized.

@roxma

This comment has been minimized.

@neur1n

This comment has been minimized.

@jalcine
Copy link

jalcine commented Jul 26, 2018

Have any consideration gone into moving some of this pre-init logic into the plugin itself? Like under a let g:ncm2#auto = 1 flag?

@roxma
Copy link
Member Author

roxma commented Jul 26, 2018

@jalcine

Have any consideration gone into moving some of this pre-init logic into the plugin itself? Like under a let g:ncm2#auto = 1 flag?

No. My own configuration is different from this version. It's hard to generalize.

@jalcine
Copy link

jalcine commented Jul 26, 2018

Fair enough!

@uorbe001
Copy link

screen shot 2018-08-24 at 12 02 57

Does this parameter preview on the menu (to, msg) and the parenthesis completion depend on the source or a specific config option? I have it set up with lsp and I'm not getting that, so I wonder if it is because the source doesn't support that?

@filipekiss
Copy link
Contributor

@uorbe001 from my experience with NCM, it depends on the source, not a config option.

@uorbe001
Copy link

@filipekiss thanks, I will see if adding that to the source is possible.

@terkelg
Copy link

terkelg commented Jan 27, 2019

I'm not sure I understand what this line does:

inoremap <silent> <expr> <CR> ((pumvisible() && empty(v:completed_item)) ?  "\<c-y>\<cr>" : (!empty(v:completed_item) ? ncm2_ultisnips#expand_or("", 'n') : "\<CR>" ))

@roxma
Copy link
Member Author

roxma commented Jan 27, 2019

@terkelg

1. (pumvisible() && empty(v:completed_item)) -> 
    popup menu is visible but non was selected ->  "\<c-y>\<cr>" -> 
        close the popup with <c-y> and break line with <CR>

2. !empty(v:completed_item) -> 
    popup menu may or may not be visible, but there's a valid completion there -> 
        try expand its snippet, if expansion fails, do nothing else

3. empty(v:completed_item) -> 
    this implies that !pumvisible() in step 1, popup menu is not visible, no valid completion out there -> 
        break the line with <CR>

I don't remember why I chose this mapping. Currently I'm using inoremap <silent> <expr> <CR> ncm2_ultisnips#expand_or("\<CR>", 'n') in my vimrc.

@wizzup
Copy link

wizzup commented Mar 8, 2019

(Neovim)

Forgive me if it sound too stupid, I am very new to ncm2.

Where is the declaration and what is the value of $WORKSPACE_DIR?

I am using junegunn/vim-plug by manually install it

$ curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

and my current init.vim ($MYVIMRC) structure is like this

call plug#begin()
    Plug 'morhetz/gruvbox'
    Plug 'autozimu/LanguageClient-neovim', {'branch': 'next', 'do': './install.sh'}
call plug#end()

let g:LanguageClient_serverCommands = {
    \ 'haskell': ['hie-wrapper', '--lsp'],
    \ 'python': ['pyls'],
\ }

I don't understand the purpose and usage of $WORKSPACE_DIR.

When I try using (your) provided config file, I don't seem to get any completion as shown in the picture.

@roxma
Copy link
Member Author

roxma commented Mar 8, 2019

Where is the declaration and what is the value of $WORKSPACE_DIR?

$WORKSPACE_DIR is a environment that variable points to my ncm2 development workspace. :help let-$

You could remove it since you do call plug#begin() with no parameteres.

@ukrdev
Copy link

ukrdev commented Mar 21, 2019

Sorry, but i don't understand, how to put function arguments on autocomplete.

@roxma
Copy link
Member Author

roxma commented Mar 21, 2019

@ukrdev you should be familiar with one of ultisnips, neosnippet or snipmate before using the snippet feature for parameter expansion.

@faulesocke
Copy link

I tried for half a day getting parameter expansion to work. I didn't even manage to make it work with the vimrc from above. When I type the name of the function, it shows the completion popup but when I select it and press Enter the dialog closes, a new line is entered but no parameter expansion happens. Am I missing a key or something?

I was trying with a rust source with LanguageClient-neovim and RLS nightly. Everything else works and I'm using that stuff for quite a while but parameter expansion just simply wont work. What am I missing?

@faulesocke
Copy link

Wow, it looks like I finally found it:

let g:LanguageClient_hasSnippetSupport = 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants