Added nvim/which-key

This commit is contained in:
2021-12-11 21:01:39 -05:00
parent 2a66bd1116
commit 8510339154
6 changed files with 95 additions and 97 deletions

View File

@@ -2,7 +2,7 @@
require('plugins')
-- Key maps
require('keymaps')
require('mappings')
-- Common settings
require('settings')

View File

@@ -1,4 +1,4 @@
-- disable v
--isable v
-- local presets = require("which-key.plugins.presets")
-- presets.operators["v"] = nil
require("which-key").setup {
@@ -63,8 +63,8 @@ require("which-key").setup {
i = {"j", "k"},
v = {"j", "k"}
}
}
}
local wk = require("which-key")
default_options = {noremap = true, silent = true}
@@ -72,8 +72,17 @@ default_options = {noremap = true, silent = true}
--wk.register({ga = {"<Plug>(EasyAlign)", "Align", mode = "x"}})
-- Register all leader based mappings
local wk = require("which-key")
-- As an example, we will create the following mappings:
-- * <leader>ff find files
-- * <leader>fr show recent files
-- * <leader>fb Foobar
-- we'll document:
-- * <leader>fn new file
-- * <leader>fe edit file
-- and hide <leader>1
wk.register({
["<Tab>"] = {"<cmd>e#<cr>", "Switch to previously opened buffer"},
["<leader>"] = {
b = {
name = "Buffers",
b = {
@@ -82,40 +91,15 @@ wk.register({
}
},
f = {
name = "Files",
s = {"<cmd>w<cr>", "Save Buffer"},
f = {
"<cmd>lua require'telescope.builtin'.find_files({ find_command = {'fd', '--hidden', '--type', 'file', '--follow'}})<cr>",
"Find File"
},
l = {"<cmd>Lf<cr>", "Open LF"},
p = {"<cmd>NvimTreeToggle<cr>", "Toogle Tree"},
name = "File",
f = { "<cmd>Telescope find_files<cr>", "Find File" },
r = { "<cmd>Telescope oldfiles<cr>", "Open Recent File" },
T = {"<cmd>NvimTreeFindFile<CR>", "Find in Tree"}
n = { "<cmd>enew<cr>", "New File" },
},
},
s = {
name = "Search",
c = {"<cmd>Telescope colorscheme<cr>", "Colorscheme"},
h = {"<cmd>Telescope help_tags<cr>", "Find Help"},
M = {"<cmd>Telescope man_pages<cr>", "Man Pages"},
R = {"<cmd>Telescope registers<cr>", "Registers"},
t = {"<cmd>Telescope live_grep<cr>", "Text"},
s = {"<cmd>Telescope grep_string<cr>", "Text under cursor"},
k = {"<cmd>Telescope keymaps<cr>", "Keymaps"},
C = {"<cmd>Telescope commands<cr>", "Commands"},
p = {"<cmd>Telescope projects<cr>", "Projects"},
P = {
"<cmd>lua require('telescope.builtin.internal').colorscheme({enable_preview = true})<cr>",
"Colorscheme with Preview"
c = {"<cmd>Telescope colorscheme<cr>", "Colorscheme" }
}
},
w = {
name = "Window",
q = {"<cmd>:q<cr>", "Close"},
s = {"<cmd>:split<cr>", "Horizontal Split"},
t = {"<c-w>t", "Move to new tab"},
["="] = {"<c-w>=", "Equally size"},
v = {"<cmd>:vsplit<cr>", "Verstical Split"},
w = {"<c-w>x", "Swap"}
},
}, {prefix = "<leader>", mode = "n", default_options})
})

View File

@@ -1,28 +0,0 @@
local keymap = vim.api.nvim_set_keymap
default_options = {noremap = true, silent = true}
expr_options = {noremap = true, expr = true, silent = true}
-- map the leader key
--keymap('n', '<Space>', '<NOP>', default_options)
vim.g.mapleader = ","
-- easier escape key mapping
keymap('i', 'jk', '<ESC>', default_options)
keymap('n', '<c-s>', ':w<CR>', default_options)
keymap('i', '<c-s>', '<ESC>:w<CR>a', default_options)
-- buffer focus
local opts = { noremap = true }
keymap('n', '<c-j>', '<c-w>j', default_options)
keymap('n', '<c-h>', '<c-w>h', default_options)
keymap('n', '<c-k>', '<c-w>k', default_options)
keymap('n', '<c-l>', '<c-w>l', default_options)
-- refresh config
--keymap('n', '<Leader>so', ':so $MYVIMRC<CR>', default_opts)
--keymap('n', '<C-n>', ':NvimTreeToggle<CR>', default_opts)
-- find files
--keymap('n', '<Leader>f', ':Telescope find_files<cr>', default_opts)

View File

