R-nvim / cmp-r

Completion source for nvim-cmp using R.nvim as backend.
GNU General Public License v3.0
17 stars 1 forks source link

Completions are not given for objects within browser() environments #10

Open conig opened 5 hours ago

conig commented 5 hours ago

Thanks for your time on R.nvim and cmp-r. I'm really enjoing both.

I have found that completions do not work for objects within browser().

Example code:

df <- data.frame(x = 1, y = 2)
# completions work outside of browser
df

start_browser <- function(){
 browser()
}

start_browser()
# completions do not work inside browser
df2 <- data.frame(x = 1, y = 2)
df2

Video demonstration:

https://github.com/user-attachments/assets/5c4161aa-d93a-4b6f-abbd-4112239b2edf

I'm using the example setup.

cmp.setup({
    formatting = {
        fields = {'abbr', 'kind', 'menu'},
        format = lspkind.cmp_format({
            mode = 'symbol', -- show only symbol annotations
            maxwidth = 50, -- prevent the popup from showing more than provided characters
            ellipsis_char = '...', -- the truncated part when popup menu exceed maxwidth
            before = function(entry, item)
                local menu_icon = {
                    nvim_lsp = '',
                    vsnip = '',
                    path = '',
                    cmp_zotcite = 'z',
                    cmp_r = 'R'
                }
                item.menu = menu_icon[entry.source.name]
                return item
            end,
        })
    },
    sources = cmp.config.sources({
        { name = 'vsnip' },
        { name = 'cmp_zotcite' },
        { name = 'cmp_r' },
        { name = 'nvim_lsp' },
        { name = 'path', option = { trailing_slash = true } },
    }),
})
jalvesaq commented 5 hours ago

Thanks for reporting! I could never find a way to get the list of objects from the current browsing environment in C. This limitation affects both the Object Browser and auto-completion. I will add this issue to the known bugs section.