R-nvim / R.nvim

Neovim plugin to edit R files
GNU General Public License v3.0
147 stars 15 forks source link

omnifunc not set #202

Closed manumart closed 1 month ago

manumart commented 1 month ago

When trying to omnicomplete (Ctrl+X+O) I systematically get a 'omnifunc' not set. I tried to debug but as I do not understand well how R.Nvim, cmp and omnifunc interact this is difficult for me. Could anyone help me? I run NVIM 0.10.1 on Ubuntu 24.04. Please find attached my init.vim and conf.lua (called from the init.vim) in case it helps.

Cheers, Manuel

init.vim :

call plug#begin()

Plug 'hrsh7th/nvim-cmp'

 Plug 'SirVer/ultisnips'
" Plug 'honza/vim-snippets'
 Plug 'scrooloose/nerdTree'
"
"
Plug 'neovim/nvim-lspconfig'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
Plug 'hrsh7th/cmp-cmdline'
Plug 'hrsh7th/cmp-omni'
Plug 'hrsh7th/nvim-cmp'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
" Plug 'preservim/vim-pencil'
"
Plug 'jalvesaq/cmp-zotcite'
Plug 'jalvesaq/zotcite'

Plug 'R-nvim/cmp-r'
Plug 'R-nvim/R.nvim'
" Plug 'jalvesaq/Nvim-R'
" Plug 'mipmip/vim-scimark'
" " If you have nodejs and yarn
" " Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': 'markdown' }
" "
Plug 'simnalamburt/vim-mundo'
" Plug 'jpalardy/vim-slime'
" Plug 'bling/vim-airline'
" Plug 'vim-airline/vim-airline-themes'
" Plug 'ayu-theme/ayu-vim' 
Plug 'morhetz/gruvbox'
Plug 'kyazdani42/nvim-devicons'
" Plug 'lukas-reineke/indent-blankline.nvim'
"
" " dev
Plug 'kdheepak/lazygit.nvim'
"
" " for Neuron
" " Plug 'nvim-lua/popup.nvim'
" " Plug 'sharkdp/fd'
" Plug 'Shatur/neovim-session-manager'
" Plug 'nvim-lua/plenary.nvim'

" telescope
Plug 'nvim-lua/plenary.nvim'
Plug 'sharkdp/fd'
Plug 'nvim-telescope/telescope.nvim'
Plug 'nvim-telescope/telescope-live-grep-args.nvim'
Plug 'terrortylor/nvim-comment'
Plug 'numToStr/Comment.nvim'
"
" " instead of pandoc
" Plug 'godlygeek/tabular'
" """ tempo remove
" " Plug 'plasticboy/vim-markdown'
" """
" " Pandoc
" " Plug 'vim-pandoc/vim-pandoc'
" " Plug 'vim-pandoc/vim-pandoc-syntax'
" "
" " do not distract me
Plug 'junegunn/goyo.vim'
"
" " should be at the end Keep or remove?
" Plug 'ryanoasis/vim-devicons'
"
"
" " Plug 'neovim/nvim-lspconfig'
" " Plug 'hrsh7th/cmp-nvim-lsp'
" Plug 'hrsh7th/cmp-buffer'
" Plug 'hrsh7th/cmp-path'
" Plug 'hrsh7th/cmp-cmdline'
"
" " For ultisnips users.
" Plug 'SirVer/ultisnips'
" Plug 'quangnguyen30192/cmp-nvim-ultisnips'

" buffer management
Plug 'dzfrias/arena.nvim'

call plug#end()

source /home/manuel/.config/nvim/conf.lua

" Somewhere after plug#end()

"  telescope """""""""""""""""""""""""""""""""""
"  Using Lua functions

let mapleader = ";"
" nnoremap <leader>ff <cmd>lua require('telescope.builtin').find_files()<cr>
" nnoremap <leader>fg <cmd>lua require('telescope.builtin').live_grep({type_filter='r'})<cr>
" nnoremap <leader>fg <cmd>lua require('telescope.builtin').live_grep({type_filter='r'})<cr>
" nnoremap <leader>fb <cmd>lua require('telescope.builtin').buffers()<cr>
" nnoremap <leader>fh <cmd>lua require('telescope.builtin').help_tags()<cr>

"  Find files using Telescope command-line sugar.
nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
nnoremap <leader>fG <cmd>Telescope grep_string search=<C-R><C-W><CR>
vnoremap <leader>qq "zy:Telescope grep_string default_text=<C-r>z<cr>

" telescope """""""""""""""""""""""""""""""""""
" Using Lua functions

let mapleader = ";"
"nnoremap <leader>ff <cmd>lua require('telescope.builtin').find_files()<cr>
"nnoremap <leader>fg <cmd>lua require('telescope.builtin').live_grep({type_filter='r'})<cr>
"nnoremap <leader>fg <cmd>lua require('telescope.builtin').live_grep({type_filter='r'})<cr>
"nnoremap <leader>fb <cmd>lua require('telescope.builtin').buffers()<cr>
"nnoremap <leader>fh <cmd>lua require('telescope.builtin').help_tags()<cr>

" Find files using Telescope command-line sugar.
nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
nnoremap <leader>fG <cmd>Telescope grep_string search=<C-R><C-W><CR>
vnoremap <leader>qq "zy:Telescope grep_string default_text=<C-r>z<cr>
"lua <<EOF
"require('telescope').setup{
"  defaults = {
"    vimgrep_arguments = {
"      'rg',
"      '-Thtml'    },
"}
"}
"EOF
""""""""""""""""""""""""""""""""""""""""""""""""""
"""" vim-devicons """""
let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols = {} " needed
let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['r'] = '󰰠'

set clipboard+=unnamedplus

filetype plugin indent on
filetype plugin on " load filetype plugins
"syntax on

set timeoutlen=1000 ttimeoutlen=0

set foldmethod=marker 

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Files/Backups
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set undodir=~/tmp/vimtmp
set backupdir=~/tmp/vimtmp
set directory=~/tmp/vimtmp
set undofile
set backup " make backup file
set bk
set makeef=error.err " When using make, where should it dump the file

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vim UI
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"set lsp=0 " space it out a little more (easier to read)
set number " turn on line numbers
set mouse=a " use mouse everywhere
set shortmess=atI " shortens messages to avoid 'press a key' prompt 
set noerrorbells " don't make noise

"" snippets
let g:UltiSnipsExpandTrigger="<Tab>"
let g:UltiSnipsSnippetsDir='/home/manuel/.config/nvim/mySnippets'

" colors
autocmd vimenter * colorscheme gruvbox 
set background=dark

"let R_args = ['--quiet', '--no-save', '-d', 'gdb']
"let R_args = ['--quiet', '--no-save', '--debugger=valgrind']

""Pandoc to use vim-pandoc-syntax without the vim-pandoc

" in order to avoid concealing math equations
set conceallevel=0

" NerdTree
nmap <C-n> :NERDTreeToggle<CR>

" Gundo
"nnoremap <F6> :GundoToggle<CR>
nnoremap <F5> :MundoToggle<CR>

" airline
"
let g:airline#extensions#tabline#enabled = 2
let g:airline#extensions#tabline#fnamemod = ':t'
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
let g:airline#extensions#tabline#right_sep = ' '
let g:airline#extensions#tabline#right_alt_sep = '|'
let g:airline#extensions#tabline#buffer_nr_show = 1
let g:airline_left_sep = ' '
let g:airline_left_alt_sep = '|'
let g:airline_right_sep = ' '
let g:airline_right_alt_sep = '|'
set t_Co=256
"let g:airline_theme= 'solarized'
let g:airline_theme= 'sol'
let g:airline_solarized_bg='light'
let g:airline_powerline_fonts = 1

"" VIM SLIME : to send selections to antoher tmux (or other) pane 
let g:slime_target = "tmux"

" ag similar to ack but faster
let g:ackprg = 'ag --vimgrep'

" old nvim-r

imap <F2> <Esc>:call SendSelectionToR("echo", "stay")<CR>0
vmap <F2> <Esc>:call SendSelectionToR("echo", "stay")<CR>0

""""" 0 means R console in another terminal  """"
let R_external_term = 0 
" let R_external_term = 'gnome-terminal'
let R_applescript = 0
let maplocalleader = ","
let R_assign_map = '<M-_>'
let R_debug = 0

conf.lua :

-- nvim CMP --------------------
--
--
--
--
--
local cmp = require'cmp'

