mirror of
https://github.com/hrsh7th/nvim-cmp
synced 2024-09-16 20:54:03 +02:00
Fix CI
This commit is contained in:
parent
3aea293169
commit
f38680a248
5 changed files with 19 additions and 9 deletions
|
@ -1,2 +1,3 @@
|
|||
globals = { 'vim', 'describe', 'it', 'before_each', 'after_each', 'assert', 'async' }
|
||||
max_line_length = false
|
||||
ignore = { '311', '431', '432' }
|
||||
|
|
|
@ -89,7 +89,7 @@ describe('cmp', function()
|
|||
})
|
||||
end,
|
||||
}, {
|
||||
trigger_characters = { 'v' }
|
||||
trigger_characters = { 'v' },
|
||||
})
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
assert.are.same(vim.tbl_values(c.sources)[1]:get_trigger_characters(), { 'v' })
|
||||
|
|
|
@ -4,8 +4,8 @@ local Cache = require('cmp.kit.App.Cache')
|
|||
---@alias cmp.kit.App.Config.SchemaInternal cmp.kit.App.Config.Schema|{ revision: integer }
|
||||
|
||||
---@class cmp.kit.App.Config
|
||||
---@field private cache cmp.kit.App.Cache
|
||||
---@field private default cmp.kit.App.Config.SchemaInternal
|
||||
---@field private _cache cmp.kit.App.Cache
|
||||
---@field private _default cmp.kit.App.Config.SchemaInternal
|
||||
---@field private _global cmp.kit.App.Config.SchemaInternal
|
||||
---@field private _filetype table<string, cmp.kit.App.Config.SchemaInternal>
|
||||
---@field private _buffer table<integer, cmp.kit.App.Config.SchemaInternal>
|
||||
|
@ -16,14 +16,20 @@ Config.__index = Config
|
|||
---@param default? cmp.kit.App.Config.Schema
|
||||
function Config.new(default)
|
||||
local self = setmetatable({}, Config)
|
||||
self.cache = Cache.new()
|
||||
self.default = default or {}
|
||||
self._cache = Cache.new()
|
||||
self._default = default or {}
|
||||
self._global = {}
|
||||
self._filetype = {}
|
||||
self._buffer = {}
|
||||
return self
|
||||
end
|
||||
|
||||
---Set default configuration.
|
||||
---@param default cmp.kit.App.Config.Schema
|
||||
function Config:default(default)
|
||||
self._default = default
|
||||
end
|
||||
|
||||
---Update global config.
|
||||
---@param config cmp.kit.App.Config.Schema
|
||||
function Config:global(config)
|
||||
|
@ -58,12 +64,12 @@ end
|
|||
function Config:get()
|
||||
local filetype = vim.api.nvim_buf_get_option(0, 'filetype')
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
return self.cache:ensure({
|
||||
return self._cache:ensure({
|
||||
tostring(self._global.revision or 0),
|
||||
tostring((self._buffer[bufnr] or {}).revision or 0),
|
||||
tostring((self._filetype[filetype] or {}).revision or 0),
|
||||
}, function()
|
||||
local config = self.default
|
||||
local config = self._default
|
||||
config = kit.merge(self._global, config)
|
||||
config = kit.merge(self._filetype[filetype] or {}, config)
|
||||
config = kit.merge(self._buffer[bufnr] or {}, config)
|
||||
|
|
|
@ -42,8 +42,10 @@ function Event:off(name, listener)
|
|||
self._events[name] = nil
|
||||
else
|
||||
for i = #self._events[name], 1, -1 do
|
||||
table.remove(self._events[name], i)
|
||||
break
|
||||
if self._events[name][i] == listener then
|
||||
table.remove(self._events[name], i)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,6 +26,7 @@ end
|
|||
---@param text string
|
||||
---@param pattern string
|
||||
---@param pos number 1-origin index
|
||||
---@return string?, integer?, integer? 1-origin-index
|
||||
function RegExp.extract_at(text, pattern, pos)
|
||||
local before_text = text:sub(1, pos - 1)
|
||||
local after_text = text:sub(pos)
|
||||
|
|
Loading…
Reference in a new issue