{"id":13646474,"url":"https://github.com/zk-phi/git-complete","last_synced_at":"2025-04-14T13:03:43.129Z","repository":{"id":152679624,"uuid":"76531041","full_name":"zk-phi/git-complete","owner":"zk-phi","description":"Yet another completion engine powered by \"git grep\"","archived":false,"fork":false,"pushed_at":"2021-11-25T08:22:45.000Z","size":313,"stargazers_count":66,"open_issues_count":7,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-08-02T01:26:05.265Z","etag":null,"topics":["emacs"],"latest_commit_sha":null,"homepage":"","language":"Emacs Lisp","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zk-phi.png","metadata":{"files":{"readme":"Readme.org","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2016-12-15T06:36:00.000Z","updated_at":"2024-07-01T06:10:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"3f9b81e1-c748-4838-88c9-1030cd7356e3","html_url":"https://github.com/zk-phi/git-complete","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/zk-phi%2Fgit-complete","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zk-phi%2Fgit-complete/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zk-phi%2Fgit-complete/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zk-phi%2Fgit-complete/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zk-phi","download_url":"https://codeload.github.com/zk-phi/git-complete/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223634005,"owners_count":17176871,"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":["emacs"],"created_at":"2024-08-02T01:02:56.786Z","updated_at":"2024-11-08T04:35:08.821Z","avatar_url":"https://github.com/zk-phi.png","language":"Emacs Lisp","readme":"* git-complete.el\n\nYet another completion engine powered by =git grep=\n\n=git grep= を使った補完エンジン\n\n** Description\n\n=git-complete= provides an interactive command which, when invoked,\nscans the current git project with =git grep= and suggests what you\nmay want to insert.\n\n[[screencast.gif]]\n\n=git-complete= CAN:\n\n- complete *not just a symbol but the whole idiom* if appropreate,\n  unlike other completion engines (rather like snippet engines)\n\n- be used as an \"omni (smart) completion\" engine, i.e. =git-complete=\n  tries to suggest expressions you may want to insert next, according\n  to the context, *even when you don't remember it*, by grepping your\n  project (class methods after a class name, typical argument for a\n  function, for examples)\n\n- be used with *no per-language configurations or dictionaries*,\n  unlike snippet engines or omni-completion engines\n\n=git-complete= CAN'T:\n\n- complete expressions which has not been used in the git project yet\n\n- start completion automatically, since it's a bit time-consuming to\n  grep over the project (especially for the first invokation)\n\n- be 100% accurate, since =git-complete= has no knowledge about the\n  language you are coding in\n\nEXTRA FEATURES:\n\n- \"autopair\"\n  - =git-complete= (optionally) tries to keep the parentheses balanced\n    by inserting or merging some parens if appropreate\n\n- DWIM newline insertion\n  - =git-complete= tries to insert newline after completion if you may\n    want so\n\n*** See also:\n\nThe =git grep= idea is taken from =auto-programming.el= by hitode909.\n\nhttps://github.com/hitode909/emacs-auto-programming\n\n- Atom version: =atom-auto-programming= by the author of\n  =auto-programming.el=\n  - https://github.com/hitode909/atom-auto-programming\n\n- Vim version: =vim-auto-programming= by haya14busa\n  - https://github.com/haya14busa/vim-auto-programming\n\n** Quickstart\n*** Installation\n\n#+begin_src emacs-lisp\n  (require 'git-complete)\n#+end_src\n\nand (optionally) bind some keys.\n\n#+begin_src emacs-lisp\n  (global-set-key (kbd \"C-c C-c\") 'git-complete)\n#+end_src\n\nYou may also invoke git-complete with =M-x git-complete=.\n\nNote that you also need to install =git= if it's not installed yet.\n\n*** Examples\n\n(Consider \"|\" as the cursor in following examples)\n\n- after a part of a package name:\n\n  #+begin_src perl\n    SHA|\n  #+end_src\n\n  git-complete completes the import statement.\n\n  #+begin_src perl\n    use Digest::SHA;\n    |\n  #+end_src\n\n- after a constructor:\n\n  #+begin_src javascript\n    var foo = moment().|\n  #+end_src\n\n  git-complete suggests method names frequently used in your project.\n\n  #+begin_src javascript\n    var foo = moment().format(|\n  #+end_src\n\n  and =M-x git-complete= (again) suggests typical arguments to the\n  method frequently used in your project.\n\n  #+begin_src javascript\n    var foo = moment().format(\"YYYY-MM-DD HH:mm:ss\"|\n  #+end_src\n\n- after a newline:\n\n  #+begin_src perl\n    use strict;\n    |\n  #+end_src\n\n  suggests next line which usually follows the line =use strict;= in\n  your project.\n\n  #+begin_src perl\n    use strict;\n    use warnings;\n    |\n  #+end_src\n\n** Customizations\n\n- =git-complete-enable-autopair= : either git-complete should keep the\n  parenthesis balance during completion\n\n- =git-complete-ignore-case= : either to use =--ignore-case= option or\n  not when git grepping\n\n- =git-complete-grep-function= : function used to grep over the\n  repo. git-complete by default uses =git grep= but you may tell\n  git-complete to use =rg= instead by setting this variable to\n  ='git-complete-ripgrep=\n\nSee \"How it works\" section for the options below:\n\n- =git-complete-threshold=\n- =git-complete-whole-line-completion-threshold=\n- =git-complete-next-line-completion-threshold=\n- =git-complete-repeat-completion=\n\n** How it works\n\nThere are three methods to collect completions:\n\n- whole current-line completion\n- omni current-line completion\n- omni next-line completion\n\nUser is prompted to select one of the completions, and the selected\ncompletion is inserted to the buffer in different ways according to\nits type.\n\n*** Completion collection\n**** Whole current-line completion\n\nexample:\n\n: React|            * consider | as the cursor\n\n1. Collect lines with \"React\" in your git repo, by =git grep=-ing with\n   \"React\"\n\n   : $ git grep -F -h \"React\"\n   : import React from 'react';\n   : export default class extends React.Component {\n   : export default class extends React.Component {\n   : import React from 'react';\n   : export default class extends React.Component {\n   : import React from 'react';\n   : import ReactDOM from 'react-dom';\n   : export default class extends React.Component {\n   :     ReactDOM.render(\u003cMyComponent /\u003e);\n   : import React from 'react';\n   : export default class extends React.Component {\n   : import ReactDOM from 'react-dom';\n   :     ReactDOM.render(\u003cAnotherComponent /\u003e);\n   : ...\n\n2. If some identical lines appear \"frequently\" (as defined by\n   =git-complete-whole-line-completion-threshold=), they are added to\n   the completions list, as \"whole-line\" completions.\n\n   : |                                                 | frequency | type       |\n   : +-------------------------------------------------+-----------+------------|\n   : | export default class extends React.Component{\\n |       60% | whole-line |\n   : | import React from 'react';\\n                    |       30% | whole-line |\n   : | ...                                             |       ... |        ... |\n\n**** Omni current-line completion\n\nexample:\n\n: React|            * consider | as the cursor\n\n1. Collect lines with \"React\" in your git repo, by =git grep=-ing with\n   \"React\"\n\n   : $ git grep -F -h \"React\"\n   : import React from 'react';\n   : export default class extends React.Component {\n   : export default class extends React.Component {\n   : import React from 'react';\n   : export default class extends React.Component {\n   : import React from 'react';\n   : import ReactDOM from 'react-dom';\n   : export default class extends React.Component {\n   :     ReactDOM.render(\u003cMyComponent /\u003e);\n   : import React from 'react';\n   : export default class extends React.Component {\n   : import ReactDOM from 'react-dom';\n   :     ReactDOM.render(\u003cAnotherComponent /\u003e);\n   : ...\n\n2. Trim each lines found in 1. as follows:\n\n   - Find the query string (\"React\" in this case) inside the line and\n     remove characters before the query and the query itself.\n\n   - If the line has more close parens than open parens, remove\n     characters after the innermost matching close paren.\n\n   : from 'react';\n   : .Component {\n   : .Component {\n   : from 'react';\n   : .Component {\n   : from 'react';\n   : DOM from 'react-dom';\n   : .Component {\n   : DOM.render(\u003cMyComponent /\u003e);\n   : from 'react';\n   : .Component {\n   : DOM from 'react-dom';\n   : DOM.render(\u003cAnotherComponent /\u003e);\n   : ...\n\n3. If some identical idioms appear \"frequently\" (as defined in\n   =git-complete-threshold=) at the beginning of the lines, add the\n   idioms to the completions list as \"omni\" completions.\n\n   : |                         | frequency | type |\n   : +-------------------------+-----------+------|\n   : | .Component {\\n          |       60% | omni |\n   : | from 'react';\\n         |       30% | omni |\n   : | DOM from 'react-dom';\\n |        5% | omni |\n   : | DOM.render(\u003c            |        5% | omni |\n   : | ...                     |       ... |  ... |\n\n   Note that =DOM.render(\u003c= is added to the list but\n   =DOM.render(\u003cMyComponent /\u003e)= is not, since it does not appear\n   \"frequently\".\n\n4. If no completions are found, shorten the query by one subword\n   (configurable via =git-cmopletion-omni-completion-type=) from the\n   beginning and =git grep= again, then back to the step 3. .\n\n   example:\n\n   : var foo = bar(MyClass.|\n\n   The query =var foo = bar(MyClass.= is too specific to find some\n   \"frequent\" idioms, thus shortened to =foo = bar(MyClass.=,\n   =bar(MyClass.= then =MyClass.= which may give some \"frequent\"\n   idioms: method names of the class =MyClass=.\n\n   When the query is shortened, all completions will be type of\n   \"omni\", since the step 2. is skipped.\n\n**** Omni next-line completion\n\nexample:\n\n: use strict;\n: |\n\n1. Collect lines next to =use strict;= in your git repo, by grepping\n   with =use strict;=\n\n   : \u003e git grep -F -h -A1 \"use strict;\"\n   : use strict;\n   : sub foo {\n   : --\n   : use strict;\n   : use warnings;\n   : --\n   : use strict;\n   : use warnings;\n   : --\n   : use strict;\n   : sub bar {\n   : --\n   : use strict;\n   : use utf8;\n   : --\n   : ...\n\n2. Find identical lines as like the step 2. of \"Whole current-line\n   completion\", according to\n   =git-complete-next-line-completion-threshold=\n\n   : |                 | frequency | type |\n   : +-----------------+-----------+------|\n   : | use warnings;\\n |       80% | omni |\n   : | use utf8;\\n     |       20% | omni |\n   : | ...             |       ... |  ... |\n\n3. If no completions are found, shorten the query and repeat like the\n   step 3 of \"Omni current-line completion\".\n\n*** Completion insertion\n**** Whole-line completion\n\nexample:\n\n: React|\n\nwhen you select a \"whole-line\" completion like below:\n\n: export default class extends React.Component {\\n\n\nthen\n\n1. Delete all characters in the current line\n\n   : |\n\n2. Insert the completion\n\n   : export default class extends React.Component {\n   :     |\n\n3. Add some close parens as needed (if \"autopair\" feature is not disabled)\n\n   : export default class extends React.Component {\n   :     |\n   : }\n\n**** Omni completion\n\nexample:\n\n: var foo = moment().format|\n\nwhen you select a \"omni\" completion like below:\n\n: (\"YYYY-MM-DD HH:mm:ss\",\n\nthen\n\n1. Insert the completion after the cursor\n\n   : var foo = moment().format(\"YYYY-MM-DD HH:mm:ss\",|\n\n2. Add some close parens as needed (if \"autopair\" feature is not\n   disabled) after the cursor\n\n   : var foo = moment().format(\"YYYY-MM-DD HH:mm:ss\",|)\n","funding_links":[],"categories":["Emacs Lisp"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzk-phi%2Fgit-complete","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzk-phi%2Fgit-complete","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzk-phi%2Fgit-complete/lists"}