jugglerchris / textadept-vi

Customisation for the textadept editor to make it a bit more like vim.
MIT License
35 stars 5 forks source link

Autocompletion question #37

Open Nanoc-ice opened 3 years ago

Nanoc-ice commented 3 years ago

I am using textadept more and have to have textadept-vi as my fingers just can’t do it any other way, so thank you again for this great plugin. I am not completely knowledgeable about textadept so maybe I am just doing something incorrectly. My question is about textadept’s ability to do autocompletion and the keys that are used. When I am on my Mac, the keys use the escape key as part of the keystroke to use. That seems to interfere with the vi keys since it uses the escape key too. I know that most of the keys can be remapped, but not sure if this could be used with your vi plugin. I think it is maybe in the same spirit of CTL-p (and looking at the code it looks like CTL-n does the same thing, or does it have a different function?).

jugglerchris commented 3 years ago

Hi, Glad you're finding it useful! My fingers are also hard-wired to vi-style editors. ctrl-n is the same as ctrl-p but searches for matches in the other direction.

Can you describe how you're trying to use textadept's autocompletion - what keys you press and what should happen? There's a lot of textadept I haven't used, but if it's useful functionality not covered by textadept-vi I'd ideally like it to be usable.

Nanoc-ice commented 3 years ago

For autocompletion the word completion is Ctrl-Enter for windows, linux and BSD but for Mac it is ctrl-ESC. And then for symbols it’s Ctrl-Space for the others and for Mac is option-ESC. It seems that hitting the ESC messes with the keys used by the textadept-vi plugin. I will look into changing those key strokes outside of the plugin to see if that will address it.

jugglerchris commented 3 years ago

I've had a play around (on Linux/curses, which is my normal environment). Here the complete symbol key is ctrl-space (as you say). It didn't work at first, because textadept-vi's insert mode (which uses a separate key binding table) didn't have that mapping. I've just pushed a commit adding ctrl-space and ctrl-enter to insert mode. At least ctrl-space seems to work.

ESC is pretty fundamental in vi/vim, but I don't see why ctrl-ESC or option-ESC shouldn't work. You may have the same issue as I had. If your problem is in insert mode, can you try adding the lines:

    ['ctrl+esc'] = keys['ctrl+esc'],
    ['alt+esc'] = keys['alt+esc'],

to the vi_mode.mode_insert.bindings table around line 469 of vi_mode.lua?

Also, are you using the GUI version or terminal?

Nanoc-ice commented 3 years ago

I happen to be using the GUI on OS X and once I get it configured the way I want I will switch over to using the terminal version. And, yes, those bindings worked perfectly on OS X. I assume this would be something that would only be set if using OS X. Is there a check that can be made to selectively set these (c-esc, a-esc)?

jugglerchris commented 3 years ago

Textadept itself has some globals set which it uses when setting up the keys - CURSES and OSX - see modules/textadept/keys.lua in Textadept for how they're used.