Last active
January 24, 2019 18:14
-
-
Save anelson/63cd090e80944713b935e84543dfec38 to your computer and use it in GitHub Desktop.
Minimal vimrc to reproduce problem with ncm2 and neosnippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"" vim:fdm=expr:fdl=0 | |
"" vim:fde=getline(v\:lnum)=~'^"#'?'>'.(matchend(getline(v\:lnum),'"#*')-1)\:'=' | |
if has('nvim') | |
set runtimepath+=~/.vim,~/.vim/after | |
set packpath+=~/.vim | |
endif | |
"# Standard boilerplate | |
set nocompatible " be iMproved, required | |
filetype off " required | |
syntax on "enable syntax highlighting | |
"# vim-plug | |
"# vim plugins | |
call plug#begin('~/.vim/plugged') | |
"## rust support | |
Plug 'rust-lang/rust.vim' | |
let g:rustfmt_autosave = 1 " automatically rustfmt on save | |
"## LanguageClient-neovim LSP support | |
" LSP client for those languages that provide a language server | |
Plug 'autozimu/LanguageClient-neovim', { | |
\ 'branch': 'next', | |
\ 'do': 'bash install.sh', | |
\ } | |
" TODO: add other languages' LSP configs here over time, and make sure if you add other languages here that you disable | |
" ALE linters above so they don't step on each other | |
let g:LanguageClient_serverCommands = { | |
\ 'rust': ['rustup', 'run', 'nightly', 'rls'] | |
\ } | |
"## ncm2 autocompleter (replaces deoplete) | |
Plug 'ncm2/ncm2' | |
Plug 'roxma/nvim-yarp' | |
" enable ncm2 for all buffers | |
autocmd BufEnter * call ncm2#enable_for_buffer() | |
" Use two different sets of completeop values: one for Ncm2PopupOpen, and the | |
" other when neovim's built-in completion is being used (like the command | |
" line) | |
au User Ncm2PopupOpen set completeopt=noinsert,menuone,noselect | |
au User Ncm2PopupClose set completeopt=menuone | |
" suppress the annoying 'match x of y', 'The only match' and 'Pattern not | |
" found' messages | |
set shortmess+=c | |
"### Completion source plugins | |
" 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 | |
" | |
" I have not included any of the language-specific completion plugins. They | |
" exist for just about every popular language, but right now I'm working with | |
" langauges that have LSP support which is obviously going to be much richer. | |
" Down the road it may be necessary to bring in some language support if LSP | |
" is lacking. | |
Plug 'ncm2/ncm2-bufword' " any word that appears in the current buffer | |
"### Other ncm2-related plugins | |
Plug 'ncm2/ncm2-neosnippet' " integrate with neosnippet for snippet autocompletion | |
"## neosnippet for snippets | |
" I used to use Ultisnips but switched to neosnippet because it integrates | |
" with deoplete. Maybe Ultisnips does too by now but I am happy with it as it | |
" is. | |
Plug 'Shougo/neosnippet.vim' " the snippet plugin itself | |
Plug 'Shougo/context_filetype.vim' " another plugin which detects the filetype at the cursor for complex files | |
Plug 'Shougo/neosnippet-snippets' " a default collection of snippets | |
imap <C-k> <Plug>(neosnippet_expand_or_jump) | |
smap <C-k> <Plug>(neosnippet_expand_or_jump) | |
xmap <C-k> <Plug>(neosnippet_expand_target) | |
" Press enter key to trigger snippet expansion | |
" The parameters are the same as `:help feedkeys()` | |
inoremap <silent> <expr> <CR> ncm2_neosnippet#expand_or("\<CR>", 'n') | |
func! TabPressed() | |
echom "TabPressed" | |
echom "neosnippet#expandable_or_jumpable(): " . neosnippet#expandable_or_jumpable() | |
echom "pumvisible(): ". pumvisible() | |
echom "ncm2_neosnippet#completed_is_snippet(): " . ncm2_neosnippet#completed_is_snippet() | |
echom "Completed item:" | |
echom json_encode(v:completed_item) | |
if ncm2_neosnippet#completed_is_snippet() | |
"return "\<Plug>(ncm2_neosnippet_expand_completed)" | |
"return "\<Plug>(neosnippet_expand_or_jump)" | |
"call feedkeys("\<Plug>(neosnippet_expand_or_jump)", "im") | |
return "\<C-k>" | |
elseif pumvisible() | |
return "\<C-n>" | |
else | |
return "\<TAB>" | |
endif | |
endfunction | |
" SuperTab like snippets behavior. I want this to work whether a popup is | |
" currently displayed or not. | |
" Note: It must be "imap" and "smap". It uses <Plug> mappings. | |
imap <expr><TAB> TabPressed() | |
\ ncm2_neosnippet#completed_is_snippet() ? "\<Plug>(ncm2_neosnippet_expand_completed)" : | |
\ pumvisible() ? "\<C-n>" : "\<TAB>" | |
"## end plugins | |
" Add plugins to &runtimepath | |
call plug#end() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment