Repository: hrsh7th/cmp-nvim-lua
Branch: main
Commit: e3a22cb071eb
Files: 4
Total size: 3.7 KB
Directory structure:
gitextract_csdc37fq/
├── LICENSE
├── README.md
├── after/
│ └── plugin/
│ └── cmp_nvim_lua.lua
└── lua/
└── cmp_nvim_lua/
└── init.lua
================================================
FILE CONTENTS
================================================
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2025 hrsh7th
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# cmp-nvim-lua
nvim-cmp source for neovim Lua API.
# Setup
```lua
require'cmp'.setup {
sources = {
{ name = 'nvim_lua' }
}
}
```
# Options
### `include_deprecated` (boolean: default false)
Specify should includes deprecated things or not.
# What is this source?
This source will complete neovim's Lua runtime API such `vim.lsp.*`.
You can get the `vim.lsp.util.*` API with this source.
================================================
FILE: after/plugin/cmp_nvim_lua.lua
================================================
require'cmp'.register_source('nvim_lua', require'cmp_nvim_lua'.new())
================================================
FILE: lua/cmp_nvim_lua/init.lua
================================================
local cmp = require('cmp')
local source = {}
source.new = function()
local self = setmetatable({}, { __index = source })
self.regex = vim.regex([[\%(\.\|\w\)\+\ze\.\w*$]])
return self
end
source.is_available = function()
return vim.bo.filetype == 'lua' or vim.bo.filetype == 'vim'
end
source.get_keyword_pattern = function()
return [[\w\+]]
end
source.get_trigger_characters = function()
return { '.' }
end
source.complete = function(self, request, callback)
local s, e = self.regex:match_str(request.context.cursor_before_line)
if not s then
return callback()
end
local items = self:items(string.sub(request.context.cursor_before_line, s + 1, e))
if not request.option.include_deprecated then
items = vim.tbl_filter(function(item)
return not item.label:match('^_')
end, items)
end
callback({
items = items,
})
end
source.items = function(self, path)
local target = _G
local target_keys = vim.tbl_keys(_G)
for _, name in ipairs(vim.split(path, '.', true)) do
if vim.tbl_contains(target_keys, name) and type(target[name]) == 'table' then
target = target[name]
target_keys = vim.tbl_keys(target)
elseif name ~= '' then
return {}
end
end
local candidates = {}
for _, key in ipairs(target_keys) do
if string.match(key, '^%a[%a_]*$') then
table.insert(candidates, self:item(key, target[key]))
end
end
for _, key in ipairs(target_keys) do
if not string.match(key, '^%a[%a_]*$') then
table.insert(candidates, self:item(key, target[key]))
end
end
return candidates
end
source.item = function(_, key, value)
key = tostring(key)
local kind = cmp.lsp.CompletionItemKind.Field
local t = type(value)
if t == 'function' then
kind = cmp.lsp.CompletionItemKind.Function
elseif t == 'table' then
kind = cmp.lsp.CompletionItemKind.Struct
elseif t == 'string' then
kind = cmp.lsp.CompletionItemKind.Value
elseif t == 'boolean' then
kind = cmp.lsp.CompletionItemKind.Value
elseif t == 'number' then
kind = cmp.lsp.CompletionItemKind.Value
elseif t == 'nil' then
kind = cmp.lsp.CompletionItemKind.Value
end
return {
label = key,
kind = kind,
detail = t,
}
end
return source
gitextract_csdc37fq/
├── LICENSE
├── README.md
├── after/
│ └── plugin/
│ └── cmp_nvim_lua.lua
└── lua/
└── cmp_nvim_lua/
└── init.lua
Condensed preview — 4 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (4K chars).
[
{
"path": "LICENSE",
"chars": 1064,
"preview": "MIT License\n\nCopyright (c) 2025 hrsh7th\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof"
},
{
"path": "README.md",
"chars": 404,
"preview": "# cmp-nvim-lua\n\nnvim-cmp source for neovim Lua API.\n\n# Setup\n\n```lua\nrequire'cmp'.setup {\n sources = {\n { name = 'nv"
},
{
"path": "after/plugin/cmp_nvim_lua.lua",
"chars": 70,
"preview": "require'cmp'.register_source('nvim_lua', require'cmp_nvim_lua'.new())\n"
},
{
"path": "lua/cmp_nvim_lua/init.lua",
"chars": 2253,
"preview": "local cmp = require('cmp')\n\nlocal source = {}\n\nsource.new = function()\n local self = setmetatable({}, { __index = sourc"
}
]
About this extraction
This page contains the full source code of the hrsh7th/cmp-nvim-lua GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 4 files (3.7 KB), approximately 1.1k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.