[
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2025 hrsh7th\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# cmp-nvim-lua\n\nnvim-cmp source for neovim Lua API.\n\n# Setup\n\n```lua\nrequire'cmp'.setup {\n  sources = {\n    { name = 'nvim_lua' }\n  }\n}\n```\n\n# Options\n\n### `include_deprecated` (boolean: default false)\n\nSpecify should includes deprecated things or not.\n\n\n# What is this source?\n\nThis source will complete neovim's Lua runtime API such `vim.lsp.*`.\n\nYou can get the `vim.lsp.util.*` API with this source.\n"
  },
  {
    "path": "after/plugin/cmp_nvim_lua.lua",
    "content": "require'cmp'.register_source('nvim_lua', require'cmp_nvim_lua'.new())\n"
  },
  {
    "path": "lua/cmp_nvim_lua/init.lua",
    "content": "local cmp = require('cmp')\n\nlocal source = {}\n\nsource.new = function()\n  local self = setmetatable({}, { __index = source })\n  self.regex = vim.regex([[\\%(\\.\\|\\w\\)\\+\\ze\\.\\w*$]])\n  return self\nend\n\nsource.is_available = function()\n  return vim.bo.filetype == 'lua' or vim.bo.filetype == 'vim'\nend\n\nsource.get_keyword_pattern = function()\n  return [[\\w\\+]]\nend\n\nsource.get_trigger_characters = function()\n  return { '.' }\nend\n\nsource.complete = function(self, request, callback)\n  local s, e = self.regex:match_str(request.context.cursor_before_line)\n  if not s then\n    return callback()\n  end\n  local items = self:items(string.sub(request.context.cursor_before_line, s + 1, e))\n  if not request.option.include_deprecated then\n    items = vim.tbl_filter(function(item)\n      return not item.label:match('^_')\n    end, items)\n  end\n  callback({\n    items = items,\n  })\nend\n\nsource.items = function(self, path)\n  local target = _G\n  local target_keys = vim.tbl_keys(_G)\n  for _, name in ipairs(vim.split(path, '.', true)) do\n    if vim.tbl_contains(target_keys, name) and type(target[name]) == 'table' then\n      target = target[name]\n      target_keys = vim.tbl_keys(target)\n    elseif name ~= '' then\n      return {}\n    end\n  end\n\n  local candidates = {}\n  for _, key in ipairs(target_keys) do\n    if string.match(key, '^%a[%a_]*$') then\n      table.insert(candidates, self:item(key, target[key]))\n    end\n  end\n  for _, key in ipairs(target_keys) do\n    if not string.match(key, '^%a[%a_]*$') then\n      table.insert(candidates, self:item(key, target[key]))\n    end\n  end\n\n  return candidates\nend\n\nsource.item = function(_, key, value)\n  key = tostring(key)\n\n  local kind = cmp.lsp.CompletionItemKind.Field\n  local t = type(value)\n  if t == 'function' then\n    kind = cmp.lsp.CompletionItemKind.Function\n  elseif t == 'table' then\n    kind = cmp.lsp.CompletionItemKind.Struct\n  elseif t == 'string' then\n    kind = cmp.lsp.CompletionItemKind.Value\n  elseif t == 'boolean' then\n    kind = cmp.lsp.CompletionItemKind.Value\n  elseif t == 'number' then\n    kind = cmp.lsp.CompletionItemKind.Value\n  elseif t == 'nil' then\n    kind = cmp.lsp.CompletionItemKind.Value\n  end\n  return {\n    label = key,\n    kind = kind,\n    detail = t,\n  }\nend\n\nreturn source\n"
  }
]