fix StyLua command (#190)
* style: fix StyLua glob pattern * style: fix style with StyLua run './utils/stylua --config-path stylua.toml --glob 'lua/**/*.lua' -- lua'
This commit is contained in:
6
Makefile
6
Makefile
@@ -1,6 +1,6 @@
|
|||||||
.PHONY: fmt
|
.PHONY: fmt
|
||||||
fmt:
|
fmt:
|
||||||
stylua --config-path stylua.toml --glob lua/**/*.lua -- lua
|
stylua --config-path stylua.toml --glob 'lua/**/*.lua' -- lua
|
||||||
|
|
||||||
.PHONY: lint
|
.PHONY: lint
|
||||||
lint:
|
lint:
|
||||||
@@ -12,13 +12,13 @@ test:
|
|||||||
|
|
||||||
.PHONY: pre-commit
|
.PHONY: pre-commit
|
||||||
pre-commit:
|
pre-commit:
|
||||||
./utils/stylua --config-path stylua.toml --glob lua/**/*.lua -- lua
|
./utils/stylua --config-path stylua.toml --glob 'lua/**/*.lua' -- lua
|
||||||
luacheck lua
|
luacheck lua
|
||||||
vusted lua
|
vusted lua
|
||||||
|
|
||||||
.PHONY: integration
|
.PHONY: integration
|
||||||
integration:
|
integration:
|
||||||
./utils/stylua --config-path stylua.toml --check --glob lua/**/*.lua -- lua
|
./utils/stylua --config-path stylua.toml --check --glob 'lua/**/*.lua' -- lua
|
||||||
luacheck lua
|
luacheck lua
|
||||||
vusted lua
|
vusted lua
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
local types = require'cmp.types'
|
local types = require('cmp.types')
|
||||||
local misc = require 'cmp.utils.misc'
|
local misc = require('cmp.utils.misc')
|
||||||
|
|
||||||
local compare = {}
|
local compare = {}
|
||||||
|
|
||||||
@@ -85,4 +85,3 @@ compare.order = function(entry1, entry2)
|
|||||||
end
|
end
|
||||||
|
|
||||||
return compare
|
return compare
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ return function()
|
|||||||
keyword_length = 1,
|
keyword_length = 1,
|
||||||
get_trigger_characters = function(trigger_characters)
|
get_trigger_characters = function(trigger_characters)
|
||||||
return trigger_characters
|
return trigger_characters
|
||||||
end
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
snippet = {
|
snippet = {
|
||||||
@@ -37,7 +37,7 @@ return function()
|
|||||||
default_behavior = types.cmp.ConfirmBehavior.Insert,
|
default_behavior = types.cmp.ConfirmBehavior.Insert,
|
||||||
get_commit_characters = function(commit_characters)
|
get_commit_characters = function(commit_characters)
|
||||||
return commit_characters
|
return commit_characters
|
||||||
end
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
sorting = {
|
sorting = {
|
||||||
@@ -50,7 +50,7 @@ return function()
|
|||||||
compare.sort_text,
|
compare.sort_text,
|
||||||
compare.length,
|
compare.length,
|
||||||
compare.order,
|
compare.order,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
event = {},
|
event = {},
|
||||||
@@ -61,7 +61,7 @@ return function()
|
|||||||
deprecated = true,
|
deprecated = true,
|
||||||
format = function(_, vim_item)
|
format = function(_, vim_item)
|
||||||
return vim_item
|
return vim_item
|
||||||
end
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
experimental = {
|
experimental = {
|
||||||
@@ -71,4 +71,3 @@ return function()
|
|||||||
sources = {},
|
sources = {},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -104,4 +104,3 @@ cmp.PreselectMode.None = 'none'
|
|||||||
---@field public max_item_count number
|
---@field public max_item_count number
|
||||||
|
|
||||||
return cmp
|
return cmp
|
||||||
|
|
||||||
|
|||||||
@@ -5,4 +5,3 @@ types.lsp = require('cmp.types.lsp')
|
|||||||
types.vim = require('cmp.types.vim')
|
types.vim = require('cmp.types.vim')
|
||||||
|
|
||||||
return types
|
return types
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
|
local misc = require('cmp.utils.misc')
|
||||||
local misc = require "cmp.utils.misc"
|
|
||||||
---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/
|
---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/
|
||||||
---@class lsp
|
---@class lsp
|
||||||
local lsp = {}
|
local lsp = {}
|
||||||
@@ -18,7 +17,7 @@ lsp.Position.to_vim = function(buf, position)
|
|||||||
if #lines > 0 then
|
if #lines > 0 then
|
||||||
return {
|
return {
|
||||||
row = position.line + 1,
|
row = position.line + 1,
|
||||||
col = misc.to_vimindex(lines[1], position.character)
|
col = misc.to_vimindex(lines[1], position.character),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
return {
|
return {
|
||||||
@@ -196,4 +195,3 @@ lsp.CompletionItemKind = vim.tbl_add_reverse_lookup(lsp.CompletionItemKind)
|
|||||||
---@field public dup boolean|nil
|
---@field public dup boolean|nil
|
||||||
|
|
||||||
return lsp
|
return lsp
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
local spec = require'cmp.utils.spec'
|
local spec = require('cmp.utils.spec')
|
||||||
local lsp = require'cmp.types.lsp'
|
local lsp = require('cmp.types.lsp')
|
||||||
|
|
||||||
describe('types.lsp', function()
|
describe('types.lsp', function()
|
||||||
before_each(spec.before)
|
before_each(spec.before)
|
||||||
@@ -44,4 +44,3 @@ describe('types.lsp', function ()
|
|||||||
assert.are.equal(lsp_position.character, 5)
|
assert.are.equal(lsp_position.character, 5)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
@@ -15,4 +15,3 @@
|
|||||||
---@class vim.Range
|
---@class vim.Range
|
||||||
---@field public start vim.Position
|
---@field public start vim.Position
|
||||||
---@field public end vim.Position
|
---@field public end vim.Position
|
||||||
|
|
||||||
|
|||||||
@@ -27,11 +27,15 @@ async.throttle = function(fn, timeout)
|
|||||||
timer:stop()
|
timer:stop()
|
||||||
|
|
||||||
local delta = math.max(0, self.timeout - (vim.loop.now() - time))
|
local delta = math.max(0, self.timeout - (vim.loop.now() - time))
|
||||||
timer:start(delta, 0, vim.schedule_wrap(function()
|
timer:start(
|
||||||
|
delta,
|
||||||
|
0,
|
||||||
|
vim.schedule_wrap(function()
|
||||||
time = nil
|
time = nil
|
||||||
fn(unpack(args))
|
fn(unpack(args))
|
||||||
end))
|
end)
|
||||||
end
|
)
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -52,4 +56,3 @@ async.dedup = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
return async
|
return async
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
local async = require "cmp.utils.async"
|
local async = require('cmp.utils.async')
|
||||||
|
|
||||||
describe('utils.async', function()
|
describe('utils.async', function()
|
||||||
|
|
||||||
it('throttle', function()
|
it('throttle', function()
|
||||||
local count = 0
|
local count = 0
|
||||||
local now
|
local now
|
||||||
@@ -13,14 +12,18 @@ describe('utils.async', function()
|
|||||||
now = vim.loop.now()
|
now = vim.loop.now()
|
||||||
f.timeout = 100
|
f.timeout = 100
|
||||||
f()
|
f()
|
||||||
vim.wait(1000, function() return count == 1 end)
|
vim.wait(1000, function()
|
||||||
|
return count == 1
|
||||||
|
end)
|
||||||
assert.is.truthy(math.abs(f.timeout - (vim.loop.now() - now)) < 10)
|
assert.is.truthy(math.abs(f.timeout - (vim.loop.now() - now)) < 10)
|
||||||
|
|
||||||
-- 2. delay for 500ms
|
-- 2. delay for 500ms
|
||||||
now = vim.loop.now()
|
now = vim.loop.now()
|
||||||
f.timeout = 500
|
f.timeout = 500
|
||||||
f()
|
f()
|
||||||
vim.wait(1000, function() return count == 2 end)
|
vim.wait(1000, function()
|
||||||
|
return count == 2
|
||||||
|
end)
|
||||||
assert.is.truthy(math.abs(f.timeout - (vim.loop.now() - now)) < 10)
|
assert.is.truthy(math.abs(f.timeout - (vim.loop.now() - now)) < 10)
|
||||||
|
|
||||||
-- 4. delay for 500ms and wait 100ms (remain 400ms)
|
-- 4. delay for 500ms and wait 100ms (remain 400ms)
|
||||||
@@ -32,9 +35,9 @@ describe('utils.async', function()
|
|||||||
now = vim.loop.now()
|
now = vim.loop.now()
|
||||||
f.timeout = 100
|
f.timeout = 100
|
||||||
f()
|
f()
|
||||||
vim.wait(1000, function() return count == 3 end)
|
vim.wait(1000, function()
|
||||||
|
return count == 3
|
||||||
|
end)
|
||||||
assert.is.truthy(math.abs(vim.loop.now() - now) < 10)
|
assert.is.truthy(math.abs(vim.loop.now() - now) < 10)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
@@ -54,4 +54,3 @@ cache.key = function(_, key)
|
|||||||
end
|
end
|
||||||
|
|
||||||
return cache
|
return cache
|
||||||
|
|
||||||
|
|||||||
@@ -110,4 +110,3 @@ char.match = function(byte1, byte2)
|
|||||||
end
|
end
|
||||||
|
|
||||||
return char
|
return char
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ end
|
|||||||
|
|
||||||
---Feedkeys with callback
|
---Feedkeys with callback
|
||||||
keymap.feedkeys = setmetatable({
|
keymap.feedkeys = setmetatable({
|
||||||
callbacks = {}
|
callbacks = {},
|
||||||
}, {
|
}, {
|
||||||
__call = function(self, keys, mode, callback)
|
__call = function(self, keys, mode, callback)
|
||||||
if #keys ~= 0 then
|
if #keys ~= 0 then
|
||||||
@@ -104,7 +104,7 @@ keymap.feedkeys = setmetatable({
|
|||||||
wait()
|
wait()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end,
|
||||||
})
|
})
|
||||||
misc.set(_G, { 'cmp', 'utils', 'keymap', 'feedkeys', 'run' }, function(id)
|
misc.set(_G, { 'cmp', 'utils', 'keymap', 'feedkeys', 'run' }, function(id)
|
||||||
if keymap.feedkeys.callbacks[id] then
|
if keymap.feedkeys.callbacks[id] then
|
||||||
@@ -201,4 +201,3 @@ misc.set(_G, { 'cmp', 'utils', 'keymap', 'listen', 'run' }, function(mode, keys)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
return keymap
|
return keymap
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ end
|
|||||||
---@param v2 T
|
---@param v2 T
|
||||||
---@return T
|
---@return T
|
||||||
misc.merge = function(v1, v2)
|
misc.merge = function(v1, v2)
|
||||||
local merge1 = type(v1) == "table" and (not vim.tbl_islist(v1) or vim.tbl_isempty(v1))
|
local merge1 = type(v1) == 'table' and (not vim.tbl_islist(v1) or vim.tbl_isempty(v1))
|
||||||
local merge2 = type(v2) == "table" and (not vim.tbl_islist(v1) or vim.tbl_isempty(v1))
|
local merge2 = type(v2) == 'table' and (not vim.tbl_islist(v1) or vim.tbl_isempty(v1))
|
||||||
if merge1 and merge2 then
|
if merge1 and merge2 then
|
||||||
local new_tbl = {}
|
local new_tbl = {}
|
||||||
for k, v in pairs(v2) do
|
for k, v in pairs(v2) do
|
||||||
@@ -48,16 +48,15 @@ misc.merge = function(v1, v2)
|
|||||||
return v1
|
return v1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
---Generate id for group name
|
---Generate id for group name
|
||||||
misc.id = setmetatable({
|
misc.id = setmetatable({
|
||||||
group = {}
|
group = {},
|
||||||
}, {
|
}, {
|
||||||
__call = function(_, group)
|
__call = function(_, group)
|
||||||
misc.id.group[group] = misc.id.group[group] or 0
|
misc.id.group[group] = misc.id.group[group] or 0
|
||||||
misc.id.group[group] = misc.id.group[group] + 1
|
misc.id.group[group] = misc.id.group[group] + 1
|
||||||
return misc.id.group[group]
|
return misc.id.group[group]
|
||||||
end
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
---Check the value is nil or not.
|
---Check the value is nil or not.
|
||||||
|
|||||||
@@ -8,21 +8,20 @@ describe('misc', function()
|
|||||||
it('merge', function()
|
it('merge', function()
|
||||||
local merged
|
local merged
|
||||||
merged = misc.merge({
|
merged = misc.merge({
|
||||||
a = {}
|
a = {},
|
||||||
}, {
|
}, {
|
||||||
a = {
|
a = {
|
||||||
b = 1
|
b = 1,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
assert.are.equal(merged.a.b, 1)
|
assert.are.equal(merged.a.b, 1)
|
||||||
merged = misc.merge({
|
merged = misc.merge({
|
||||||
a = false
|
a = false,
|
||||||
}, {
|
}, {
|
||||||
a = {
|
a = {
|
||||||
b = 1
|
b = 1,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
assert.are.equal(merged.a, false)
|
assert.are.equal(merged.a, false)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
@@ -26,4 +26,3 @@ pattern.matchstr = function(p, text)
|
|||||||
end
|
end
|
||||||
|
|
||||||
return pattern
|
return pattern
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
local context = require'cmp.context'
|
local context = require('cmp.context')
|
||||||
local source = require 'cmp.source'
|
local source = require('cmp.source')
|
||||||
local types = require('cmp.types')
|
local types = require('cmp.types')
|
||||||
|
|
||||||
local spec = {}
|
local spec = {}
|
||||||
|
|
||||||
spec.before = function()
|
spec.before = function()
|
||||||
vim.cmd [[
|
vim.cmd([[
|
||||||
bdelete!
|
bdelete!
|
||||||
enew!
|
enew!
|
||||||
setlocal virtualedit=all
|
setlocal virtualedit=all
|
||||||
]]
|
]])
|
||||||
end
|
end
|
||||||
|
|
||||||
spec.state = function(text, row, col)
|
spec.state = function(text, row, col)
|
||||||
@@ -17,8 +17,7 @@ spec.state = function(text, row, col)
|
|||||||
vim.fn.cursor(row, col)
|
vim.fn.cursor(row, col)
|
||||||
local ctx = context.empty()
|
local ctx = context.empty()
|
||||||
local s = source.new('spec', {
|
local s = source.new('spec', {
|
||||||
complete = function()
|
complete = function() end,
|
||||||
end
|
|
||||||
})
|
})
|
||||||
return {
|
return {
|
||||||
context = function()
|
context = function()
|
||||||
@@ -46,9 +45,8 @@ spec.state = function(text, row, col)
|
|||||||
ctx = context.new(ctx, { reason = types.cmp.ContextReason.Manual })
|
ctx = context.new(ctx, { reason = types.cmp.ContextReason.Manual })
|
||||||
s:complete(ctx, function() end)
|
s:complete(ctx, function() end)
|
||||||
return ctx
|
return ctx
|
||||||
end
|
end,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
return spec
|
return spec
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
local char = require'cmp.utils.char'
|
local char = require('cmp.utils.char')
|
||||||
local pattern = require 'cmp.utils.pattern'
|
local pattern = require('cmp.utils.pattern')
|
||||||
|
|
||||||
local str = {}
|
local str = {}
|
||||||
|
|
||||||
@@ -179,4 +179,3 @@ str.escape = function(text, chars)
|
|||||||
end
|
end
|
||||||
|
|
||||||
return str
|
return str
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
local str = require "cmp.utils.str"
|
local str = require('cmp.utils.str')
|
||||||
|
|
||||||
describe('utils.str', function()
|
describe('utils.str', function()
|
||||||
|
|
||||||
it('get_word', function()
|
it('get_word', function()
|
||||||
assert.are.equal(str.get_word('print'), 'print')
|
assert.are.equal(str.get_word('print'), 'print')
|
||||||
assert.are.equal(str.get_word('$variable'), '$variable')
|
assert.are.equal(str.get_word('$variable'), '$variable')
|
||||||
@@ -27,7 +26,4 @@ describe('utils.str', function()
|
|||||||
assert.are.equal(str.escape('plain\\"', {}), 'plain\\\\"')
|
assert.are.equal(str.escape('plain\\"', {}), 'plain\\\\"')
|
||||||
assert.are.equal(str.escape('pla"in', { '"' }), 'pla\\"in')
|
assert.are.equal(str.escape('pla"in', { '"' }), 'pla\\"in')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user