1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-24 05:40:05 +08:00
SpaceVim/bundle/format.nvim/plugin/format.lua

20 lines
529 B
Lua
Raw Normal View History

2024-04-16 11:27:49 +08:00
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,
2024-04-16 11:27:49 +08:00
})