Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for native vim auto-complete and mappings (eg ^X - ^T) #7

Open
petRUShka opened this issue Apr 17, 2016 · 6 comments
Open

Support for native vim auto-complete and mappings (eg ^X - ^T) #7

petRUShka opened this issue Apr 17, 2016 · 6 comments

Comments

@petRUShka
Copy link

There is native vim support for thesaurus:

'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. 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.

It would be great for that plugin to replace that functionality. Because sometimes it much better for speed and convenience to have autocomplete list.

@Ron89
Copy link
Owner

Ron89 commented Apr 18, 2016

Hmm. Actually, one of the original motivation for me to create this plugin is that I don't like the menu-like synonym choosing interface, browsing dozens or even hundreds of synonyms one by one could be a very painful experience. I intended to design it to be similar to Vim's spell check function rather than auto-completion functionality, so that all options are displayed nice and clean. And you can choose the synonym with a simple number. But if you want, I guess sending the query result back to Vim's auto-completion is doable. I'll need some time to read-up on how, though.

There is one issue I can think of. If user choose to use this plugin's query result as a source for Vim's auto-completion(after it's made possible). Each auto-complete invoking key-stroke will invoke online query function, which can take seconds to complete. That might pose significant lagging. With async feature provided by NeoVim or Vim 8+, it is possible to reduce the lag time. But that is still yet to be seen.

@Ron89
Copy link
Owner

Ron89 commented Apr 21, 2016

Insert-mode auto-completion is added through completefunc (commit 98a3d20). That is, by <ctrl-x ctrl-u> in insert mode, online-query functionality will be invoked.

@petRUShka
Copy link
Author

Great! I'll try it!

@petRUShka
Copy link
Author

By the way. Is it impossible to bind ctrl-X ctrl-T?

@petRUShka
Copy link
Author

petRUShka commented Apr 21, 2016

When I try to use ctrl-x ctrl-u for Enlish word I catch an error:

WARNING: one or more query backends report error. Please check on thesaurus source(s).    
Error detected while processing function thesaurus_query#auto_complete_integrate:    
line 23:     
Traceback (most recent call last):    
Error detected while processing function thesaurus_query#auto_complete_integrate:    
line 23:     
 File "<string>", line 8, in <module>    
Error detected while processing function thesaurus_query#auto_complete_integrate:    
line 23:     
vim.error: Vim(let):E121: Undefined variable: u 

When I use it for Russian word it is just:

User defined completion (^U^N^P) Pattern not found

When I use <Leader>-cs it works perfectly both for Russian and English.

@Ron89
Copy link
Owner

Ron89 commented Apr 22, 2016

The issue is likely caused by:

  1. the decoding of utf-8 characters. Implementing it was an afterthought, so there were a lot of inconsistencies in the code.
  2. Vim 7.3 don't accept decoded unicode string return from Python while Vim 7.4 do, hence when there are Russian words, Vim 7.3 tend to report error when result is returned from Python.

In latest commits(1b323a6), I have systematically went through all the encoding details within modules. It should work fine at this point(I have already tested it on OS X and Linux, both Vim 7.3 and Vim 7.4).


Your

User defined completion (^U^N^P) Pattern not found

for Russian query is possibly caused by not setting g:tq_language or buffer specific b:tq_language correctly. You should set it to either ['ru', 'en'] or 'ru' in your ~/.vimrc to activate Russian synonym query.


I don't know if overriding ctrl-X ctrl-T is possible. As far as I know, the documentation of Vim didn't cover it. And I don't believe it's as simple as remapping. But after reading Vim's documentation, I find completefunc flexible enough for me to implement the insert-mode autocompletion functionality, so I coded as such.

Hope you find the fixed plugin better suited your working style. :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants