{"id":16227649,"url":"https://github.com/leafoftree/vim-imagine","last_synced_at":"2025-06-15T01:32:15.527Z","repository":{"id":98920346,"uuid":"105113109","full_name":"leafOfTree/vim-imagine","owner":"leafOfTree","description":"A simple context-based vim completion plugin.","archived":false,"fork":false,"pushed_at":"2024-09-12T03:09:56.000Z","size":59,"stargazers_count":3,"open_issues_count":4,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-03T02:51:15.349Z","etag":null,"topics":["complete","completion","plugin","vim"],"latest_commit_sha":null,"homepage":"","language":"Vim Script","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/leafOfTree.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":"2017-09-28T06:57:17.000Z","updated_at":"2024-09-12T03:09:59.000Z","dependencies_parsed_at":"2024-09-12T12:29:32.157Z","dependency_job_id":"db326c43-d1e7-409b-b272-b6ba863d1c04","html_url":"https://github.com/leafOfTree/vim-imagine","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/leafOfTree/vim-imagine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafOfTree%2Fvim-imagine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafOfTree%2Fvim-imagine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafOfTree%2Fvim-imagine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafOfTree%2Fvim-imagine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leafOfTree","download_url":"https://codeload.github.com/leafOfTree/vim-imagine/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafOfTree%2Fvim-imagine/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259908627,"owners_count":22930445,"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":["complete","completion","plugin","vim"],"created_at":"2024-10-10T12:53:24.754Z","updated_at":"2025-06-15T01:32:15.500Z","avatar_url":"https://github.com/leafOfTree.png","language":"Vim Script","readme":"# vim-imagine\n\nA simple context-based vim completion plugin. It wil try to return the most possible word based on current context. Choosing a word from the menu should be avoided.\n\n**Supports**\n\n- Literial \u003ckbd\u003etab\u003c/kbd\u003e.\n- [Custom snippets](#custom_snippets).\n- [Extensible fuzzy match](#fuzzy_match).\n- [emmet-vim][0].\n- [supertab][1].\n\n## Usage\n\nIn INSERT mode, press \u003ckbd\u003etab\u003c/kbd\u003e to complete the word. Press \u003ckbd\u003ec-u\u003c/kbd\u003e to undo the completion.\n\n## Install\n\n- Use [VundleVim](https://github.com/VundleVim/Vundle.vim): \n\n        Plugin 'leafOfTree/vim-imagine'\n\n- Or manually, clone this plugin, drop it in custom `path/to/this_plugin`, and add it to `rtp` in vimrc\n\n        set rpt+=path/to/this_plugin\n\n## How it works\n\nIt tries these methods in order to find out the completion word.\n\n- Literial \u003ckbd\u003etab\u003c/kbd\u003e.\n- [Custom snippets](#custom_snippets).\n- [Extensible fuzzy match](#fuzzy_match).\n- [emmet-vim][0].\n- [supertab][1].\n\n### Literial \u003ckbd\u003etab\u003c/kbd\u003e\n\nIt will return literial \u003ckbd\u003etab\u003c/kbd\u003e if there are blanks or the start of line before the cursor.\n\n### Custom snippets \u003ca name=\"custom_snippets\"\u003e\u003c/a\u003e\n\nIt will return the snippet if the characters before the cursor match the key in the dictionary defined by [snippets file](#snippets).\n\n### Extensible fuzzy search \u003ca name=\"fuzzy_match\"\u003e\u003c/a\u003e\n\nIt returns the first match that fuzzy methods find in current file. The order can be changed by [g:vim_imagine_fuzzy_chain](#fuzzy_chain) except the `favoured` method. \n\nThe longest is used if there are more than one matched words.\n\nThe fuuzy search will try lines near current line first, then all the lines. See [fuzzy_near](#fuzzy_near).\n\n#### Builtin methods\n\n- favoured(Always try it at first)\n\n    If [g:vim_imagine_fuzzy_favoured_words](#fuzzy_favoured_words) is `['myLongName', 'anotherLongName']`, \n\n        mln -\u003e myLongName\n\n- hyphen\n\n        adg -\u003e abc-def-ghi\n\n- capital\n\n        adg -\u003e abcDefGhi\n\n- dot\n\n        adg -\u003e abc.def.ghi\n\n    **Note**: context words won't be split by `.` in this method\n    \n- underscore\n\n        adg -\u003e abc_def_ghi\n\n- include\n\n        xyz -\u003e 000x111y222z\n\n\n#### Custom methods \n\nAll methods defined in [g:vim_imagine_fuzzy_custom_methods](#fuzzy_custom_methods) are used in fuzzy completion. See the [example](#custom_methods_eample).\n\n### Emmet\n\nIt will return [emmet-vim][0]'s result if it's installed when there is only one character before the cursor or [b:vim_imagine_use_emmet](#use_emmet) is 1.\n\n### Supertab\n\nIt will return [supertab][1]'s result if it's installed. It's worth nothing that \u003ckbd\u003etab\u003c/kbd\u003e can't be used to move in popup menu, but \u003ckbd\u003eup\u003c/kbd\u003e, \u003ckbd\u003edown\u003c/kbd\u003e, \u003ckbd\u003eenter\u003c/kbd\u003e still work.\n\n## Configuration\n\n### Variables\n\n#### g:vim_imagine_snippets_path \u003ca name=\"snippets\"\u003e\u003c/a\u003e\n\n- description: the path of the snippets file under the `runtimepath`. See [the example snippets](/setting/example_snippets.vim)\n- type: `string`.\n- default: `'plugin/imagine_snippets.vim'`. \n\nIt's recommended to put it under `.vim` or `vimfiles`. It's a normal vimscript file. The only requirement is that these dictionary variables \n`g:vim_imagine_dict`,\n`g:vim_imagine_dict_1`,\n`g:vim_imagine_dict_2`\nare defined as expected. If the path is not readable, [the example snippets](/setting/example_snippets.vim) will be used.\n\n#### Snippets file format\nFor dictionary variable\n`g:vim_imagine_dict`,\n`g:vim_imagine_dict_1`,\n`g:vim_imagine_dict_2`, the key is the chars before the cursor, and the value is the snippet string. \n\nSpecial characters like `\\r`, `\\t`, `\\e` are supported in double quoted string(see `:h string`). Normal mode commands can be executed after `\\e`.\n\n`|` can be used to mark cursor location. \n\n#### g:vim_imagine_fuzzy_chain \u003ca name=\"fuzzy_chain\"\u003e\u003c/a\u003e\n\n- description: the order of methods that fuzzy search uses.\n- type: `list`.\n- default: \n\n    ```vim\n    let g:vim_imagine_fuzzy_chain = [\n        \\'capital', \n        \\'dot', \n        \\'hyphen', \n        \\'underscore', \n        \\'include',\n        \\]\n    ```\n\n#### g:vim_imagine_fuzzy_near \u003ca name=\"fuzzy_near\"\u003e\u003c/a\u003e\n\n- description: the top and bottom offset to current line which defines the lines to search first. Both of offsets are positive value.\n- type: `list`.\n- default: \n\n    ```vim\n    let g:vim_imagine_fuzzy_near = [5, 0]\n    ```\n\n#### g:vim_imagine_fuzzy_near_chain \u003ca name=\"fuzzy_near_chain\"\u003e\u003c/a\u003e\n\n- description: the order of methods that fuzzy near search uses.\n- type: `list`.\n- default: \n\n    ```vim\n    let g:vim_imagine_fuzzy_chain = [\n        \\'capital', \n        \\'dot', \n        \\'hyphen', \n        \\'underscore', \n        \\'include',\n        \\]\n    ```\n\n\n#### g:vim_imagine_fuzzy_custom_methods \u003ca name=\"fuzzy_custom_methods\"\u003e\u003c/a\u003e\n\n- description: defines custom methods that fuzzy search uses.\n- type: `dictionary`.\n\n    - members: `chars =\u003e regexp`. The `chars` is the characters before the cursor and the `regexp` is used to match words in current file. The member name can be used in `g:vim_imagine_fuzzy_chain`.\n\n    - members end with `_splits`: `splits =\u003e modified splits`. Modify `splits` which determines how words is generated from current file. Default is a comma-separated string(comma and space will always be added).\n\n            (,),{,},\u003c,\u003e,[,],=,:,'',\",;,/,\\,+,!,#,*,`,|,.\n        \n\n- default: `{}`\n- example:\u003ca name=\"custom_methods_eample\"\u003e\u003c/a\u003e \n\n    ```vim\n    let g:vim_imagine_fuzzy_custom_methods = {}\n\n    function! g:vim_imagine_fuzzy_custom_methods.same_first(chars)\n      let case_flag = ''\n      if a:chars =~ '\\v\\C[A-Z]'\n        let case_flag = '\\C'\n      endif\n\n      let regexp = join(split(a:chars, '\\zs'), '.*')\n      let regexp = escape(regexp, '()@$')\n      let regexp = '\\v'.case_flag.'^(\\@|\\$)?'.regexp.'.*\u003e'\n      return regexp\n    endfunction\n\n    let g:vim_imagine_fuzzy_chain = [\n        \\'capital', \n        \\'hyphen', \n        \\'dot', \n        \\'underscore', \n        \\'same_first',\n        \\'include',\n        \\]\n    ```\n\n#### g:vim_imagine_fuzzy_favoured_words \u003ca name=\"fuzzy_favoured_words\"\u003e\u003c/a\u003e\n\n- description: The words to check firstly when fuzzy search starts. The list can be changed while editing files by \u003ckbd\u003eleader\u003c/kbd\u003e \u003ckbd\u003ea\u003c/kbd\u003e in NORMAL mode.\n- type: `list`.\n- default: `[]`\n\n#### b:vim_imagine_use_emmet \u003ca name=\"use_emmet\"\u003e\u003c/a\u003e\n\n- description: Enable emmet method at first. It can be togggled by \u003ckbd\u003ec-f\u003c/kbd\u003e.\n- type: `int` (0 or 1)\n- default: `0`\n- example:\n\n    ```vim\n    autocmd FileType html,pug,xml,css,less let b:vim_imagine_use_emmet = 1\n    ```\n\n### Mappings\n\n#### INSERT mode\n\n- \u003ckbd\u003etab\u003c/kbd\u003e: complete the chars before the cursor.\n\n- \u003ckbd\u003ec-u\u003c/kbd\u003e: undo the completion. \n\n    ```vim\n    let g:vim_imagine_mapping_undo_completion = '\u003cc-u\u003e'\n    ```\n\n- \u003ckbd\u003ec-f\u003c/kbd\u003e: toggle emmet.\n\n    ```vim\n    let g:vim_imagine_mapping_toggle_emmet = '\u003cc-f\u003e'\n    ```\n\n#### NORMAL mode\n\n- \u003ckbd\u003eleader\u003c/kbd\u003e \u003ckbd\u003ea\u003c/kbd\u003e: add the word under the cursor to favoured words \u003ca name=\"add_favoured_word\"\u003e\u003c/a\u003e.\n\n    ```vim\n    let g:vim_imagine_mapping_add_favoured_word = '\u003cleader\u003ea'\n    ```\n\n[0]: https://github.com/mattn/emmet-vim\n[1]: https://github.com/ervandew/supertab\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleafoftree%2Fvim-imagine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleafoftree%2Fvim-imagine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleafoftree%2Fvim-imagine/lists"}