|
1 | 1 | --- @class (exact) blink.cmp.ConfigStrict
|
2 |
| ---- @field blocked_filetypes string[] |
| 2 | +--- @field enabled fun(): boolean |
3 | 3 | --- @field keymap blink.cmp.KeymapConfig
|
4 | 4 | --- @field completion blink.cmp.CompletionConfig
|
5 | 5 | --- @field sources blink.cmp.SourceConfig
|
|
12 | 12 | --- but this seems to be a bug. See https://github.com/LuaLS/lua-language-server/issues/2561
|
13 | 13 | --- Much easier than copying every class and marking everything as optional for now :)
|
14 | 14 |
|
15 |
| -local validate = require('blink.cmp.config.utils').validate |
| 15 | +local validate = require("blink.cmp.config.utils").validate |
16 | 16 | --- @type blink.cmp.ConfigStrict
|
17 | 17 | local config = {
|
18 |
| - blocked_filetypes = {}, |
19 |
| - keymap = require('blink.cmp.config.keymap').default, |
20 |
| - completion = require('blink.cmp.config.completion').default, |
21 |
| - fuzzy = require('blink.cmp.config.fuzzy').default, |
22 |
| - sources = require('blink.cmp.config.sources').default, |
23 |
| - signature = require('blink.cmp.config.signature').default, |
24 |
| - snippets = require('blink.cmp.config.snippets').default, |
25 |
| - appearance = require('blink.cmp.config.appearance').default, |
| 18 | + enabled = function() |
| 19 | + return vim.bo.buftype ~= "prompt" |
| 20 | + end, |
| 21 | + keymap = require("blink.cmp.config.keymap").default, |
| 22 | + completion = require("blink.cmp.config.completion").default, |
| 23 | + fuzzy = require("blink.cmp.config.fuzzy").default, |
| 24 | + sources = require("blink.cmp.config.sources").default, |
| 25 | + signature = require("blink.cmp.config.signature").default, |
| 26 | + snippets = require("blink.cmp.config.snippets").default, |
| 27 | + appearance = require("blink.cmp.config.appearance").default, |
26 | 28 | }
|
27 | 29 |
|
28 | 30 | --- @type blink.cmp.Config
|
29 | 31 | local M = {}
|
30 | 32 |
|
31 | 33 | --- @param self blink.cmp.ConfigStrict
|
32 | 34 | function M.validate(self)
|
33 |
| - validate('config', { |
34 |
| - blocked_filetypes = { self.blocked_filetypes, 'table' }, |
35 |
| - keymap = { self.keymap, 'table' }, |
36 |
| - completion = { self.completion, 'table' }, |
37 |
| - sources = { self.sources, 'table' }, |
38 |
| - signature = { self.signature, 'table' }, |
39 |
| - snippets = { self.snippets, 'table' }, |
40 |
| - appearance = { self.appearance, 'table' }, |
41 |
| - }) |
42 |
| - require('blink.cmp.config.completion').validate(self.completion) |
43 |
| - require('blink.cmp.config.sources').validate(self.sources) |
44 |
| - require('blink.cmp.config.signature').validate(self.signature) |
45 |
| - require('blink.cmp.config.snippets').validate(self.snippets) |
46 |
| - require('blink.cmp.config.appearance').validate(self.appearance) |
| 35 | + validate("config", { |
| 36 | + enabled = { self.enabled, "function" }, |
| 37 | + keymap = { self.keymap, "table" }, |
| 38 | + completion = { self.completion, "table" }, |
| 39 | + sources = { self.sources, "table" }, |
| 40 | + signature = { self.signature, "table" }, |
| 41 | + snippets = { self.snippets, "table" }, |
| 42 | + appearance = { self.appearance, "table" }, |
| 43 | + }) |
| 44 | + require("blink.cmp.config.completion").validate(self.completion) |
| 45 | + require("blink.cmp.config.sources").validate(self.sources) |
| 46 | + require("blink.cmp.config.signature").validate(self.signature) |
| 47 | + require("blink.cmp.config.snippets").validate(self.snippets) |
| 48 | + require("blink.cmp.config.appearance").validate(self.appearance) |
47 | 49 | end
|
48 | 50 |
|
49 | 51 | --- @param user_config blink.cmp.Config
|
50 | 52 | function M.merge_with(user_config)
|
51 |
| - config = vim.tbl_deep_extend('force', config, user_config) |
52 |
| - M.validate(config) |
| 53 | + config = vim.tbl_deep_extend("force", config, user_config) |
| 54 | + M.validate(config) |
53 | 55 | end
|
54 | 56 |
|
55 |
| -return setmetatable(M, { __index = function(_, k) return config[k] end }) |
| 57 | +return setmetatable(M, { |
| 58 | + __index = function(_, k) |
| 59 | + return config[k] |
| 60 | + end, |
| 61 | +}) |
0 commit comments