|
@@ -5,33 +5,30 @@
|
|
|
-- visual_block_mode = "x",
|
|
|
-- term_mode = "t",
|
|
|
-- command_mode = "c",
|
|
|
-
|
|
|
-- leader key 为空
|
|
|
-vim.g.mapleader=" "
|
|
|
+vim.g.mapleader = " "
|
|
|
vim.g.maplocalleader = " "
|
|
|
-
|
|
|
+-- MAC 设置alt 键
|
|
|
alt_send_esc = true
|
|
|
|
|
|
local opt = {
|
|
|
- noremap = true,
|
|
|
- silent = true,
|
|
|
+ noremap = true,
|
|
|
+ silent = true
|
|
|
}
|
|
|
-
|
|
|
-- 本地变量
|
|
|
local map = vim.api.nvim_set_keymap
|
|
|
|
|
|
--- 分屏
|
|
|
+-- 取消 s 默认功能
|
|
|
+map("n", "s", "", opt)
|
|
|
map("n", "sv", ":vsp<CR>", opt)
|
|
|
map("n", "sh", ":sp<CR>", opt)
|
|
|
--- 关闭当前窗口
|
|
|
map("n", "sc", "<C-w>c", opt)
|
|
|
--- 关闭其他窗口
|
|
|
map("n", "so", "<C-w>o", opt)
|
|
|
-- 切换窗口
|
|
|
-map("n", "<A-h>", "<C-w>h", opt)
|
|
|
-map("n", "<A-j>", "<C-w>j", opt)
|
|
|
-map("n", "<A-k>", "<C-w>k", opt)
|
|
|
-map("n", "<A-l>", "<C-w>l", opt)
|
|
|
+map("n", "<A-Right>", "<C-w>l", opt)
|
|
|
+map("n", "<A-Down>", "<C-w>j", opt)
|
|
|
+map("n", "<A-Up>", "<C-w>k", opt)
|
|
|
+map("n", "<A-Left>", "<C-w>h", opt)
|
|
|
-- terminal 相关
|
|
|
map("n", "<leader>t", ":sp | terminal<CR>", opt)
|
|
|
-- 代码缩进
|
|
@@ -39,3 +36,101 @@ map("v", "<", "<gv", opt)
|
|
|
map("v", ">", ">gv", opt)
|
|
|
map("v", "J", ":move '>+1<CR>gv-gv>'", opt)
|
|
|
map("v", "K", ":move '<-2<CR>gv-gv>'", opt)
|
|
|
+-- 保存配置
|
|
|
+map("n", "<leader>w", ":w<CR>", opt)
|
|
|
+map("n", "<leader>wq", ":wqa!<CR>", opt)
|
|
|
+-- 退出
|
|
|
+map("n", "qq", ":q!<CR>", opt)
|
|
|
+map("n", "<leader>q", ":qa!<CR>", opt)
|
|
|
+-- 上下滚动浏览
|
|
|
+map("n", "<C-j>", "5j", opt)
|
|
|
+map("n", "<C-k>", "5k", opt)
|
|
|
+map("v", "<C-j>", "5j", opt)
|
|
|
+map("v", "<C-k>", "5k", opt)
|
|
|
+
|
|
|
+-- Telescope 查找文件
|
|
|
+-- 文件名查找
|
|
|
+map("n", "<leader>f", ":Telescope find_files<CR>", opt)
|
|
|
+-- 全局搜索 关键词key 查找
|
|
|
+map("n", "<leader>k", ":Telescope live_grep<CR>", opt)
|
|
|
+-- git 文件
|
|
|
+map("n", "<leader>g", ":Telescope git_files<CR>", opt)
|
|
|
+-- project
|
|
|
+map("n", "<leader>p", ":Telescope projects<CR>", opt)
|
|
|
+-- 插件快捷键
|
|
|
+local pluginKeys = {}
|
|
|
+
|
|
|
+-- nvim-tree
|
|
|
+map("n", "<leader>e", ":NvimTreeToggle<CR>", opt)
|
|
|
+-- 列表快捷键
|
|
|
+pluginKeys.nvimTreeList = { -- 打开文件或文件夹
|
|
|
+{
|
|
|
+ key = {"o", "<2-LeftMouse>"},
|
|
|
+ action = "edit"
|
|
|
+}, {
|
|
|
+ key = "<CR>",
|
|
|
+ action = "system_open"
|
|
|
+}, -- v分屏打开文件
|
|
|
+{
|
|
|
+ key = "v",
|
|
|
+ action = "vsplit"
|
|
|
+}, -- h分屏打开文件
|
|
|
+{
|
|
|
+ key = "h",
|
|
|
+ action = "split"
|
|
|
+}, -- Ignore (node_modules)
|
|
|
+{
|
|
|
+ key = "i",
|
|
|
+ action = "toggle_ignored"
|
|
|
+}, -- Hide (dotfiles)
|
|
|
+{
|
|
|
+ key = ".",
|
|
|
+ action = "toggle_dotfiles"
|
|
|
+}, {
|
|
|
+ key = "R",
|
|
|
+ action = "refresh"
|
|
|
+}, -- 文件操作
|
|
|
+{
|
|
|
+ key = "a",
|
|
|
+ action = "create"
|
|
|
+}, {
|
|
|
+ key = "d",
|
|
|
+ action = "remove"
|
|
|
+}, {
|
|
|
+ key = "r",
|
|
|
+ action = "rename"
|
|
|
+}, {
|
|
|
+ key = "x",
|
|
|
+ action = "cut"
|
|
|
+}, {
|
|
|
+ key = "c",
|
|
|
+ action = "copy"
|
|
|
+}, {
|
|
|
+ key = "p",
|
|
|
+ action = "paste"
|
|
|
+}, {
|
|
|
+ key = "y",
|
|
|
+ action = "copy_name"
|
|
|
+}, {
|
|
|
+ key = "Y",
|
|
|
+ action = "copy_path"
|
|
|
+}, {
|
|
|
+ key = "gy",
|
|
|
+ action = "copy_absolute_path"
|
|
|
+}, {
|
|
|
+ key = "I",
|
|
|
+ action = "toggle_file_info"
|
|
|
+}, {
|
|
|
+ key = "n",
|
|
|
+ action = "tabnew"
|
|
|
+}, -- 进入下一级
|
|
|
+{
|
|
|
+ key = {"]"},
|
|
|
+ action = "cd"
|
|
|
+}, -- 进入上一级
|
|
|
+{
|
|
|
+ key = {"["},
|
|
|
+ action = "dir_up"
|
|
|
+}}
|
|
|
+
|
|
|
+return pluginKeys
|