{"id":13942159,"url":"https://github.com/jalvesaq/cmp-nvim-r","last_synced_at":"2025-07-20T05:32:17.143Z","repository":{"id":145186229,"uuid":"570626893","full_name":"jalvesaq/cmp-nvim-r","owner":"jalvesaq","description":null,"archived":false,"fork":false,"pushed_at":"2024-02-18T14:44:00.000Z","size":34,"stargazers_count":18,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-27T11:38:58.011Z","etag":null,"topics":["nvim-cmp","r"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jalvesaq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-25T16:50:24.000Z","updated_at":"2024-04-22T03:22:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"dd02207c-f181-4bec-9bb0-26737c2db23a","html_url":"https://github.com/jalvesaq/cmp-nvim-r","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jalvesaq/cmp-nvim-r","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jalvesaq%2Fcmp-nvim-r","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jalvesaq%2Fcmp-nvim-r/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jalvesaq%2Fcmp-nvim-r/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jalvesaq%2Fcmp-nvim-r/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jalvesaq","download_url":"https://codeload.github.com/jalvesaq/cmp-nvim-r/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jalvesaq%2Fcmp-nvim-r/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266071519,"owners_count":23871940,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nvim-cmp","r"],"created_at":"2024-08-08T02:01:43.689Z","updated_at":"2025-07-20T05:32:12.105Z","avatar_url":"https://github.com/jalvesaq.png","language":"Lua","funding_links":[],"categories":["Lua"],"sub_categories":[],"readme":"# cmp-nvim-r\n\nCompletion source for [nvim-cmp](https://github.com/hrsh7th/nvim-cmp) using [Nvim-R](https://github.com/jalvesaq/Nvim-R) as backend.\n\n## Installation\n\nUse a plugin manager such as [vim-plug](https://github.com/junegunn/vim-plug)\nor [packer](https://github.com/wbthomason/packer.nvim).\n\n## Setup\n\nRegister the source for `nvim-cmp`:\n\n```lua\nrequire'cmp'.setup {\n  sources = {\n    { name = 'cmp_nvim_r' },\n  }\n}\n```\n\n## Configuration\n\n### cmp-nvim-r\n\n`cmp-nvim-r` has the following options:\n\n  - `filetypes`: The list of file types for which the source should be enabled.\n    Default: `{'r', 'rmd', 'quarto', 'rnoweb', 'rhelp'}`\n\n\n  - `doc_width`: The expected maximum width of the floating documentation\n    window. This value is used to format the usage section of function\n    documentation. Arguments are concatenated, but line breaks are inserted\n    between arguments before the line reaches the number of columns defined by\n    `doc_width`. Default: `58`.\n\n    See also the option `maxwidth` in [lspkind.nvim](https://github.com/onsails/lspkind.nvim).\n\n  - `fun_data_1`: List of functions that receive a `data.frame` as its first\n    argument and for which the `data.frame`s columns names should be\n    completed. This option is overridden by `g:R_fun_data_1`. Default:\n    `{'select', 'rename', 'mutate', 'filter'}`.\n\n  - `fun_data_2`: Dictionary with parent functions as keys. The value of each\n    key is a list of functions that are expected to be nested in the parent\n    function which receives a data.frame as its first arguments. Column names\n    of the `data.frame` are completed as arguments of the nested function.\n    This option is overridden by `g:R_fun_data_1`. Default:\n    `{ggplot = {'aes'}, with = {'*'}}`.\n\n  - `quarto_intel`: Path to `yaml-intelligence-resources.json` which is part\n    of `quarto` application and has all necessary information for completion\n    of valid YAML options in an Quarto document.  This option is overridden by\n    `g:R_quarto_intel`. Default: `nil` (`cmp-nvim-r` will try to find the file).\n\nBelow is an example of how to set theses options:\n\n```lua\nrequire(\"cmp_nvim_r\").setup({\n  filetypes = {\"r\", \"rmd\", \"quarto\"},\n  doc_width = 58\n  quarto_intel = \"~/Downloads/quarto-1.1.251/share/editor/tools/yaml/yaml-intelligence-resources.json\"\n  })\n```\n\n### nvim-cmp\n\nThe source `cmp_nvim_r` does not require any special configuration of\n`nvim-cmp` to work, and people have different preferences and workflows.\nAnyway, I share below what worked best for me:\n\n  - `cmp-nvim-r` sets the field `sortText` of completed items as \"0\" for\n    function arguments and \"9\" for everything else. This means that function\n    arguments will always be at the top of the list of suggestions if you put\n    `cmp.config.compare.sort_text` at the top of list of compare `nvim-cmp`\n    functions.\n\n  - Install a Nerd font and install and configure your terminal emulator to\n    use it. Then install [lspkind.nvim](https://github.com/onsails/lspkind.nvim)\n    to have symbols representing the kind of object whose name is being completed.\n\n  - The names of kind of objects are generic names of the LSP server protocol\n    and do not match the classes of R objects. So, it is better to hide the\n    names and display only the symbols.\n\nAn example following the above suggestions:\n\n```lua\ncmp.setup({\n    formatting = {\n        fields = {'abbr', 'kind', 'menu'},\n        format = lspkind.cmp_format({\n            mode = 'symbol', -- show only symbol annotations\n            maxwidth = 50, -- prevent the popup from showing more than provided characters\n            ellipsis_char = '...', -- the truncated part when popup menu exceed maxwidth\n            before = function(entry, item)\n                local menu_icon = {\n                    nvim_lsp = '',\n                    vsnip = '',\n                    path = '',\n                    cmp_zotcite = 'z',\n                    cmp_nvim_r = 'R'\n                }\n                item.menu = menu_icon[entry.source.name]\n                return item\n            end,\n        })\n    },\n    sources = cmp.config.sources({\n        { name = 'vsnip' },\n        { name = 'cmp_zotcite' },\n        { name = 'cmp_nvim_r' },\n        { name = 'nvim_lsp' },\n        { name = 'path', option = { trailing_slash = true } },\n    }),\n})\n```\n### languageserver\n\nSince `cmp-nvim-r` and the R package `languageserver` provide completions for\nthe same code, and completions from the `languageserver` might be the first\nones to be displayed by `nvim-cmp`, you may want to put this in your `~/.Rprofile`:\n\n```r\n# Disable completion from the language server\noptions(languageserver.server_capabilities =\n        list(completionProvider = FALSE, completionItemResolve = FALSE))\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjalvesaq%2Fcmp-nvim-r","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjalvesaq%2Fcmp-nvim-r","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjalvesaq%2Fcmp-nvim-r/lists"}