-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathneominimap.lua
More file actions
38 lines (37 loc) · 1.5 KB
/
neominimap.lua
File metadata and controls
38 lines (37 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
local api = vim.api
local config = require("neominimap.config")
api.nvim_create_user_command("Neominimap", function(opts)
local fargs = opts.fargs
local subcommand_key = fargs[1]
local args = #fargs > 1 and vim.list_slice(fargs, 2, #fargs) or {}
local subcommand_tbl = require("neominimap.command").subcommand_tbl
local subcommand = subcommand_tbl[subcommand_key]
if not subcommand then
local logger = require("neominimap.logger")
logger.notify("Neominimap: Unknown command: " .. subcommand_key, vim.log.levels.ERROR)
return
end
subcommand.impl(args, opts)
end, {
nargs = "+",
desc = "Neominimap command",
complete = function(arg_lead, cmdline, _)
local subcommand_tbl = require("neominimap.command").subcommand_tbl
local subcmd_key, subcmd_arg_lead = cmdline:match("^['<,'>]*Neominimap[!]*%s(%S+)%s(.*)$")
if subcmd_key and subcmd_arg_lead and subcommand_tbl[subcmd_key] and subcommand_tbl[subcmd_key].complete then
return subcommand_tbl[subcmd_key].complete(subcmd_arg_lead)
end
if cmdline:match("^['<,'>]*Neominimap[!]*%s+%w*$") then
local subcommand_keys = vim.tbl_keys(subcommand_tbl)
return vim.iter(subcommand_keys)
:filter(function(key)
return key:find(arg_lead) ~= nil
end)
:totable()
end
end,
bang = false,
})
if config.auto_enable then
require("neominimap.autocmds").create_autocmds()
end