@@ -0,0 +1,33 @@
local keymap = vim.api.nvim_set_keymap
default_options = {noremap = true, silent = true}
expr_options = {noremap = true, expr = true, silent = true}
-- map the leader key
keymap('n', '<Space>', '<NOP>', default_options)
vim.g.mapleader = " "
-- easier escape key mapping
keymap('i', 'jk', '<ESC>', default_options)
keymap('n', '<c-s>', ':w<CR>', default_options)
keymap('i', '<c-s>', '<ESC>:w<CR>a', default_options)
-- paste over currently selected text without yanking it
keymap("v", "p", "\"_dP", default_options)
-- buffer focus
local opts = { noremap = true }
keymap('n', '<c-j>', '<c-w>j', default_options)
keymap('n', '<c-h>', '<c-w>h', default_options)
keymap('n', '<c-k>', '<c-w>k', default_options)
keymap('n', '<c-l>', '<c-w>l', default_options)
-- Resizing panes
keymap("n", "<Left>", ":vertical resize +1<CR>", default_options)
keymap("n", "<Right>", ":vertical resize -1<CR>", default_options)
keymap("n", "<Up>", ":resize -1<CR>", default_options)
keymap("n", "<Down>", ":resize +1<CR>", default_options)
-- Move selected line / block of text in visual mode
keymap("x", "K", ":move '<-2<CR>gv-gv", default_options)
keymap("x", "J", ":move '>+1<CR>gv-gv", default_options)

View File

@@ -1,24 +1,3 @@
-- Nightfox
require('nightfox').load('nordfox')
-- Tokyo Night
-- Example config in Lua
--vim.g.tokyonight_style = "storm"
--vim.g.tokyonight_italic_functions = true
--vim.g.tokyonight_sidebars = { "qf", "vista_kind", "terminal", "packer" }
-- Change the "hint" color to the "orange" color, and make the "error" color bright red
--vim.g.tokyonight_colors = { hint = "orange", error = "#ff0000" }
-- Load the colorscheme
--vim.cmd[[colorscheme tokyonight]]
-- Nord
-- Example config in lua
--vim.g.nord_contrast = true
--vim.g.nord_borders = false
--vim.g.nord_disable_background = false
--vim.g.nord_italic = false
-- Load the colorscheme
--require('nord').set()

View File

@@ -87,6 +87,17 @@ _G.packer_plugins = {
path = "/Users/michael/.local/share/nvim/site/pack/packer/start/nvim-tree.lua",
url = "https://github.com/kyazdani42/nvim-tree.lua"
},
["nvim-treesitter"] = {
config = { 'require("config/treesitter")' },
loaded = true,
path = "/Users/michael/.local/share/nvim/site/pack/packer/start/nvim-treesitter",
url = "https://github.com/nvim-treesitter/nvim-treesitter"
},
["nvim-treesitter-textobjects"] = {
loaded = true,
path = "/Users/michael/.local/share/nvim/site/pack/packer/start/nvim-treesitter-textobjects",
url = "https://github.com/nvim-treesitter/nvim-treesitter-textobjects"
},
["nvim-web-devicons"] = {
loaded = true,
path = "/Users/michael/.local/share/nvim/site/pack/packer/start/nvim-web-devicons",
@@ -107,14 +118,22 @@ _G.packer_plugins = {
loaded = true,
path = "/Users/michael/.local/share/nvim/site/pack/packer/start/telescope.nvim",
url = "https://github.com/nvim-telescope/telescope.nvim"
},
["which-key.nvim"] = {
config = { 'require("config/which")' },
loaded = false,
needs_bufread = false,
only_cond = false,
path = "/Users/michael/.local/share/nvim/site/pack/packer/opt/which-key.nvim",
url = "https://github.com/folke/which-key.nvim"
}
}
time([[Defining packer_plugins]], false)
-- Config for: nvim-tree.lua
time([[Config for nvim-tree.lua]], true)
require("config/nvim-tree")
time([[Config for nvim-tree.lua]], false)
-- Config for: lualine.nvim
time([[Config for lualine.nvim]], true)
require("config/lualine")
time([[Config for lualine.nvim]], false)
-- Config for: nightfox.nvim
time([[Config for nightfox.nvim]], true)
require("config/nightfox")
@@ -123,10 +142,21 @@ time([[Config for nightfox.nvim]], false)
time([[Config for telescope.nvim]], true)
require("config/telescope")
time([[Config for telescope.nvim]], false)
-- Config for: lualine.nvim
time([[Config for lualine.nvim]], true)
require("config/lualine")
time([[Config for lualine.nvim]], false)
-- Config for: nvim-treesitter
time([[Config for nvim-treesitter]], true)
require("config/treesitter")
time([[Config for nvim-treesitter]], false)
-- Config for: nvim-tree.lua
time([[Config for nvim-tree.lua]], true)
require("config/nvim-tree")
time([[Config for nvim-tree.lua]], false)
vim.cmd [[augroup packer_load_aucmds]]
vim.cmd [[au!]]
-- Event lazy-loads
time([[Defining lazy-load event autocommands]], true)
vim.cmd [[au VimEnter * ++once lua require("packer.load")({'which-key.nvim'}, { event = "VimEnter *" }, _G.packer_plugins)]]
time([[Defining lazy-load event autocommands]], false)
vim.cmd("augroup END")
if should_profile then save_profiles() end
end)