I would like to get completion working in R.
I have tried using nvim-r, which populates vim omnifunc. I tried adding
let g:deoplete#sources.r = ['omni', 'ultisnips']
with a couple options:
call deoplete#custom#source('omni', 'input_patterns', {
\ 'r': '[^. *\t]\.\w*',
\})
(suggested at https://github.com/Shougo/deoplete.nvim/blob/master/doc/deoplete.txt#L1551 - is this a typo? I was under the impression input patterns should be a var, not a source)
call deoplete#custom#var('omni', 'input_patterns', {
\ 'r': '[^. *\t]\.\w*',
\})
(suggested at https://github.com/Shougo/deoplete.nvim/blob/master/doc/deoplete.txt#L555)
call deoplete#custom#source('omni_patterns', {
\ 'r': '[^. *\t]\.\w*',
\})
(suggested at https://github.com/Shougo/deoplete.nvim/blob/master/doc/deoplete.txt#L189)
However, all I see in deoplete completion is ultisnips snippets. Manually calling <C-x><C-o> will bring up nvim-r's function completions. Do you have any suggestions?
Vimrc:
source $HOME/.config/nvim/general.vim
call plug#begin('$HOME/.dotfiles/nvim/plugged')
Plug 'autozimu/LanguageClient-neovim', {'branch': 'next', 'do': './install.sh'}
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
Plug 'jalvesaq/nvim-r'
""" Deoplete config
" automatically start{{{
let g:deoplete#enable_at_startup = 1
let g:deoplete#enable_smart_case = 1
let g:deoplete#sources = {}
let g:deoplete#sources._ = ['file', 'buffer']
let g:deoplete#sources.python = ['LanguageClient', 'jedi', 'ultisnips']
let g:deoplete#sources.python3 = ['LanguageClient', 'jedi', 'ultisnips']
let g:deoplete#sources.rust = ['LanguageClient', 'ultisnips']
let g:deoplete#sources.tex = ['ultisnips', 'omni']
let g:deoplete#sources.vim = ['vim', 'ultisnips']
let g:deoplete#sources.r = ['omni', 'ultisnips']
"let g:deoplete#sources.r = ['LanguageClient', 'ultisnips']
""" Disable the candidates in Comment/String syntaxes.
call deoplete#custom#source('_',
\ 'disabled_syntaxes', ['Comment', 'String'])
""" deoplete-racer config
let g:deoplete#sources#rust#racer_binary='/usr/local/bin/racer'
let g:deoplete#sources#rust#rust_source_path='$HOME/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src'
" put snippets at the top of completion menu
"call deoplete#custom#source('ultisnips', 'rank', 1000)
call deoplete#custom#var('omni', 'input_patterns', {
\ 'r': '[^. *\t]\.\w*',
\})
""" Deoplete and vimtex config
call deoplete#custom#var('omni', 'input_patterns', {
\ 'tex' : g:vimtex#re#deoplete,
\})
I have tried using LanguageClient-neovim with the R language server to get completion.
I set let g:deoplete#sources.r = ['LanguageClient'] and configure with
let g:LanguageClient_autoStart = 1
let g:LanguageClient_serverCommands = {}
let g:LanguageClient_serverCommands.r = ['R', '--quiet', '--slave', '-e', 'languageserver::run()']
When working in python for example, setting LanguageClient as a deoplete source will populate completion. But with the same configuration for R it does not work.
deoplete version: 57d3f0c3cdfcfc1d91901a6d59d08f9008abd166
OS: Arch Linux on 4.16.5-1 kernel
Features: +acl +iconv +jemalloc +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/share/nvim"
:checkhealth or :CheckHealth result(neovim only): all OKI tried updating my sources to the new format:
call deoplete#custom#option('sources', {
\ '_': ['file', 'buffer'],
\ 'python': ['LanguageClient', 'ultisnips'],
\ 'python3': ['LanguageClient', 'ultisnips'],
\ 'rust': ['LanguageClient', 'ultisnips'],
\ 'tex': ['ultisnips', 'omni'],
\ 'r': ['LanguageClient', 'omni', 'ultisnips']
\})
but am still running into issues specifically with R.
(suggested at https://github.com/Shougo/deoplete.nvim/blob/master/doc/deoplete.txt#L1551 - is this a typo? I was under the impression input patterns should be a var, not a source)
Yes. It is typo.
call deoplete#custom#var() is correct.
call deoplete#custom#var('omni', 'input_patterns', {
\ 'r': '[^. *\t]\.\w*',
\})
""" Deoplete and vimtex config
call deoplete#custom#var('omni', 'input_patterns', {
\ 'tex' : g:vimtex#re#deoplete,
\})
It overwrites the previous configuration.
This is the correct pattern.
""" Deoplete and vimtex config
call deoplete#custom#var('omni', 'input_patterns', {
\ 'tex' : g:vimtex#re#deoplete,
\ 'r': '[^. *\t]\.\w*',
\})
Hi @Shougo, I'm trying to make deoplete work with nvim-r omnicompletion. I want to able to (auto)complete whenever I type .. However when I use the following minimal vimrc:
set nocompatible
let $DOTVIM = expand('$HOME/.vim')
set runtimepath+=$DOTVIM/bundle/repos/github.com/Shougo/deoplete.nvim
set runtimepath+=$DOTVIM/bundle/repos/github.com/jalvesaq/Nvim-R
filetype plugin indent on
let g:deoplete#enable_at_startup = 1
call deoplete#custom#var('omni', 'input_patterns', {
\ 'r': '[^. *\t]\.\w*',
\ }
\)
and in a empty foo.R file type data. the cursor jumps back just period the period. This can be seen in the following GIF:

On the other hand I remove/comment the input_patterns lines and type C-X C-O after data. then the manual omnicompletion works just fine:

Also how can I modify the regex to also autocomplete immediately after the following symbols ::, $?
I think nvim-r plugin does not support omni source.
You should use deoplete#custom#option() instead.
call deoplete#custom#option('omni_patterns', {
\ 'r': '[^. *\t]\.\w*',
\})
Thanks @Shougo. Indeed adding the following seems to work:
\ 'omni_patterns': {
\ 'r': ['[^. *\t]\.\w*', '\h\w*::\w*', '\h\w*\$\w*'],
\},
@jalvesaq @gaalcaras any chance of improving nvim-r/deoplete interaction?
Most helpful comment
Thanks @Shougo. Indeed adding the following seems to work:
@jalvesaq @gaalcaras any chance of improving nvim-r/deoplete interaction?