mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 20:00:05 +08:00
20 lines
529 B
Lua
20 lines
529 B
Lua
vim.api.nvim_create_user_command('Format', function(opts)
|
|
require('format').format(opts.bang, opts.args, opts.line1, opts.line2)
|
|
end, {
|
|
nargs = '*',
|
|
range = '%',
|
|
bang = true,
|
|
bar = true,
|
|
complete = function(_, line)
|
|
local ft = vim.o.filetype
|
|
local l = vim.split(line, '%s+')
|
|
local ok, default = pcall(require, 'format.ft.' .. ft)
|
|
if ok then
|
|
return vim.tbl_filter(function(val)
|
|
return vim.startswith(val, l[#l])
|
|
end, default.enabled())
|
|
else
|
|
end
|
|
end,
|
|
})
|