1

Refresh generated neovim config

This commit is contained in:
2024-08-15 13:01:03 +02:00
parent 64b51cf53a
commit f5af8e2b28
1836 changed files with 38979 additions and 31094 deletions

View File

@ -212,7 +212,9 @@ compare.scopes = setmetatable({
-- Cursor scope.
local cursor_scope = nil
for _, scope in ipairs(locals.get_scopes(buf)) do
-- Prioritize the older get_scopes method from nvim-treesitter `master` over get from `main`
local scopes = locals.get_scopes and locals.get_scopes(buf) or select(3, locals.get(buf))
for _, scope in ipairs(scopes) do
if scope:start() <= cursor_row and cursor_row <= scope:end_() then
if not cursor_scope then
cursor_scope = scope

View File

@ -88,6 +88,12 @@ cmp.visible = cmp.sync(function()
return cmp.core.view:visible() or vim.fn.pumvisible() == 1
end)
---Get what number candidates are currently selected.
---If not selected, nil is returned.
cmp.get_selected_index = cmp.sync(function()
return cmp.core.view:get_selected_index()
end)
---Get current selected entry or nil
cmp.get_selected_entry = cmp.sync(function()
return cmp.core.view:get_selected_entry()

View File

@ -14,7 +14,7 @@ feedkeys.call = setmetatable({
if #keys > 0 then
table.insert(queue, { keymap.t('<Cmd>setlocal lazyredraw<CR>'), 'n' })
table.insert(queue, { keymap.t('<Cmd>setlocal textwidth=0<CR>'), 'n' })
table.insert(queue, { keymap.t('<Cmd>setlocal backspace=2<CR>'), 'n' })
table.insert(queue, { keymap.t('<Cmd>setlocal backspace=nostop<CR>'), 'n' })
table.insert(queue, { keys, string.gsub(mode, '[itx]', ''), true })
table.insert(queue, { keymap.t('<Cmd>setlocal %slazyredraw<CR>'):format(vim.o.lazyredraw and '' or 'no'), 'n' })
table.insert(queue, { keymap.t('<Cmd>setlocal textwidth=%s<CR>'):format(vim.bo.textwidth or 0), 'n' })
@ -44,7 +44,10 @@ feedkeys.call = setmetatable({
})
feedkeys.run = function(id)
if feedkeys.call.callbacks[id] then
feedkeys.call.callbacks[id]()
local ok, err = pcall(feedkeys.call.callbacks[id])
if not ok then
vim.notify(err, vim.log.levels.ERROR)
end
feedkeys.call.callbacks[id] = nil
end
return ''

View File

@ -211,6 +211,13 @@ view.scroll_docs = function(self, delta)
self.docs_view:scroll(delta)
end
---Get what number candidates are currently selected.
---If not selected, nil is returned.
---@return integer|nil
view.get_selected_index = function(self)
return self:_get_entries_view():get_selected_index()
end
---Select prev menu item.
---@param option cmp.SelectOption
view.select_next_item = function(self, option)

View File

@ -306,9 +306,15 @@ custom_entries_view.info = function(self)
return self.entries_win:info()
end
custom_entries_view.get_selected_index = function(self)
if self:visible() and self.entries_win:option('cursorline') then
return vim.api.nvim_win_get_cursor(self.entries_win.win)[1]
end
end
custom_entries_view.select_next_item = function(self, option)
if self:visible() then
local cursor = vim.api.nvim_win_get_cursor(self.entries_win.win)[1]
local cursor = self:get_selected_index()
local is_top_down = self:is_direction_top_down()
local last = #self.entries
@ -345,7 +351,7 @@ end
custom_entries_view.select_prev_item = function(self, option)
if self:visible() then
local cursor = vim.api.nvim_win_get_cursor(self.entries_win.win)[1]
local cursor = self:get_selected_index()
local is_top_down = self:is_direction_top_down()
local last = #self.entries
@ -402,7 +408,7 @@ end
custom_entries_view.get_selected_entry = function(self)
if self:visible() and self.entries_win:option('cursorline') then
return self.entries[vim.api.nvim_win_get_cursor(self.entries_win.win)[1]]
return self.entries[self:get_selected_index()]
end
end

View File

@ -1,7 +1,7 @@
local config = require('cmp.config')
local misc = require('cmp.utils.misc')
local snippet = require('cmp.utils.snippet')
local str = require('cmp.utils.str')
-- local str = require('cmp.utils.str')
local api = require('cmp.utils.api')
local types = require('cmp.types')

View File

@ -116,6 +116,15 @@ native_entries_view.preselect = function(self, index)
end
end
native_entries_view.get_selected_index = function(self)
if self:visible() then
local idx = vim.fn.complete_info({ 'selected' }).selected
if idx > -1 then
return math.max(0, idx) + 1
end
end
end
native_entries_view.select_next_item = function(self, option)
local callback = function()
self.event:emit('change')
@ -163,11 +172,9 @@ native_entries_view.get_first_entry = function(self)
end
native_entries_view.get_selected_entry = function(self)
if self:visible() then
local idx = vim.fn.complete_info({ 'selected' }).selected
if idx > -1 then
return self.entries[math.max(0, idx) + 1]
end
local idx = self:get_selected_index()
if idx then
return self.entries[idx]
end
end

View File

@ -179,6 +179,12 @@ wildmenu_entries_view.info = function(self)
return self.entries_win:info()
end
wildmenu_entries_view.get_selected_index = function(self)
if self:visible() and self.active then
return self.selected_index
end
end
wildmenu_entries_view.select_next_item = function(self, option)
if self:visible() then
local cursor
@ -223,8 +229,9 @@ wildmenu_entries_view.get_first_entry = function(self)
end
wildmenu_entries_view.get_selected_entry = function(self)
if self:visible() and self.active then
return self.entries[self.selected_index]
local idx = self:get_selected_index()
if idx then
return self.entries[idx]
end
end