require'cmp'.setup {
  sources = {
    {
      name = 'omni',
      option = {
        disable_omnifuncs = { 'v:lua.vim.lsp.omnifunc' }
      }
    }
  }
}

-- Global setup.
cmp.setup({
  snippet = {
    expand = function(args)
      vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
      -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
      -- require'snippy'.expand_snippet(args.body) -- For `snippy` users.
      -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
      -- vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+)
    end,
  },
  window = {
    -- completion = cmp.config.window.bordered(),
    -- documentation = cmp.config.window.bordered(),
  },
  mapping = cmp.mapping.preset.insert({
    ['<C-d>'] = cmp.mapping.scroll_docs(-4),
    ['<C-f>'] = cmp.mapping.scroll_docs(4),
    ['<C-Space>'] = cmp.mapping.complete(),
    ['<CR>'] = cmp.mapping.confirm({ select = true }),
  }),
  sources = cmp.config.sources({
    { name = 'nvim_lsp' },
    { name = 'vsnip' }, -- For vsnip users.
    { name = 'cmp_zotcite' },
    { name = 'cmp_r' },
    -- { name = 'luasnip' }, -- For luasnip users.
    -- { name = 'snippy' }, -- For snippy users.
    -- { name = 'ultisnips' }, -- For ultisnips users.
  }, {
    { name = 'buffer' },
  })
})

-- `/` cmdline setup.
cmp.setup.cmdline('/', {
  mapping = cmp.mapping.preset.cmdline(),
  sources = {
    { name = 'buffer' }
  }
})

-- `:` cmdline setup.
cmp.setup.cmdline(':', {
  mapping = cmp.mapping.preset.cmdline(),
  sources = cmp.config.sources({
    { name = 'path' }
  }, {
    { name = 'cmdline' }
  }),
  matching = { disallow_symbol_nonprefix_matching = false }
})

-- Setup lspconfig.
local capabilities = require('cmp_nvim_lsp').default_capabilities()

-- Setup lspconfig.
-- from CHAT local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities())
local lspconfig = require('lspconfig')

-- Configure multiple LSP servers
local servers = { 'pyright', 'tsserver', 'gopls', 'rust_analyzer', 'clangd' }

for _, lsp in ipairs(servers) do
  lspconfig[lsp].setup {
    capabilities = capabilities,
  }
end
--
--
--
--
--
--
--
--
--

-- R-nvim
--
-- 

--  Session
--  nb : adapted from https://github.com/Shatur/neovim-session-manager#configuration

local config_group = vim.api.nvim_create_augroup('MyConfigGroup', {}) -- A global group for all your config autocommands

vim.api.nvim_create_autocmd({ 'User' }, {
  pattern = "SessionLoadPost",
  group = config_group,
  callback = function()
    vim.cmd("NERDTree")
  end,
})

-- 
-- 
require('Comment').setup()

-- zotcite
require("zotcite").setup({
    -- your options here (see doc/zotcite.txt)
})

require("nvim-treesitter.configs").setup({
                sync_install = true,
                ensure_installed = {
                    "html",
                    "latex",
                    "markdown",
                    "markdown_inline",
                    "yaml",
            "r", 
            "rnoweb"
                },
                highlight = {
                    enable = true,
                },
                indent = {
                    enable = true,
                },
            })

local opts = {
    R_args = {"--quiet", "--no-save"},
    min_editor_width = 72,
    rconsole_width = 78,
    disable_cmds = {
            "RClearConsole",
            "RCustomStart",
            "RSPlot",
            "RSaveClose",
        },
    }
    -- Check if the environment variable "R_AUTO_START" exists.
    -- If using fish shell, you could put in your config.fish:
    -- alias r "R_AUTO_START=true nvim"
    if vim.env.R_AUTO_START == "true" then
        opts.auto_start = 1
        opts.objbr_auto_start = true
    end
require("r").setup(opts)

-- arena buffer mgnt
-- require("arena").setup()
manumart commented 1 month ago

Edit : indeed completion is working, but in an automatic way : it pops up while I type. But Ctrl+X+O is not working. Is this what is expected?

Cheers, Manuel

jalvesaq commented 1 month ago

Yes. It's in the README. We no longer support omni completion.

manumart commented 1 month ago

Indeed yes it is. Thanks a lot for the hint.