diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-10-17 14:13:09 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-10-17 14:13:09 +0100 |
commit | f4d8b76d304dabc39c06d2344cd4c7b28484811b (patch) | |
tree | 56f98aadab44534d6529e802c00bbff8adbf0969 /runtime | |
parent | 9d4b8caf9eddb2db09395587c621309f4513befa (diff) | |
download | vim-git-f4d8b76d304dabc39c06d2344cd4c7b28484811b.tar.gz |
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scopev8.2.3528
Problem: 'thesaurus' and 'thesaurusfunc' do not have the same scope.
Solution: Make 'thesaurusfunc' global-local.
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/insert.txt | 74 | ||||
-rw-r--r-- | runtime/doc/options.txt | 31 |
2 files changed, 70 insertions, 35 deletions
diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt index 8d47a7e96..7788c0b71 100644 --- a/runtime/doc/insert.txt +++ b/runtime/doc/insert.txt @@ -824,6 +824,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 @@ -832,22 +835,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. - - 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. - CTRL-T or CTRL-N Search forward for next matching keyword. This keyword replaces the previous matching keyword. @@ -855,6 +842,61 @@ 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 + + if has('patch-8.2.3520') + set thesaurusfunc=Thesaur + endif + Completing keywords in the current and included files *compl-keyword* diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index aed0ad41c..f884448bf 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -8027,35 +8027,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. - - 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. + 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) - local to buffer + global or local to buffer |global-local| {not available when compiled without the |+eval| feature} This option specifies a function to be used for thesaurus completion - with CTRL-X CTRL-T. |i_CTRL-X_CTRL-T| - See |complete-functions| for an explanation of how the function is - invoked and what it should return. + 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. |