You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
1.8 KiB
95 lines
1.8 KiB
1 month ago
|
local django = require "django.utils"
|
||
|
|
||
|
local mappings = {
|
||
|
n = {
|
||
|
["<leader>j"] = { desc = " Django" },
|
||
|
["<leader>ja"] = {
|
||
|
function()
|
||
|
django.create_app()
|
||
|
end,
|
||
|
desc = "create app",
|
||
|
},
|
||
|
["<leader>jp"] = {
|
||
|
function()
|
||
|
django.create_package()
|
||
|
end,
|
||
|
desc = "create python package",
|
||
|
},
|
||
|
["<leader>js"] = {
|
||
|
function()
|
||
|
django.manage_shell_plus(true)
|
||
|
end,
|
||
|
desc = "shell plus",
|
||
|
},
|
||
|
["<leader>je"] = {
|
||
|
function()
|
||
|
django.create_env_file()
|
||
|
end,
|
||
|
desc = "create env file",
|
||
|
},
|
||
|
|
||
|
["<leader>jr"] = {
|
||
|
function()
|
||
|
django.manage_run_server "make run"
|
||
|
end,
|
||
|
desc = "run server",
|
||
|
},
|
||
|
["<leader>jm"] = {
|
||
|
function()
|
||
|
django.manage_make_migrations()
|
||
|
end,
|
||
|
desc = "make migrations",
|
||
|
},
|
||
|
["<leader>ji"] = {
|
||
|
function()
|
||
|
django.manage_migrate()
|
||
|
end,
|
||
|
desc = "migrate",
|
||
|
},
|
||
|
["<leader>jc"] = {
|
||
|
function()
|
||
|
django.check()
|
||
|
end,
|
||
|
desc = "check",
|
||
|
},
|
||
|
["<leader>jh"] = {
|
||
|
function()
|
||
|
django.show_migrations()
|
||
|
end,
|
||
|
desc = "show migrations",
|
||
|
},
|
||
|
["<leader>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
|