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.

133 lines
6.5 KiB

local astro = require "astrocore"
return {
{
"AstroNvim/astrocore",
---@type AstroCoreOpts
opts = {
mappings = {
n = {
--essentials
["d"] = { "_d" },
["<esc>"] = { "<Nop>" },
["<C-z>"] = { "<Nop>" },
["G"] = { "Gzz" },
["<C-t>"] = { "ggVG<cr>", desc = "select all" },
["<leader>W"] = { "<cmd>w<cr>", desc = "Save" },
["<S-s>"] = { "ciw", desc = "replace word" },
["<S-r>"] = { "cc", desc = "replace line" },
["<M-s>"] = { "viw", desc = "select word" },
["<M-y>"] = { "viwy", desc = "copy word" },
["<M-p>"] = { "viwpgvy", desc = "replace word by copied word" },
["<C-n>"] = { require("dial.map").inc_normal(), desc = "dial increment" },
["<A-j>"] = { ":m .+1<CR>==" },
["<A-k>"] = { ":m .-2<CR>==" },
["<M-o>"] = { "o<esc>p" },
["<S-y>"] = { "0v$y", desc = "copy entire row" },
["<C-]>"] = { "<cmd>tabNext<cr>", desc = "move to next Tab" },
["<C-[>"] = { "<cmd>tabprevious<cr>", desc = "move to previous Tab" },
["<CS-]>"] = { "<cmd>cnext<cr>", desc = "next quickfix" },
["<leader>fl"] = { function() require('helpers').oldfiles({}) end, desc = "find oldfiles" },
--git
["<leader>gy"] = { "<cmd>DiffviewFileHistory %<cr>", desc = "Git file diff history" },
["<leader>gY"] = { "<cmd>DiffviewFileHistory<cr>", desc = "Git diff history" },
--tabs
["<tab>"] = { function() require("astrocore.buffer").nav(vim.v.count1) end, desc = "Next buffer" },
["<S-tab>"] = { function() require("astrocore.buffer").nav(-vim.v.count1) end, desc = "Previous buffer" },
["<leader>bt"] = { "<cmd>tabclose<cr>", desc = "Close tab" },
--window moviment
["<C-h>"] = { "<C-w>h", desc = "Go to left window" },
["<C-l>"] = { "<C-w>l", desc = "Go to right window" },
["<C-j>"] = { "<C-w>j", desc = "Go to lower window" },
["<C-k>"] = { "<C-w>k", desc = "Go to upper window" },
-- split window
["|"] = { "<C-w>v", desc = "Vertical Split" },
["\\"] = { "<C-w>s", desc = "Horizontal Split" },
--terminals get or create
-- ["<C-\\>"] = { "<cmd>ToggleTerm<cr>" },
["<C-\\>"] = { function() require("helpers").toggle_term() end, desc = "Toggle Terminal" },
["<c-;>"] = { function() require("helpers").select_terminal() end, desc = "List All opened terminals" },
["<M-1>"] = {
function() require("helpers").term_horizontal() end,
desc = "Horizontal Terminal",
},
["<M-2>"] = {
function() require("helpers").term_vertical() end,
desc = "Vertical Terminal",
},
["<M-3>"] = {
function() require("helpers").term_float() end,
desc = "Float Terminal",
},
--buffers
["<leader>b"] = { name = "Buffers" },
["<leader>bn"] = { "<cmd>tabnew<cr>", desc = "New tab" },
-- navigate buffer tabs with `H` and `L`
L = { function() require("astrocore.buffer").nav(vim.v.count1) end, desc = "Next buffer" },
H = { function() require("astrocore.buffer").nav(-vim.v.count1) end, desc = "Previous buffer" },
["<Leader>bD"] = {
function()
require("astroui.status.heirline").buffer_picker(
function(bufnr) require("astrocore.buffer").close(bufnr) end
)
end,
desc = "Pick to close",
},
--user extra commands
["<leader>kd"] = {desc =" Database commands"},
["<leader>kdu"] = {"<cmd>DBUIToggle<cr>",desc ="Toggle ui"},
["<leader>kda"] = {"<cmd>DBUIAddConnection<cr>",desc ="Add connection"},
["<leader>k"] = { desc = " User extra commands" },
["<leader>kr"] = { "<cmd>lua require('helpers').openMDfile()<cr>", desc = "Open md file in glow" },
["<leader>km"] = {
"<cmd>lua require('helpers').openMDfile(\"com.github.marktext.marktext\")<cr>",
desc = "Open md file in MarkText",
},
["<leader>kj"] = { "<cmd>set ft=htmldjango<cr>", desc = "set ft=htmldjango" },
["<leader>kh"] = { "<cmd>set ft=html<cr>", desc = "set ft=html" },
["<leader>kt"] = { "<cmd>set ft=templ<cr>", desc = "set ft=templ" },
["<leader>ke"] = {"<cmd>redir! > error_messages | silent messages | redir END | edit!<CR>", desc = "Create error_messages file with vim messages"},
--terminal compile sass to css
["<leader>ts"] = {
function() require("helpers").compile_sass() end,
desc = "compile sass to css.",
},
--python test
["<leader>T"] = { desc = "󰌠 Tests" },
["<leader>Tr"] = { "<cmd>lua require('neotest').run.run()<cr>", desc = "Run test" },
["<leader>Tf"] = { "<cmd>lua require('neotest').run.run(vim.fn.expand('%'))<cr>", desc = "Run test expand" },
["<leader>Td"] = { "<cmd>lua require('neotest').run.run({strategy = 'dap'})<cr>", desc = "Run test dap" },
["<leader>Ts"] = { "<cmd>lua require('neotest').summary.toggle()<cr>", desc = "Toggle test summary" },
["<leader>Tp"] = { "<cmd>lua require('neotest').output_panel.toggle()<cr>", desc = "Toggle output panel" },
--trouble
["<leader>xx"] = { function() require("trouble").toggle() end, desc = "Trouble toggle" },
["<leader>xw"] = {
function() require("trouble").toggle "workspace_diagnostics" end,
desc = "Trouble Workspace",
},
["<leader>xd"] = {
function() require("trouble").toggle "document_diagnostics" end,
desc = "Trouble Document",
},
["<leader>xq"] = { function() require("trouble").toggle "quickfix" end, desc = "Trouble Quickfix" },
["<leader>xl"] = { function() require("trouble").toggle "loclist" end, desc = "Trouble Location" },
["gR"] = { function() require("trouble").toggle "lsp_references" end, desc = "Trouble LSP References" },
},
t = {
["<C-\\>"] = { "<cmd>ToggleTerm<cr>" },
},
v = {
["<S-s>"] = { "ciw", desc = "select word" },
["<"] = { "<gv" },
[">"] = { ">gv" },
["p"] = { "pgvy" },
["d"] = { "_d" },
},
x = {
["<A-j>"] = { ":m '>+1<CR>gv-gv" },
["<A-k>"] = { ":m '<-2<CR>gv-gv" },
},
},
},
},
}