{"id":17776361,"url":"https://github.com/m-pilia/vim-mediawiki","last_synced_at":"2025-03-15T17:31:33.344Z","repository":{"id":45493367,"uuid":"217062498","full_name":"m-pilia/vim-mediawiki","owner":"m-pilia","description":"Vim plugin to edit MediaWiki pages","archived":false,"fork":false,"pushed_at":"2024-10-26T20:07:27.000Z","size":102,"stargazers_count":20,"open_issues_count":10,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-27T03:54:50.286Z","etag":null,"topics":["coc","completion","mediawiki","mediawiki-client","neovim","nvim-cmp","source","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/m-pilia.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}},"created_at":"2019-10-23T13:19:56.000Z","updated_at":"2025-02-05T18:46:03.000Z","dependencies_parsed_at":"2023-01-30T22:30:37.011Z","dependency_job_id":null,"html_url":"https://github.com/m-pilia/vim-mediawiki","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/m-pilia%2Fvim-mediawiki","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m-pilia%2Fvim-mediawiki/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m-pilia%2Fvim-mediawiki/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m-pilia%2Fvim-mediawiki/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/m-pilia","download_url":"https://codeload.github.com/m-pilia/vim-mediawiki/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243766695,"owners_count":20344800,"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":["coc","completion","mediawiki","mediawiki-client","neovim","nvim-cmp","source","vim"],"created_at":"2024-10-26T22:05:19.674Z","updated_at":"2025-03-15T17:31:33.011Z","avatar_url":"https://github.com/m-pilia.png","language":"Vim Script","funding_links":[],"categories":[],"sub_categories":[],"readme":"vim-mediawiki: vim plugin to edit MediaWiki pages\n===============================================================\n[![Travis CI Build Status](https://travis-ci.org/m-pilia/vim-mediawiki.svg?branch=master)](https://travis-ci.org/m-pilia/vim-mediawiki)\n[![codecov](https://codecov.io/gh/m-pilia/vim-mediawiki/branch/master/graph/badge.svg)](https://codecov.io/gh/m-pilia/vim-mediawiki/branch/master)\n[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/m-pilia/vim-mediawiki/blob/master/LICENSE)\n\nThis is a plugin to help editing pages of a MediaWiki site from vim/neovim. It\nprovides:\n* filetype detection\n* improved syntax highlighting\n* page preview\n* semantic auto-completion of links and templates with\n  [coc.nvim](https://github.com/neoclide/coc.nvim) and [nvim-cmp](https://github.com/hrsh7th/nvim-cmp) sources\n* [UltiSnips](https://github.com/SirVer/ultisnips) snippets\n* `\u003cplug\u003e` mappings for text objects\n* matching pairs for [matchit.vim](https://github.com/vim/vim/blob/master/runtime/pack/dist/opt/matchit/doc/matchit.txt)\n* integration with [vim-surround](https://github.com/tpope/vim-surround)\n\nInstallation\n============\n\nThe plugin can be installed with any package manager. Prerequisites are vim\n8.1+ or neovim 0.4+, a working Python3 installation, and the `mwclient` Python\npackage (`pip install mwclient`).\n\nAuto-completion\n===============\n\nIf [coc.nvim](https://github.com/neoclide/coc.nvim) is installed and configured\nproperly, the completion source should work out-of-the-box for buffers of type\n`mediawiki`.\n\nFor [nvim-cmp](https://github.com/hrsh7th/nvim-cmp), add the `cmp_mediawiki`\nsource:\n```lua\nrequire('vim-mediawiki.cmp_mediawiki')\nrequire('cmp').setup({\n    sources = {\n        {name = 'cmp_mediawiki'},\n    },\n})\n```\n\nCompletion is triggered when typing inside double square brackets\nor double braces, and the minimum number of characters to type before\ncompletion can be configured. Multi-word completion is supported, so\ncompletions will be suggested when typing more than one word inside the\nbrackets, together with a hint of the full page name.\n\n![image](https://user-images.githubusercontent.com/8300317/68047476-2894dc00-fce7-11e9-9f7f-9be1c0485616.png)\n\nWhen inserting a template, semantic completion of parameter names is provided,\nand the documentation for each parameter is provided in the floating window,\nbased on the\n[TemplateData](https://www.mediawiki.org/wiki/Extension:TemplateData) API.\n\n![image](https://user-images.githubusercontent.com/8300317/77249684-35d54780-6c43-11ea-9d39-aa16d7a983e1.png)\n\nYou can refer to the relevant [upstream\ndocumentation](https://github.com/neoclide/coc.nvim/wiki/Completion-with-sources)\nto configure the source in coc.nvim. Settings can be defined in the\n[coc-settings.json](https://github.com/neoclide/coc.nvim/wiki/Using-the-configuration-file):\n```json\n{\n    \"coc\": {\n        \"source\": {\n            \"mediawiki\": {\n                \"enable\": true,\n                \"priority\": 99\n            }\n        }\n    }\n}\n```\nTo further configure completion, see the [following\nsection](#Completion).\n\nIf you do not use coc.nvim, you may be able to use the function\n`coc#source#mediawiki#complete()` to implement an\n[omnifunc](https://vimhelp.org/options.txt.html#%27omnifunc%27), or to write an\nadapter to plug it in other completion mechanisms. Please refer to the\n[upstream documentation of the\nAPI](https://github.com/neoclide/coc.nvim/wiki/Create-custom-source) used by\nthis source.\n\nSnippets\n========\n\nSnippets in the [UltiSnips](https://github.com/SirVer/ultisnips) format are\nshipped with this plugin, and they should work out-of-the-box if UltiSnips is\ninstalled and configured. UltiSnips snippets can be used in coc.nvim through\nthe [coc-ultisnips source](https://github.com/neoclide/coc-sources).\n\nPlease note that this plugin aims to be site-agnostic, therefore no snippets\nare shipped for specific sites, e.g. common templates used on the English\nWikipedia. Snippets of such kind are out of the scope of this project, but can\nbe easily defined in your own configuration, please refer to the [upstream\ndocumentation](https://github.com/SirVer/ultisnips/blob/master/doc/UltiSnips.txt)\nfor more information.\n\nText objects\n============\n\nThe plugin provides a set of text objects:\n* `\u003cplug\u003e(mediawiki-text-object-inside-tick)` and\n  `\u003cplug\u003e(mediawiki-text-object-around-tick)` to operate inside or around\n  italic and bold markers\n* `\u003cplug\u003e(mediawiki-text-object-inside-heading)` and\n  `\u003cplug\u003e(mediawiki-text-object-around-heading)` to operate inside or around\n  headings\n* `\u003cplug\u003e(mediawiki-text-object-inside-pipes)` and\n  `\u003cplug\u003e(mediawiki-text-object-around-pipes)` to operate inside or around\n  pipes (e.g. positional template arguments)\n* `\u003cplug\u003e(mediawiki-text-object-inside-link-page)` and\n  `\u003cplug\u003e(mediawiki-text-object-around-link-page)` to operate inside or around\n  the leftmost part of a link (between `[[` and `|`), containing the page of a\n  link\n* `\u003cplug\u003e(mediawiki-text-object-inside-link-name)` and\n  `\u003cplug\u003e(mediawiki-text-object-around-link-name)` to operate inside or around\n  the rightmost part of a link (between `|` and `]]`), containing the name of a\n  link\n* `\u003cplug\u003e(mediawiki-text-object-inside-template-begin)` and\n  `\u003cplug\u003e(mediawiki-text-object-around-template-begin)` to operate inside or around\n  the leftmost part of a template (between `{{` and `|`)\n* `\u003cplug\u003e(mediawiki-text-object-inside-template-end)` and\n  `\u003cplug\u003e(mediawiki-text-object-around-template-end)` to operate inside or around\n  the rightmost part of a template (between `|` and `}}`)\n* `\u003cplug\u003e(mediawiki-text-object-inside-named-argument)` and\n  `\u003cplug\u003e(mediawiki-text-object-around-named-argument)` to operate inside or around\n  a named argument (between `=` and `|`, where `|` is always excluded from the\n  text object)\n\nThe `\u003cplug\u003e` mappings can be associated to key mappings, for instance:\n```viml\nvmap \u003csilent\u003e \u003cbuffer\u003e i' \u003cplug\u003e(mediawiki-text-object-inside-tick)\nvmap \u003csilent\u003e \u003cbuffer\u003e a' \u003cplug\u003e(mediawiki-text-object-around-tick)\nomap \u003csilent\u003e \u003cbuffer\u003e i' \u003cplug\u003e(mediawiki-text-object-inside-tick)\nomap \u003csilent\u003e \u003cbuffer\u003e a' \u003cplug\u003e(mediawiki-text-object-around-tick)\n```\n\nSurround\n========\n\nIf [vim-surround](https://github.com/tpope/vim-surround) is installed, mappings\nare created to surround text with wiki-link or template double-brackets, or\nwith bold or italic ticks. The characters bound to the surround map can be\nconfigured with the variables\n```viml\nlet g:vim_mediawiki_surround_wikilink = 'l'\nlet g:vim_mediawiki_surround_template = 't'\nlet g:vim_mediawiki_surround_bold = 'b'\nlet g:vim_mediawiki_surround_italic = 'i'\n```\nand can be disabled by setting\n```viml\nlet g:vim_mediawiki_surround = 0\n```\n\nConfiguration\n=============\n\nA set of variables allows to customise the behaviour of the plugin. All\nvariables can either be set globally as `g:vim_mediawiki_...` or locally for\neach buffer with `b:vim_mediawiki_...`.\n\n## Site\n\nThe value of `g:vim_mediawiki_site` sets the address of the wiki to edit.\nThe default is an empty string, and you need to set this in order to use\nfeatures such as auto-completion. Example:\n```viml\nlet g:vim_mediawiki_site = 'en.wikipedia.org'\n```\n\nSite-specific options are stored in dictionaries, allowing to map different\nsettings to different sites for each buffer, according to the value of\n`b:vim_mediawiki_site`. It is possible to automatically map custom file\nextensions to site-specific settings by creating a custom\n`ftdetect/mediawiki.vim`. For instance, to map files with extension `*.enwiki`\nto settings specific for the English language Wikipedia:\n```viml\nautocmd BufRead,BufNewFile *.enwiki\n\\   set filetype=mediawiki |\n\\   let b:vim_mediawiki_site = 'en.wikipedia.org' |\n\\   set spelllang=en\n\n```\n\n## Completion\n\nIt is possible to customise which\n[namespaces](https://www.mediawiki.org/wiki/Help:Namespaces) to auto-complete.\nThe configuration is stored on a per-site basis in a dictionary called\n`g:vim_mediawiki_completion_namespaces`, whose keys are possible values of\n`g:vim_mediawiki_site`. Each site is mapped to a dictionary, that associates\neach trigger sequence to the number of the corresponding namespace on that\nsite. Example:\n```viml\nlet g:vim_mediawiki_completion_namespaces = {\n\\   'en.wikipedia.org': {\n\\       '[[': 0,\n\\       '{{': 10,\n\\   },\n\\   'sv.wikipedia.org': {\n\\       '[[': 0,\n\\       '[[File:': 6,\n\\       '[[Kategori:': 14,\n\\   },\n\\ }\n```\nOnly the namespaces listed in this map will be completed. A `default` entry is\nused for sites not present among the keys. The pre-defined configuration is\n```viml\nlet g:vim_mediawiki_completion_namespaces = {\n\\   'default': {\n\\       '[[': 0,\n\\   },\n\\ }\n```\nand the custom configuration is merged with it, so the `default` key is\npresent unless it is overridden. Moreover, the buffer-local configuration is\nmerged with the global configuration, so it is not necessary to duplicate the\nwhole configuration in buffer-local variables, but it is sufficient to add or\noverwrite only the desired sites. To disable completion for a site, map it to\nan empty dictionary.\n\nA complete configuration to edit the English language Wikipedia\n[would be](https://en.wikipedia.org/wiki/Wikipedia:Namespace):\n```viml\nlet g:vim_mediawiki_completion_namespaces = {\n\\   'en.wikipedia.org': {\n\\       '[[': 0,\n\\       '[[Talk:': 1,\n\\       '[[User:': 2,\n\\       '[[User talk:': 3,\n\\       '[[Wikipedia:': 4,\n\\       '[[Wikipedia talk:': 5,\n\\       '[[File:': 6,\n\\       '[[:File:': 6,\n\\       '[[File talk:': 7,\n\\       '[[MediaWiki:': 8,\n\\       '[[MediaWiki talk:': 9,\n\\       '[[Template:': 10,\n\\       '{{': 10,\n\\       '[[Template talk:': 11,\n\\       '[[Help:': 12,\n\\       '[[Help talk:': 13,\n\\       '[[Category:': 14,\n\\       '[[:Category:': 14,\n\\       '[[Category talk:': 15,\n\\       '[[Portal:': 100,\n\\       '[[Portal talk:': 101,\n\\       '[[Book:': 108,\n\\       '[[Book talk:': 109,\n\\       '[[Draft:': 118,\n\\       '[[Draft talk:': 119,\n\\       '[[TimedText:': 710,\n\\       '[[TimedText talk:': 711,\n\\       '[[Module:': 828,\n\\       '[[Module talk:': 829,\n\\   },\n\\ }\n```\n\nThe value of `g:vim_mediawiki_completion_prefix_length` determines the minimum\nnumber of characters required after the trigger sequence to trigger completion.\nDefault:\n```viml\nlet g:vim_mediawiki_completion_prefix_length = 5\n```\n\nThe value of `g:vim_mediawiki_completion_limit` determines how many suggestions are\nfetched. Default:\n```viml\nlet g:vim_mediawiki_completion_limit = 15\n```\n\n## Preview\n\nThe command `MediaWikiPreview` generates a preview of the page being edited,\nand loads it in a web browser window. It is possible to customise the command\nused to open the browser, by setting\n```viml\nlet g:vim_mediawiki_browser_command = \"chromium \\r\"\n```\nwhere the carriage return character `\\r` will be replaced with the address of\nthe page to open (attention should be paid to insert an actual carriage return\ncharacter, and to not escape the backslash).\n\n## Mappings\n\nNo mappings are set out-of-the-box. The following optional navigation mappings\n```viml\nnoremap \u003cbuffer\u003e j gj\nnoremap \u003cbuffer\u003e k gk\nnoremap \u003cbuffer\u003e 0 g0\nnoremap \u003cbuffer\u003e ^ g^\nnoremap \u003cbuffer\u003e $ g$\nnnoremap \u003cbuffer\u003e D dg$\nnnoremap \u003cbuffer\u003e C cg$\nnnoremap \u003cbuffer\u003e A g$a\n```\nthat help navigating wrapped lines can be enabled by setting to true the\nvariable\n```viml\nlet g:vim_mediawiki_mappings = 1\n```\n\n## Syntax highlighting\n\nLanguages within `\u003csource\u003e` or `\u003csyntaxhighlight\u003e` tags will be highlighted. A\nlist of languages (identified by their wiki name) to be ignored can be set:\n```viml\nlet g:vim_mediawiki_ignored_wikilangs = ['cobol', 'pascal']\n```\n\nSyntax highlight settings are loaded for the languages detected within the\nbuffer at load or save time. Language settings can be preloaded for selected\nlanguages:\n```viml\nlet g:vim_mediawiki_preloaded_wikilangs = ['c', 'python']\n```\n\nA language name can be remapped to a different vim syntax highlighting:\n```viml\nlet g:vim_mediawiki_wikilang_map = {'c': 'cpp'}\n```\n\nCredits and license\n===================\n\nThe `syntax/mediawiki.vim` file is based on code originally published on\n[Wikipedia:Text editor\nsupport](http://en.wikipedia.org/wiki/Wikipedia:Text_editor_support) as public\ndomain, and distributed within the plugins\n[wikipedia.vim](https://www.vim.org/scripts/script.php?script_id=1787) and\n[mediawiki.vim](https://www.vim.org/scripts/script.php?script_id=3970).\n\nThe `ftplugin/mediawiki.vim` file contains some portions of code from the [HTML\nftplugin](https://github.com/vim/vim/blob/946e27ab65/runtime/ftplugin/html.vim#L28-L35)\nof the vim runtime, by Johannes Zellner and Benji Fisher, and from\n[mediawiki.vim](https://github.com/chikamichi/mediawiki.vim) by Jean-Denis\nVauguet (a.k.a. chikamichi).\n\nThe `autoload/mediawiki/fenced_languages.vim` file is adapted from\n[mediawiki.vim](https://github.com/chikamichi/mediawiki.vim/blob/26e573726/autoload/mediawiki.vim)\nby Olivier Teulière (a.k.a. ipkiss42).\n\nAll the original parts of this software, where not differently attributed or\nlicensed, are distributed under the MIT license. The full text of the license\nis available in the [LICENSE\nfile](https://github.com/m-pilia/vim-mediawiki/blob/master/LICENSE) distributed\nalongside the source code.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm-pilia%2Fvim-mediawiki","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fm-pilia%2Fvim-mediawiki","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm-pilia%2Fvim-mediawiki/lists"}