Skip to content
This repository has been archived by the owner on Jan 27, 2022. It is now read-only.

add preselect confirm mode #256

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

oberblastmeister
Copy link

@oberblastmeister oberblastmeister commented Mar 14, 2021

Closes #254. I added a new confirm function in lua because I can't access the Config in vimscript. Also lua is much easier to write and probably faster as a side benefit. To use it you will have to do

vim.cmd [[imap <silent><expr> <Tab> luaeval('require("compe").confirm("<Tab>")')]]

@hrsh7th
Copy link
Owner

hrsh7th commented Mar 15, 2021

I think we should implement compe#confirm({ 'fallback': '<Tab>', 'select': v:true }) instead of this solution.
I will implement it.

This PR has no vim side implementation so I can't merge it. Sorry.

@hrsh7th
Copy link
Owner

hrsh7th commented Mar 15, 2021

@oberblastmeister Could you test select-option branch?

@oberblastmeister
Copy link
Author

just curious, why must it be a vimscript implementation?

@hrsh7th
Copy link
Owner

hrsh7th commented Mar 16, 2021

Because the Lua's keymapping is problematic, I think.

@gegoune
Copy link
Contributor

gegoune commented Mar 16, 2021

Because the Lua's keymapping is problematic, I think.

In what way? As in, too verbose?
Would be nice not to have any viml here. :)

@hrsh7th
Copy link
Owner

hrsh7th commented Mar 16, 2021

For example, nvim-compe is providing the compe#complete that is expected for use in <expr> mapping.
I think the <expr> mapping can't call directly in Lua so after all, it is useful if it is written in Vim script.

@gegoune
Copy link
Contributor

gegoune commented Mar 16, 2021

I think it does work, one can do that:

vim.api.nvim_set_keymap("i", "<CR>", "v:lua.OnEnter()", {noremap = true, expr = true})

which is what I am doing. Would be possible to just call compe.Complete or something like that, I believe.

@hrsh7th
Copy link
Owner

hrsh7th commented Mar 16, 2021

Hm... I can't think it is better... (It has no difference for my eyes)

Now

vim.api.nvim_set_keymap("i", "<CR>", "compe#complete('<CR>')", {noremap = true, expr = true})

Proposed

vim.api.nvim_set_keymap("i", "<CR>", "v:lua.compe.complete('<CR>')", {noremap = true, expr = true})

@gegoune
Copy link
Contributor

gegoune commented Mar 16, 2021

From this perspective it really changes very little, but would allow for getting rid of viml completely.

@oberblastmeister
Copy link
Author

I think both implementations are okay on the outside and expr mappings definately work with lua. However, lua is trying to be a first class citizen in neovim and since this plugin doesn't support vim I feel like it makes sense to use lua and get rid of viml. In addition, lua keymaps and autocommands are coming so it can make the above snippet even nicer, as we can directly map to lua functions. To me, lua is objectively a better language and we are using nvim so we should use it. Those were just my (slightly opinionated) thoughts. Anyways, thanks for your work on this plugin because it has made the completion experience very nice and smooth.

@stale
Copy link

stale bot commented Aug 13, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Aug 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
wontfix This will not be worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

disable default <CR> mapping
3 participants