feat: improve mappings, move custom/init.lua & chadrc.lua
-> custom/example_init.lua & example_chadrc.lua
This commit is contained in:
parent
9961cc0113
commit
ee586047e5
@ -113,21 +113,9 @@ M.misc = function()
|
|||||||
-- cmd "silent! command! NvChadReload lua require('nvchad').reload_config()"
|
-- cmd "silent! command! NvChadReload lua require('nvchad').reload_config()"
|
||||||
end
|
end
|
||||||
|
|
||||||
local function user_config_mappings()
|
|
||||||
local custom_maps = config.mappings.custom or ""
|
|
||||||
if type(custom_maps) ~= "table" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
for _, map_table in pairs(custom_maps) do
|
|
||||||
map(unpack(map_table))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
non_config_mappings()
|
non_config_mappings()
|
||||||
optional_mappings()
|
optional_mappings()
|
||||||
required_mappings()
|
required_mappings()
|
||||||
user_config_mappings()
|
|
||||||
hooks.run("setup_mappings", map)
|
hooks.run("setup_mappings", map)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,31 +1,23 @@
|
|||||||
-- IMPORTANT NOTE : This is the user config, can be edited. Will be preserved if updated with internal updater
|
-- IMPORTANT NOTE : This is the user config, can be edited. Will be preserved if updated with internal updater
|
||||||
|
-- This file is for NvChad options & tools, custom settings are split between here and 'lua/custom/init.lua'
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
M.options, M.ui, M.mappings, M.plugins = {}, {}, {}, {}
|
M.options, M.ui, M.mappings, M.plugins = {}, {}, {}, {}
|
||||||
|
|
||||||
|
-- NOTE: To use this, make a copy with `cp example_chadrc.lua chadrc.lua`
|
||||||
|
|
||||||
|
--------------------------------------------------------------------
|
||||||
|
|
||||||
-- To use this file, copy the strucutre of `core/default_config.lua`,
|
-- To use this file, copy the strucutre of `core/default_config.lua`,
|
||||||
-- then define your new var, an example of setting relative number:
|
-- examples of setting relative number & changing theme:
|
||||||
|
|
||||||
-- M.options = {
|
-- M.options = {
|
||||||
-- relativenumber = true,
|
-- relativenumber = true,
|
||||||
-- }
|
-- }
|
||||||
|
|
||||||
|
-- M.ui = {
|
||||||
-- user custom mappings
|
-- theme = "nord"
|
||||||
-- format: name = { "mode" , "keys" , "cmd" , "options"}
|
-- }
|
||||||
-- name: can be empty or something unique with repect to other custom mappings
|
|
||||||
-- { mode, key, cmd } or name = { mode, key, cmd }
|
|
||||||
-- mode: usage: mode or { mode1, mode2 }, multiple modes allowed, available modes => :h map-modes,
|
|
||||||
-- keys: multiple keys allowed, same synxtax as modes
|
|
||||||
-- cmd: for vim commands, must use ':' at start and add <CR> at the end if want to execute
|
|
||||||
-- options: see :h nvim_set_keymap() opts section
|
|
||||||
M.mappings.custom = {
|
|
||||||
-- clear_all = {
|
|
||||||
-- "n",
|
|
||||||
-- "<leader>cc",
|
|
||||||
-- "gg0vG$d",
|
|
||||||
-- },
|
|
||||||
}
|
|
||||||
|
|
||||||
-- NvChad included plugin options & overrides
|
-- NvChad included plugin options & overrides
|
||||||
M.plugins = {
|
M.plugins = {
|
48
lua/custom/example_init.lua
Normal file
48
lua/custom/example_init.lua
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
-- This is where you custom modules and plugins goes.
|
||||||
|
-- See the wiki for a guide on how to extend NvChad
|
||||||
|
|
||||||
|
local hooks = require "core.hooks"
|
||||||
|
|
||||||
|
-- NOTE: To use this, make a copy with `cp example_init.lua init.lua`
|
||||||
|
|
||||||
|
--------------------------------------------------------------------
|
||||||
|
|
||||||
|
-- To modify packaged plugin configs, use the overrides functionality
|
||||||
|
-- if the override does not exist in the plugin config, make or request a PR,
|
||||||
|
-- or you can override the whole plugin config with 'chadrc' -> M.plugins.default_plugin_config_replace{}
|
||||||
|
-- this will run your config instead of the NvChad config for the given plugin
|
||||||
|
|
||||||
|
-- hooks.override("lsp", "publish_diagnostics", function(current)
|
||||||
|
-- current.virtual_text = false;
|
||||||
|
-- return current;
|
||||||
|
-- end)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- To add new mappings, use the "setup_mappings" hook,
|
||||||
|
-- you can set one or many mappings
|
||||||
|
-- example below:
|
||||||
|
|
||||||
|
-- hooks.add("setup_mappings", function(map)
|
||||||
|
-- map("n", "<leader>cc", "gg0vG$d", opt) -- example to delete the buffer
|
||||||
|
-- .... many more mappings ....
|
||||||
|
-- end)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- To add new plugins, use the "install_plugin" hook,
|
||||||
|
-- NOTE: we heavily suggest using Packer's lazy loading (with the 'event' field)
|
||||||
|
-- see: https://github.com/wbthomason/packer.nvim
|
||||||
|
-- examples below:
|
||||||
|
|
||||||
|
-- hooks.add("install_plugins", function(use)
|
||||||
|
-- use {
|
||||||
|
-- "max397574/better-escape.nvim",
|
||||||
|
-- event = "InsertEnter",
|
||||||
|
-- }
|
||||||
|
-- end)
|
||||||
|
|
||||||
|
-- alternatively, put this in a sub-folder like "lua/custom/plugins/mkdir"
|
||||||
|
-- then source it with
|
||||||
|
|
||||||
|
-- require "custom.plugins.mkdir"
|
@ -1,11 +0,0 @@
|
|||||||
-- This is where you custom modules and plugins goes.
|
|
||||||
-- See the wiki for a guide on how to extend NvChad
|
|
||||||
|
|
||||||
local hooks = require "core.hooks"
|
|
||||||
|
|
||||||
-- For example, the hook below overrieds 'publish_diagnostics' in the 'lspconfig' file,
|
|
||||||
--
|
|
||||||
-- hooks.override("lsp", "publish_diagnostics", function(current)
|
|
||||||
-- current.virtual_text = false;
|
|
||||||
-- return current;
|
|
||||||
-- end)
|
|
Loading…
Reference in New Issue
Block a user