robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

robinmerge: 1dc9728daa1d8a2702

master
33.6 KiB715 linesraw
1---@param x string
2---@return string
3local function N_(x)
4  return vim.fn.gettext(x)
5end
6
7---@type {header:string,[integer]:[string,string]}[]
8local options_list = {
9  {
10    header = N_ 'important',
11    { 'cpoptions', N_ 'list of flags to specify Vi compatibility' },
12    { 'runtimepath', N_ 'list of directories used for runtime files and plugins' },
13    { 'packpath', N_ 'list of directories used for plugin packages' },
14    { 'helpfile', N_ 'name of the main help file' },
15  },
16  {
17    header = N_ 'moving around, searching and patterns',
18    { 'whichwrap', N_ 'list of flags specifying which commands wrap to another line' },
19    {
20      'startofline',
21      N_ 'many jump commands move the cursor to the first non-blank\ncharacter of a line',
22    },
23    { 'follow', N_ 'multicursor: motions cascade to all cursors' },
24    { 'paragraphs', N_ 'nroff macro names that separate paragraphs' },
25    { 'sections', N_ 'nroff macro names that separate sections' },
26    { 'path', N_ 'list of directory names used for file searching' },
27    { 'findfunc', N_ 'function called for :find' },
28    { 'cdhome', N_ ':cd without argument goes to the home directory' },
29    { 'cdpath', N_ 'list of directory names used for :cd' },
30    { 'autochdir', N_ 'change to directory of file in buffer' },
31    { 'wrapscan', N_ 'search commands wrap around the end of the buffer' },
32    { 'incsearch', N_ 'show match for partly typed search command' },
33    { 'regexpengine', N_ 'select the default regexp engine used' },
34    { 'ignorecase', N_ 'ignore case when using a search pattern' },
35    { 'smartcase', N_ "override 'ignorecase' when pattern has upper case characters" },
36    { 'maxsearchcount', N_ 'maximum number for the search count feature' },
37    { 'casemap', N_ 'what method to use for changing case of letters' },
38    { 'maxmempattern', N_ 'maximum amount of memory in Kbyte used for pattern matching' },
39    { 'define', N_ 'pattern for a macro definition line' },
40    { 'include', N_ 'pattern for an include-file line' },
41    { 'includeexpr', N_ 'expression used to transform an include line to a file name' },
42    { 'jumpoptions', N_ 'controls the behavior of the jumplist' },
43  },
44  {
45    header = N_ 'tags',
46    { 'tagbsearch', N_ 'use binary searching in tags files' },
47    { 'taglength', N_ 'number of significant characters in a tag name or zero' },
48    { 'tags', N_ 'list of file names to search for tags' },
49    {
50      'tagcase',
51      N_ 'how to handle case when searching in tags files:\n"followic" to follow \'ignorecase\', "ignore" or "match"',
52    },
53    { 'tagrelative', N_ 'file names in a tags file are relative to the tags file' },
54    { 'tagstack', N_ 'a :tag command will use the tagstack' },
55    { 'showfulltag', N_ 'when completing tags in Insert mode show more info' },
56    { 'tagfunc', N_ 'a function to be used to perform tag searches' },
57  },
58  {
59    header = N_ 'displaying text',
60    { 'scroll', N_ 'number of lines to scroll for CTRL-U and CTRL-D' },
61    { 'smoothscroll', N_ 'scroll by screen line' },
62    { 'scrolloff', N_ 'number of screen lines to show around the cursor' },
63    { 'scrolloffpad', N_ 'vertically center cursor even at end of file' },
64    { 'wrap', N_ 'long lines wrap' },
65    { 'linebreak', N_ "wrap long lines at a character in 'breakat'" },
66    { 'breakindent', N_ 'preserve indentation in wrapped text' },
67    { 'breakindentopt', N_ 'adjust breakindent behaviour' },
68    { 'breakat', N_ 'which characters might cause a line break' },
69    { 'showbreak', N_ 'string to put before wrapped screen lines' },
70    { 'sidescroll', N_ 'minimal number of columns to scroll horizontally' },
71    { 'sidescrolloff', N_ 'minimal number of columns to keep left and right of the cursor' },
72    {
73      'display',
74      N_ 'include "lastline" to show the last line even if it doesn\'t fit\ninclude "uhex" to show unprintable characters as a hex number',
75    },
76    {
77      'fillchars',
78      N_ 'characters to use for the status line, folds, diffs,\nbuffer text, filler lines and truncation in the completion menu',
79    },
80    { 'cmdheight', N_ 'number of lines used for the command-line' },
81    { 'columns', N_ 'width of the display' },
82    { 'lines', N_ 'number of lines in the display' },
83    { 'window', N_ 'number of lines to scroll for CTRL-F and CTRL-B' },
84    { 'lazyredraw', N_ "don't redraw while executing macros" },
85    { 'redrawtime', N_ "timeout for 'hlsearch' and :match highlighting in msec" },
86    { 'writedelay', N_ 'delay in msec for each char written to the display' },
87    { 'redrawdebug', N_ 'change the way redrawing works (debug)' },
88    { 'list', N_ 'show <Tab> as ^I and end-of-line as $' },
89    { 'listchars', N_ 'list of strings used for list mode' },
90    { 'number', N_ 'show the line number for each line' },
91    { 'relativenumber', N_ 'show the relative line number for each line' },
92    { 'numberwidth', N_ 'number of columns to use for the line number' },
93    { 'chistory', N_ 'maximum number of quickfix lists that can be stored in history' },
94    { 'lhistory', N_ 'maximum number of location lists that can be stored in history' },
95    { 'conceallevel', N_ 'controls whether concealable text is hidden' },
96    { 'concealcursor', N_ 'modes in which text in the cursor line can be concealed' },
97  },
98  {
99    header = N_ 'syntax, highlighting and spelling',
100    { 'background', N_ '"dark" or "light"; the background color brightness' },
101    { 'filetype', N_ 'type of file; triggers the FileType event when set' },
102    { 'syntax', N_ 'name of syntax highlighting used' },
103    { 'synmaxcol', N_ 'maximum column to look for syntax items' },
104    { 'hlsearch', N_ 'highlight all matches for the last used search pattern' },
105    { 'termguicolors', N_ 'use GUI colors for the terminal' },
106    { 'cursorcolumn', N_ 'highlight the screen column of the cursor' },
107    { 'cursorline', N_ 'highlight the screen line of the cursor' },
108    { 'cursorlineopt', N_ "specifies which area 'cursorline' highlights" },
109    { 'colorcolumn', N_ 'columns to highlight' },
110    { 'spell', N_ 'highlight spelling mistakes' },
111    { 'spelllang', N_ 'list of accepted languages' },
112    { 'spellfile', N_ 'file that "zg" adds good words to' },
113    { 'spellcapcheck', N_ 'pattern to locate the end of a sentence' },
114    { 'spelloptions', N_ 'flags to change how spell checking works' },
115    { 'spellsuggest', N_ 'methods used to suggest corrections' },
116    { 'mkspellmem', N_ 'amount of memory used by :mkspell before compressing' },
117    { 'winhighlight', N_ 'override highlighting-groups window-locally' },
118  },
119  {
120    header = N_ 'multiple windows',
121    { 'laststatus', N_ '0, 1, 2 or 3; when to use a status line for the last window' },
122    { 'statuscolumn', N_ 'custom format for the status column' },
123    { 'statusline', N_ 'alternate format to be used for a status line' },
124    { 'equalalways', N_ 'make all windows the same size when adding/removing windows' },
125    { 'eadirection', N_ 'in which direction \'equalalways\' works: "ver", "hor" or "both"' },
126    { 'winheight', N_ 'minimal number of lines used for the current window' },
127    { 'winminheight', N_ 'minimal number of lines used for any window' },
128    { 'winfixbuf', N_ 'keep window focused on a single buffer' },
129    { 'winfixheight', N_ 'keep the height of the window' },
130    { 'winfixwidth', N_ 'keep the width of the window' },
131    { 'winwidth', N_ 'minimal number of columns used for the current window' },
132    { 'winminwidth', N_ 'minimal number of columns used for any window' },
133    { 'winpinned', N_ 'prevent closing window with :only and :fclose' },
134    { 'helpheight', N_ 'initial height of the help window' },
135    { 'previewheight', N_ 'default height for the preview window' },
136    { 'previewpopup', N_ 'use floating window for preview' },
137    { 'previewwindow', N_ 'identifies the preview window' },
138    { 'winbar', N_ 'custom format for the window bar' },
139    { 'winborder', N_ 'border of floating window' },
140    { 'winblend', N_ 'transparency level for floating windows' },
141    { 'hidden', N_ "don't unload a buffer when no longer shown in a window" },
142    { 'switchbuf', N_ '"useopen" and/or "split"; which window to use when jumping\nto a buffer' },
143    { 'splitbelow', N_ 'a new window is put below the current one' },
144    { 'splitkeep', N_ 'determines scroll behavior for split windows' },
145    { 'splitright', N_ 'a new window is put right of the current one' },
146    { 'scrollbind', N_ 'this window scrolls together with other bound windows' },
147    { 'scrollopt', N_ '"ver", "hor" and/or "jump"; list of options for \'scrollbind\'' },
148    { 'cursorbind', N_ "this window's cursor moves together with other bound windows" },
149  },
150  {
151    header = N_ 'multiple tab pages',
152    { 'showtabline', N_ '0, 1 or 2; when to use a tab pages line' },
153    { 'tabclose', N_ 'behaviour when closing tab pages: left, uselast or empty' },
154    { 'tabpagemax', N_ 'maximum number of tab pages to open for -p and "tab all"' },
155    { 'tabline', N_ 'custom tab pages line' },
156  },
157  {
158    header = N_ 'terminal',
159    { 'scrolljump', N_ 'minimal number of lines to scroll at a time' },
160    { 'guicursor', N_ 'specifies what the cursor looks like in different modes' },
161    { 'title', N_ 'show info in the window title' },
162    { 'titlelen', N_ "percentage of 'columns' used for the window title" },
163    { 'titlestring', N_ 'when not empty, string to be used for the window title' },
164    { 'titleold', N_ 'string to restore the title to when exiting Vim' },
165    { 'icon', N_ 'set the text of the icon for this window' },
166    { 'iconstring', N_ 'when not empty, text for the icon of this window' },
167  },
168  {
169    header = N_ 'using the mouse',
170    { 'mouse', N_ 'list of flags for using the mouse' },
171    { 'mousescroll', N_ 'amount to scroll by when scrolling with a mouse' },
172    { 'mousefocus', N_ 'the window with the mouse pointer becomes the current one' },
173    { 'mousehide', N_ 'hide the mouse pointer while typing' },
174    {
175      'mousemodel',
176      N_ '"extend", "popup" or "popup_setpos"; what the right\nmouse button is used for',
177    },
178    { 'mousetime', N_ 'maximum time in msec to recognize a double-click' },
179    { 'mousemoveevent', N_ 'deliver mouse move events to input queue' },
180  },
181  {
182    header = N_ 'GUI',
183    { 'guifont', N_ 'list of font names to be used in the GUI' },
184    { 'guifontwide', N_ 'list of font names to be used for double-wide characters' },
185    { 'browsedir', N_ '"last", "buffer" or "current": which directory used for\nthe file browser' },
186    { 'langmenu', N_ 'language to be used for the menus' },
187    { 'menuitems', N_ 'maximum number of items in one menu' },
188    { 'winaltkeys', N_ '"no", "yes" or "menu"; how to use the ALT key' },
189    { 'linespace', N_ 'number of pixel lines to use between characters' },
190    { 'termsync', N_ 'synchronize redraw output with the host terminal' },
191  },
192  {
193    header = N_ 'messages and info',
194    { 'shortmess', N_ 'list of flags to make messages shorter' },
195    { 'messagesopt', N_ 'options for outputting messages' },
196    { 'showcmd', N_ "show (partial) command keys in location given by 'showcmdloc'" },
197    { 'showcmdloc', N_ "location where to show the (partial) command keys for 'showcmd'" },
198    { 'showmode', N_ 'display the current mode in the status line' },
199    { 'ruler', N_ 'show cursor position below each window' },
200    { 'rulerformat', N_ 'alternate format to be used for the ruler' },
201    { 'report', N_ 'threshold for reporting number of changed lines' },
202    { 'verbose', N_ 'the higher the more messages are given' },
203    { 'verbosefile', N_ 'file to write messages in' },
204    { 'more', N_ 'pause listings when the screen is full' },
205    { 'confirm', N_ 'start a dialog when a command fails' },
206    { 'errorbells', N_ 'ring the bell for error messages' },
207    { 'visualbell', N_ 'use a visual bell instead of beeping' },
208    { 'belloff', N_ 'do not ring the bell for these reasons' },
209    { 'helplang', N_ 'list of preferred languages for finding help' },
210  },
211  {
212    header = N_ 'selecting text',
213    { 'selection', N_ '"old", "inclusive" or "exclusive"; how selecting text behaves' },
214    {
215      'selectmode',
216      N_ '"mouse", "key" and/or "cmd"; when to start Select mode\ninstead of Visual mode',
217    },
218    {
219      'clipboard',
220      N_ '"unnamed" to use the * register like unnamed register\n"autoselect" to always put selected text on the clipboard',
221    },
222    { 'keymodel', N_ '"startsel" and/or "stopsel"; what special keys can do' },
223  },
224  {
225    header = N_ 'editing text',
226    { 'undolevels', N_ 'maximum number of changes that can be undone' },
227    { 'undofile', N_ 'automatically save and restore undo history' },
228    { 'undodir', N_ 'list of directories for undo files' },
229    { 'undoreload', N_ 'maximum number lines to save for undo on a buffer reload' },
230    { 'modified', N_ 'changes have been made and not written to a file' },
231    { 'readonly', N_ 'buffer is not to be written' },
232    { 'modifiable', N_ 'changes to the text are possible' },
233    { 'textwidth', N_ 'line length above which to break a line' },
234    { 'wrapmargin', N_ 'margin from the right in which to break a line' },
235    { 'backspace', N_ 'specifies what <BS>, CTRL-W, etc. can do in Insert mode' },
236    { 'comments', N_ 'definition of what comment lines look like' },
237    { 'commentstring', N_ 'template for comments; used to put the marker in' },
238    { 'formatoptions', N_ 'list of flags that tell how automatic formatting works' },
239    { 'formatlistpat', N_ 'pattern to recognize a numbered list' },
240    { 'formatexpr', N_ 'expression used for "gq" to format lines' },
241    { 'complete', N_ 'specifies how Insert mode completion works for CTRL-N and CTRL-P' },
242    { 'autocomplete', N_ 'automatic completion in insert mode' },
243    { 'autocompletetimeout', N_ "initial decay timeout for 'autocomplete' algorithm" },
244    { 'completetimeout', N_ 'initial decay timeout for CTRL-N and CTRL-P completion' },
245    { 'autocompletedelay', N_ 'delay in msec before menu appears after typing' },
246    { 'completeopt', N_ 'whether to use a popup menu for Insert mode completion' },
247    { 'completeitemalign', N_ 'popup menu item align order' },
248    { 'pumheight', N_ 'maximum height of the popup menu' },
249    { 'pumwidth', N_ 'minimum width of the popup menu' },
250    { 'pummaxwidth', N_ 'maximum width of the popup menu' },
251    { 'pumblend', N_ 'transparency level of popup menu' },
252    { 'pumborder', N_ 'border of popupmenu' },
253    { 'completefunc', N_ 'user defined function for Insert mode completion' },
254    { 'omnifunc', N_ 'function for filetype-specific Insert mode completion' },
255    { 'dictionary', N_ 'list of dictionary files for keyword completion' },
256    { 'thesaurus', N_ 'list of thesaurus files for keyword completion' },
257    { 'thesaurusfunc', N_ 'function used for thesaurus completion' },
258    { 'infercase', N_ 'adjust case of a keyword completion match' },
259    { 'digraph', N_ 'enable entering digraphs with c1 <BS> c2' },
260    { 'tildeop', N_ 'the "~" command behaves like an operator' },
261    { 'operatorfunc', N_ 'function called for the "g@" operator' },
262    { 'showmatch', N_ 'when inserting a bracket, briefly jump to its match' },
263    { 'matchtime', N_ "tenth of a second to show a match for 'showmatch'" },
264    { 'matchpairs', N_ 'list of pairs that match for the "%" command' },
265    { 'joinspaces', N_ "use two spaces after '.' when joining a line" },
266    {
267      'nrformats',
268      N_ '"alpha", "octal", "hex", "bin" and/or "unsigned"; number formats\nrecognized for CTRL-A and CTRL-X commands',
269    },
270  },
271  {
272    header = N_ 'tabs and indenting',
273    { 'tabstop', N_ 'number of spaces a <Tab> in the text stands for' },
274    { 'shiftwidth', N_ 'number of spaces used for each step of (auto)indent' },
275    { 'vartabstop', N_ 'list of number of spaces a tab counts for' },
276    { 'varsofttabstop', N_ 'list of number of spaces a soft tabsstop counts for' },
277    { 'smarttab', N_ "a <Tab> in an indent inserts 'shiftwidth' spaces" },
278    { 'softtabstop', N_ 'if non-zero, number of spaces to insert for a <Tab>' },
279    { 'shiftround', N_ 'round to \'shiftwidth\' for "<<" and ">>"' },
280    { 'expandtab', N_ 'expand <Tab> to spaces in Insert mode' },
281    { 'autoindent', N_ 'automatically set the indent of a new line' },
282    { 'smartindent', N_ 'do clever autoindenting' },
283    { 'cindent', N_ 'enable specific indenting for C code' },
284    { 'cinoptions', N_ 'options for C-indenting' },
285    { 'cinkeys', N_ 'keys that trigger C-indenting in Insert mode' },
286    { 'cinwords', N_ 'list of words that cause more C-indent' },
287    { 'cinscopedecls', N_ 'list of scope declaration names used by cino-g' },
288    { 'indentexpr', N_ 'expression used to obtain the indent of a line' },
289    { 'indentkeys', N_ "keys that trigger indenting with 'indentexpr' in Insert mode" },
290    { 'copyindent', N_ 'copy whitespace for indenting from previous line' },
291    { 'preserveindent', N_ 'preserve kind of whitespace when changing indent' },
292    { 'lisp', N_ 'enable lisp mode' },
293    { 'lispwords', N_ 'words that change how lisp indenting works' },
294    { 'lispoptions', N_ 'options for Lisp indenting' },
295  },
296  {
297    header = N_ 'folding',
298    { 'foldenable', N_ 'unset to display all folds open' },
299    { 'foldlevel', N_ 'folds with a level higher than this number will be closed' },
300    { 'foldlevelstart', N_ "value for 'foldlevel' when starting to edit a file" },
301    { 'foldcolumn', N_ 'width of the column used to indicate folds' },
302    { 'foldtext', N_ 'expression used to display the text of a closed fold' },
303    { 'foldclose', N_ 'set to "all" to close a fold when the cursor leaves it' },
304    { 'foldopen', N_ 'specifies for which commands a fold will be opened' },
305    { 'foldminlines', N_ 'minimum number of screen lines for a fold to be closed' },
306    { 'foldmethod', N_ 'folding type: "manual", "indent", "expr", "marker",\n"syntax" or "diff"' },
307    { 'foldexpr', N_ 'expression used when \'foldmethod\' is "expr"' },
308    { 'foldignore', N_ 'used to ignore lines when \'foldmethod\' is "indent"' },
309    { 'foldmarker', N_ 'markers used when \'foldmethod\' is "marker"' },
310    { 'foldnestmax', N_ 'maximum fold depth for when \'foldmethod\' is "indent" or "syntax"' },
311  },
312  {
313    header = N_ 'diff mode',
314    { 'diff', N_ 'use diff mode for the current window' },
315    { 'diffopt', N_ 'options for using diff mode' },
316    { 'diffexpr', N_ 'expression used to obtain a diff file' },
317    { 'diffanchors', N_ 'list of addresses for anchoring a diff' },
318    { 'patchexpr', N_ 'expression used to patch a file' },
319  },
320  {
321    header = N_ 'mapping',
322    { 'maxmapdepth', N_ 'maximum depth of mapping' },
323    { 'timeout', N_ 'allow timing out halfway into a mapping' },
324    { 'ttimeout', N_ 'allow timing out halfway into a key code' },
325    { 'timeoutlen', N_ "time in msec for 'timeout'" },
326    { 'ttimeoutlen', N_ "time in msec for 'ttimeout'" },
327  },
328  {
329    header = N_ 'reading and writing files',
330    { 'modeline', N_ 'enable using settings from modelines when reading a file' },
331    { 'modelineexpr', N_ 'allow setting expression options from a modeline' },
332    { 'modelines', N_ 'number of lines to check for modelines' },
333    { 'binary', N_ 'binary file editing' },
334    { 'endofline', N_ 'last line in the file has an end-of-line' },
335    { 'endoffile', N_ 'last line in the file followed by CTRL-Z' },
336    { 'fixendofline', N_ 'fixes missing end-of-line at end of text file' },
337    { 'bomb', N_ 'prepend a Byte Order Mark to the file' },
338    { 'fileformat', N_ 'end-of-line format: "dos", "unix" or "mac"' },
339    { 'fileformats', N_ 'list of file formats to look for when editing a file' },
340    { 'write', N_ 'writing files is allowed' },
341    { 'writebackup', N_ 'write a backup file before overwriting a file' },
342    { 'backup', N_ 'keep a backup after overwriting a file' },
343    { 'backupskip', N_ 'patterns that specify for which files a backup is not made' },
344    { 'backupcopy', N_ 'whether to make the backup as a copy or rename the existing file' },
345    { 'backupdir', N_ 'list of directories to put backup files in' },
346    { 'backupext', N_ 'file name extension for the backup file' },
347    { 'autowrite', N_ 'automatically write a file when leaving a modified buffer' },
348    { 'autowriteall', N_ "as 'autowrite', but works with more commands" },
349    { 'writeany', N_ 'always write without asking for confirmation' },
350    { 'autoread', N_ 'automatically read a file when it was modified outside of Vim' },
351    { 'patchmode', N_ 'keep oldest version of a file; specifies file name extension' },
352    { 'fsync', N_ 'forcibly sync the file to disk after writing it' },
353  },
354  {
355    header = N_ 'the swap file',
356    { 'directory', N_ 'list of directories for the swap file' },
357    { 'swapfile', N_ 'use a swap file for this buffer' },
358    { 'updatecount', N_ 'number of characters typed to cause a swap file update' },
359    { 'updatetime', N_ 'time in msec after which the swap file will be updated' },
360  },
361  {
362    header = N_ 'command line editing',
363    { 'history', N_ 'how many command lines are remembered' },
364    { 'wildchar', N_ 'key that triggers command-line expansion' },
365    { 'wildcharm', N_ "like 'wildchar' but can also be used in a mapping" },
366    { 'wildmode', N_ 'specifies how command line completion works' },
367    { 'wildoptions', N_ 'empty or "tagfile" to list file name of matching tags' },
368    { 'suffixes', N_ 'list of file name extensions that have a lower priority' },
369    { 'suffixesadd', N_ 'list of file name extensions added when searching for a file' },
370    { 'wildignore', N_ 'list of patterns to ignore files for file name completion' },
371    { 'fileignorecase', N_ 'ignore case when using file names' },
372    { 'wildignorecase', N_ 'ignore case when completing file names' },
373    { 'wildmenu', N_ 'command-line completion shows a list of matches' },
374    { 'cedit', N_ 'key used to open the command-line window' },
375    { 'cmdwinheight', N_ 'height of the command-line window' },
376  },
377  {
378    header = N_ 'executing external commands',
379    { 'shell', N_ 'name of the shell program used for external commands' },
380    { 'shellquote', N_ 'character(s) to enclose a shell command in' },
381    { 'shellxquote', N_ "like 'shellquote' but include the redirection" },
382    { 'shellxescape', N_ "characters to escape when 'shellxquote' is (" },
383    { 'shellcmdflag', N_ "argument for 'shell' to execute a command" },
384    { 'shellredir', N_ 'used to redirect command output to a file' },
385    { 'shelltemp', N_ 'use a temp file for shell commands instead of using a pipe' },
386    { 'equalprg', N_ 'program used for "=" command' },
387    { 'formatprg', N_ 'program used to format lines with "gq" command' },
388    { 'keywordprg', N_ 'program used for the "K" command' },
389    { 'warn', N_ 'warn when using a shell command and a buffer has changes' },
390  },
391  {
392    header = N_ 'running make and jumping to errors (quickfix)',
393    { 'errorfile', N_ 'name of the file that contains error messages' },
394    { 'errorformat', N_ 'list of formats for error messages' },
395    { 'makeprg', N_ 'program used for the ":make" command' },
396    { 'shellpipe', N_ 'string used to put the output of ":make" in the error file' },
397    { 'makeef', N_ "name of the errorfile for the 'makeprg' command" },
398    { 'grepprg', N_ 'program used for the ":grep" command' },
399    { 'grepformat', N_ "list of formats for output of 'grepprg'" },
400    { 'makeencoding', N_ 'encoding of the ":make" and ":grep" output' },
401    { 'quickfixtextfunc', N_ 'function to display text in the quickfix window' },
402  },
403  {
404    header = N_ 'system specific',
405    { 'shellslash', N_ 'use forward slashes in file names; for Unix-like shells' },
406    { 'completeslash', N_ 'specifies slash/backslash used for completion' },
407  },
408  {
409    header = N_ 'language specific',
410    { 'isfname', N_ 'specifies the characters in a file name' },
411    { 'isident', N_ 'specifies the characters in an identifier' },
412    { 'iskeyword', N_ 'specifies the characters in a keyword' },
413    { 'isprint', N_ 'specifies printable characters' },
414    { 'quoteescape', N_ 'specifies escape characters in a string' },
415    { 'rightleft', N_ 'display the buffer right-to-left' },
416    { 'rightleftcmd', N_ 'when to edit the command-line right-to-left' },
417    { 'revins', N_ 'insert characters backwards' },
418    { 'allowrevins', N_ "allow CTRL-_ in Insert and Command-line mode to toggle 'revins'" },
419    { 'arabic', N_ 'prepare for editing Arabic text' },
420    { 'arabicshape', N_ 'perform shaping of Arabic characters' },
421    { 'termbidi', N_ 'terminal will perform bidi handling' },
422    { 'keymap', N_ 'name of a keyboard mapping' },
423    { 'langmap', N_ 'list of characters that are translated in Normal mode' },
424    { 'langremap', N_ "apply 'langmap' to mapped characters" },
425    { 'iminsert', N_ 'in Insert mode: 1: use :lmap; 2: use IM; 0: neither' },
426    { 'imsearch', N_ 'entering a search pattern: 1: use :lmap; 2: use IM; 0: neither' },
427  },
428  {
429    header = N_ 'multi-byte characters',
430    { 'fileencoding', N_ 'character encoding for the current file' },
431    { 'fileencodings', N_ 'automatically detected character encodings' },
432    { 'charconvert', N_ 'expression used for character encoding conversion' },
433    { 'delcombine', N_ 'delete combining (composing) characters on their own' },
434    { 'ambiwidth', N_ 'width of ambiguous width characters' },
435    { 'emoji', N_ 'emoji characters are full width' },
436  },
437  {
438    header = N_ 'various',
439    { 'virtualedit', N_ 'when to use virtual editing: "block", "insert", "all"\nand/or "onemore"' },
440    { 'eventignore', N_ 'list of autocommand events which are to be ignored' },
441    { 'eventignorewin', N_ 'list of autocommand events which are to be ignored in a window' },
442    { 'loadplugins', N_ 'load plugin scripts when starting up' },
443    { 'exrc', N_ 'enable reading .vimrc/.exrc/.gvimrc in the current directory' },
444    { 'maxfuncdepth', N_ 'maximum depth of function calls' },
445    { 'sessionoptions', N_ 'list of words that specifies what to put in a session file' },
446    { 'viewoptions', N_ 'list of words that specifies what to save for :mkview' },
447    { 'viewdir', N_ 'directory where to store files with :mkview' },
448    { 'shada', N_ 'list that specifies what to write in the ShaDa file' },
449    { 'shadafile', N_ 'overrides the filename used for shada' },
450    { 'bufhidden', N_ "what happens with a buffer when it's no longer in a window" },
451    { 'buftype', N_ 'empty, "nofile", "nowrite", "quickfix", etc.: type of buffer' },
452    { 'buflisted', N_ 'whether the buffer shows up in the buffer list' },
453    { 'debug', N_ 'set to "msg" to see all error messages' },
454    { 'signcolumn', N_ 'whether to show the signcolumn' },
455    { 'pyxversion', N_ 'whether to use Python 2 or 3' },
456    { 'inccommand', N_ 'live preview of substitution' },
457    { 'busy', N_ 'buffer is busy' },
458    { 'termpastefilter', N_ 'characters removed when pasting into terminal window' },
459    { 'scrollback', N_ 'number of lines kept beyond the visible screen in terminal buffer' },
460    { 'ttyfast', N_ 'assume terminal responds quickly, enabling more features' },
461    { 'packlockfile', N_ 'sets the path used for vim.pack lockfile' },
462  },
463}
464
465local local_to_window = N_ '(local to window)'
466local local_to_buffer = N_ '(local to buffer)'
467local local_to_tabpage = N_ '(local to tabpage)'
468local global_or_local_to_buffer = N_ '(global or local to buffer)'
469local global_or_local_to_window = N_ '(global or local to window)'
470local global_or_local_to_tabpage = N_ '(global or local to tabpage)'
471
472local lines = {
473  N_ '" Each "set" line shows the current value of an option (on the left).',
474  N_ '" Hit <Enter> on a "set" line to execute it.',
475  N_ '"            A boolean option will be toggled.',
476  N_ '"            For other options you can edit the value before hitting <Enter>.',
477  N_ '" Hit <Enter> on a help line to open a help window on this option.',
478  N_ '" Hit <Enter> on an index line to jump there.',
479  N_ '" Hit <Space> on a "set" line to refresh it.',
480  '',
481}
482
483for header_number, options in ipairs(options_list) do
484  table.insert(lines, ('%2d %s'):format(header_number, options.header))
485end
486table.insert(lines, '')
487
488for header_number, options in ipairs(options_list) do
489  table.insert(lines, '')
490  table.insert(lines, ('%2d %s'):format(header_number, options.header))
491  table.insert(lines, '')
492  for _, opt_desc_and_name in ipairs(options) do
493    local name, desc = unpack(opt_desc_and_name)
494
495    vim.list_extend(
496      lines,
497      vim.split(
498        ('%s%s\t%s'):format(name, #name >= 15 and '\n' or '', desc:gsub('\n', '\n\t')),
499        '\n'
500      )
501    )
502
503    local info = vim.api.nvim_get_option_info2(name, {})
504
505    if info.scope == 'buf' and info.global_local then
506      table.insert(lines, '\t' .. global_or_local_to_buffer)
507    elseif info.scope == 'win' and info.global_local then
508      table.insert(lines, '\t' .. global_or_local_to_window)
509    elseif info.scope == 'tab' and info.global_local then
510      table.insert(lines, '\t' .. global_or_local_to_tabpage)
511    elseif info.scope == 'buf' then
512      table.insert(lines, '\t' .. local_to_buffer)
513    elseif info.scope == 'win' then
514      table.insert(lines, '\t' .. local_to_window)
515    elseif info.scope == 'tab' then
516      table.insert(lines, '\t' .. local_to_tabpage)
517    end
518
519    local shortname = info.shortname or name
520    if shortname == '' then
521      shortname = name
522    end
523
524    if info.type == 'boolean' then
525      if vim.o[name] then
526        table.insert(lines, (' \tset %s\tno%s'):format(shortname, shortname))
527      else
528        table.insert(lines, (' \tset no%s\t%s'):format(shortname, shortname))
529      end
530    else
531      local value = vim.o[name] --[[@as string]]
532      table.insert(lines, (' \tset %s=%s'):format(shortname, value))
533    end
534  end
535end
536
537--- An optwin buffer has 5 types of lines (given pattern):
538--- '^".*'       : comment (other)
539--- '^ *[0-9]+'  : header (header)
540--- '^[^\ts].*'  : option header + description (opt-desc)
541--- '^\t.*'      : description continuation (desc-cont)
542--- '^ \tset .*' : option set (set)
543---
544---@param line string
545---@return 'set'|'opt-desc'|'desc-cont'|'header'|'other'
546local function line_get_type(line)
547  if line:find('^ \tset ') then
548    return 'set'
549  elseif line:find('^%s-[0-9]') then
550    return 'header'
551  elseif line:find('^\t') then
552    return 'desc-cont'
553  elseif line:find('^[a-z]') then
554    return 'opt-desc'
555  end
556  return 'other'
557end
558
559---@return integer
560local function find_window_to_have_options_in()
561  local thiswin = vim.fn.winnr()
562  local altwin = vim.fn.winnr('#')
563
564  if vim.bo[vim.fn.winbufnr(altwin)].filetype == 'help' then
565    altwin = altwin + 1
566    if altwin == thiswin then
567      altwin = altwin + 1 --[[@as integer]]
568    end
569  end
570
571  if
572    altwin == 0
573    or altwin == thiswin
574    or vim.fn.winnr('$') < altwin
575    or vim.bo[vim.fn.winbufnr(altwin)].filetype == 'help'
576  then
577    return vim.fn.win_getid(thiswin)
578  end
579
580  return vim.fn.win_getid(altwin)
581end
582
583local function update_current_line()
584  local line = vim.api.nvim_get_current_line()
585  if line_get_type(line) ~= 'set' then
586    return
587  end
588
589  ---@type string
590  local name
591  if line:find('=') then
592    name = assert(line:match('^ \tset (.-)='))
593  else
594    name = assert(line:match('^ \tset ([a-z]*)')):gsub('^no', '') --[[@as string]]
595  end
596
597  local info = vim.api.nvim_get_option_info2(name, {})
598
599  ---@type any
600  local value
601  if info.global_local or info.scope == 'global' or info.scope == 'tab' then
602    value = vim.o[name] --[[@as any]]
603  else
604    local win = find_window_to_have_options_in()
605
606    value = vim._with({
607      win = win,
608    }, function()
609      return vim.o[name]
610    end)
611  end
612
613  if info.type == 'boolean' then
614    if value then
615      vim.api.nvim_set_current_line((' \tset %s\tno%s'):format(name, name))
616    else
617      vim.api.nvim_set_current_line((' \tset no%s\t%s'):format(name, name))
618    end
619  else
620    vim.api.nvim_set_current_line((' \tset %s=%s'):format(name, value))
621  end
622end
623
624local function current_line_set_option()
625  local line = vim.api.nvim_get_current_line()
626  if line_get_type(line) ~= 'set' then
627    return
628  end
629
630  ---@type string?
631  local name
632  ---@type string|boolean|integer?
633  local value
634  if line:find('=') then
635    name, value = line:match('^ \tset (.-)=(.*)')
636  else
637    local option = assert(line:match('^ \tset ([a-z]*)'))
638    name = option:gsub('^no', '') --[[@as string]]
639    value = vim.startswith(option, 'no')
640  end
641  assert(name and value ~= nil)
642
643  local info = vim.api.nvim_get_option_info2(name, {})
644
645  if info.type == 'number' then
646    value = vim._assert_integer(value)
647  end
648
649  if info.global_local or info.scope == 'global' or info.scope == 'tab' then
650    ---@diagnostic disable-next-line: no-unknown
651    vim.o[name] = value
652  else
653    local win = find_window_to_have_options_in()
654
655    vim._with({
656      win = win,
657    }, function()
658      ---@diagnostic disable-next-line: no-unknown
659      vim.o[name] = value
660    end)
661  end
662
663  update_current_line()
664end
665
666local buf = vim.fn.bufnr('nvim-optwin://optwin')
667if buf >= 0 then
668  local winids = vim.fn.win_findbuf(buf)
669  if #winids > 0 and vim.fn.win_gotoid(winids[1]) == 1 then
670    return
671  end
672
673  vim.cmd((vim.env.OPTWIN_CMD or '') .. ' new nvim-optwin://optwin')
674else
675  vim.cmd((vim.env.OPTWIN_CMD or '') .. ' new nvim-optwin://optwin')
676
677  buf = vim.api.nvim_get_current_buf()
678  vim.bo[buf].tabstop = 15
679  vim.bo[buf].buftype = 'nofile'
680  vim.api.nvim_buf_set_lines(buf, 0, -1, true, lines)
681
682  vim.bo[buf].filetype = 'vim'
683  vim.cmd [[
684  syn match optwinHeader "^ \=[0-9].*"
685  syn match optwinName "^[a-z]*\t" nextgroup=optwinComment
686  syn match optwinComment ".*" contained
687  syn match optwinComment "^\t.*"
688  if !exists("did_optwin_syntax_inits")
689    let did_optwin_syntax_inits = 1
690    hi link optwinHeader Title
691    hi link optwinName Identifier
692    hi link optwinComment Comment
693  endif
694  ]]
695
696  vim.keymap.set({ 'n', 'i' }, '<CR>', function()
697    local lnum = vim.fn.search('^[^\t]', 'bcWn')
698    local line = vim.fn.getline(lnum)
699
700    local line_type = line_get_type(line)
701
702    if line_type == 'set' then
703      current_line_set_option()
704    elseif line_type == 'header' then
705      vim.fn.search(line, 'w')
706    elseif line_type == 'opt-desc' then
707      local name = assert(line:match('[^\t]*'))
708      vim.cmd.help(("'%s'"):format(name))
709    end
710  end, { buf = buf })
711
712  vim.keymap.set({ 'n', 'i' }, '<space>', update_current_line, { buf = buf })
713end
714
715vim.cmd '1'