fixed mappings bug

master
Elias Almqvist 4 months ago
parent 0d7ea5ee59
commit c096e5bea1
No known key found for this signature in database
GPG Key ID: E31A99CE3E75A158
  1. 18
      nvchad/.config/nvim/lua/chadrc.lua
  2. 49
      nvchad/.config/nvim/lua/mappings.lua

@ -15,22 +15,4 @@ M.ui = {
hl_add = highlights.add,
}
M.plugins = "plugins"
-- Get the mappings
M.mappings = require "mappings"
-- Load the mapping because the devs are retarded and changed it from a good system to a bad one
local function set_mappings(mode, key, value)
local opts = value.opts or {}
opts.desc = value[2]
vim.keymap.set(mode, key, value[1], opts)
end
for mode, mode_mappings in pairs(M.mappings.general) do
for key, mapping in pairs(mode_mappings) do
set_mappings(mode, key, mapping)
end
end
return M

@ -1,38 +1,25 @@
---@type MappingsTable
local M = {}
M.general = {
n = {
[";"] = { ":", "enter command mode", opts = { nowait = true } },
require "nvchad.mappings"
-- format with conform
["<leader>fm"] = {
function()
require("conform").format()
end,
"formatting",
},
},
local map = vim.keymap.set
v = {
-- Indentation
[">"] = { ">gv", "indent" },
-- Move selection up/down with K/J
["J"] = { ":m '>+1<CR>gv=gv", "move selection down" },
["K"] = { ":m '<-2<CR>gv=gv", "move selection up" },
},
-- General
map("n", ";", ":", { desc = "enter command mode", nowait = true })
i = {
["<C-l>"] = {
function()
vim.fn.feedkeys(vim.fn["copilot#Accept"](), "")
end,
"Copilot Accept",
{ replace_keycodes = true, nowait = true, silent = true, expr = true, noremap = true },
},
},
}
-- Format with conform
map("n", "<leader>fm", function()
require("conform").format()
end, { desc = "formatting" })
-- more keybinds!
-- Indentation in visual mode
map("v", ">", ">gv", { desc = "indent" })
return M
-- Move selection up/down with K/J in visual mode
map("v", "J", ":m '>+1<CR>gv=gv", { desc = "move selection down" })
map("v", "K", ":m '<-2<CR>gv=gv", { desc = "move selection up" })
-- Copilot accept in insert mode
map("i", "<C-l>", function()
vim.fn.feedkeys(vim.fn["copilot#Accept"](), "")
end, { desc = "Copilot Accept", replace_keycodes = true, nowait = true, silent = true, expr = true, noremap = true })

Loading…
Cancel
Save