initial
This commit is contained in:
commit
5931cb012f
9 changed files with 900 additions and 0 deletions
94
lua/django/mappings.lua
Normal file
94
lua/django/mappings.lua
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue