From caa9419355456e85f27006291abc6643d83f01a7 Mon Sep 17 00:00:00 2001 From: altermo <107814000+altermo@users.noreply.github.com> Date: Thu, 20 Nov 2025 05:43:15 +0100 Subject: [PATCH] refactor!: optwin.lua #36505 Co-authored-by: zeertzjq Co-authored-by: Justin M. Keyes --- runtime/optwin.vim | 1340 ------------------------ runtime/scripts/optwin.lua | 713 +++++++++++++ src/nvim/option.c | 2 +- src/nvim/po/CMakeLists.txt | 8 +- src/nvim/vim_defs.h | 2 +- test/functional/plugin/optwin_spec.lua | 101 ++ test/old/testdir/test_options.vim | 14 +- 7 files changed, 824 insertions(+), 1356 deletions(-) delete mode 100644 runtime/optwin.vim create mode 100644 runtime/scripts/optwin.lua create mode 100644 test/functional/plugin/optwin_spec.lua diff --git a/runtime/optwin.vim b/runtime/optwin.vim deleted file mode 100644 index e142a39f8e..0000000000 --- a/runtime/optwin.vim +++ /dev/null @@ -1,1340 +0,0 @@ -" These commands create the option window. -" -" Maintainer: The Vim Project -" Last Change: 2025 Sep 30 -" Former Maintainer: Bram Moolenaar - -" If there already is an option window, jump to that one. -let buf = bufexists('option-window') ? bufnr('option-window') : -1 -if buf >= 0 - let winids = win_findbuf(buf) - if len(winids) > 0 - if win_gotoid(winids[0]) == 1 - finish - endif - endif -endif - -" Make sure the '<' flag is not included in 'cpoptions', otherwise would -" not be recognized. See ":help 'cpoptions'". -let s:cpo_save = &cpo -set cpo&vim - -" function to be called when is hit in the option-window -func CR() - - " If on a continued comment line, go back to the first comment line - let lnum = search("^[^\t]", 'bWcn') - let line = getline(lnum) - - " on a "set" line executes the option line - if match(line, "^ \tset ") >= 0 - - " For a local option: go to the previous window - " If this is a help window, go to the window below it - let thiswin = winnr() - let local = Find(lnum) - if local >= 0 - exe line - call Update(lnum, line, local, thiswin) - endif - - " on a "option" line shows help for that option - elseif match(line, "^[a-z]") >= 0 - let name = substitute(line, '\([^\t]*\).*', '\1', "") - exe "help '" . name . "'" - - " on an index line jumps to the group - elseif match(line, '^ \=[0-9]') >= 0 - exe "norm! /" . line . "\zt" - endif -endfunc - -" function to be called when is hit in the option-window -func Space() - - let lnum = line(".") - let line = getline(lnum) - - " on a "set" line refreshes the option line - if match(line, "^ \tset ") >= 0 - - " For a local option: go to the previous window - " If this is a help window, go to the window below it - let thiswin = winnr() - let local = Find(lnum) - if local >= 0 - call Update(lnum, line, local, thiswin) - endif - - endif -endfunc - -let s:local_to_window = gettext('(local to window)') -let s:local_to_buffer = gettext('(local to buffer)') -let s:global_or_local = gettext('(global or local to buffer)') - -" find the window in which the option applies -" returns 0 for global option, 1 for local option, -1 for error -func Find(lnum) - let line = getline(a:lnum - 1) - if line =~ s:local_to_window || line =~ s:local_to_buffer - let local = 1 - let thiswin = winnr() - wincmd p - if exists("b:current_syntax") && b:current_syntax == "help" - wincmd j - if winnr() == thiswin - wincmd j - endif - endif - else - let local = 0 - endif - if local && (winnr() == thiswin || (exists("b:current_syntax") - \ && b:current_syntax == "help")) - echo "Don't know in which window" - let local = -1 - endif - return local -endfunc - -" Update a "set" line in the option window -func Update(lnum, line, local, thiswin) - " get the new value of the option and update the option window line - if match(a:line, "=") >= 0 - let name = substitute(a:line, '^ \tset \([^=]*\)=.*', '\1', "") - else - let name = substitute(a:line, '^ \tset \(no\)\=\([a-z]*\).*', '\2', "") - endif - let val = escape(eval('&' . name), " \t\\\"|") - if a:local - exe a:thiswin . "wincmd w" - endif - if match(a:line, "=") >= 0 || (val != "0" && val != "1") - call setline(a:lnum, " \tset " . name . "=" . val) - else - if val - call setline(a:lnum, " \tset " . name . "\tno" . name) - else - call setline(a:lnum, " \tset no" . name . "\t" . name) - endif - endif - set nomodified -endfunc - -" Reset 'title' and 'icon' to make it work faster. -" Reset 'undolevels' to avoid undo'ing until the buffer is empty. -let s:old_title = &title -let s:old_icon = &icon -let s:old_sc = &sc -let s:old_ru = &ru -let s:old_ul = &ul -set notitle noicon nosc noru ul=-1 - -" If the current window is a help window, try finding a non-help window. -" Relies on syntax highlighting to be switched on. -let s:thiswin = winnr() -while exists("b:current_syntax") && b:current_syntax == "help" - wincmd w - if s:thiswin == winnr() - break - endif -endwhile - -" Open the window. $OPTWIN_CMD is set to "tab" for ":tab options". -exe $OPTWIN_CMD . ' new option-window' -setlocal ts=15 tw=0 noro buftype=nofile - -" Insert help and a "set" command for each option. -call append(0, gettext('" Each "set" line shows the current value of an option (on the left).')) -call append(1, gettext('" Hit on a "set" line to execute it.')) -call append(2, gettext('" A boolean option will be toggled.')) -call append(3, gettext('" For other options you can edit the value before hitting .')) -call append(4, gettext('" Hit on a help line to open a help window on this option.')) -call append(5, gettext('" Hit on an index line to jump there.')) -call append(6, gettext('" Hit on a "set" line to refresh it.')) - -" These functions are called often below. Keep them fast! - -" Add an option name and explanation. The text can contain "\n" characters -" where a line break is to be inserted. -func AddOption(name, text) - let lines = split(a:text, "\n") - call append("$", a:name .. "\t" .. lines[0]) - for line in lines[1:] - call append("$", "\t" .. line) - endfor -endfunc - -" Init a local binary option -func BinOptionL(name) - let val = getwinvar(winnr('#'), '&' . a:name) - call append("$", substitute(substitute(" \tset " . val . a:name . "\t" . - \!val . a:name, "0", "no", ""), "1", "", "")) -endfunc - -" Init a global binary option -func BinOptionG(name, val) - call append("$", substitute(substitute(" \tset " . a:val . a:name . "\t" . - \!a:val . a:name, "0", "no", ""), "1", "", "")) -endfunc - -" Init a local string option -func OptionL(name) - let val = escape(getwinvar(winnr('#'), '&' . a:name), " \t\\\"|") - call append("$", " \tset " . a:name . "=" . val) -endfunc - -" Init a global string option -func OptionG(name, val) - call append("$", " \tset " . a:name . "=" . escape(a:val, " \t\\\"|")) -endfunc - -let s:idx = 1 -let s:lnum = line("$") -call append("$", "") - -func Header(text) - let line = s:idx . " " . a:text - if s:idx < 10 - let line = " " . line - endif - call append("$", "") - call append("$", line) - call append("$", "") - call append(s:lnum, line) - let s:idx = s:idx + 1 - let s:lnum = s:lnum + 1 -endfunc - -" Restore the previous value of 'cpoptions' here, it's used below. -let &cpo = s:cpo_save - -" List of all options, organized by function. -" The text should be sufficient to know what the option is used for. - -call Header(gettext("important")) -call AddOption("compatible", gettext("behave very Vi compatible (not advisable)")) -call BinOptionG("cp", &cp) -call AddOption("cpoptions", gettext("list of flags to specify Vi compatibility")) -call OptionG("cpo", &cpo) -call AddOption("paste", gettext("paste mode, insert typed text literally")) -call BinOptionG("paste", &paste) -call AddOption("runtimepath", gettext("list of directories used for runtime files and plugins")) -call OptionG("rtp", &rtp) -call AddOption("packpath", gettext("list of directories used for plugin packages")) -call OptionG("pp", &pp) -call AddOption("helpfile", gettext("name of the main help file")) -call OptionG("hf", &hf) - - -call Header(gettext("moving around, searching and patterns")) -call AddOption("whichwrap", gettext("list of flags specifying which commands wrap to another line")) -call OptionG("ww", &ww) -call AddOption("startofline", gettext("many jump commands move the cursor to the first non-blank\ncharacter of a line")) -call BinOptionG("sol", &sol) -call AddOption("paragraphs", gettext("nroff macro names that separate paragraphs")) -call OptionG("para", ¶) -call AddOption("sections", gettext("nroff macro names that separate sections")) -call OptionG("sect", §) -call AddOption("path", gettext("list of directory names used for file searching")) -call append("$", "\t" .. s:global_or_local) -call OptionG("pa", &pa) -call AddOption("cdhome", gettext(":cd without argument goes to the home directory")) -call BinOptionG("cdh", &cdh) -call AddOption("cdpath", gettext("list of directory names used for :cd")) -call OptionG("cd", &cd) -if exists("+autochdir") - call AddOption("autochdir", gettext("change to directory of file in buffer")) - call BinOptionG("acd", &acd) -endif -call AddOption("wrapscan", gettext("search commands wrap around the end of the buffer")) -call BinOptionG("ws", &ws) -call AddOption("incsearch", gettext("show match for partly typed search command")) -call BinOptionG("is", &is) -call AddOption("magic", gettext("change the way backslashes are used in search patterns")) -call BinOptionG("magic", &magic) -call AddOption("regexpengine", gettext("select the default regexp engine used")) -call OptionG("re", &re) -call AddOption("ignorecase", gettext("ignore case when using a search pattern")) -call BinOptionG("ic", &ic) -call AddOption("smartcase", gettext("override 'ignorecase' when pattern has upper case characters")) -call BinOptionG("scs", &scs) -call AddOption("maxsearchcount", gettext("maximum number for the search count feature")) -call OptionG("msc", &msc) -call AddOption("casemap", gettext("what method to use for changing case of letters")) -call OptionG("cmp", &cmp) -call AddOption("maxmempattern", gettext("maximum amount of memory in Kbyte used for pattern matching")) -call append("$", " \tset mmp=" . &mmp) -call AddOption("define", gettext("pattern for a macro definition line")) -call append("$", "\t" .. s:global_or_local) -call OptionG("def", &def) -if has("find_in_path") - call AddOption("include", gettext("pattern for an include-file line")) - call append("$", "\t" .. s:local_to_buffer) - call OptionL("inc") - call AddOption("includeexpr", gettext("expression used to transform an include line to a file name")) - call append("$", "\t" .. s:local_to_buffer) - call OptionL("inex") -endif - - -call Header(gettext("tags")) -call AddOption("tagbsearch", gettext("use binary searching in tags files")) -call BinOptionG("tbs", &tbs) -call AddOption("taglength", gettext("number of significant characters in a tag name or zero")) -call append("$", " \tset tl=" . &tl) -call AddOption("tags", gettext("list of file names to search for tags")) -call append("$", "\t" .. s:global_or_local) -call OptionG("tag", &tag) -call AddOption("tagcase", gettext("how to handle case when searching in tags files:\n\"followic\" to follow 'ignorecase', \"ignore\" or \"match\"")) -call append("$", "\t" .. s:global_or_local) -call OptionG("tc", &tc) -call AddOption("tagrelative", gettext("file names in a tags file are relative to the tags file")) -call BinOptionG("tr", &tr) -call AddOption("tagstack", gettext("a :tag command will use the tagstack")) -call BinOptionG("tgst", &tgst) -call AddOption("showfulltag", gettext("when completing tags in Insert mode show more info")) -call BinOptionG("sft", &sft) -if has("eval") - call AddOption("tagfunc", gettext("a function to be used to perform tag searches")) - call append("$", "\t" .. s:local_to_buffer) - call OptionL("tfu") -endif - - -call Header(gettext("displaying text")) -call AddOption("scroll", gettext("number of lines to scroll for CTRL-U and CTRL-D")) -call append("$", "\t" .. s:local_to_window) -call OptionL("scr") -call AddOption("smoothscroll", gettext("scroll by screen line")) -call append("$", "\t" .. s:local_to_window) -call BinOptionL("sms") -call AddOption("scrolloff", gettext("number of screen lines to show around the cursor")) -call append("$", " \tset so=" . &so) -call AddOption("wrap", gettext("long lines wrap")) -call append("$", "\t" .. s:local_to_window) -call BinOptionL("wrap") -call AddOption("linebreak", gettext("wrap long lines at a character in 'breakat'")) -call append("$", "\t" .. s:local_to_window) -call BinOptionL("lbr") -call AddOption("breakindent", gettext("preserve indentation in wrapped text")) -call append("$", "\t" .. s:local_to_window) -call BinOptionL("bri") -call AddOption("breakindentopt", gettext("adjust breakindent behaviour")) -call append("$", "\t" .. s:local_to_window) -call OptionL("briopt") -call AddOption("breakat", gettext("which characters might cause a line break")) -call OptionG("brk", &brk) -call AddOption("showbreak", gettext("string to put before wrapped screen lines")) -call OptionG("sbr", &sbr) -call AddOption("sidescroll", gettext("minimal number of columns to scroll horizontally")) -call append("$", " \tset ss=" . &ss) -call AddOption("sidescrolloff", gettext("minimal number of columns to keep left and right of the cursor")) -call append("$", " \tset siso=" . &siso) -call AddOption("display", gettext("include \"lastline\" to show the last line even if it doesn't fit\ninclude \"uhex\" to show unprintable characters as a hex number")) -call OptionG("dy", &dy) -call AddOption("fillchars", gettext("characters to use for the status line, folds, diffs,\nbuffer text, filler lines and truncation in the completion menu")) -call OptionG("fcs", &fcs) -call AddOption("cmdheight", gettext("number of lines used for the command-line")) -call append("$", " \tset ch=" . &ch) -call AddOption("columns", gettext("width of the display")) -call append("$", " \tset co=" . &co) -call AddOption("lines", gettext("number of lines in the display")) -call append("$", " \tset lines=" . &lines) -call AddOption("window", gettext("number of lines to scroll for CTRL-F and CTRL-B")) -call append("$", " \tset window=" . &window) -call AddOption("lazyredraw", gettext("don't redraw while executing macros")) -call BinOptionG("lz", &lz) -if has("reltime") - call AddOption("redrawtime", gettext("timeout for 'hlsearch' and :match highlighting in msec")) - call append("$", " \tset rdt=" . &rdt) -endif -call AddOption("writedelay", gettext("delay in msec for each char written to the display\n(for debugging)")) -call append("$", " \tset wd=" . &wd) -call AddOption("list", gettext("show as ^I and end-of-line as $")) -call append("$", "\t" .. s:local_to_window) -call BinOptionL("list") -call AddOption("listchars", gettext("list of strings used for list mode")) -call OptionG("lcs", &lcs) -call AddOption("number", gettext("show the line number for each line")) -call append("$", "\t" .. s:local_to_window) -call BinOptionL("nu") -call AddOption("relativenumber", gettext("show the relative line number for each line")) -call append("$", "\t" .. s:local_to_window) -call BinOptionL("rnu") -if has("linebreak") - call AddOption("numberwidth", gettext("number of columns to use for the line number")) - call append("$", "\t" .. s:local_to_window) - call OptionL("nuw") -endif -if has("quickfix") - call AddOption("chistory", gettext("maximum number of quickfix lists that can be stored in history")) - call OptionL("chi") - call AddOption("lhistory", gettext("maximum number of location lists that can be stored in history")) - call append("$", "\t" .. s:local_to_window) - call OptionL("lhi") -endif -if has("conceal") - call AddOption("conceallevel", gettext("controls whether concealable text is hidden")) - call append("$", "\t" .. s:local_to_window) - call OptionL("cole") - call AddOption("concealcursor", gettext("modes in which text in the cursor line can be concealed")) - call append("$", "\t" .. s:local_to_window) - call OptionL("cocu") -endif - - -call Header(gettext("syntax, highlighting and spelling")) -call AddOption("background", gettext("\"dark\" or \"light\"; the background color brightness")) -call OptionG("bg", &bg) -call AddOption("filetype", gettext("type of file; triggers the FileType event when set")) -call append("$", "\t" .. s:local_to_buffer) -call OptionL("ft") -if has("syntax") - call AddOption("syntax", gettext("name of syntax highlighting used")) - call append("$", "\t" .. s:local_to_buffer) - call OptionL("syn") - call AddOption("synmaxcol", gettext("maximum column to look for syntax items")) - call append("$", "\t" .. s:local_to_buffer) - call OptionL("smc") -endif -call AddOption("highlight", gettext("which highlighting to use for various occasions")) -call OptionG("hl", &hl) -call AddOption("hlsearch", gettext("highlight all matches for the last used search pattern")) -call BinOptionG("hls", &hls) -if has("termguicolors") - call AddOption("termguicolors", gettext("use GUI colors for the terminal")) - call BinOptionG("tgc", &tgc) -endif -if has("syntax") - call AddOption("cursorcolumn", gettext("highlight the screen column of the cursor")) - call append("$", "\t" .. s:local_to_window) - call BinOptionL("cuc") - call AddOption("cursorline", gettext("highlight the screen line of the cursor")) - call append("$", "\t" .. s:local_to_window) - call BinOptionL("cul") - call AddOption("cursorlineopt", gettext("specifies which area 'cursorline' highlights")) - call append("$", "\t" .. s:local_to_window) - call OptionL("culopt") - call AddOption("colorcolumn", gettext("columns to highlight")) - call append("$", "\t" .. s:local_to_window) - call OptionL("cc") - call AddOption("spell", gettext("highlight spelling mistakes")) - call append("$", "\t" .. s:local_to_window) - call BinOptionL("spell") - call AddOption("spelllang", gettext("list of accepted languages")) - call append("$", "\t" .. s:local_to_buffer) - call OptionL("spl") - call AddOption("spellfile", gettext("file that \"zg\" adds good words to")) - call append("$", "\t" .. s:local_to_buffer) - call OptionL("spf") - call AddOption("spellcapcheck", gettext("pattern to locate the end of a sentence")) - call append("$", "\t" .. s:local_to_buffer) - call OptionL("spc") - call AddOption("spelloptions", gettext("flags to change how spell checking works")) - call append("$", "\t" .. s:local_to_buffer) - call OptionL("spo") - call AddOption("spellsuggest", gettext("methods used to suggest corrections")) - call OptionG("sps", &sps) - call AddOption("mkspellmem", gettext("amount of memory used by :mkspell before compressing")) - call OptionG("msm", &msm) -endif - - -call Header(gettext("multiple windows")) -call AddOption("laststatus", gettext("0, 1, 2 or 3; when to use a status line for the last window")) -call append("$", " \tset ls=" . &ls) -if has("statusline") - call AddOption("statuscolumn", gettext("custom format for the status column")) - call append("$", "\t" .. s:local_to_window) - call OptionG("stc", &stc) - call AddOption("statusline", gettext("alternate format to be used for a status line")) - call OptionG("stl", &stl) -endif -call append("$", "\t" .. s:local_to_window) -call AddOption("equalalways", gettext("make all windows the same size when adding/removing windows")) -call BinOptionG("ea", &ea) -call AddOption("eadirection", gettext("in which direction 'equalalways' works: \"ver\", \"hor\" or \"both\"")) -call OptionG("ead", &ead) -call AddOption("winheight", gettext("minimal number of lines used for the current window")) -call append("$", " \tset wh=" . &wh) -call AddOption("winminheight", gettext("minimal number of lines used for any window")) -call append("$", " \tset wmh=" . &wmh) -call AddOption("winfixbuf", gettext("keep window focused on a single buffer")) -call OptionG("wfb", &wfb) -call AddOption("winfixheight", gettext("keep the height of the window")) -call append("$", "\t" .. s:local_to_window) -call BinOptionL("wfh") -call AddOption("winfixwidth", gettext("keep the width of the window")) -call append("$", "\t" .. s:local_to_window) -call BinOptionL("wfw") -call AddOption("winwidth", gettext("minimal number of columns used for the current window")) -call append("$", " \tset wiw=" . &wiw) -call AddOption("winminwidth", gettext("minimal number of columns used for any window")) -call append("$", " \tset wmw=" . &wmw) -call AddOption("helpheight", gettext("initial height of the help window")) -call append("$", " \tset hh=" . &hh) -if has("quickfix") - " call AddOption("previewpopup", gettext("use a popup window for preview")) - " call append("$", " \tset pvp=" . &pvp) - call AddOption("previewheight", gettext("default height for the preview window")) - call append("$", " \tset pvh=" . &pvh) - call AddOption("previewwindow", gettext("identifies the preview window")) - call append("$", "\t" .. s:local_to_window) - call BinOptionL("pvw") -endif -call AddOption("hidden", gettext("don't unload a buffer when no longer shown in a window")) -call BinOptionG("hid", &hid) -call AddOption("switchbuf", gettext("\"useopen\" and/or \"split\"; which window to use when jumping\nto a buffer")) -call OptionG("swb", &swb) -call AddOption("splitbelow", gettext("a new window is put below the current one")) -call BinOptionG("sb", &sb) -call AddOption("splitkeep", gettext("determines scroll behavior for split windows")) -call OptionG("spk", &spk) -call AddOption("splitright", gettext("a new window is put right of the current one")) -call BinOptionG("spr", &spr) -call AddOption("scrollbind", gettext("this window scrolls together with other bound windows")) -call append("$", "\t" .. s:local_to_window) -call BinOptionL("scb") -call AddOption("scrollopt", gettext("\"ver\", \"hor\" and/or \"jump\"; list of options for 'scrollbind'")) -call OptionG("sbo", &sbo) -call AddOption("cursorbind", gettext("this window's cursor moves together with other bound windows")) -call append("$", "\t" .. s:local_to_window) -call BinOptionL("crb") -if has("terminal") - call AddOption("termsize", gettext("size of a terminal window")) - call append("$", "\t" .. s:local_to_window) - call OptionL("tms") - call AddOption("termkey", gettext("key that precedes Vim commands in a terminal window")) - call append("$", "\t" .. s:local_to_window) - call OptionL("tk") -endif - - -call Header(gettext("multiple tab pages")) -call AddOption("showtabline", gettext("0, 1 or 2; when to use a tab pages line")) -call append("$", " \tset stal=" . &stal) -call AddOption("tabclose", gettext("behaviour when closing tab pages: left, uselast or empty")) -call append("$", " \tset tcl=" . &tcl) -call AddOption("tabpagemax", gettext("maximum number of tab pages to open for -p and \"tab all\"")) -call append("$", " \tset tpm=" . &tpm) -call AddOption("tabline", gettext("custom tab pages line")) -call OptionG("tal", &tal) -if has("gui") - call AddOption("guitablabel", gettext("custom tab page label for the GUI")) - call OptionG("gtl", >l) - call AddOption("guitabtooltip", gettext("custom tab page tooltip for the GUI")) - call OptionG("gtt", >t) -endif - - -call Header(gettext("terminal")) -call AddOption("scrolljump", gettext("minimal number of lines to scroll at a time")) -call append("$", " \tset sj=" . &sj) -if has("gui") || has("msdos") || has("win32") - call AddOption("guicursor", gettext("specifies what the cursor looks like in different modes")) - call OptionG("gcr", &gcr) -endif -if has("title") - let &title = s:old_title - call AddOption("title", gettext("show info in the window title")) - call BinOptionG("title", &title) - set notitle - call AddOption("titlelen", gettext("percentage of 'columns' used for the window title")) - call append("$", " \tset titlelen=" . &titlelen) - call AddOption("titlestring", gettext("when not empty, string to be used for the window title")) - call OptionG("titlestring", &titlestring) - call AddOption("titleold", gettext("string to restore the title to when exiting Vim")) - call OptionG("titleold", &titleold) - let &icon = s:old_icon - call AddOption("icon", gettext("set the text of the icon for this window")) - call BinOptionG("icon", &icon) - set noicon - call AddOption("iconstring", gettext("when not empty, text for the icon of this window")) - call OptionG("iconstring", &iconstring) -endif - - -call Header(gettext("using the mouse")) -call AddOption("mouse", gettext("list of flags for using the mouse")) -call OptionG("mouse", &mouse) -if has("gui") - call AddOption("mousefocus", gettext("the window with the mouse pointer becomes the current one")) - call BinOptionG("mousef", &mousef) - call AddOption("mousehide", gettext("hide the mouse pointer while typing")) - call BinOptionG("mh", &mh) -endif -call AddOption("mousemodel", gettext("\"extend\", \"popup\" or \"popup_setpos\"; what the right\nmouse button is used for")) -call OptionG("mousem", &mousem) -call AddOption("mousetime", gettext("maximum time in msec to recognize a double-click")) -call append("$", " \tset mouset=" . &mouset) -if has("mouseshape") - call AddOption("mouseshape", gettext("what the mouse pointer looks like in different modes")) - call OptionG("mouses", &mouses) -endif - - -if has("gui") - call Header(gettext("GUI")) - call AddOption("guifont", gettext("list of font names to be used in the GUI")) - call OptionG("gfn", &gfn) - if has("xfontset") - call AddOption("guifontset", gettext("pair of fonts to be used, for multibyte editing")) - call OptionG("gfs", &gfs) - endif - call AddOption("guifontwide", gettext("list of font names to be used for double-wide characters")) - call OptionG("gfw", &gfw) - call AddOption("guioptions", gettext("list of flags that specify how the GUI works")) - call OptionG("go", &go) - if has("gui_gtk") - call AddOption("toolbar", gettext("\"icons\", \"text\" and/or \"tooltips\"; how to show the toolbar")) - call OptionG("tb", &tb) - if has("gui_gtk2") - call AddOption("toolbariconsize", gettext("size of toolbar icons")) - call OptionG("tbis", &tbis) - endif - endif - if has("browse") - call AddOption("browsedir", gettext("\"last\", \"buffer\" or \"current\": which directory used for\nthe file browser")) - call OptionG("bsdir", &bsdir) - endif - if has("multi_lang") - call AddOption("langmenu", gettext("language to be used for the menus")) - call OptionG("langmenu", &lm) - endif - call AddOption("menuitems", gettext("maximum number of items in one menu")) - call append("$", " \tset mis=" . &mis) - if has("winaltkeys") - call AddOption("winaltkeys", gettext("\"no\", \"yes\" or \"menu\"; how to use the ALT key")) - call OptionG("wak", &wak) - endif - call AddOption("linespace", gettext("number of pixel lines to use between characters")) - call append("$", " \tset lsp=" . &lsp) - if has("balloon_eval") || has("balloon_eval_term") - call AddOption("balloondelay", gettext("delay in milliseconds before a balloon may pop up")) - call append("$", " \tset bdlay=" . &bdlay) - if has("balloon_eval") - call AddOption("ballooneval", gettext("use balloon evaluation in the GUI")) - call BinOptionG("beval", &beval) - endif - if has("balloon_eval_term") - call AddOption("balloonevalterm", gettext(" \nuse balloon evaluation in the terminal")) - call BinOptionG("bevalterm", &beval) - endif - if has("eval") - call AddOption("balloonexpr", gettext("expression to show in balloon eval")) - call append("$", " \tset bexpr=" . &bexpr) - endif - endif -endif - -call Header(gettext("messages and info")) -call AddOption("terse", gettext("add 's' flag in 'shortmess' (don't show search message)")) -call BinOptionG("terse", &terse) -call AddOption("shortmess", gettext("list of flags to make messages shorter")) -call OptionG("shm", &shm) -call AddOption("messagesopt", gettext("options for outputting messages")) -call OptionG("mopt", &mopt) -call AddOption("showcmd", gettext("show (partial) command keys in location given by 'showcmdloc'")) -let &sc = s:old_sc -call BinOptionG("sc", &sc) -set nosc -call AddOption("showcmdloc", gettext("location where to show the (partial) command keys for 'showcmd'")) - call OptionG("sloc", &sloc) -call AddOption("showmode", gettext("display the current mode in the status line")) -call BinOptionG("smd", &smd) -call AddOption("ruler", gettext("show cursor position below each window")) -let &ru = s:old_ru -call BinOptionG("ru", &ru) -set noru -if has("statusline") - call AddOption("rulerformat", gettext("alternate format to be used for the ruler")) - call OptionG("ruf", &ruf) -endif -call AddOption("report", gettext("threshold for reporting number of changed lines")) -call append("$", " \tset report=" . &report) -call AddOption("verbose", gettext("the higher the more messages are given")) -call append("$", " \tset vbs=" . &vbs) -call AddOption("verbosefile", gettext("file to write messages in")) -call OptionG("vfile", &vfile) -call AddOption("more", gettext("pause listings when the screen is full")) -call BinOptionG("more", &more) -if has("dialog_con") || has("dialog_gui") - call AddOption("confirm", gettext("start a dialog when a command fails")) - call BinOptionG("cf", &cf) -endif -call AddOption("errorbells", gettext("ring the bell for error messages")) -call BinOptionG("eb", &eb) -call AddOption("visualbell", gettext("use a visual bell instead of beeping")) -call BinOptionG("vb", &vb) -call AddOption("belloff", gettext("do not ring the bell for these reasons")) -call OptionG("belloff", &belloff) -if has("multi_lang") - call AddOption("helplang", gettext("list of preferred languages for finding help")) - call OptionG("hlg", &hlg) -endif - - -call Header(gettext("selecting text")) -call AddOption("selection", gettext("\"old\", \"inclusive\" or \"exclusive\"; how selecting text behaves")) -call OptionG("sel", &sel) -call AddOption("selectmode", gettext("\"mouse\", \"key\" and/or \"cmd\"; when to start Select mode\ninstead of Visual mode")) -call OptionG("slm", &slm) -if has("clipboard") - call AddOption("clipboard", gettext("\"unnamed\" to use the * register like unnamed register\n\"autoselect\" to always put selected text on the clipboard")) - call OptionG("cb", &cb) -endif -call AddOption("keymodel", gettext("\"startsel\" and/or \"stopsel\"; what special keys can do")) -call OptionG("km", &km) - - -call Header(gettext("editing text")) -call AddOption("undolevels", gettext("maximum number of changes that can be undone")) -call append("$", "\t" .. s:global_or_local) -call append("$", " \tset ul=" . s:old_ul) -call AddOption("undofile", gettext("automatically save and restore undo history")) -call BinOptionG("udf", &udf) -call AddOption("undodir", gettext("list of directories for undo files")) -call OptionG("udir", &udir) -call AddOption("undoreload", gettext("maximum number lines to save for undo on a buffer reload")) -call append("$", " \tset ur=" . &ur) -call AddOption("modified", gettext("changes have been made and not written to a file")) -call append("$", "\t" .. s:local_to_buffer) -call BinOptionL("mod") -call AddOption("readonly", gettext("buffer is not to be written")) -call append("$", "\t" .. s:local_to_buffer) -call BinOptionL("ro") -call AddOption("modifiable", gettext("changes to the text are possible")) -call append("$", "\t" .. s:local_to_buffer) -call BinOptionL("ma") -call AddOption("textwidth", gettext("line length above which to break a line")) -call append("$", "\t" .. s:local_to_buffer) -call OptionL("tw") -call AddOption("wrapmargin", gettext("margin from the right in which to break a line")) -call append("$", "\t" .. s:local_to_buffer) -call OptionL("wm") -call AddOption("backspace", gettext("specifies what , CTRL-W, etc. can do in Insert mode")) -call append("$", " \tset bs=" . &bs) -call AddOption("comments", gettext("definition of what comment lines look like")) -call append("$", "\t" .. s:local_to_buffer) -call OptionL("com") -call AddOption("formatoptions", gettext("list of flags that tell how automatic formatting works")) -call append("$", "\t" .. s:local_to_buffer) -call OptionL("fo") -call AddOption("formatlistpat", gettext("pattern to recognize a numbered list")) -call append("$", "\t" .. s:local_to_buffer) -call OptionL("flp") -if has("eval") - call AddOption("formatexpr", gettext("expression used for \"gq\" to format lines")) - call append("$", "\t" .. s:local_to_buffer) - call OptionL("fex") -endif -if has("insert_expand") - call AddOption("complete", gettext("specifies how Insert mode completion works for CTRL-N and CTRL-P")) - call append("$", "\t" .. s:local_to_buffer) - call OptionL("cpt") - call AddOption("autocomplete", gettext("automatic completion in insert mode")) - call append("$", "\t" .. s:global_or_local) - call BinOptionG("ac", &ac) - call AddOption("autocompletetimeout", gettext(" \ninitial decay timeout for 'autocomplete' algorithm")) - call append("$", " \tset act=" . &act) - call AddOption("completetimeout", gettext(" \ninitial decay timeout for CTRL-N and CTRL-P completion")) - call append("$", " \tset cto=" . &cto) - call AddOption("autocompletedelay", gettext(" \ndelay in msec before menu appears after typing")) - call append("$", " \tset acl=" . &acl) - call AddOption("completeopt", gettext("whether to use a popup menu for Insert mode completion")) - call OptionL("cot") - call AddOption("completeitemalign", gettext(" \npopup menu item align order")) - call OptionG("cia", &cia) - call AddOption("completefuzzycollect", gettext(" \nuse fuzzy collection for specific completion modes")) - call OptionL("cfc") - if exists("+completepopup") - call AddOption("completepopup", gettext("options for the Insert mode completion info popup")) - call OptionG("cpp", &cpp) - endif - call AddOption("pumheight", gettext("maximum height of the popup menu")) - call OptionG("ph", &ph) - call AddOption("pumwidth", gettext("minimum width of the popup menu")) - call OptionG("pw", &pw) - call AddOption("pummaxwidth", gettext("maximum width of the popup menu")) - call OptionG("pmw", &pmw) - call AddOption("completefunc", gettext("user defined function for Insert mode completion")) - call append("$", "\t" .. s:local_to_buffer) - call OptionL("cfu") - call AddOption("omnifunc", gettext("function for filetype-specific Insert mode completion")) - call append("$", "\t" .. s:local_to_buffer) - call OptionL("ofu") - call AddOption("dictionary", gettext("list of dictionary files for keyword completion")) - call append("$", "\t" .. s:global_or_local) - call OptionG("dict", &dict) - call AddOption("thesaurus", gettext("list of thesaurus files for keyword completion")) - call append("$", "\t" .. s:global_or_local) - call OptionG("tsr", &tsr) - call AddOption("thesaurusfunc", gettext("function used for thesaurus completion")) - call append("$", "\t" .. s:global_or_local) - call OptionG("tsrfu", &tsrfu) -endif -call AddOption("infercase", gettext("adjust case of a keyword completion match")) -call append("$", "\t" .. s:local_to_buffer) -call BinOptionL("inf") -if has("digraphs") - call AddOption("digraph", gettext("enable entering digraphs with c1 c2")) - call BinOptionG("dg", &dg) -endif -call AddOption("tildeop", gettext("the \"~\" command behaves like an operator")) -call BinOptionG("top", &top) -call AddOption("operatorfunc", gettext("function called for the \"g@\" operator")) -call OptionG("opfunc", &opfunc) -call AddOption("showmatch", gettext("when inserting a bracket, briefly jump to its match")) -call BinOptionG("sm", &sm) -call AddOption("matchtime", gettext("tenth of a second to show a match for 'showmatch'")) -call append("$", " \tset mat=" . &mat) -call AddOption("matchpairs", gettext("list of pairs that match for the \"%\" command")) -call append("$", "\t" .. s:local_to_buffer) -call OptionL("mps") -call AddOption("joinspaces", gettext("use two spaces after '.' when joining a line")) -call BinOptionG("js", &js) -call AddOption("nrformats", gettext("\"alpha\", \"octal\", \"hex\", \"bin\" and/or \"unsigned\"; number formats\nrecognized for CTRL-A and CTRL-X commands")) -call append("$", "\t" .. s:local_to_buffer) -call OptionL("nf") - - -call Header(gettext("tabs and indenting")) -call AddOption("tabstop", gettext("number of spaces a in the text stands for")) -call append("$", "\t" .. s:local_to_buffer) -call OptionL("ts") -call AddOption("shiftwidth", gettext("number of spaces used for each step of (auto)indent")) -call append("$", "\t" .. s:local_to_buffer) -call OptionL("sw") -if has("vartabs") - call AddOption("vartabstop", gettext("list of number of spaces a tab counts for")) - call append("$", "\t" .. s:local_to_buffer) - call OptionL("vts") - call AddOption("varsofttabstop", gettext("list of number of spaces a soft tabsstop counts for")) - call append("$", "\t" .. s:local_to_buffer) - call OptionL("vsts") -endif -call AddOption("smarttab", gettext("a in an indent inserts 'shiftwidth' spaces")) -call BinOptionG("sta", &sta) -call AddOption("softtabstop", gettext("if non-zero, number of spaces to insert for a ")) -call append("$", "\t" .. s:local_to_buffer) -call OptionL("sts") -call AddOption("shiftround", gettext("round to 'shiftwidth' for \"<<\" and \">>\"")) -call BinOptionG("sr", &sr) -call AddOption("expandtab", gettext("expand to spaces in Insert mode")) -call append("$", "\t" .. s:local_to_buffer) -call BinOptionL("et") -call AddOption("autoindent", gettext("automatically set the indent of a new line")) -call append("$", "\t" .. s:local_to_buffer) -call BinOptionL("ai") -if has("smartindent") - call AddOption("smartindent", gettext("do clever autoindenting")) - call append("$", "\t" .. s:local_to_buffer) - call BinOptionL("si") -endif -if has("cindent") - call AddOption("cindent", gettext("enable specific indenting for C code")) - call append("$", "\t" .. s:local_to_buffer) - call BinOptionL("cin") - call AddOption("cinoptions", gettext("options for C-indenting")) - call append("$", "\t" .. s:local_to_buffer) - call OptionL("cino") - call AddOption("cinkeys", gettext("keys that trigger C-indenting in Insert mode")) - call append("$", "\t" .. s:local_to_buffer) - call OptionL("cink") - call AddOption("cinwords", gettext("list of words that cause more C-indent")) - call append("$", "\t" .. s:local_to_buffer) - call OptionL("cinw") - call AddOption("cinscopedecls", gettext("list of scope declaration names used by cino-g")) - call append("$", "\t" .. s:local_to_buffer) - call OptionL("cinsd") - call AddOption("indentexpr", gettext("expression used to obtain the indent of a line")) - call append("$", "\t" .. s:local_to_buffer) - call OptionL("inde") - call AddOption("indentkeys", gettext("keys that trigger indenting with 'indentexpr' in Insert mode")) - call append("$", "\t" .. s:local_to_buffer) - call OptionL("indk") -endif -call AddOption("copyindent", gettext("copy whitespace for indenting from previous line")) -call append("$", "\t" .. s:local_to_buffer) -call BinOptionL("ci") -call AddOption("preserveindent", gettext("preserve kind of whitespace when changing indent")) -call append("$", "\t" .. s:local_to_buffer) -call BinOptionL("pi") -if has("lispindent") - call AddOption("lisp", gettext("enable lisp mode")) - call append("$", "\t" .. s:local_to_buffer) - call BinOptionL("lisp") - call AddOption("lispwords", gettext("words that change how lisp indenting works")) - call OptionL("lw") - call AddOption("lispoptions", gettext("options for Lisp indenting")) - call OptionL("lop") -endif - - -if has("folding") - call Header(gettext("folding")) - call AddOption("foldenable", gettext("unset to display all folds open")) - call append("$", "\t" .. s:local_to_window) - call BinOptionL("fen") - call AddOption("foldlevel", gettext("folds with a level higher than this number will be closed")) - call append("$", "\t" .. s:local_to_window) - call OptionL("fdl") - call AddOption("foldlevelstart", gettext("value for 'foldlevel' when starting to edit a file")) - call append("$", " \tset fdls=" . &fdls) - call AddOption("foldcolumn", gettext("width of the column used to indicate folds")) - call append("$", "\t" .. s:local_to_window) - call OptionL("fdc") - call AddOption("foldtext", gettext("expression used to display the text of a closed fold")) - call append("$", "\t" .. s:local_to_window) - call OptionL("fdt") - call AddOption("foldclose", gettext("set to \"all\" to close a fold when the cursor leaves it")) - call OptionG("fcl", &fcl) - call AddOption("foldopen", gettext("specifies for which commands a fold will be opened")) - call OptionG("fdo", &fdo) - call AddOption("foldminlines", gettext("minimum number of screen lines for a fold to be closed")) - call append("$", "\t" .. s:local_to_window) - call OptionL("fml") - call AddOption("commentstring", gettext("template for comments; used to put the marker in")) - call OptionL("cms") - call AddOption("foldmethod", gettext("folding type: \"manual\", \"indent\", \"expr\", \"marker\",\n\"syntax\" or \"diff\"")) - call append("$", "\t" .. s:local_to_window) - call OptionL("fdm") - call AddOption("foldexpr", gettext("expression used when 'foldmethod' is \"expr\"")) - call append("$", "\t" .. s:local_to_window) - call OptionL("fde") - call AddOption("foldignore", gettext("used to ignore lines when 'foldmethod' is \"indent\"")) - call append("$", "\t" .. s:local_to_window) - call OptionL("fdi") - call AddOption("foldmarker", gettext("markers used when 'foldmethod' is \"marker\"")) - call append("$", "\t" .. s:local_to_window) - call OptionL("fmr") - call AddOption("foldnestmax", gettext("maximum fold depth for when 'foldmethod' is \"indent\" or \"syntax\"")) - call append("$", "\t" .. s:local_to_window) - call OptionL("fdn") -endif - - -if has("diff") - call Header(gettext("diff mode")) - call AddOption("diff", gettext("use diff mode for the current window")) - call append("$", "\t" .. s:local_to_window) - call BinOptionL("diff") - call AddOption("diffopt", gettext("options for using diff mode")) - call OptionG("dip", &dip) - call AddOption("diffexpr", gettext("expression used to obtain a diff file")) - call OptionG("dex", &dex) - call AddOption("diffanchors", gettext("list of addresses for anchoring a diff")) - call append("$", "\t" .. s:global_or_local) - call OptionG("dia", &dia) - call AddOption("patchexpr", gettext("expression used to patch a file")) - call OptionG("pex", &pex) -endif - - -call Header(gettext("mapping")) -call AddOption("maxmapdepth", gettext("maximum depth of mapping")) -call append("$", " \tset mmd=" . &mmd) -call AddOption("timeout", gettext("allow timing out halfway into a mapping")) -call BinOptionG("to", &to) -call AddOption("ttimeout", gettext("allow timing out halfway into a key code")) -call BinOptionG("ttimeout", &ttimeout) -call AddOption("timeoutlen", gettext("time in msec for 'timeout'")) -call append("$", " \tset tm=" . &tm) -call AddOption("ttimeoutlen", gettext("time in msec for 'ttimeout'")) -call append("$", " \tset ttm=" . &ttm) - - -call Header(gettext("reading and writing files")) -call AddOption("modeline", gettext("enable using settings from modelines when reading a file")) -call append("$", "\t" .. s:local_to_buffer) -call BinOptionL("ml") -call AddOption("modelineexpr", gettext("allow setting expression options from a modeline")) -call BinOptionG("mle", &mle) -call AddOption("modelines", gettext("number of lines to check for modelines")) -call append("$", " \tset mls=" . &mls) -call AddOption("binary", gettext("binary file editing")) -call append("$", "\t" .. s:local_to_buffer) -call BinOptionL("bin") -call AddOption("endofline", gettext("last line in the file has an end-of-line")) -call append("$", "\t" .. s:local_to_buffer) -call BinOptionL("eol") -call AddOption("endoffile", gettext("last line in the file followed by CTRL-Z")) -call append("$", "\t" .. s:local_to_buffer) -call BinOptionL("eof") -call AddOption("fixendofline", gettext("fixes missing end-of-line at end of text file")) -call append("$", "\t" .. s:local_to_buffer) -call BinOptionL("fixeol") -call AddOption("bomb", gettext("prepend a Byte Order Mark to the file")) -call append("$", "\t" .. s:local_to_buffer) -call BinOptionL("bomb") -call AddOption("fileformat", gettext("end-of-line format: \"dos\", \"unix\" or \"mac\"")) -call append("$", "\t" .. s:local_to_buffer) -call OptionL("ff") -call AddOption("fileformats", gettext("list of file formats to look for when editing a file")) -call OptionG("ffs", &ffs) -call AddOption("write", gettext("writing files is allowed")) -call BinOptionG("write", &write) -call AddOption("writebackup", gettext("write a backup file before overwriting a file")) -call BinOptionG("wb", &wb) -call AddOption("backup", gettext("keep a backup after overwriting a file")) -call BinOptionG("bk", &bk) -call AddOption("backupskip", gettext("patterns that specify for which files a backup is not made")) -call append("$", " \tset bsk=" . &bsk) -call AddOption("backupcopy", gettext("whether to make the backup as a copy or rename the existing file")) -call append("$", "\t" .. s:global_or_local) -call append("$", " \tset bkc=" . &bkc) -call AddOption("backupdir", gettext("list of directories to put backup files in")) -call OptionG("bdir", &bdir) -call AddOption("backupext", gettext("file name extension for the backup file")) -call OptionG("bex", &bex) -call AddOption("autowrite", gettext("automatically write a file when leaving a modified buffer")) -call BinOptionG("aw", &aw) -call AddOption("autowriteall", gettext("as 'autowrite', but works with more commands")) -call BinOptionG("awa", &awa) -call AddOption("writeany", gettext("always write without asking for confirmation")) -call BinOptionG("wa", &wa) -call AddOption("autoread", gettext("automatically read a file when it was modified outside of Vim")) -call append("$", "\t" .. s:global_or_local) -call BinOptionG("ar", &ar) -call AddOption("patchmode", gettext("keep oldest version of a file; specifies file name extension")) -call OptionG("pm", &pm) -call AddOption("fsync", gettext("forcibly sync the file to disk after writing it")) -call BinOptionG("fs", &fs) - - -call Header(gettext("the swap file")) -call AddOption("directory", gettext("list of directories for the swap file")) -call OptionG("dir", &dir) -call AddOption("swapfile", gettext("use a swap file for this buffer")) -call append("$", "\t" .. s:local_to_buffer) -call BinOptionL("swf") -call AddOption("updatecount", gettext("number of characters typed to cause a swap file update")) -call append("$", " \tset uc=" . &uc) -call AddOption("updatetime", gettext("time in msec after which the swap file will be updated")) -call append("$", " \tset ut=" . &ut) - - -call Header(gettext("command line editing")) -call AddOption("history", gettext("how many command lines are remembered")) -call append("$", " \tset hi=" . &hi) -call AddOption("wildchar", gettext("key that triggers command-line expansion")) -call append("$", " \tset wc=" . &wc) -call AddOption("wildcharm", gettext("like 'wildchar' but can also be used in a mapping")) -call append("$", " \tset wcm=" . &wcm) -call AddOption("wildmode", gettext("specifies how command line completion works")) -call OptionG("wim", &wim) -if has("wildoptions") - call AddOption("wildoptions", gettext("empty or \"tagfile\" to list file name of matching tags")) - call OptionG("wop", &wop) -endif -call AddOption("suffixes", gettext("list of file name extensions that have a lower priority")) -call OptionG("su", &su) -if has("file_in_path") - call AddOption("suffixesadd", gettext("list of file name extensions added when searching for a file")) - call append("$", "\t" .. s:local_to_buffer) - call OptionL("sua") -endif -if has("wildignore") - call AddOption("wildignore", gettext("list of patterns to ignore files for file name completion")) - call OptionG("wig", &wig) -endif -call AddOption("fileignorecase", gettext("ignore case when using file names")) -call BinOptionG("fic", &fic) -call AddOption("wildignorecase", gettext("ignore case when completing file names")) -call BinOptionG("wic", &wic) -if has("wildmenu") - call AddOption("wildmenu", gettext("command-line completion shows a list of matches")) - call BinOptionG("wmnu", &wmnu) -endif -call AddOption("cedit", gettext("key used to open the command-line window")) -call OptionG("cedit", &cedit) -call AddOption("cmdwinheight", gettext("height of the command-line window")) -call OptionG("cwh", &cwh) - - -call Header(gettext("executing external commands")) -call AddOption("shell", gettext("name of the shell program used for external commands")) -call OptionG("sh", &sh) -call AddOption("shellquote", gettext("character(s) to enclose a shell command in")) -call OptionG("shq", &shq) -call AddOption("shellxquote", gettext("like 'shellquote' but include the redirection")) -call OptionG("sxq", &sxq) -call AddOption("shellxescape", gettext("characters to escape when 'shellxquote' is (")) -call OptionG("sxe", &sxe) -call AddOption("shellcmdflag", gettext("argument for 'shell' to execute a command")) -call OptionG("shcf", &shcf) -call AddOption("shellredir", gettext("used to redirect command output to a file")) -call OptionG("srr", &srr) -call AddOption("shelltemp", gettext("use a temp file for shell commands instead of using a pipe")) -call BinOptionG("stmp", &stmp) -call AddOption("equalprg", gettext("program used for \"=\" command")) -call append("$", "\t" .. s:global_or_local) -call OptionG("ep", &ep) -call AddOption("formatprg", gettext("program used to format lines with \"gq\" command")) -call OptionG("fp", &fp) -call AddOption("keywordprg", gettext("program used for the \"K\" command")) -call OptionG("kp", &kp) -call AddOption("warn", gettext("warn when using a shell command and a buffer has changes")) -call BinOptionG("warn", &warn) - - -if has("quickfix") - call Header(gettext("running make and jumping to errors (quickfix)")) - call AddOption("errorfile", gettext("name of the file that contains error messages")) - call OptionG("ef", &ef) - call AddOption("errorformat", gettext("list of formats for error messages")) - call append("$", "\t" .. s:global_or_local) - call OptionG("efm", &efm) - call AddOption("makeprg", gettext("program used for the \":make\" command")) - call append("$", "\t" .. s:global_or_local) - call OptionG("mp", &mp) - call AddOption("shellpipe", gettext("string used to put the output of \":make\" in the error file")) - call OptionG("sp", &sp) - call AddOption("makeef", gettext("name of the errorfile for the 'makeprg' command")) - call OptionG("mef", &mef) - call AddOption("grepprg", gettext("program used for the \":grep\" command")) - call append("$", "\t" .. s:global_or_local) - call OptionG("gp", &gp) - call AddOption("grepformat", gettext("list of formats for output of 'grepprg'")) - call OptionG("gfm", &gfm) - call AddOption("makeencoding", gettext("encoding of the \":make\" and \":grep\" output")) - call append("$", "\t" .. s:global_or_local) - call OptionG("menc", &menc) - call AddOption("quickfixtextfunc", gettext(" \nfunction to display text in the quickfix window")) - call OptionG("qftf", &qftf) -endif - - -if has("win32") - call Header(gettext("system specific")) - call AddOption("shellslash", gettext("use forward slashes in file names; for Unix-like shells")) - call BinOptionG("ssl", &ssl) - call AddOption("completeslash", gettext("specifies slash/backslash used for completion")) - call OptionG("csl", &csl) -endif - - -call Header(gettext("language specific")) -call AddOption("isfname", gettext("specifies the characters in a file name")) -call OptionG("isf", &isf) -call AddOption("isident", gettext("specifies the characters in an identifier")) -call OptionG("isi", &isi) -call AddOption("isexpand", gettext("defines trigger strings for complete_match()")) -call append("$", "\t" .. s:local_to_buffer) -call AddOption("iskeyword", gettext("specifies the characters in a keyword")) -call append("$", "\t" .. s:local_to_buffer) -call OptionL("isk") -call AddOption("isprint", gettext("specifies printable characters")) -call OptionG("isp", &isp) -if has("textobjects") - call AddOption("quoteescape", gettext("specifies escape characters in a string")) - call append("$", "\t" .. s:local_to_buffer) - call OptionL("qe") -endif -if has("rightleft") - call AddOption("rightleft", gettext("display the buffer right-to-left")) - call append("$", "\t" .. s:local_to_window) - call BinOptionL("rl") - call AddOption("rightleftcmd", gettext("when to edit the command-line right-to-left")) - call append("$", "\t" .. s:local_to_window) - call OptionL("rlc") - call AddOption("revins", gettext("insert characters backwards")) - call BinOptionG("ri", &ri) - call AddOption("allowrevins", gettext("allow CTRL-_ in Insert and Command-line mode to toggle 'revins'")) - call BinOptionG("ari", &ari) - call AddOption("aleph", gettext("the ASCII code for the first letter of the Hebrew alphabet")) - call append("$", " \tset al=" . &al) - call AddOption("hkmap", gettext("use Hebrew keyboard mapping")) - call BinOptionG("hk", &hk) - call AddOption("hkmapp", gettext("use phonetic Hebrew keyboard mapping")) - call BinOptionG("hkp", &hkp) -endif -if has("arabic") - call AddOption("arabic", gettext("prepare for editing Arabic text")) - call append("$", "\t" .. s:local_to_window) - call BinOptionL("arab") - call AddOption("arabicshape", gettext("perform shaping of Arabic characters")) - call BinOptionG("arshape", &arshape) - call AddOption("termbidi", gettext("terminal will perform bidi handling")) - call BinOptionG("tbidi", &tbidi) -endif -if has("keymap") - call AddOption("keymap", gettext("name of a keyboard mapping")) - call OptionL("kmp") -endif -if has("langmap") - call AddOption("langmap", gettext("list of characters that are translated in Normal mode")) - call OptionG("lmap", &lmap) - call AddOption("langremap", gettext("apply 'langmap' to mapped characters")) - call BinOptionG("lrm", &lrm) -endif -if has("xim") - call AddOption("imdisable", gettext("when set never use IM; overrules following IM options")) - call BinOptionG("imd", &imd) -endif -call AddOption("iminsert", gettext("in Insert mode: 1: use :lmap; 2: use IM; 0: neither")) -call append("$", "\t" .. s:local_to_window) -call OptionL("imi") -call AddOption("imsearch", gettext("entering a search pattern: 1: use :lmap; 2: use IM; 0: neither")) -call append("$", "\t" .. s:local_to_window) -call OptionL("ims") -if has("xim") - call AddOption("imcmdline", gettext("when set always use IM when starting to edit a command line")) - call BinOptionG("imc", &imc) - call AddOption("imstatusfunc", gettext("function to obtain IME status")) - call OptionG("imsf", &imsf) - call AddOption("imactivatefunc", gettext("function to enable/disable IME")) - call OptionG("imaf", &imaf) -endif - - -call Header(gettext("multi-byte characters")) -call AddOption("encoding", gettext("character encoding used in Nvim: \"utf-8\"")) -call OptionG("enc", &enc) -call AddOption("fileencoding", gettext("character encoding for the current file")) -call append("$", "\t" .. s:local_to_buffer) -call OptionL("fenc") -call AddOption("fileencodings", gettext("automatically detected character encodings")) -call OptionG("fencs", &fencs) -call AddOption("charconvert", gettext("expression used for character encoding conversion")) -call OptionG("ccv", &ccv) -call AddOption("delcombine", gettext("delete combining (composing) characters on their own")) -call BinOptionG("deco", &deco) -call AddOption("maxcombine", gettext("maximum number of combining (composing) characters displayed")) -call OptionG("mco", &mco) -if has("xim") && has("gui_gtk") - call AddOption("imactivatekey", gettext("key that activates the X input method")) - call OptionG("imak", &imak) -endif -call AddOption("ambiwidth", gettext("width of ambiguous width characters")) -call OptionG("ambw", &ambw) -call AddOption("emoji", gettext("emoji characters are full width")) -call BinOptionG("emo", &emo) - - -call Header(gettext("various")) -call AddOption("virtualedit", gettext("when to use virtual editing: \"block\", \"insert\", \"all\"\nand/or \"onemore\"")) -call OptionG("ve", &ve) -call AddOption("eventignore", gettext("list of autocommand events which are to be ignored")) -call OptionG("ei", &ei) -call AddOption("eventignorewin", gettext("list of autocommand events which are to be ignored in a window")) -call OptionG("eiw", &eiw) -call AddOption("loadplugins", gettext("load plugin scripts when starting up")) -call BinOptionG("lpl", &lpl) -call AddOption("exrc", gettext("enable reading .vimrc/.exrc/.gvimrc in the current directory")) -call BinOptionG("ex", &ex) -call AddOption("secure", gettext("safer working with script files in the current directory")) -call BinOptionG("secure", &secure) -call AddOption("gdefault", gettext("use the 'g' flag for \":substitute\"")) -call BinOptionG("gd", &gd) -if exists("+opendevice") - call AddOption("opendevice", gettext("allow reading/writing devices")) - call BinOptionG("odev", &odev) -endif -if exists("+maxfuncdepth") - call AddOption("maxfuncdepth", gettext("maximum depth of function calls")) - call append("$", " \tset mfd=" . &mfd) -endif -if has("mksession") - call AddOption("sessionoptions", gettext("list of words that specifies what to put in a session file")) - call OptionG("ssop", &ssop) - call AddOption("viewoptions", gettext("list of words that specifies what to save for :mkview")) - call OptionG("vop", &vop) - call AddOption("viewdir", gettext("directory where to store files with :mkview")) - call OptionG("vdir", &vdir) -endif -if has("shada") - call AddOption("viminfo", gettext("list that specifies what to write in the ShaDa file")) - call OptionG("vi", &vi) -endif -if has("quickfix") - call AddOption("bufhidden", gettext("what happens with a buffer when it's no longer in a window")) - call append("$", "\t" .. s:local_to_buffer) - call OptionL("bh") - call AddOption("buftype", gettext("empty, \"nofile\", \"nowrite\", \"quickfix\", etc.: type of buffer")) - call append("$", "\t" .. s:local_to_buffer) - call OptionL("bt") -endif -call AddOption("buflisted", gettext("whether the buffer shows up in the buffer list")) -call append("$", "\t" .. s:local_to_buffer) -call BinOptionL("bl") -call AddOption("debug", gettext("set to \"msg\" to see all error messages")) -call append("$", " \tset debug=" . &debug) -if has("signs") - call AddOption("signcolumn", gettext("whether to show the signcolumn")) - call append("$", "\t" .. s:local_to_window) - call OptionL("scl") -endif - -set cpo&vim - -" go to first line -1 - -" reset 'modified', so that ":q" can be used to close the window -setlocal nomodified - -if has("syntax") - " Use Vim highlighting, with some additional stuff - setlocal ft=vim - syn match optwinHeader "^ \=[0-9].*" - syn match optwinName "^[a-z]*\t" nextgroup=optwinComment - syn match optwinComment ".*" contained - syn match optwinComment "^\t.*" - if !exists("did_optwin_syntax_inits") - let did_optwin_syntax_inits = 1 - hi link optwinHeader Title - hi link optwinName Identifier - hi link optwinComment Comment - endif -endif -if exists("&mzschemedll") - call AddOption("mzschemedll", gettext("name of the MzScheme dynamic library")) - call OptionG("mzschemedll", &mzschemedll) - call AddOption("mzschemegcdll", gettext("name of the MzScheme GC dynamic library")) - call OptionG("mzschemegcdll", &mzschemegcdll) -endif -if has('pythonx') - call AddOption("pyxversion", gettext("whether to use Python 2 or 3")) - call append("$", " \tset pyx=" . &wd) -endif - -" Install autocommands to enable mappings in option-window -noremap :call CR() -inoremap :call CR() -noremap :call Space() - -" Make the buffer be deleted when the window is closed. -setlocal buftype=nofile bufhidden=delete noswapfile - -augroup optwin - au! BufUnload,BufHidden option-window nested - \ call unload() | delfun unload -augroup END - -func unload() - delfun CR - delfun Space - delfun Find - delfun Update - delfun OptionL - delfun OptionG - delfun BinOptionL - delfun BinOptionG - delfun Header - au! optwin -endfunc - -" Restore the previous value of 'title' and 'icon'. -let &title = s:old_title -let &icon = s:old_icon -let &ru = s:old_ru -let &sc = s:old_sc -let &cpo = s:cpo_save -let &ul = s:old_ul -unlet s:old_title s:old_icon s:old_ru s:old_sc s:cpo_save s:idx s:lnum s:old_ul - -" vim: ts=8 sw=2 sts=2 diff --git a/runtime/scripts/optwin.lua b/runtime/scripts/optwin.lua new file mode 100644 index 0000000000..2615cfa241 --- /dev/null +++ b/runtime/scripts/optwin.lua @@ -0,0 +1,713 @@ +---@param x string +---@return string +local function N_(x) + return vim.fn.gettext(x) +end + +---@type {header:string,[integer]:[string,string]}[] +local options_list = { + { + header = N_ 'important', + { 'cpoptions', N_ 'list of flags to specify Vi compatibility' }, + { 'runtimepath', N_ 'list of directories used for runtime files and plugins' }, + { 'packpath', N_ 'list of directories used for plugin packages' }, + { 'helpfile', N_ 'name of the main help file' }, + }, + { + header = N_ 'moving around, searching and patterns', + { 'whichwrap', N_ 'list of flags specifying which commands wrap to another line' }, + { + 'startofline', + N_ 'many jump commands move the cursor to the first non-blank\ncharacter of a line', + }, + { 'paragraphs', N_ 'nroff macro names that separate paragraphs' }, + { 'sections', N_ 'nroff macro names that separate sections' }, + { 'path', N_ 'list of directory names used for file searching' }, + { 'findfunc', N_ 'function called for :find' }, + { 'cdhome', N_ ':cd without argument goes to the home directory' }, + { 'cdpath', N_ 'list of directory names used for :cd' }, + { 'autochdir', N_ 'change to directory of file in buffer' }, + { 'wrapscan', N_ 'search commands wrap around the end of the buffer' }, + { 'incsearch', N_ 'show match for partly typed search command' }, + { 'magic', N_ 'change the way backslashes are used in search patterns' }, + { 'regexpengine', N_ 'select the default regexp engine used' }, + { 'ignorecase', N_ 'ignore case when using a search pattern' }, + { 'smartcase', N_ "override 'ignorecase' when pattern has upper case characters" }, + { 'maxsearchcount', N_ 'maximum number for the search count feature' }, + { 'casemap', N_ 'what method to use for changing case of letters' }, + { 'maxmempattern', N_ 'maximum amount of memory in Kbyte used for pattern matching' }, + { 'define', N_ 'pattern for a macro definition line' }, + { 'include', N_ 'pattern for an include-file line' }, + { 'includeexpr', N_ 'expression used to transform an include line to a file name' }, + { 'jumpoptions', N_ 'controls the behavior of the jumplist' }, + }, + { + header = N_ 'tags', + { 'tagbsearch', N_ 'use binary searching in tags files' }, + { 'taglength', N_ 'number of significant characters in a tag name or zero' }, + { 'tags', N_ 'list of file names to search for tags' }, + { + 'tagcase', + N_ 'how to handle case when searching in tags files:\n"followic" to follow \'ignorecase\', "ignore" or "match"', + }, + { 'tagrelative', N_ 'file names in a tags file are relative to the tags file' }, + { 'tagstack', N_ 'a :tag command will use the tagstack' }, + { 'showfulltag', N_ 'when completing tags in Insert mode show more info' }, + { 'tagfunc', N_ 'a function to be used to perform tag searches' }, + }, + { + header = N_ 'displaying text', + { 'scroll', N_ 'number of lines to scroll for CTRL-U and CTRL-D' }, + { 'smoothscroll', N_ 'scroll by screen line' }, + { 'scrolloff', N_ 'number of screen lines to show around the cursor' }, + { 'wrap', N_ 'long lines wrap' }, + { 'linebreak', N_ "wrap long lines at a character in 'breakat'" }, + { 'breakindent', N_ 'preserve indentation in wrapped text' }, + { 'breakindentopt', N_ 'adjust breakindent behaviour' }, + { 'breakat', N_ 'which characters might cause a line break' }, + { 'showbreak', N_ 'string to put before wrapped screen lines' }, + { 'sidescroll', N_ 'minimal number of columns to scroll horizontally' }, + { 'sidescrolloff', N_ 'minimal number of columns to keep left and right of the cursor' }, + { + 'display', + N_ 'include "lastline" to show the last line even if it doesn\'t fit\ninclude "uhex" to show unprintable characters as a hex number', + }, + { + 'fillchars', + N_ 'characters to use for the status line, folds, diffs,\nbuffer text, filler lines and truncation in the completion menu', + }, + { 'cmdheight', N_ 'number of lines used for the command-line' }, + { 'columns', N_ 'width of the display' }, + { 'lines', N_ 'number of lines in the display' }, + { 'window', N_ 'number of lines to scroll for CTRL-F and CTRL-B' }, + { 'lazyredraw', N_ "don't redraw while executing macros" }, + { 'redrawtime', N_ "timeout for 'hlsearch' and :match highlighting in msec" }, + { 'writedelay', N_ 'delay in msec for each char written to the display' }, + { 'redrawdebug', N_ 'change the way redrawing works (debug)' }, + { 'list', N_ 'show as ^I and end-of-line as $' }, + { 'listchars', N_ 'list of strings used for list mode' }, + { 'number', N_ 'show the line number for each line' }, + { 'relativenumber', N_ 'show the relative line number for each line' }, + { 'numberwidth', N_ 'number of columns to use for the line number' }, + { 'chistory', N_ 'maximum number of quickfix lists that can be stored in history' }, + { 'lhistory', N_ 'maximum number of location lists that can be stored in history' }, + { 'conceallevel', N_ 'controls whether concealable text is hidden' }, + { 'concealcursor', N_ 'modes in which text in the cursor line can be concealed' }, + }, + { + header = N_ 'syntax, highlighting and spelling', + { 'background', N_ '"dark" or "light"; the background color brightness' }, + { 'filetype', N_ 'type of file; triggers the FileType event when set' }, + { 'syntax', N_ 'name of syntax highlighting used' }, + { 'synmaxcol', N_ 'maximum column to look for syntax items' }, + { 'hlsearch', N_ 'highlight all matches for the last used search pattern' }, + { 'termguicolors', N_ 'use GUI colors for the terminal' }, + { 'cursorcolumn', N_ 'highlight the screen column of the cursor' }, + { 'cursorline', N_ 'highlight the screen line of the cursor' }, + { 'cursorlineopt', N_ "specifies which area 'cursorline' highlights" }, + { 'colorcolumn', N_ 'columns to highlight' }, + { 'spell', N_ 'highlight spelling mistakes' }, + { 'spelllang', N_ 'list of accepted languages' }, + { 'spellfile', N_ 'file that "zg" adds good words to' }, + { 'spellcapcheck', N_ 'pattern to locate the end of a sentence' }, + { 'spelloptions', N_ 'flags to change how spell checking works' }, + { 'spellsuggest', N_ 'methods used to suggest corrections' }, + { 'mkspellmem', N_ 'amount of memory used by :mkspell before compressing' }, + { 'winhighlight', N_ 'override highlighting-groups window-locally' }, + }, + { + header = N_ 'multiple windows', + { 'laststatus', N_ '0, 1, 2 or 3; when to use a status line for the last window' }, + { 'statuscolumn', N_ 'custom format for the status column' }, + { 'statusline', N_ 'alternate format to be used for a status line' }, + { 'equalalways', N_ 'make all windows the same size when adding/removing windows' }, + { 'eadirection', N_ 'in which direction \'equalalways\' works: "ver", "hor" or "both"' }, + { 'winheight', N_ 'minimal number of lines used for the current window' }, + { 'winminheight', N_ 'minimal number of lines used for any window' }, + { 'winfixbuf', N_ 'keep window focused on a single buffer' }, + { 'winfixheight', N_ 'keep the height of the window' }, + { 'winfixwidth', N_ 'keep the width of the window' }, + { 'winwidth', N_ 'minimal number of columns used for the current window' }, + { 'winminwidth', N_ 'minimal number of columns used for any window' }, + { 'helpheight', N_ 'initial height of the help window' }, + { 'previewheight', N_ 'default height for the preview window' }, + { 'previewwindow', N_ 'identifies the preview window' }, + { 'winbar', N_ 'custom format for the window bar' }, + { 'winborder', N_ 'border of floating window' }, + { 'winblend', N_ 'transparency level for floating windows' }, + { 'hidden', N_ "don't unload a buffer when no longer shown in a window" }, + { 'switchbuf', N_ '"useopen" and/or "split"; which window to use when jumping\nto a buffer' }, + { 'splitbelow', N_ 'a new window is put below the current one' }, + { 'splitkeep', N_ 'determines scroll behavior for split windows' }, + { 'splitright', N_ 'a new window is put right of the current one' }, + { 'scrollbind', N_ 'this window scrolls together with other bound windows' }, + { 'scrollopt', N_ '"ver", "hor" and/or "jump"; list of options for \'scrollbind\'' }, + { 'cursorbind', N_ "this window's cursor moves together with other bound windows" }, + }, + { + header = N_ 'multiple tab pages', + { 'showtabline', N_ '0, 1 or 2; when to use a tab pages line' }, + { 'tabclose', N_ 'behaviour when closing tab pages: left, uselast or empty' }, + { 'tabpagemax', N_ 'maximum number of tab pages to open for -p and "tab all"' }, + { 'tabline', N_ 'custom tab pages line' }, + }, + { + header = N_ 'terminal', + { 'scrolljump', N_ 'minimal number of lines to scroll at a time' }, + { 'guicursor', N_ 'specifies what the cursor looks like in different modes' }, + { 'title', N_ 'show info in the window title' }, + { 'titlelen', N_ "percentage of 'columns' used for the window title" }, + { 'titlestring', N_ 'when not empty, string to be used for the window title' }, + { 'titleold', N_ 'string to restore the title to when exiting Vim' }, + { 'icon', N_ 'set the text of the icon for this window' }, + { 'iconstring', N_ 'when not empty, text for the icon of this window' }, + }, + { + header = N_ 'using the mouse', + { 'mouse', N_ 'list of flags for using the mouse' }, + { 'mousescroll', N_ 'amount to scroll by when scrolling with a mouse' }, + { 'mousefocus', N_ 'the window with the mouse pointer becomes the current one' }, + { 'mousehide', N_ 'hide the mouse pointer while typing' }, + { + 'mousemodel', + N_ '"extend", "popup" or "popup_setpos"; what the right\nmouse button is used for', + }, + { 'mousetime', N_ 'maximum time in msec to recognize a double-click' }, + { 'mousemoveevent', N_ 'deliver mouse move events to input queue' }, + }, + { + header = N_ 'GUI', + { 'guifont', N_ 'list of font names to be used in the GUI' }, + { 'guifontwide', N_ 'list of font names to be used for double-wide characters' }, + { 'browsedir', N_ '"last", "buffer" or "current": which directory used for\nthe file browser' }, + { 'langmenu', N_ 'language to be used for the menus' }, + { 'menuitems', N_ 'maximum number of items in one menu' }, + { 'winaltkeys', N_ '"no", "yes" or "menu"; how to use the ALT key' }, + { 'linespace', N_ 'number of pixel lines to use between characters' }, + { 'termsync', N_ 'synchronize redraw output with the host terminal' }, + }, + { + header = N_ 'messages and info', + { 'shortmess', N_ 'list of flags to make messages shorter' }, + { 'messagesopt', N_ 'options for outputting messages' }, + { 'showcmd', N_ "show (partial) command keys in location given by 'showcmdloc'" }, + { 'showcmdloc', N_ "location where to show the (partial) command keys for 'showcmd'" }, + { 'showmode', N_ 'display the current mode in the status line' }, + { 'ruler', N_ 'show cursor position below each window' }, + { 'rulerformat', N_ 'alternate format to be used for the ruler' }, + { 'report', N_ 'threshold for reporting number of changed lines' }, + { 'verbose', N_ 'the higher the more messages are given' }, + { 'verbosefile', N_ 'file to write messages in' }, + { 'more', N_ 'pause listings when the screen is full' }, + { 'confirm', N_ 'start a dialog when a command fails' }, + { 'errorbells', N_ 'ring the bell for error messages' }, + { 'visualbell', N_ 'use a visual bell instead of beeping' }, + { 'belloff', N_ 'do not ring the bell for these reasons' }, + { 'helplang', N_ 'list of preferred languages for finding help' }, + }, + { + header = N_ 'selecting text', + { 'selection', N_ '"old", "inclusive" or "exclusive"; how selecting text behaves' }, + { + 'selectmode', + N_ '"mouse", "key" and/or "cmd"; when to start Select mode\ninstead of Visual mode', + }, + { + 'clipboard', + N_ '"unnamed" to use the * register like unnamed register\n"autoselect" to always put selected text on the clipboard', + }, + { 'keymodel', N_ '"startsel" and/or "stopsel"; what special keys can do' }, + }, + { + header = N_ 'editing text', + { 'undolevels', N_ 'maximum number of changes that can be undone' }, + { 'undofile', N_ 'automatically save and restore undo history' }, + { 'undodir', N_ 'list of directories for undo files' }, + { 'undoreload', N_ 'maximum number lines to save for undo on a buffer reload' }, + { 'modified', N_ 'changes have been made and not written to a file' }, + { 'readonly', N_ 'buffer is not to be written' }, + { 'modifiable', N_ 'changes to the text are possible' }, + { 'textwidth', N_ 'line length above which to break a line' }, + { 'wrapmargin', N_ 'margin from the right in which to break a line' }, + { 'backspace', N_ 'specifies what , CTRL-W, etc. can do in Insert mode' }, + { 'comments', N_ 'definition of what comment lines look like' }, + { 'formatoptions', N_ 'list of flags that tell how automatic formatting works' }, + { 'formatlistpat', N_ 'pattern to recognize a numbered list' }, + { 'formatexpr', N_ 'expression used for "gq" to format lines' }, + { 'complete', N_ 'specifies how Insert mode completion works for CTRL-N and CTRL-P' }, + { 'autocomplete', N_ 'automatic completion in insert mode' }, + { 'autocompletetimeout', N_ "initial decay timeout for 'autocomplete' algorithm" }, + { 'completetimeout', N_ 'initial decay timeout for CTRL-N and CTRL-P completion' }, + { 'autocompletedelay', N_ 'delay in msec before menu appears after typing' }, + { 'completeopt', N_ 'whether to use a popup menu for Insert mode completion' }, + { 'completeitemalign', N_ 'popup menu item align order' }, + { 'completefuzzycollect', N_ 'use fuzzy collection for specific completion modes' }, + { 'pumheight', N_ 'maximum height of the popup menu' }, + { 'pumwidth', N_ 'minimum width of the popup menu' }, + { 'pummaxwidth', N_ 'maximum width of the popup menu' }, + { 'pumblend', N_ 'transparency level of popup menu' }, + { 'pumborder', N_ 'border of popupmenu' }, + { 'completefunc', N_ 'user defined function for Insert mode completion' }, + { 'omnifunc', N_ 'function for filetype-specific Insert mode completion' }, + { 'dictionary', N_ 'list of dictionary files for keyword completion' }, + { 'thesaurus', N_ 'list of thesaurus files for keyword completion' }, + { 'thesaurusfunc', N_ 'function used for thesaurus completion' }, + { 'infercase', N_ 'adjust case of a keyword completion match' }, + { 'digraph', N_ 'enable entering digraphs with c1 c2' }, + { 'tildeop', N_ 'the "~" command behaves like an operator' }, + { 'operatorfunc', N_ 'function called for the "g@" operator' }, + { 'showmatch', N_ 'when inserting a bracket, briefly jump to its match' }, + { 'matchtime', N_ "tenth of a second to show a match for 'showmatch'" }, + { 'matchpairs', N_ 'list of pairs that match for the "%" command' }, + { 'joinspaces', N_ "use two spaces after '.' when joining a line" }, + { + 'nrformats', + N_ '"alpha", "octal", "hex", "bin" and/or "unsigned"; number formats\nrecognized for CTRL-A and CTRL-X commands', + }, + }, + { + header = N_ 'tabs and indenting', + { 'tabstop', N_ 'number of spaces a in the text stands for' }, + { 'shiftwidth', N_ 'number of spaces used for each step of (auto)indent' }, + { 'vartabstop', N_ 'list of number of spaces a tab counts for' }, + { 'varsofttabstop', N_ 'list of number of spaces a soft tabsstop counts for' }, + { 'smarttab', N_ "a in an indent inserts 'shiftwidth' spaces" }, + { 'softtabstop', N_ 'if non-zero, number of spaces to insert for a ' }, + { 'shiftround', N_ 'round to \'shiftwidth\' for "<<" and ">>"' }, + { 'expandtab', N_ 'expand to spaces in Insert mode' }, + { 'autoindent', N_ 'automatically set the indent of a new line' }, + { 'smartindent', N_ 'do clever autoindenting' }, + { 'cindent', N_ 'enable specific indenting for C code' }, + { 'cinoptions', N_ 'options for C-indenting' }, + { 'cinkeys', N_ 'keys that trigger C-indenting in Insert mode' }, + { 'cinwords', N_ 'list of words that cause more C-indent' }, + { 'cinscopedecls', N_ 'list of scope declaration names used by cino-g' }, + { 'indentexpr', N_ 'expression used to obtain the indent of a line' }, + { 'indentkeys', N_ "keys that trigger indenting with 'indentexpr' in Insert mode" }, + { 'copyindent', N_ 'copy whitespace for indenting from previous line' }, + { 'preserveindent', N_ 'preserve kind of whitespace when changing indent' }, + { 'lisp', N_ 'enable lisp mode' }, + { 'lispwords', N_ 'words that change how lisp indenting works' }, + { 'lispoptions', N_ 'options for Lisp indenting' }, + }, + { + header = N_ 'folding', + { 'foldenable', N_ 'unset to display all folds open' }, + { 'foldlevel', N_ 'folds with a level higher than this number will be closed' }, + { 'foldlevelstart', N_ "value for 'foldlevel' when starting to edit a file" }, + { 'foldcolumn', N_ 'width of the column used to indicate folds' }, + { 'foldtext', N_ 'expression used to display the text of a closed fold' }, + { 'foldclose', N_ 'set to "all" to close a fold when the cursor leaves it' }, + { 'foldopen', N_ 'specifies for which commands a fold will be opened' }, + { 'foldminlines', N_ 'minimum number of screen lines for a fold to be closed' }, + { 'commentstring', N_ 'template for comments; used to put the marker in' }, + { 'foldmethod', N_ 'folding type: "manual", "indent", "expr", "marker",\n"syntax" or "diff"' }, + { 'foldexpr', N_ 'expression used when \'foldmethod\' is "expr"' }, + { 'foldignore', N_ 'used to ignore lines when \'foldmethod\' is "indent"' }, + { 'foldmarker', N_ 'markers used when \'foldmethod\' is "marker"' }, + { 'foldnestmax', N_ 'maximum fold depth for when \'foldmethod\' is "indent" or "syntax"' }, + }, + { + header = N_ 'diff mode', + { 'diff', N_ 'use diff mode for the current window' }, + { 'diffopt', N_ 'options for using diff mode' }, + { 'diffexpr', N_ 'expression used to obtain a diff file' }, + { 'diffanchors', N_ 'list of addresses for anchoring a diff' }, + { 'patchexpr', N_ 'expression used to patch a file' }, + }, + { + header = N_ 'mapping', + { 'maxmapdepth', N_ 'maximum depth of mapping' }, + { 'timeout', N_ 'allow timing out halfway into a mapping' }, + { 'ttimeout', N_ 'allow timing out halfway into a key code' }, + { 'timeoutlen', N_ "time in msec for 'timeout'" }, + { 'ttimeoutlen', N_ "time in msec for 'ttimeout'" }, + }, + { + header = N_ 'reading and writing files', + { 'modeline', N_ 'enable using settings from modelines when reading a file' }, + { 'modelineexpr', N_ 'allow setting expression options from a modeline' }, + { 'modelines', N_ 'number of lines to check for modelines' }, + { 'binary', N_ 'binary file editing' }, + { 'endofline', N_ 'last line in the file has an end-of-line' }, + { 'endoffile', N_ 'last line in the file followed by CTRL-Z' }, + { 'fixendofline', N_ 'fixes missing end-of-line at end of text file' }, + { 'bomb', N_ 'prepend a Byte Order Mark to the file' }, + { 'fileformat', N_ 'end-of-line format: "dos", "unix" or "mac"' }, + { 'fileformats', N_ 'list of file formats to look for when editing a file' }, + { 'write', N_ 'writing files is allowed' }, + { 'writebackup', N_ 'write a backup file before overwriting a file' }, + { 'backup', N_ 'keep a backup after overwriting a file' }, + { 'backupskip', N_ 'patterns that specify for which files a backup is not made' }, + { 'backupcopy', N_ 'whether to make the backup as a copy or rename the existing file' }, + { 'backupdir', N_ 'list of directories to put backup files in' }, + { 'backupext', N_ 'file name extension for the backup file' }, + { 'autowrite', N_ 'automatically write a file when leaving a modified buffer' }, + { 'autowriteall', N_ "as 'autowrite', but works with more commands" }, + { 'writeany', N_ 'always write without asking for confirmation' }, + { 'autoread', N_ 'automatically read a file when it was modified outside of Vim' }, + { 'patchmode', N_ 'keep oldest version of a file; specifies file name extension' }, + { 'fsync', N_ 'forcibly sync the file to disk after writing it' }, + }, + { + header = N_ 'the swap file', + { 'directory', N_ 'list of directories for the swap file' }, + { 'swapfile', N_ 'use a swap file for this buffer' }, + { 'updatecount', N_ 'number of characters typed to cause a swap file update' }, + { 'updatetime', N_ 'time in msec after which the swap file will be updated' }, + }, + { + header = N_ 'command line editing', + { 'history', N_ 'how many command lines are remembered' }, + { 'wildchar', N_ 'key that triggers command-line expansion' }, + { 'wildcharm', N_ "like 'wildchar' but can also be used in a mapping" }, + { 'wildmode', N_ 'specifies how command line completion works' }, + { 'wildoptions', N_ 'empty or "tagfile" to list file name of matching tags' }, + { 'suffixes', N_ 'list of file name extensions that have a lower priority' }, + { 'suffixesadd', N_ 'list of file name extensions added when searching for a file' }, + { 'wildignore', N_ 'list of patterns to ignore files for file name completion' }, + { 'fileignorecase', N_ 'ignore case when using file names' }, + { 'wildignorecase', N_ 'ignore case when completing file names' }, + { 'wildmenu', N_ 'command-line completion shows a list of matches' }, + { 'cedit', N_ 'key used to open the command-line window' }, + { 'cmdwinheight', N_ 'height of the command-line window' }, + }, + { + header = N_ 'executing external commands', + { 'shell', N_ 'name of the shell program used for external commands' }, + { 'shellquote', N_ 'character(s) to enclose a shell command in' }, + { 'shellxquote', N_ "like 'shellquote' but include the redirection" }, + { 'shellxescape', N_ "characters to escape when 'shellxquote' is (" }, + { 'shellcmdflag', N_ "argument for 'shell' to execute a command" }, + { 'shellredir', N_ 'used to redirect command output to a file' }, + { 'shelltemp', N_ 'use a temp file for shell commands instead of using a pipe' }, + { 'equalprg', N_ 'program used for "=" command' }, + { 'formatprg', N_ 'program used to format lines with "gq" command' }, + { 'keywordprg', N_ 'program used for the "K" command' }, + { 'warn', N_ 'warn when using a shell command and a buffer has changes' }, + }, + { + header = N_ 'running make and jumping to errors (quickfix)', + { 'errorfile', N_ 'name of the file that contains error messages' }, + { 'errorformat', N_ 'list of formats for error messages' }, + { 'makeprg', N_ 'program used for the ":make" command' }, + { 'shellpipe', N_ 'string used to put the output of ":make" in the error file' }, + { 'makeef', N_ "name of the errorfile for the 'makeprg' command" }, + { 'grepprg', N_ 'program used for the ":grep" command' }, + { 'grepformat', N_ "list of formats for output of 'grepprg'" }, + { 'makeencoding', N_ 'encoding of the ":make" and ":grep" output' }, + { 'quickfixtextfunc', N_ 'function to display text in the quickfix window' }, + }, + { + header = N_ 'system specific', + { 'shellslash', N_ 'use forward slashes in file names; for Unix-like shells' }, + { 'completeslash', N_ 'specifies slash/backslash used for completion' }, + }, + { + header = N_ 'language specific', + { 'isfname', N_ 'specifies the characters in a file name' }, + { 'isident', N_ 'specifies the characters in an identifier' }, + { 'isexpand', N_ 'defines trigger strings for complete_match()' }, + { 'iskeyword', N_ 'specifies the characters in a keyword' }, + { 'isprint', N_ 'specifies printable characters' }, + { 'quoteescape', N_ 'specifies escape characters in a string' }, + { 'rightleft', N_ 'display the buffer right-to-left' }, + { 'rightleftcmd', N_ 'when to edit the command-line right-to-left' }, + { 'revins', N_ 'insert characters backwards' }, + { 'allowrevins', N_ "allow CTRL-_ in Insert and Command-line mode to toggle 'revins'" }, + { 'arabic', N_ 'prepare for editing Arabic text' }, + { 'arabicshape', N_ 'perform shaping of Arabic characters' }, + { 'termbidi', N_ 'terminal will perform bidi handling' }, + { 'keymap', N_ 'name of a keyboard mapping' }, + { 'langmap', N_ 'list of characters that are translated in Normal mode' }, + { 'langremap', N_ "apply 'langmap' to mapped characters" }, + { 'iminsert', N_ 'in Insert mode: 1: use :lmap; 2: use IM; 0: neither' }, + { 'imsearch', N_ 'entering a search pattern: 1: use :lmap; 2: use IM; 0: neither' }, + }, + { + header = N_ 'multi-byte characters', + { 'fileencoding', N_ 'character encoding for the current file' }, + { 'fileencodings', N_ 'automatically detected character encodings' }, + { 'charconvert', N_ 'expression used for character encoding conversion' }, + { 'delcombine', N_ 'delete combining (composing) characters on their own' }, + { 'ambiwidth', N_ 'width of ambiguous width characters' }, + { 'emoji', N_ 'emoji characters are full width' }, + }, + { + header = N_ 'various', + { 'virtualedit', N_ 'when to use virtual editing: "block", "insert", "all"\nand/or "onemore"' }, + { 'eventignore', N_ 'list of autocommand events which are to be ignored' }, + { 'eventignorewin', N_ 'list of autocommand events which are to be ignored in a window' }, + { 'loadplugins', N_ 'load plugin scripts when starting up' }, + { 'exrc', N_ 'enable reading .vimrc/.exrc/.gvimrc in the current directory' }, + { 'gdefault', N_ 'use the \'g\' flag for ":substitute"' }, + { 'maxfuncdepth', N_ 'maximum depth of function calls' }, + { 'sessionoptions', N_ 'list of words that specifies what to put in a session file' }, + { 'viewoptions', N_ 'list of words that specifies what to save for :mkview' }, + { 'viewdir', N_ 'directory where to store files with :mkview' }, + { 'shada', N_ 'list that specifies what to write in the ShaDa file' }, + { 'shadafile', N_ 'overrides the filename used for shada' }, + { 'bufhidden', N_ "what happens with a buffer when it's no longer in a window" }, + { 'buftype', N_ 'empty, "nofile", "nowrite", "quickfix", etc.: type of buffer' }, + { 'buflisted', N_ 'whether the buffer shows up in the buffer list' }, + { 'debug', N_ 'set to "msg" to see all error messages' }, + { 'signcolumn', N_ 'whether to show the signcolumn' }, + { 'pyxversion', N_ 'whether to use Python 2 or 3' }, + { 'inccommand', N_ 'live preview of substitution' }, + { 'busy', N_ 'buffer is busy' }, + { 'termpastefilter', N_ 'characters removed when pasting into terminal window' }, + { 'scrollback', N_ 'number of lines kept beyond the visible screen in terminal buffer' }, + }, +} + +local local_to_window = N_ '(local to window)' +local local_to_buffer = N_ '(local to buffer)' +local global_or_local_to_buffer = N_ '(global or local to buffer)' +local global_or_local_to_window = N_ '(global or local to window)' + +local lines = { + N_ '" Each "set" line shows the current value of an option (on the left).', + N_ '" Hit on a "set" line to execute it.', + N_ '" A boolean option will be toggled.', + N_ '" For other options you can edit the value before hitting .', + N_ '" Hit on a help line to open a help window on this option.', + N_ '" Hit on an index line to jump there.', + N_ '" Hit on a "set" line to refresh it.', + '', +} + +for header_number, options in ipairs(options_list) do + table.insert(lines, ('%2d %s'):format(header_number, options.header)) +end +table.insert(lines, '') + +for header_number, options in ipairs(options_list) do + table.insert(lines, '') + table.insert(lines, ('%2d %s'):format(header_number, options.header)) + table.insert(lines, '') + for _, opt_desc_and_name in ipairs(options) do + local name, desc = unpack(opt_desc_and_name) + + vim.list_extend( + lines, + vim.split( + ('%s%s\t%s'):format(name, #name >= 15 and '\n' or '', desc:gsub('\n', '\n\t')), + '\n' + ) + ) + + local info = vim.api.nvim_get_option_info2(name, {}) + + if info.scope == 'buf' and info.global_local then + table.insert(lines, '\t' .. global_or_local_to_buffer) + elseif info.scope == 'win' and info.global_local then + table.insert(lines, '\t' .. global_or_local_to_window) + elseif info.scope == 'buf' then + table.insert(lines, '\t' .. local_to_buffer) + elseif info.scope == 'win' then + table.insert(lines, '\t' .. local_to_window) + end + + local shortname = info.shortname or name + if shortname == '' then + shortname = name + end + + if info.type == 'boolean' then + if vim.o[name] then + table.insert(lines, (' \tset %s\tno%s'):format(shortname, shortname)) + else + table.insert(lines, (' \tset no%s\t%s'):format(shortname, shortname)) + end + else + local value = vim.o[name] --[[@as string]] + table.insert(lines, (' \tset %s=%s'):format(shortname, value)) + end + end +end + +--- An optwin buffer has 5 types of lines (given pattern): +--- '^".*' : comment (other) +--- '^ *[0-9]+' : header (header) +--- '^[^\ts].*' : option header + description (opt-desc) +--- '^\t.*' : description continuation (desc-cont) +--- '^ \tset .*' : option set (set) +--- +---@param line string +---@return 'set'|'opt-desc'|'desc-cont'|'header'|'other' +local function line_get_type(line) + if line:find('^ \tset ') then + return 'set' + elseif line:find('^%s-[0-9]') then + return 'header' + elseif line:find('^\t') then + return 'desc-cont' + elseif line:find('^[a-z]') then + return 'opt-desc' + end + return 'other' +end + +---@return integer|false +local function find_window_to_have_options_in() + local thiswin = vim.fn.winnr() + local altwin = vim.fn.winnr('#') + + if vim.bo[vim.fn.winbufnr(altwin)].filetype == 'help' then + altwin = altwin + 1 + if altwin == thiswin then + altwin = altwin + 1 --[[@as integer]] + end + end + + if + altwin == 0 + or altwin == thiswin + or vim.bo[vim.fn.winbufnr(altwin)].filetype == 'help' + or vim.fn.winnr('$') < altwin + then + vim.notify("Don't know in which window") + return false + end + + return vim.fn.win_getid(altwin) +end + +local function update_current_line() + local line = vim.api.nvim_get_current_line() + if line_get_type(line) ~= 'set' then + return + end + + ---@type string + local name + if line:find('=') then + name = line:match('^ \tset (.-)=') + else + name = line:match('^ \tset ([a-z]*)'):gsub('^no', '') --[[@as string]] + end + + local info = vim.api.nvim_get_option_info2(name, {}) + + ---@type any + local value + if info.global_local or info.scope == 'global' then + value = vim.o[name] --[[@as any]] + else + local win = find_window_to_have_options_in() + if not win then + return + end + + value = vim._with({ + win = win, + }, function() + return vim.o[name] + end) + end + + if info.type == 'boolean' then + if value then + vim.api.nvim_set_current_line((' \tset %s\tno%s'):format(name, name)) + else + vim.api.nvim_set_current_line((' \tset no%s\t%s'):format(name, name)) + end + else + vim.api.nvim_set_current_line((' \tset %s=%s'):format(name, value)) + end +end + +local function current_line_set_option() + local line = vim.api.nvim_get_current_line() + if line_get_type(line) ~= 'set' then + return + end + + ---@type string + local name + ---@type string|boolean|integer + local value + if line:find('=') then + name, value = line:match('^ \tset (.-)=(.*)') + else + local option = line:match('^ \tset ([a-z]*)') + name = option:gsub('^no', '') --[[@as string]] + value = vim.startswith(option, 'no') + end + + local info = vim.api.nvim_get_option_info2(name, {}) + + if info.type == 'number' then + value = assert(tonumber(value), value .. ' is not a number') + end + + if info.global_local or info.scope == 'global' then + ---@diagnostic disable-next-line: no-unknown + vim.o[name] = value + else + local win = find_window_to_have_options_in() + if not win then + return + end + + vim._with({ + win = win, + }, function() + ---@diagnostic disable-next-line: no-unknown + vim.o[name] = value + end) + end + + update_current_line() +end + +local buf = vim.fn.bufnr('nvim-optwin://optwin') +if buf >= 0 then + local winids = vim.fn.win_findbuf(buf) + if #winids > 0 and vim.fn.win_gotoid(winids[1]) == 1 then + return + end + + vim.cmd((vim.env.OPTWIN_CMD or '') .. ' new nvim-optwin://optwin') +else + vim.cmd((vim.env.OPTWIN_CMD or '') .. ' new nvim-optwin://optwin') + + buf = vim.api.nvim_get_current_buf() + vim.bo[buf].tabstop = 15 + vim.bo[buf].buftype = 'nofile' + vim.api.nvim_buf_set_lines(buf, 0, -1, true, lines) + + vim.bo[buf].filetype = 'vim' + vim.cmd [[ + syn match optwinHeader "^ \=[0-9].*" + syn match optwinName "^[a-z]*\t" nextgroup=optwinComment + syn match optwinComment ".*" contained + syn match optwinComment "^\t.*" + if !exists("did_optwin_syntax_inits") + let did_optwin_syntax_inits = 1 + hi link optwinHeader Title + hi link optwinName Identifier + hi link optwinComment Comment + endif + ]] + + vim.keymap.set({ 'n', 'i' }, '', function() + local lnum = vim.fn.search('^[^\t]', 'bcWn') + local line = vim.fn.getline(lnum) + + local line_type = line_get_type(line) + + if line_type == 'set' then + current_line_set_option() + elseif line_type == 'header' then + vim.fn.search(line, 'w') + elseif line_type == 'opt-desc' then + local name = line:match('[^\t]*') + vim.cmd.help(("'%s'"):format(name)) + end + end, { buffer = buf }) + + vim.keymap.set({ 'n', 'i' }, '', update_current_line, { buffer = buf }) +end + +vim.cmd '1' diff --git a/src/nvim/option.c b/src/nvim/option.c index 0edc393e76..eacdb84c72 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -12,7 +12,7 @@ // - If it's a numeric option, add any necessary bounds checks to check_num_option_bounds(). // - If it's a list of flags, add some code in do_set(), search for WW_ALL. // - Add documentation! "desc" in options.lua, and any other related places. -// - Add an entry in runtime/optwin.vim. +// - Add an entry in runtime/scripts/optwin.lua. #define IN_OPTION_C #include diff --git a/src/nvim/po/CMakeLists.txt b/src/nvim/po/CMakeLists.txt index f0436a2743..e9e9832b42 100644 --- a/src/nvim/po/CMakeLists.txt +++ b/src/nvim/po/CMakeLists.txt @@ -55,16 +55,10 @@ if(HAVE_WORKING_LIBINTL AND GETTEXT_FOUND AND XGETTEXT_PRG AND ICONV_PRG) list(SORT NVIM_RELATIVE_SOURCES) add_custom_command( OUTPUT ${NVIM_POT} - COMMAND $ -u NONE -i NONE -n --headless --cmd "set cpo+=+" - -c "silent source ${CMAKE_CURRENT_SOURCE_DIR}/tojavascript.vim" - ${NVIM_POT} ${PROJECT_SOURCE_DIR}/runtime/optwin.vim COMMAND ${XGETTEXT_PRG} -o ${NVIM_POT} --default-domain=nvim --add-comments --keyword=_ --keyword=N_ --keyword=NGETTEXT:1,2 -D ${CMAKE_CURRENT_SOURCE_DIR} -D ${CMAKE_CURRENT_BINARY_DIR} - ${NVIM_RELATIVE_SOURCES} optwin.js - COMMAND $ -u NONE -i NONE -n --headless --cmd "set cpo+=+" - -c "silent source ${CMAKE_CURRENT_SOURCE_DIR}/fixfilenames.vim" - ${NVIM_POT} ${PROJECT_SOURCE_DIR}/runtime/optwin.vim + ${NVIM_RELATIVE_SOURCES} ${PROJECT_SOURCE_DIR}/runtime/scripts/optwin.lua VERBATIM DEPENDS ${NVIM_SOURCES} nvim_bin nvim_runtime_deps) diff --git a/src/nvim/vim_defs.h b/src/nvim/vim_defs.h index 72aaa77533..0eadcf5b03 100644 --- a/src/nvim/vim_defs.h +++ b/src/nvim/vim_defs.h @@ -2,7 +2,7 @@ // Some defines from the old feature.h #define SESSION_FILE "Session.vim" -#define SYS_OPTWIN_FILE "$VIMRUNTIME/optwin.vim" +#define SYS_OPTWIN_FILE "$VIMRUNTIME/scripts/optwin.lua" #define RUNTIME_DIRNAME "runtime" enum { diff --git a/test/functional/plugin/optwin_spec.lua b/test/functional/plugin/optwin_spec.lua new file mode 100644 index 0000000000..143ffdd693 --- /dev/null +++ b/test/functional/plugin/optwin_spec.lua @@ -0,0 +1,101 @@ +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local command = n.command +local api = n.api +local fn = n.fn +local eval = n.eval +local feed = n.feed +local clear = n.clear +local eq = t.eq +local neq = t.neq + +describe('optwin.lua', function() + before_each(clear) + + it(':options shows options UI', function() + command 'options' + + command '/^ 1' + local lnum = fn.line('.') + feed('') + neq(lnum, fn.line('.')) + + n.add_builddir_to_rtp() + command '/^startofline' + local win = api.nvim_get_current_win() + feed('') + neq(win, api.nvim_get_current_win()) + eq('help', eval('&filetype')) + api.nvim_win_close(0, true) + eq(win, api.nvim_get_current_win()) + + command '/^ \t' + local opt_value = eval('&startofline') + local line = api.nvim_get_current_line() + feed('') + neq(opt_value, eval('&startofline')) + neq(line, api.nvim_get_current_line()) + + command('set startofline!') + neq(line, api.nvim_get_current_line()) + feed('') + eq(line, api.nvim_get_current_line()) + + command 'wincmd j' + command 'wincmd k' + command '/^number' + command '/^ \t' + line = api.nvim_get_current_line() + feed('') + neq(line, api.nvim_get_current_line()) + command 'wincmd o' + feed('') + neq(line, api.nvim_get_current_line()) + end) + + it(':options shows all options', function() + local ignore = { + -- These options are removed/unused/deprecated + 'compatible', + 'paste', + 'highlight', + 'terse', + 'aleph', + 'encoding', + 'termencoding', + 'maxcombine', + 'secure', + 'prompt', + 'edcompatible', + 'guioptions', + 'guitablabel', + 'guitabtooltip', + 'insertmode', + 'mouseshape', + 'imcmdline', + 'imdisable', + 'pastetoggle', + 'langnoremap', + 'opendevice', + 'ttyfast', + 'remap', + 'hkmap', + 'hkmapp', + + -- These options are read-only + 'channel', + } + + command 'options' + + local options = ignore + for _, line in ipairs(api.nvim_buf_get_lines(0, 0, -1, true)) do + if line:match('^[a-z]') then + table.insert(options, line:match('^[a-z]+')) + end + end + + eq(fn.sort(vim.tbl_keys(api.nvim_get_all_options_info())), fn.sort(options)) + end) +end) diff --git a/test/old/testdir/test_options.vim b/test/old/testdir/test_options.vim index 1268591c70..77e3d6b5e4 100644 --- a/test/old/testdir/test_options.vim +++ b/test/old/testdir/test_options.vim @@ -108,9 +108,9 @@ func Test_options_command() " Check if the option-window is opened horizontally. wincmd j - call assert_notequal('option-window', bufname('')) + call assert_notequal('nvim-optwin://optwin', bufname('')) wincmd k - call assert_equal('option-window', bufname('')) + call assert_equal('nvim-optwin://optwin', bufname('')) " close option-window close @@ -118,9 +118,9 @@ func Test_options_command() vert options " Check if the option-window is opened vertically. wincmd l - call assert_notequal('option-window', bufname('')) + call assert_notequal('nvim-optwin://optwin', bufname('')) wincmd h - call assert_equal('option-window', bufname('')) + call assert_equal('nvim-optwin://optwin', bufname('')) " close option-window close @@ -141,16 +141,16 @@ func Test_options_command() tab options " Check if the option-window is opened in a tab. normal gT - call assert_notequal('option-window', bufname('')) + call assert_notequal('nvim-optwin://optwin', bufname('')) normal gt - call assert_equal('option-window', bufname('')) + call assert_equal('nvim-optwin://optwin', bufname('')) " close option-window close " Open the options window browse if has('browse') browse set - call assert_equal('option-window', bufname('')) + call assert_equal('nvim-optwin://optwin', bufname('')) close endif endfunc