{"id":13682378,"url":"https://github.com/tzachar/cmp-fuzzy-buffer","last_synced_at":"2026-02-04T14:23:03.252Z","repository":{"id":63606038,"uuid":"422587449","full_name":"tzachar/cmp-fuzzy-buffer","owner":"tzachar","description":null,"archived":false,"fork":false,"pushed_at":"2023-04-02T10:30:56.000Z","size":31,"stargazers_count":85,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-08-02T13:34:03.149Z","etag":null,"topics":["neovim","nvim-cmp"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tzachar.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}},"created_at":"2021-10-29T13:33:49.000Z","updated_at":"2024-07-23T16:57:34.000Z","dependencies_parsed_at":"2024-01-14T15:23:16.356Z","dependency_job_id":"3d3e8fe2-42b8-45a9-8264-3dcf5bbea97c","html_url":"https://github.com/tzachar/cmp-fuzzy-buffer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tzachar%2Fcmp-fuzzy-buffer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tzachar%2Fcmp-fuzzy-buffer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tzachar%2Fcmp-fuzzy-buffer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tzachar%2Fcmp-fuzzy-buffer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tzachar","download_url":"https://codeload.github.com/tzachar/cmp-fuzzy-buffer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224206038,"owners_count":17273378,"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":["neovim","nvim-cmp"],"created_at":"2024-08-02T13:01:45.109Z","updated_at":"2026-02-04T14:23:03.200Z","avatar_url":"https://github.com/tzachar.png","language":"Lua","readme":"# cmp-fuzzy-buffer\n\n`nvim-cmp` source for fuzzy matched items from using the current buffer.\nCan use either `fzf` or `fzy`.\n\n# Installation\n\nDepends on [fuzzy.nvim](https://github.com/tzachar/fuzzy.nvim) (which depends\neither on `fzf` or on `fzy`).\n\nUsing [Packer](https://github.com/wbthomason/packer.nvim/) with `fzf`:\n```lua\nuse {'nvim-telescope/telescope-fzf-native.nvim', run = 'make'}\nuse \"hrsh7th/nvim-cmp\"\nuse {'tzachar/cmp-fuzzy-buffer', requires = {'hrsh7th/nvim-cmp', 'tzachar/fuzzy.nvim'}}\n```\n\nUsing [Packer](https://github.com/wbthomason/packer.nvim/) with `fzy`:\n```lua\nuse {'romgrk/fzy-lua-native', run = 'make'}\nuse \"hrsh7th/nvim-cmp\"\nuse {'tzachar/cmp-fuzzy-buffer', requires = {'hrsh7th/nvim-cmp', 'tzachar/fuzzy.nvim'}}\n```\n\n# Setup\n\n```lua\nrequire'cmp'.setup {\n  sources = cmp.config.sources({\n    { name = 'fuzzy_buffer' },\n  })\n}\n```\n\nThis plugin can also be used to perform `/` searches with cmdline mode of cmp:\n```lua\ncmp.setup.cmdline('/', {\n  sources = cmp.config.sources({\n    { name = 'fuzzy_buffer' }\n  })\n})\n```\n\nIn `/` search mode, the plugin will match the input string as is, without\nparsing out tokens. This enables fuzzy search containing, for example, spaces.\n\n\n*Note:* the plugin's name is `fuzzy_buffer` in `cmp`'s config.\n\n\n# Sorting and Filtering\n\nBy default, `nvim-cmp` will filter out sequences which we matched. To prevent\nthis, we use the searched-for pattern as an input for `filterText`, such that\nall matched strings will be returned. However, this causes `nvim-cmp` to badly\nsort our returned results. To solve this issue, and sort `cmp-fuzzy-path`\nresults by the score returned by the fuzzy matcher, you can use the following:\n\n```lua\nlocal compare = require('cmp.config.compare')\n\ncmp.setup {\n\tsorting = {\n\t\tpriority_weight = 2,\n\t\tcomparators = {\n\t\t\trequire('cmp_fuzzy_buffer.compare'),\n\t\t\tcompare.offset,\n\t\t\tcompare.exact,\n\t\t\tcompare.score,\n\t\t\tcompare.recently_used,\n\t\t\tcompare.kind,\n\t\t\tcompare.sort_text,\n\t\t\tcompare.length,\n\t\t\tcompare.order,\n\t\t}\n\t},\n}\n```\n\n# Configuration\n\n\n## keyword_pattern (type: string)\n\n_Default:_ `[[\\%(-\\?\\d\\+\\%(\\.\\d\\+\\)\\?\\|\\h\\w*\\%([\\-.]\\w*\\)*\\)]]`\n_ cmdline Default:_ `[=[[^[:blank:]].*]=]`\n\nA vim's regular expression for detecting the pattern to search with (starting\nfrom where the cursor currently is)\n\n## indentifier_patter (type: vim regex)\n_Default:_\n```lua\nindentifier_patter = [=[[[:keyword:]]]=]\n```\n\nUsed to find the best matched identifier to return based on the fuzzy patter and\nmatch results.\n\n## non_indentifier_patter (type: vim regex)\n_Default:_\n```lua\nnon_indentifier_patter = [=[[^[:keyword:]]]=],\n```\n\nUsed to find the best matched identifier to return based on the fuzzy patter and\nmatch results.\n\n## max_buffer_lines (type: int)\n\nThe plugin will not work in buffers with more than `max_buffer_lines` lines for\nperformance reasons.\n\n_Default:_ 20000\n\n## max_match_length (type: int)\n\nDo not show matches longer than `max_match_length`.\n\n_Default:_ 50\n\n## min_match_length (type: int)\n\nDo not show matches shorter than `min_match_length`.\n\n_Default:_ 1\n\n## fuzzy_extra_arg\n\nThis has different meaning depending on the fuzzy matching library used.\nFor `fzf`, this is the `case_mode` argument: 0 = smart_case, 1 = ignore_case, 2 = respect_case.\nFor `fzy`, this is the `is_case_sensitive` argument. Set to `false` to do case insensitive matching.\n\n_Default:_ 0\n\n## get_bufnrs (type: function)\n\nReturn a list of buffer numbers from which to get lines.\n\n_Default_: \n```lua\nget_bufnrs = function()\n  return { vim.api.nvim_get_current_buf() }\nend\n```\n\nIf you want to use all loaded buffer, you can use the following setup:\n\n```lua\nrequire'cmp'.setup {\n  sources = cmp.config.sources({\n    { \n       name = 'fuzzy_buffer' ,\n       option = {\n          get_bufnrs = function()  \n          local bufs = {}\n          for _, buf in ipairs(vim.api.nvim_list_bufs()) do\n            local buftype = vim.api.nvim_buf_get_option(buf, 'buftype')\n            if buftype ~= 'nofile' and buftype ~= 'prompt' then\n              bufs[#bufs + 1] = buf\n            end\n          end\n          return bufs\n          end\n       },\n    },\n  })\n}\n```\n\n## max_matches (type: int)\n\nMaximal number of matches to returl.\n\n_Default:_ 15\n","funding_links":[],"categories":["Lua"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftzachar%2Fcmp-fuzzy-buffer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftzachar%2Fcmp-fuzzy-buffer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftzachar%2Fcmp-fuzzy-buffer/lists"}