aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/insert.txt68
-rw-r--r--runtime/doc/options.txt27
-rw-r--r--runtime/doc/quickref.txt1
3 files changed, 76 insertions, 20 deletions
diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt
index bfc1c235ea..fd1d0f8ea6 100644
--- a/runtime/doc/insert.txt
+++ b/runtime/doc/insert.txt
@@ -804,6 +804,9 @@ CTRL-X CTRL-K Search the files given with the 'dictionary' option
CTRL-P Search backwards for next matching keyword. This
keyword replaces the previous matching keyword.
+
+Completing words in 'thesaurus' *compl-thesaurus*
+
*i_CTRL-X_CTRL-T*
CTRL-X CTRL-T Works as CTRL-X CTRL-K, but in a special way. It uses
the 'thesaurus' option instead of 'dictionary'. If a
@@ -812,16 +815,6 @@ CTRL-X CTRL-T Works as CTRL-X CTRL-K, but in a special way. It uses
matches, even though they don't complete the word.
Thus a word can be completely replaced.
- For an example, imagine the 'thesaurus' file has a
- line like this: >
- angry furious mad enraged
-< Placing the cursor after the letters "ang" and typing
- CTRL-X CTRL-T would complete the word "angry";
- subsequent presses would change the word to "furious",
- "mad" etc.
- Other uses include translation between two languages,
- or grouping API functions by keyword.
-
CTRL-T or
CTRL-N Search forward for next matching keyword. This
keyword replaces the previous matching keyword.
@@ -829,6 +822,59 @@ CTRL-X CTRL-T Works as CTRL-X CTRL-K, but in a special way. It uses
CTRL-P Search backwards for next matching keyword. This
keyword replaces the previous matching keyword.
+In the file used by the 'thesaurus' option each line in the file should
+contain words with similar meaning, separated by non-keyword characters (white
+space is preferred). Maximum line length is 510 bytes.
+
+For an example, imagine the 'thesaurus' file has a line like this: >
+ angry furious mad enraged
+<Placing the cursor after the letters "ang" and typing CTRL-X CTRL-T would
+complete the word "angry"; subsequent presses would change the word to
+"furious", "mad" etc.
+
+Other uses include translation between two languages, or grouping API
+functions by keyword.
+
+An English word list was added to this github issue:
+https://github.com/vim/vim/issues/629#issuecomment-443293282
+Unpack thesaurus_pkg.zip, put the thesaurus.txt file somewhere, e.g.
+~/.vim/thesaurus/english.txt, and the 'thesaurus' option to this file name.
+
+
+Completing keywords with 'thesaurusfunc' *compl-thesaurusfunc*
+
+If the 'thesaurusfunc' option is set, then the user specified function is
+invoked to get the list of completion matches and the 'thesaurus' option is
+not used. See |complete-functions| for an explanation of how the function is
+invoked and what it should return.
+
+Here is an example that uses the "aiksaurus" command (provided by Magnus
+Groß): >
+
+ func Thesaur(findstart, base)
+ if a:findstart
+ let line = getline('.')
+ let start = col('.') - 1
+ while start > 0 && line[start - 1] =~ '\a'
+ let start -= 1
+ endwhile
+ return start
+ else
+ let res = []
+ let h = ''
+ for l in split(system('aiksaurus '.shellescape(a:base)), '\n')
+ if l[:3] == '=== '
+ let h = substitute(l[4:], ' =*$', '', '')
+ elseif l[0] =~ '\a'
+ call extend(res, map(split(l, ', '), {_, val -> {'word': val, 'menu': '('.h.')'}}))
+ endif
+ endfor
+ return res
+ endif
+ endfunc
+
+ set thesaurusfunc=Thesaur
+
Completing keywords in the current and included files *compl-keyword*
@@ -1032,7 +1078,7 @@ CTRL-X CTRL-Z Stop completion without changing the text.
FUNCTIONS FOR FINDING COMPLETIONS *complete-functions*
-This applies to 'completefunc' and 'omnifunc'.
+This applies to 'completefunc', 'thesaurusfunc' and 'omnifunc'.
The function is called in two different ways:
- First the function is called to find the start of the text to be completed.
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 184c6de503..399a59251a 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -6448,19 +6448,28 @@ A jump table for the options with a short description can be found at |Q_op|.
'thesaurus' 'tsr' string (default "")
global or local to buffer |global-local|
List of file names, separated by commas, that are used to lookup words
- for thesaurus completion commands |i_CTRL-X_CTRL-T|.
+ for thesaurus completion commands |i_CTRL-X_CTRL-T|. See
+ |compl-thesaurus|.
- Each line in the file should contain words with similar meaning,
- separated by non-keyword characters (white space is preferred).
- Maximum line length is 510 bytes.
+ This option is not used if 'thesaurusfunc' is set, either for the
+ buffer or globally.
To include a comma in a file name precede it with a backslash. Spaces
after a comma are ignored, otherwise spaces are included in the file
- name. See |option-backslash| about using backslashes.
- The use of |:set+=| and |:set-=| is preferred when adding or removing
- directories from the list. This avoids problems when a future version
- uses another default.
- Backticks cannot be used in this option for security reasons.
+ name. See |option-backslash| about using backslashes. The use of
+ |:set+=| and |:set-=| is preferred when adding or removing directories
+ from the list. This avoids problems when a future version uses
+ another default. Backticks cannot be used in this option for security
+ reasons.
+
+ *'thesaurusfunc'* *'tsrfu'*
+'thesaurusfunc' 'tsrfu' string (default: empty)
+ global or local to buffer |global-local|
+ This option specifies a function to be used for thesaurus completion
+ with CTRL-X CTRL-T. |i_CTRL-X_CTRL-T| See |compl-thesaurusfunc|.
+
+ This option cannot be set from a |modeline| or in the |sandbox|, for
+ security reasons.
*'tildeop'* *'top'* *'notildeop'* *'notop'*
'tildeop' 'top' boolean (default off)
diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt
index 77e69a3eea..8cabf05053 100644
--- a/runtime/doc/quickref.txt
+++ b/runtime/doc/quickref.txt
@@ -895,6 +895,7 @@ Short explanation of each option: *option-list*
'terse' shorten some messages
'textwidth' 'tw' maximum width of text that is being inserted
'thesaurus' 'tsr' list of thesaurus files for keyword completion
+'thesaurusfunc' 'tsrfu' function to be used for thesaurus completion
'tildeop' 'top' tilde command "~" behaves like an operator
'timeout' 'to' time out on mappings and key codes
'timeoutlen' 'tm' time out time in milliseconds