local django = require "django.utils" local mappings = { n = { ["j"] = { desc = " Django" }, ["ja"] = { function() django.create_app() end, desc = "create app", }, ["jp"] = { function() django.create_package() end, desc = "create python package", }, ["js"] = { function() django.manage_shell_plus(true) end, desc = "shell plus", }, ["je"] = { function() django.create_env_file() end, desc = "create env file", }, ["jr"] = { function() django.manage_run_server "make run" end, desc = "run server", }, ["jm"] = { function() django.manage_make_migrations() end, desc = "make migrations", }, ["ji"] = { function() django.manage_migrate() end, desc = "migrate", }, ["jc"] = { function() django.check() end, desc = "check", }, ["jh"] = { function() django.show_migrations() end, desc = "show migrations", }, ["jy"] = { function() django.run_celery() end, desc = "run celery", }, }, } local M = {} local function key_map(mod, lhs, rhs, opts) if type(lhs) == "string" then vim.keymap.set(mod, lhs, rhs, opts) elseif type(lhs) == "table" then for _, key in pairs(lhs) do vim.keymap.set(mod, key, rhs, opts) end end end function M.setup_global_mappings() if mappings then for k, v in pairs(mappings.n) do if unpack(v) == nil then key_map("n", k, "", { desc = v.desc }) else key_map("n", k, unpack(v), { desc = v.desc }) end end end end return M