{"id":24387477,"url":"https://github.com/dkendal/nvim-minor-mode","last_synced_at":"2025-04-11T04:32:54.168Z","repository":{"id":68785951,"uuid":"396148307","full_name":"Dkendal/nvim-minor-mode","owner":"Dkendal","description":"Emacs like minor modes for Neovim","archived":false,"fork":false,"pushed_at":"2021-08-20T16:47:35.000Z","size":29,"stargazers_count":21,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T22:04:11.189Z","etag":null,"topics":["fennel","lisp","nvim","nvim-lua","nvim-plugin"],"latest_commit_sha":null,"homepage":"","language":"Fennel","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Dkendal.png","metadata":{"files":{"readme":"README.org","changelog":"CHANGELOG.org","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-08-14T22:33:53.000Z","updated_at":"2024-10-20T12:02:01.000Z","dependencies_parsed_at":"2023-03-01T23:16:40.225Z","dependency_job_id":null,"html_url":"https://github.com/Dkendal/nvim-minor-mode","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dkendal%2Fnvim-minor-mode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dkendal%2Fnvim-minor-mode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dkendal%2Fnvim-minor-mode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dkendal%2Fnvim-minor-mode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dkendal","download_url":"https://codeload.github.com/Dkendal/nvim-minor-mode/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248345202,"owners_count":21088231,"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":["fennel","lisp","nvim","nvim-lua","nvim-plugin"],"created_at":"2025-01-19T12:54:47.135Z","updated_at":"2025-04-11T04:32:54.136Z","avatar_url":"https://github.com/Dkendal.png","language":"Fennel","funding_links":[],"categories":[],"sub_categories":[],"readme":"* Nvim-minor-mode\n\nThis package adds similar functionality as Emacs's minor modes.\n\n** Minor modes\n\nWithin the definition of this package a minor mode is a set of keymaps that\nare enabled with some command, and can be disabled using the same command.\n\nThey're useful for functionality that you don't necessarily always want to be\nactive.\n\n** Installation\n\nUse whatever package manager you like:\n\n#+begin_src vim\nPlug 'Dkendal/nvim-minor-mode'\n#+end_src\n\n#+begin_src lua\nuse { 'Dkendal/nvim-minor-mode' }\n#+end_src\n\n** Usage\n\nMinor modes can be defined using the =define_minor_mode= function.\n\nSay I wanted to defined a \"lisp\" minor mode. While I could write a new plugin\nand define it for all filetypes that are a lisp, I could instead define a\nminor mode and enable it as desired while editing files.\n\n#+begin_src lua\nlocal define_minor_mode = require('minor-mode').define_minor_mode\n\ndefine_minor_mode('lisp', [[\n  Minor modes for lisps to navigate sexps. Replaces some normal movement\n  keybindings.\n  ]], {\n  command = 'LispMode',\n  keymap = {\n    {\n      'n',\n      'j',\n      function()\n        vim.fn.search('(')\n      end,\n      { silent = true }\n    },\n\n    {\n      'n',\n      'k',\n      function()\n        vim.fn.search('(', 'b')\n      end,\n      { silent = true }\n    }\n  }\n})\n#+end_src\n\nThe second argument, =LispMode=, will be used to define a new command.\n\n#+begin_src vim\n:LispMode\n#+end_src\n\nCalling it again will remove all the keymaps.\n\n** Types\n\n#+begin_example\nvim-expr :: string\n\ncommand-name :: string\n\n  A valid vim command name.\n\nmode :: \"n\" | \"v\" | \"x\" | ... | \"!\" \"\"\n\n  See [map-overview] or [nvim_set_keymap]\n\nminor-mode-name :: string\n\nlhs :: string\n\nrhs :: vim-expr | function\n\n  Standard right hand side of a keybinding, but can also be a lua function.\n\nmapping-opts :: {\n  nowait = boolean,\n  silent = boolean,\n  script = boolean,\n  expr = boolean,\n  unique = boolean,\n  noremap = boolean,\n}\n\n  See the definition of {opts} for [nvim_set_keymap].\n\nmapping :: { mode lhs, rhs, mapping-opts || null }\n\n  Same arguments as [nvim_set_keymap], except rhs may also be a lua function.\n\nkeymap :: { mapping }\n#+end_example\n\n\n** API\nAll top level API functions should treat kebab-case methods and\nunderscore_case functions interchangeably for fennel and lua use,\nrespectively.\n\n*** =define_minor_mode(mode :: minor-mode-name, doc :: string, minor-mode-opts)=\n\nDefines a new minor mode whose name is =mode= (a string). It defines a Vim\ncommand named after =opts.command= to toggle the minor mode, standard Vim\ncommand naming rules apply (:h :user-cmd-ambiguous). Provide a short\nexplanation of what the minor mode is in =doc-string= - this value isn't\nexposed anywhere at the moment.\n\n=minor-mode-opts= is a map, key values are defined below:\n\n**** =:command= =command-name=\n\n**** =:keymap= =keymap=\n\nAn array of key bindings that will be activated with the minor mode. Key\nbindings are the same as arguments to =nvim_set_keymap= (:h nvim_set_keymap())\n\nHere's an example keymap:\n\n#+begin_src lua\n{\n  keymap = {\n    { 'n', '\u003cc-p\u003e', ':echo \\\"down\\\"', { silent = true } },\n    { 'n', '\u003cc-n\u003e', ':echo \\\"up\\\"',   { silent = true } } }\n  }\n}\n#+end_src\n\n** Caveats\n\nThis plugin uses buffer local keymaps, if you already have a buffer local\nkeymap present, or overwrite it with another while a minor mode is active and\nthen disable said minor mode, the keymap will be removed.\n\n** Related\n\n- https://github.com/kana/vim-submode\n- https://www.gnu.org/software/emacs/manual/html_node/elisp/Defining-Minor-Modes.html\n\n** Liscence\n\nMPL-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdkendal%2Fnvim-minor-mode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdkendal%2Fnvim-minor-mode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdkendal%2Fnvim-minor-mode/lists"}