breaking change : re-implement custom mappings | simplify it | add whichkey

fixes  , 
This commit is contained in:
siduck 2022-05-12 18:26:01 +05:30
parent 4fa0b4ae7d
commit 0844431d37
15 changed files with 442 additions and 240 deletions

View file

@ -39,7 +39,7 @@ local options = {
right = function()
return {
{ text = "%@Toggle_theme@" .. vim.g.toggle_theme_icon .. "%X" },
{ text = "%@Quit_vim@  %X" },
{ text = "%@Quit_vim@ %X" },
}
end,
},

View file

@ -11,8 +11,6 @@ require("plugins.configs.others").lsp_handlers()
function M.on_attach(client, _)
client.resolved_capabilities.document_formatting = false
client.resolved_capabilities.document_range_formatting = false
require("core.mappings").lspconfig()
end
local capabilities = vim.lsp.protocol.make_client_capabilities()

View file

@ -24,17 +24,6 @@ local options = {
close_on_exit = true,
auto_insert = true,
},
mappings = {
toggle = {
float = "<A-i>",
horizontal = "<A-h>",
vertical = "<A-v>",
},
new = {
horizontal = "<leader>h",
vertical = "<leader>v",
},
},
enable_new_mappings = true,
}

View file

@ -211,4 +211,22 @@ M.gitsigns = function()
}
end
M.misc_mappings = function()
local map = nvchad.map
-- Don't copy the replaced text after pasting in visual mode
map("v", "p", '"_dP')
-- Allow moving the cursor through wrapped lines with j, k, <Up> and <Down>
-- http://www.reddit.com/r/vim/comments/2k4cbr/problem_with_gj_and_gk/
-- empty mode is same as using :map
-- also don't use g[j|k] when in operator pending mode, so it doesn't alter d, y or c behaviour
map("", "j", 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', { expr = true })
map("", "k", 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', { expr = true })
map("", "<Down>", 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', { expr = true })
map("", "<Up>", 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', { expr = true })
-- esscape from terminal mode
map("t", "jk", "<C-\\><C-n>")
end
return M

View file

@ -54,6 +54,8 @@ local options = {
n = { ["q"] = require("telescope.actions").close },
},
},
extensions_list = { "themes", "terms" },
}
-- check for any override
@ -61,10 +63,8 @@ options = nvchad.load_override(options, "nvim-telescope/telescope.nvim")
telescope.setup(options)
-- load extensions
local extensions = nvchad.load_config().plugins.options.telescope.extensions
pcall(function()
for _, ext in ipairs(extensions) do
for _, ext in ipairs(options.extensions_list) do
telescope.load_extension(ext)
end
end)

View file

@ -0,0 +1,73 @@
local present, wk = pcall(require, "which-key")
if not present then
return
end
local options = {
-- NOTE : this mode_opts table isnt in the default whichkey config
-- Its added here so you could configure it in chadrc
mode_opts = {
n = {
mode = "n",
},
v = {
mode = "v",
},
i = {
mode = "i",
},
t = {
mode = "t",
},
},
icons = {
breadcrumb = "»", -- symbol used in the command line area that shows your active key combo
separator = "", -- symbol used between a key and it's label
group = "+", -- symbol prepended to a group
},
popup_mappings = {
scroll_down = "<c-d>", -- binding to scroll down inside the popup
scroll_up = "<c-u>", -- binding to scroll up inside the popup
},
window = {
border = "none", -- none/single/double/shadow
},
layout = {
spacing = 6, -- spacing between columns
},
hidden = { "<silent>", "<cmd>", "<Cmd>", "<CR>", "call", "lua", "^:", "^ " },
triggers_blacklist = {
-- list of mode / prefixes that should never be hooked by WhichKey
i = { "j", "k" },
v = { "j", "k" },
},
}
require("plugins.configs.others").misc_mappings()
local mappings = nvchad.load_config().mappings
-- register mappings
for mode, opt in pairs(options.mode_opts) do
for key, _ in pairs(mappings) do
if mappings[key][mode] then
wk.register(mappings[key][mode], opt)
end
end
end
options = nvchad.load_override(options, "folke/which-key.nvim")
wk.setup(options)

View file

@ -1,5 +1,4 @@
local plugin_settings = nvchad.load_config().plugins
local present, packer = pcall(require, plugin_settings.options.packer.init_file)
local present, packer = pcall(require, "plugins.packerInit")
if not present then
return false
@ -48,11 +47,6 @@ local plugins = {
["akinsho/bufferline.nvim"] = {
after = "nvim-web-devicons",
setup = function()
require("core.mappings").bufferline()
end,
config = function()
require "plugins.configs.bufferline"
end,
@ -194,11 +188,6 @@ local plugins = {
["numToStr/Comment.nvim"] = {
module = "Comment",
keys = { "gc", "gb" },
setup = function()
require("core.mappings").comment()
end,
config = function()
require("plugins.configs.others").comment()
end,
@ -207,10 +196,6 @@ local plugins = {
-- file managing , picker etc
["kyazdani42/nvim-tree.lua"] = {
cmd = { "NvimTreeToggle", "NvimTreeFocus" },
setup = function()
require("core.mappings").nvimtree()
end,
config = function()
require "plugins.configs.nvimtree"
end,
@ -218,18 +203,24 @@ local plugins = {
["nvim-telescope/telescope.nvim"] = {
cmd = "Telescope",
setup = function()
require("core.mappings").telescope()
end,
config = function()
require "plugins.configs.telescope"
end,
},
["folke/which-key.nvim"] = {
opt = true,
setup = function()
nvchad.packer_lazy_load "which-key.nvim"
end,
config = function()
require "plugins.configs.whichkey"
end,
},
}
plugins = nvchad.remove_default_plugins(plugins)
-- merge user plugin table & default plugin table
plugins = nvchad.plugin_list(plugins)

View file

@ -27,21 +27,22 @@ if not present then
end
end
local user_snapshot = nvchad.load_config().snapshot
packer.init {
local options = {
display = {
open_fn = function()
return require("packer.util").float { border = "single" }
return require("packer.util").float { border = "double" }
end,
prompt_border = "single",
},
git = {
clone_timeout = 6000, -- seconds
},
auto_clean = true,
compile_on_sync = true,
snapshot = user_snapshot,
snapshot = nil,
}
options = nvchad.load_override(options, "wbthomason/packer.nvim")
packer.init(options)
return packer