refactoring, lazyload lf
This commit is contained in:
parent
7f93f118a7
commit
643d80c751
5 changed files with 45 additions and 45 deletions
|
@ -5,4 +5,4 @@ require('plugins')
|
|||
require('config.autocmds').setup()
|
||||
require('config.filetypes').setup()
|
||||
require('config.icons').setup()
|
||||
require('funcs').map('general')
|
||||
require('config.keymaps').map('general')
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
local M = {}
|
||||
M.maps = {
|
||||
|
||||
local maps = {
|
||||
general = {
|
||||
n = { -- normal mode
|
||||
-- Better window navigation
|
||||
|
@ -49,13 +50,14 @@ M.maps = {
|
|||
}
|
||||
}
|
||||
|
||||
M.whichkey = {
|
||||
local wkmaps = {
|
||||
general = {
|
||||
n = {
|
||||
["w"] = { "<cmd>w!<CR>", "Save" },
|
||||
["q"] = { function() require("funcs").buf_kill() end, "Close" },
|
||||
["f"] = { function() require("lf").start("~") end, "File Picker" },
|
||||
["h"] = { "<cmd>nohlsearch<CR>", "Clear Highlights" },
|
||||
["e"] = { function() require('packer').loader("lf.nvim") require("lf").start() end, "File Picker" },
|
||||
u = {
|
||||
name = "Utility",
|
||||
c = { "<cmd>w!<CR><cmd>!compiler \"%:p\"<CR>", "Compile" },
|
||||
|
@ -232,4 +234,34 @@ M.whichkey = {
|
|||
}
|
||||
}
|
||||
|
||||
local wk_ok, whichkey = pcall(require, 'which-key')
|
||||
|
||||
M.map = function(section)
|
||||
if maps[section] then
|
||||
for mode, binds in pairs(maps[section]) do
|
||||
for _, bind in pairs(binds) do
|
||||
local key = bind[1]
|
||||
local cmd = bind[2]
|
||||
local opt = { silent = true, noremap = true }
|
||||
vim.api.nvim_set_keymap(mode, key, cmd, opt)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if wk_ok then
|
||||
if wkmaps[section] then
|
||||
for mode, binds in pairs(wkmaps[section]) do
|
||||
whichkey.register(binds, {
|
||||
mode = mode,
|
||||
prefix = "<leader>",
|
||||
buffer = nil,
|
||||
silent = true,
|
||||
noremap = true,
|
||||
nowait = true,
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
|
@ -20,37 +20,6 @@ function M.bootstrap()
|
|||
end
|
||||
end
|
||||
|
||||
function M.map(section)
|
||||
local maps = require('config.keymaplist').maps[section]
|
||||
if maps then
|
||||
for mode, binds in pairs(maps) do
|
||||
for _, bind in pairs(binds) do
|
||||
local key = bind[1]
|
||||
local cmd = bind[2]
|
||||
local opt = { silent = true, noremap = true }
|
||||
vim.api.nvim_set_keymap(mode, key, cmd, opt)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local wk_ok, whichkey = pcall(require, 'which-key')
|
||||
if wk_ok then
|
||||
local wkmaps = require('config.keymaplist').whichkey[section]
|
||||
if wkmaps then
|
||||
for mode, binds in pairs(wkmaps) do
|
||||
whichkey.register(binds, {
|
||||
mode = mode,
|
||||
prefix = "<leader>",
|
||||
buffer = nil,
|
||||
silent = true,
|
||||
noremap = true,
|
||||
nowait = true,
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function M.format_filter(client)
|
||||
local filetype = vim.bo.filetype
|
||||
local n = require "null-ls"
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
-- Defaults
|
||||
require("lf").setup({
|
||||
default_actions = {},
|
||||
winblend = 0,
|
||||
|
|
|
@ -2,7 +2,7 @@ local icons = require('config.icons').list
|
|||
local plugins = {
|
||||
{ "wbthomason/packer.nvim",
|
||||
config = function()
|
||||
require('funcs').map("packer")
|
||||
require('config.keymaps').map("packer")
|
||||
end
|
||||
},
|
||||
{ "nvim-lua/plenary.nvim" },
|
||||
|
@ -40,7 +40,7 @@ local plugins = {
|
|||
event = { "BufRead", "BufWinEnter", "BufNewFile" },
|
||||
config = function()
|
||||
require('plugins.config.bufferline')
|
||||
require('funcs').map("bufferline")
|
||||
require('config.keymaps').map("bufferline")
|
||||
end,
|
||||
},
|
||||
{ "nvim-lualine/lualine.nvim",
|
||||
|
@ -59,7 +59,7 @@ local plugins = {
|
|||
event = { "BufRead", "BufWinEnter", "BufNewFile" },
|
||||
config = function()
|
||||
require('plugins.config.indent-blankline')
|
||||
require('funcs').map("blankline")
|
||||
require('config.keymaps').map("blankline")
|
||||
end,
|
||||
},
|
||||
{ "norcalli/nvim-colorizer.lua",
|
||||
|
@ -72,7 +72,7 @@ local plugins = {
|
|||
event = { "BufRead", "BufWinEnter", "BufNewFile" },
|
||||
config = function()
|
||||
require('plugins.config.illuminate')
|
||||
require('funcs').map("illuminate")
|
||||
require('config.keymaps').map("illuminate")
|
||||
end,
|
||||
},
|
||||
{ "nvim-treesitter/nvim-treesitter",
|
||||
|
@ -112,7 +112,7 @@ local plugins = {
|
|||
},
|
||||
{ "williamboman/mason.nvim",
|
||||
setup = function()
|
||||
require('funcs').map("mason")
|
||||
require('config.keymaps').map("mason")
|
||||
end,
|
||||
config = function()
|
||||
require "plugins.config.mason"
|
||||
|
@ -124,7 +124,7 @@ local plugins = {
|
|||
event = { "BufRead", "BufWinEnter", "BufNewFile" },
|
||||
config = function()
|
||||
require('plugins.config.lspconfig')
|
||||
require('funcs').map("lspconfig")
|
||||
require('config.keymaps').map("lspconfig")
|
||||
end,
|
||||
},
|
||||
{ "jose-elias-alvarez/null-ls.nvim",
|
||||
|
@ -143,7 +143,7 @@ local plugins = {
|
|||
event = { "BufRead", "BufWinEnter", "BufNewFile" },
|
||||
config = function()
|
||||
require('plugins.config.dap')
|
||||
require('funcs').map("dap")
|
||||
require('config.keymaps').map("dap")
|
||||
end,
|
||||
},
|
||||
{ "rafamadriz/friendly-snippets",
|
||||
|
@ -182,13 +182,13 @@ local plugins = {
|
|||
event = { "BufRead", "BufWinEnter", "BufNewFile" },
|
||||
config = function()
|
||||
require('plugins.config.comment')
|
||||
require('funcs').map("comment")
|
||||
require('config.keymaps').map("comment")
|
||||
end,
|
||||
},
|
||||
{ "nvim-telescope/telescope.nvim",
|
||||
config = function()
|
||||
require('plugins.config.telescope')
|
||||
require('funcs').map("telescope")
|
||||
require('config.keymaps').map("telescope")
|
||||
end,
|
||||
},
|
||||
{ "ahmedkhalf/project.nvim",
|
||||
|
@ -205,7 +205,7 @@ local plugins = {
|
|||
opt = true,
|
||||
config = function()
|
||||
require('plugins.config.lf')
|
||||
require('funcs').map("lf")
|
||||
require('config.keymaps').map("lf")
|
||||
end
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue