feat(nvim): Add support for which key

This commit is contained in:
js0ny 2025-01-14 19:44:55 +00:00
parent 9b90b02442
commit 1b2fc3015b
21 changed files with 276 additions and 206 deletions

View file

@ -21,7 +21,7 @@ general:
config_reload_commands: [] config_reload_commands: []
# Whether to automatically focus windows underneath the cursor. # Whether to automatically focus windows underneath the cursor.
focus_follows_cursor: false focus_follows_cursor: true
# Whether to switch back and forth between the previously focused # Whether to switch back and forth between the previously focused
# workspace when focusing the current workspace. # workspace when focusing the current workspace.

View file

@ -1,2 +0,0 @@
lazy-lock.json
./lua/config/keymaps/obsidian-nvim.lua

View file

@ -21,13 +21,9 @@ vim.api.nvim_create_autocmd("FileType", {
-- 加载配置 -- 加载配置
require("config.options") require("config.options")
-- 加载键位映射
require("config.keymaps")
-- 加载插件 -- 加载插件
require("config.plugins") require("config.plugins")
-- 加载主题 -- 加载主题
require("config.colorscheme") require("config.colorscheme")
-- 加载键位映射
-- vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree }) require("config.keymaps")

View file

@ -25,6 +25,7 @@ opt.linebreak = true
-- Indentation -- Indentation
opt.expandtab = true opt.expandtab = true
opt.shiftwidth = 4 opt.shiftwidth = 4
opt.tabstop = 4
opt.shiftround = true opt.shiftround = true
-- Case -- Case

View file

@ -3,20 +3,14 @@
--- for available server and name --- for available server and name
local M = {} local M = {}
M.servers = { M.servers = {
"arduino_language_server", -- Arduino
"bashls", -- Bash
"clangd", -- C/C++ "clangd", -- C/C++
-- "cmake", -- CMake -- "cmake", -- CMake
"eslint", -- JavaScript "eslint", -- JavaScript
"gopls", -- Go
"html", -- HTML "html", -- HTML
"julials", -- Julia
"lua_ls", -- Lua "lua_ls", -- Lua
"omnisharp", -- C# & F# "omnisharp", -- C# & F#
"powershell_es", -- PowerShell "powershell_es", -- PowerShell
"pyright", -- Python "pyright", -- Python
"rust_analyzer", -- Rust
"taplo", -- TOML
"vimls", -- vimscript "vimls", -- vimscript
} }

View file

@ -1,15 +1,39 @@
local mode_arrow = { "n", "v", "o", "s", "x" } local mode_arrow = { "n", "v", "o", "s", "x" }
local keymaps_basic = { -- Modification of Original Keymap - Colemak local keymaps_basic = { -- Modification of Original Keymap - Colemak
{ mode = mode_arrow, keys = "n", cmd = "j", desc = "Down" }, -- https://github.com/LazyVim/LazyVim/blob/d1529f650fdd89cb620258bdeca5ed7b558420c7/lua/lazyvim/config/keymaps.lua#L8
{ mode = mode_arrow, keys = "e", cmd = "k", desc = "Up" }, {
{ mode = mode_arrow, keys = "i", cmd = "l", desc = "Right" }, mode = mode_arrow,
keys = "n",
cmd = "v:count == 0 ? 'gj' : 'j'",
opts = { desc = "Down", expr = true, silent = true },
},
{
mode = mode_arrow,
keys = "<Down>",
cmd = "v:count == 0 ? 'gj' : 'j'",
opts = { desc = "Up", expr = true, silent = true },
},
{
mode = mode_arrow,
keys = "e",
cmd = "v:count == 0 ? 'gk' : 'k'",
opts = { desc = "Up", expr = true, silent = true },
},
{
mode = mode_arrow,
keys = "<Up>",
cmd = "v:count == 0 ? 'gk' : 'k'",
opts = { desc = "Up", expr = true, silent = true },
},
{ mode = mode_arrow, keys = "h", cmd = "h", opts = { desc = "Left", silent = true } },
{ mode = mode_arrow, keys = "i", cmd = "l", opts = { desc = "Right", silent = true } },
{ keys = "H", cmd = ":bprevious<CR>" }, { keys = "H", cmd = ":bprevious<CR>" },
{ keys = "N", cmd = "5j" }, { keys = "N", cmd = "5j" },
{ keys = "E", cmd = "5k" }, { keys = "E", cmd = "5k" },
{ keys = "I", cmd = ":bnext<CR>" }, { keys = "I", cmd = ":bnext<CR>" },
-- Text object implementation -- Text object implementation
{ mode = { "n", "o", "x" }, keys = "l", cmd = "i", group = "inside" }, { mode = { "n", "o", "x" }, keys = "l", cmd = "i", opts = { desc = "inside" } },
{ keys = "L", cmd = "I" }, { keys = "L", cmd = "I" },
{ keys = "k", cmd = "n" }, { keys = "k", cmd = "n" },
{ keys = "K", cmd = "N" }, { keys = "K", cmd = "N" },

View file

@ -15,22 +15,24 @@ end
local keymaps_basic = require("keymaps.basic") local keymaps_basic = require("keymaps.basic")
local keymaps_nvim_tree_general = require("keymaps.nvim-tree").global local keymaps_nvim_tree_general = require("keymaps.nvim-tree").global
local keymaps_leader = require("keymaps.leaders") local keymaps_leader = require("keymaps.leaders")
local keymaps_lsp = require("keymaps.lspkeys")
set_keymaps(keymaps_basic, global_default_opts, global_default_mode) set_keymaps(keymaps_basic, global_default_opts, global_default_mode)
set_keymaps(keymaps_nvim_tree_general, global_default_opts, global_default_mode) set_keymaps(keymaps_nvim_tree_general, global_default_opts, global_default_mode)
set_keymaps(keymaps_leader, global_default_opts, global_default_mode) set_keymaps(keymaps_leader, global_default_opts, global_default_mode)
set_keymaps(keymaps_lsp, global_default_opts, global_default_mode)
M.nvim_tree_keymaps = require("keymaps.nvim-tree").plugin M.nvim_tree_keymaps = require("keymaps.nvim-tree").plugin
--- `map` default for `cmp.mapping` --- `map` default for `cmp.mapping`
function M.cmp_nvim_keymaps(map) function M.cmp_nvim_keymaps(map)
return { return {
{ keys = "<C-n>", cmd = map.select_next_item(), desc = "Select next completion item" }, { keys = "<C-n>", cmd = map.select_next_item(), opts = { desc = "Select next completion item" } },
{ keys = "<C-p>", cmd = map.select_prev_item(), desc = "Select previous completion item" }, { keys = "<C-p>", cmd = map.select_prev_item(), opts = { desc = "Select previous completion item" } },
{ keys = "<C-y>", cmd = map.confirm({ select = true }), desc = "Confirm completion" }, { keys = "<C-y>", cmd = map.confirm({ select = true }), opts = { desc = "Confirm completion" } },
{ keys = "<Tab>", cmd = map.confirm({ select = true }), desc = "Confirm completion" }, { keys = "<Tab>", cmd = map.confirm({ select = true }), opts = { desc = "Confirm completion" } },
{ keys = "<C-Space>", cmd = map.complete(), desc = "Trigger completion" }, { keys = "<C-Space>", cmd = map.complete(), opts = { desc = "Trigger completion" } },
{ keys = "<C-e>", cmd = map.abort(), desc = "Abort completion" }, { keys = "<C-e>", cmd = map.abort(), opts = { desc = "Abort completion" } },
} }
end end
@ -46,6 +48,7 @@ vim.api.nvim_create_autocmd("FileType", {
end, end,
}) })
require("keymaps.language") -- which-key.nvim
require("keymaps.which")
return M return M

View file

@ -25,4 +25,27 @@ vim.api.nvim_create_autocmd("FileType", {
end, end,
}) })
--- buffer that doesn't act as an editor or common buffer.
--- Use `q` to close the buffer.
local tmp_buf = {
"qf", -- quickfix
"crunner", -- code runner
}
M.tmp_buf_keymaps = {
{ mode = "n", keys = "q", cmd = "<Cmd>q<CR>", desc = "Close buffer" },
}
for _, buf in ipairs(tmp_buf) do
vim.api.nvim_create_autocmd("FileType", {
pattern = buf,
callback = function()
for _, map in ipairs(M.tmp_buf_keymaps) do
local opts = vim.tbl_extend("force", { buffer = 0 }, map.opts or {})
vim.keymap.set(map.mode, map.keys, map.cmd, opts)
end
end,
})
end
return M return M

View file

@ -27,139 +27,107 @@ local renameCurrentBuffer = function()
vim.cmd("bdelete " .. old_name) vim.cmd("bdelete " .. old_name)
end end
-- 通用映射函数
local function apply_mappings(maps, prefix)
for _, map in ipairs(maps) do
local new_map = {
keys = prefix .. map.keys,
cmd = map.cmd,
opts = map.opts,
}
table.insert(M, new_map)
end
end
vim.api.nvim_create_user_command("Rename", renameCurrentBuffer, {}) vim.api.nvim_create_user_command("Rename", renameCurrentBuffer, {})
local leader_general = { local leader_mappings = {
{ keys = "<space>", cmd = ":Telescope find_files<CR>", desc = "Find Files" }, general = {
{ keys = "/", cmd = ":Telescope live_grep<CR>", desc = "Grep Files" }, { keys = "<space>", cmd = ":Telescope find_files<CR>", opts = { desc = "Find Files" } },
{ keys = "-", cmd = ":split<CR>", desc = "Split to down" }, { keys = "/", cmd = ":Telescope live_grep<CR>", opts = { desc = "Grep Files" } },
{ keys = "\\", cmd = ":vsplit<CR>", desc = "Split to right" }, { keys = "-", cmd = ":split<CR>", opts = { desc = "Split to down" } },
{ keys = "|", cmd = ":vsplit<CR>", desc = "Split to right" }, { keys = "\\", cmd = ":vsplit<CR>", opts = { desc = "Split to right" } },
{ keys = "h", cmd = "<C-w>h", desc = "Left Window" }, { keys = "|", cmd = ":vsplit<CR>", opts = { desc = "Split to right" } },
{ keys = "n", cmd = "<C-w>j", desc = "Down Window" }, { keys = "h", cmd = "<C-w>h", opts = { desc = "Left Window" } },
{ keys = "e", cmd = "<C-w>k", desc = "Up Window" }, { keys = "n", cmd = "<C-w>j", opts = { desc = "Down Window" } },
{ keys = "i", cmd = "<C-w>l", desc = "Right Window" }, { keys = "e", cmd = "<C-w>k", opts = { desc = "Up Window" } },
{ keys = "i", cmd = "<C-w>l", opts = { desc = "Right Window" } },
},
b = { -- +buffer
{ keys = "a", cmd = ":Alpha<CR>", opts = { desc = "Dashboard" } },
{ keys = "b", cmd = ":Telescope buffers<CR>", opts = { desc = "List Buffers" } },
{ keys = "d", cmd = ":bdelete<CR>", opts = { desc = "Delete Buffer" } },
{ keys = "h", cmd = ":bprevious<CR>", opts = { desc = "Previous Buffer" } },
{ keys = "i", cmd = ":bnext<CR>", opts = { desc = "Next Buffer" } },
{ keys = "H", cmd = ":bfirst<CR>", opts = { desc = "First Buffer" } },
{ keys = "I", cmd = ":blast<CR>", opts = { desc = "Last Buffer" } },
{ keys = "0", cmd = ":bfirst<CR>", opts = { desc = "First Buffer" } },
{ keys = "^", cmd = ":bfirst<CR>", opts = { desc = "First Buffer" } },
{ keys = "$", cmd = ":blast<CR>", opts = { desc = "Last Buffer" } },
-- { keys = "s", cmd = ":Telescope buffers<CR>", opts = { desc = "Search buffers" } },
},
c = { -- +code/compile
{ keys = "r", cmd = ":RunCode<CR>", opts = { desc = "Run code" } },
{ keys = "e", cmd = ":Telescope diagnostics<CR>", opts = { desc = "Navigate errors/warnings" } },
{ keys = "f", cmd = formatFx, opts = { desc = "Format buffer" } },
{ keys = "s", cmd = ":Telescope treesitter<CR>", opts = { desc = "Search symbols" } },
{ keys = "S", cmd = ":Telescope grep_string<CR>", opts = { desc = "Search current symbol" } },
},
f = { -- +file/find
{ keys = "f", cmd = ":Telescope fd<CR>", opts = { desc = "Find Files" } },
{ keys = "s", cmd = ":Telescope live_grep<CR>", opts = { desc = "Grep Files" } },
{ keys = "b", cmd = ":Telescope buffers<CR>", opts = { desc = "List Buffers" } },
{ keys = "e", cmd = ":NvimTreeToggle<CR>", opts = { desc = "Toggle File Explorer" } },
{ keys = "t", cmd = ":FloatermToggle<CR>", opts = { desc = "toggle visibility of the float terminal" } },
{ keys = "T", cmd = ":FloatermNew<CR>", opts = { desc = "Spawn a float terminal" } },
{ keys = "h", cmd = ":Telescope oldfiles<CR>", opts = { desc = "Search history files" } },
{ keys = "c", cmd = ":Telescope find_files cwd=~/.config/nvim<CR>", opts = { desc = "Search Config" } },
{ keys = "o", cmd = ":!open %", opts = { desc = "Open file in default program" } },
{ keys = "R", cmd = renameCurrentBuffer, opts = { desc = "Rename current file" } },
},
p = { -- +project
{ keys = "p", cmd = ":Telescope projects<CR>", opts = { desc = "List all Projects" } },
{ keys = "g", cmd = ":Telescope projects<CR>", opts = { desc = "List all Git Projects" } },
{ keys = "s", cmd = ":Telescope session-lens<CR>", opts = { desc = "List all sessions" } },
},
q = { -- +quit
{ keys = "q", cmd = ":q<CR>", opts = { desc = "Quit" } },
{ keys = "Q", cmd = ":qa!<CR>", opts = { desc = "Force Quit" } },
{ keys = "w", cmd = ":wq<CR>", opts = { desc = "Write and Quit" } },
{ keys = "W", cmd = ":wall<CR>:qa!<CR>", opts = { desc = "Write all and Force Quit" } },
},
t = { -- +toggle
{ keys = "f", cmd = ":NvimTreeToggle", opts = { desc = "Toggle File Explorer" } },
{ keys = "F", cmd = ":FormatToggle<CR>", opts = { desc = "Toggle autoformat-on-save" } },
{ keys = "t", cmd = ":FloatermToggle<CR>", opts = { desc = "toggle visibility of the float terminal" } },
},
u = { -- +ui
{ keys = "i", cmd = ":Telescope colorscheme<CR>", opts = { desc = "Change colorscheme" } },
},
w = { -- +window
{ keys = "h", cmd = "<C-w>h", opts = { desc = "Left Window" } },
{ keys = "n", cmd = "<C-w>j", opts = { desc = "Down Window" } },
{ keys = "e", cmd = "<C-w>k", opts = { desc = "Up Window" } },
{ keys = "i", cmd = "<C-w>l", opts = { desc = "Right Window" } },
{ keys = "-", cmd = ":split<CR>", opts = { desc = "Split to down" } },
{ keys = "|", cmd = ":vsplit<CR>", opts = { desc = "Split to right" } },
{ keys = "c", cmd = "<C-w>c", opts = { desc = "Close Window" } },
{ keys = "o", cmd = "<C-w>o", opts = { desc = "Close Other Windows" } },
{ keys = "r", cmd = "<C-w>r", opts = { desc = "Rotate Windows" } },
{ keys = "R", cmd = "<C-w>R", opts = { desc = "Reverse Rotate Windows" } },
{ keys = "t", cmd = "<C-w>T", opts = { desc = "Move Window to New Tab" } },
{ keys = "H", cmd = ":vertical resize -5<CR>", opts = { desc = "Decrease Window Height" } },
{ keys = "N", cmd = ":resize +5<CR>", opts = { desc = "Increase Window Height" } },
{ keys = "E", cmd = ":vertical resize +5<CR>", opts = { desc = "Increase Window Width" } },
{ keys = "I", cmd = ":resize -5<CR>", opts = { desc = "Decrease Window Width" } },
},
} }
for _, map in ipairs(leader_general) do for key, maps in pairs(leader_mappings) do
map.keys = "<leader>" .. map.keys if key == "general" then
table.insert(M, map) apply_mappings(maps, "<leader>")
end else
apply_mappings(maps, "<leader>" .. key)
local leader_q = { -- leader q: Quit end
{ keys = "q", cmd = ":q<CR>", desc = "Quit" },
{ keys = "Q", cmd = ":qa!<CR>", desc = "Force Quit" },
{ keys = "w", cmd = ":wq<CR>", desc = "Write and Quit" },
{ keys = "W", cmd = ":wall<CR>:qa!<CR>", desc = "Write all and Force Quit" },
}
local leader_w = { -- leader w: Windows Management
{ keys = "h", cmd = "<C-w>h", desc = "Left Window" },
{ keys = "n", cmd = "<C-w>j", desc = "Down Window" },
{ keys = "e", cmd = "<C-w>k", desc = "Up Window" },
{ keys = "i", cmd = "<C-w>l", desc = "Right Window" },
{ keys = "-", cmd = ":split<CR>", desc = "Split to down" },
{ keys = "|", cmd = ":vsplit<CR>", desc = "Split to right" },
{ keys = "c", cmd = "<C-w>c", desc = "Close Window" },
{ keys = "o", cmd = "<C-w>o", desc = "Close Other Windows" },
{ keys = "r", cmd = "<C-w>r", desc = "Rotate Windows" },
{ keys = "R", cmd = "<C-w>R", desc = "Reverse Rotate Windows" },
{ keys = "t", cmd = "<C-w>T", desc = "Move Window to New Tab" },
{ keys = "H", cmd = ":vertical resize -5<CR>", desc = "Decrease Window Height" },
{ keys = "N", cmd = ":resize +5<CR>", desc = "Increase Window Height" },
{ keys = "E", cmd = ":vertical resize +5<CR>", desc = "Increase Window Width" },
{ keys = "I", cmd = ":resize -5<CR>", desc = "Decrease Window Width" },
}
local leader_f = { -- <leader>f: +files/find
{ keys = "f", cmd = ":Telescope fd<CR>", desc = "Find Files" },
{ keys = "s", cmd = ":Telescope live_grep<CR>", desc = "Grep Files" },
{ keys = "b", cmd = ":Telescope buffers<CR>", desc = "List Buffers" },
{ keys = "e", cmd = ":NvimTreeToggle<CR>", desc = "Toggle File Explorer" },
{ keys = "t", cmd = ":FloatermToggle<CR>", desc = "toggle visibility of the float terminal" },
{ keys = "T", cmd = ":FloatermNew<CR>", desc = "Spawn a float terminal" },
{ keys = "h", cmd = ":Telescope oldfiles<CR>", desc = "Search history files" },
{ keys = "c", cmd = ":Telescope find_files cwd=~/.config/nvim<CR>", desc = "Search Config" },
{ keys = "o", cmd = ":!open %", desc = "Open file in default program" },
{ keys = "R", cmd = renameCurrentBuffer, desc = "Rename current file" },
}
local leader_p = { -- leader p: Project
{ keys = "p", cmd = ":Telescope projects<CR>", desc = "List all Projects" },
{ keys = "g", cmd = ":Telescope projects<CR>", desc = "List all Git Projects" },
{ keys = "s", cmd = ":Telescope session-lens<CR>", desc = "List all sessions" },
}
local leader_b = { -- <leader>b: +buffer
{ keys = "a", cmd = ":Alpha<CR>", desc = "Dashboard" },
{ keys = "b", cmd = ":Telescope buffers<CR>", desc = "List Buffers" },
{ keys = "d", cmd = ":bdelete<CR>", desc = "Delete Buffer" },
{ keys = "h", cmd = ":bprevious<CR>", desc = "Previous Buffer" },
{ keys = "i", cmd = ":bnext<CR>", desc = "Next Buffer" },
{ keys = "H", cmd = ":bfirst<CR>", desc = "First Buffer" },
{ keys = "I", cmd = ":blast<CR>", desc = "Last Buffer" },
{ keys = "0", cmd = ":bfirst<CR>", desc = "First Buffer" },
{ keys = "^", cmd = ":bfirst<CR>", desc = "First Buffer" },
{ keys = "$", cmd = ":blast<CR>", desc = "Last Buffer" },
-- { keys = "s", cmd = ":Telescope buffers<CR>", desc = "Search buffers" },
}
local leader_t = { -- <leader>t: +toggle/test
{ keys = "f", cmd = ":NvimTreeToggle", desc = "Toggle File Explorer" },
{ keys = "F", cmd = ":FormatToggle<CR>", desc = "Toggle autoformat-on-save" },
{ keys = "t", cmd = ":FloatermToggle<CR>", desc = "toggle visibility of the float terminal" },
}
local leader_c = { -- <leader>c: +code/compile
{ keys = "r", cmd = ":RunCode<CR>", desc = "Run code" },
{ keys = "e", cmd = ":Telescope diagnostics<CR>", desc = "Navigate errors/warnings" },
{ keys = "f", cmd = formatFx, desc = "Format buffer" },
{ keys = "s", cmd = ":Telescope treesitter<CR>", desc = "Search symbols" },
{ keys = "S", cmd = ":Telescope grep_string<CR>", desc = "Search current symbol" },
}
local leader_u = { -- <leader>u: +ui
{ keys = "i", cmd = ":Telescope colorscheme<CR>", desc = "Change colorscheme" },
}
for _, map in ipairs(leader_q) do
map.keys = "<leader>q" .. map.keys
table.insert(M, map)
end
for _, map in ipairs(leader_w) do
map.keys = "<leader>w" .. map.keys
table.insert(M, map)
end
for _, map in ipairs(leader_f) do
map.keys = "<leader>f" .. map.keys
table.insert(M, map)
end
for _, map in ipairs(leader_b) do
map.keys = "<leader>b" .. map.keys
table.insert(M, map)
end
for _, map in ipairs(leader_c) do
map.keys = "<leader>c" .. map.keys
table.insert(M, map)
end
for _, map in ipairs(leader_t) do
map.keys = "<leader>t" .. map.keys
table.insert(M, map)
end
for _, map in ipairs(leader_u) do
map.keys = "<leader>u" .. map.keys
table.insert(M, map)
end
for _, map in ipairs(leader_p) do
map.keys = "<leader>p" .. map.keys
table.insert(M, map)
end end
return M return M

View file

@ -0,0 +1,8 @@
local M = {
{ keys = "gd", cmd = vim.lsp.buf.definition, opts = { desc = "Goto Definition" } },
{ keys = "gD", cmd = vim.lsp.buf.declaration, opts = { desc = "Goto Declaration" } },
{ keys = "gr", cmd = vim.lsp.buf.references, opts = { desc = "Goto References" } },
{ keys = "gi", cmd = vim.lsp.buf.implementation, opts = { desc = "Goto Implementation" } },
}
return M

View file

@ -1,7 +1,7 @@
local M = {} local M = {}
M.global = { M.global = {
{ mode = "n", keys = "<leader>e", cmd = ":NvimTreeToggle<CR>" }, { mode = "n", keys = "<leader>E", cmd = ":NvimTreeToggle<CR>" },
{ mode = "n", keys = "<A-0>", cmd = ":NvimTreeFocus<CR>" }, { mode = "n", keys = "<A-0>", cmd = ":NvimTreeFocus<CR>" },
} }

View file

@ -0,0 +1,23 @@
local wk = require("which-key")
wk.add({
-- https://github.com/folke/which-key.nvim/tree/main?tab=readme-ov-file#%EF%B8%8F-mappings
{
-- Nested mappings are allowed and can be added in any order
-- Most attributes can be inherited or overridden on any level
-- There's no limit to the depth of nesting
mode = { "n" },
{ "<leader>b", group = "Buffer" }, -- no need to specify mode since it's inherited
{ "<leader>c", group = "Code/Compile" },
{ "<leader>f", group = "File" },
{ "<leader>p", group = "Project" },
{ "<leader>q", group = "Quit" },
{ "<leader>t", group = "Toggle" },
{ "<leader>u", group = "UI" },
{ "<leader>w", group = "Window" },
},
{
"l",
mode = { "o", "x" },
group = "inside",
},
})

View file

@ -15,7 +15,7 @@ return {
-- require('hover.providers.jira') -- require('hover.providers.jira')
-- require('hover.providers.dap') -- require('hover.providers.dap')
-- require('hover.providers.fold_preview') -- require('hover.providers.fold_preview')
-- require('hover.providers.diagnostic') require("hover.providers.diagnostic")
-- require('hover.providers.man') -- require('hover.providers.man')
-- require('hover.providers.dictionary') -- require('hover.providers.dictionary')
end, end,
@ -46,4 +46,10 @@ return {
vim.o.mousemoveevent = true vim.o.mousemoveevent = true
end, end,
}, },
{
"lewis6991/gitsigns.nvim",
config = function()
require("gitsigns").setup()
end,
},
} }

View file

@ -1,25 +1,2 @@
-- Entry point of the plugin manager -- Entry point of the plugin manager
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" require("plugins.lazy-nvim")
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
{ import = "plugins.appearance" },
{ import = "plugins.completion" },
{ import = "plugins.fileutils" },
{ import = "plugins.lsp" },
{ import = "plugins.syntax" },
{ import = "plugins.misc" },
})

View file

@ -0,0 +1,39 @@
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
-- Make sure to setup `mapleader` and `maplocalleader` before
-- loading lazy.nvim so that mappings are correct.
-- This is also a good place to setup other settings (vim.opt)
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
-- Setup lazy.nvim
require("lazy").setup({
spec = {
-- import your plugins
{ import = "plugins.appearance" },
{ import = "plugins.completion" },
{ import = "plugins.fileutils" },
{ import = "plugins.lsp" },
{ import = "plugins.syntax" },
{ import = "plugins.misc" },
},
-- Configure any other settings here. See the documentation for more details.
-- colorscheme that will be used when installing plugins.
-- automatically check for plugin updates
checker = { enabled = true },
})

View file

@ -1,8 +1,7 @@
return { return {
{ import = "plugins.mod.lspconfig" },
{ {
"NoahTheDuke/vim-just", "neovim/nvim-lspconfig",
ft = { "just" }, lazy = false,
}, },
{ import = "plugins.mod.render-markdown" }, { import = "plugins.mod.render-markdown" },
-- { import = "plugins.mod.markview" }, -- { import = "plugins.mod.markview" },
@ -63,4 +62,8 @@ return {
}, },
{ import = "plugins.mod.conform-nvim" }, { import = "plugins.mod.conform-nvim" },
{ "nvim-treesitter/nvim-treesitter-context" }, { "nvim-treesitter/nvim-treesitter-context" },
{
"NoahTheDuke/vim-just",
ft = { "just" },
},
} }

View file

@ -7,25 +7,7 @@ return {
} }, } },
{ "CRAG666/code_runner.nvim", config = true }, { "CRAG666/code_runner.nvim", config = true },
{ import = "plugins.mod.obsidian-nvim" }, { import = "plugins.mod.obsidian-nvim" },
{ { import = "plugins.mod.which-keys-nvim" },
"folke/which-key.nvim",
event = "VeryLazy",
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
},
keys = {
{
"<leader>?",
function()
require("which-key").show({ global = false })
end,
desc = "Buffer Local Keymaps (which-key)",
},
},
},
{ {
"github/copilot.vim", "github/copilot.vim",
lazy = false, lazy = false,

View file

@ -91,7 +91,7 @@ ins_left({
ins_left({ ins_left({
-- mode component -- mode component
function() function()
return "" return ""
end, end,
color = function() color = function()
-- auto change color according to neovims mode -- auto change color according to neovims mode

View file

@ -0,0 +1,18 @@
return {
"folke/which-key.nvim",
event = "VeryLazy",
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
},
keys = {
{
"<leader>?",
function()
require("which-key").show({ global = false })
end,
desc = "Buffer Local Keymaps (which-key)",
},
},
}

View file

@ -0,0 +1,4 @@
(((
This is a playground file.
{(1 + 2) * 3}
)))

View file

@ -17,6 +17,7 @@ noremap N 5j
noremap E 5k noremap E 5k
" Similar position to i " Similar position to i
" The `noremap` implements text-object-like behavior in VSCodeVim
noremap l i noremap l i
noremap L I noremap L I
" ne[k]st " ne[k]st
@ -29,9 +30,10 @@ noremap J E
" Y to yank to end of line " Y to yank to end of line
noremap Y y$ noremap Y y$
noremap <esc> :nohlsearch<CR>
" 分词版本的w和b支持中文需要插件 " 分词版本的w和b支持中文需要插件
" 为了保证递归解析,而不是打断,使用 `nmap` 而不是 `nnoremap` " 为了保证递归解析,而不是打断,使用 `nmap` 而不是 `nnoremap`
" 由于 VSCode Vim 的限制递归解析存在缺陷目前这种情况2w 符合预期,但 dw 不符合预期
" Comment if you don't use cjk or the plugin " Comment if you don't use cjk or the plugin
nmap w cjkWordHandler.cursorWordEndRight nmap w cjkWordHandler.cursorWordEndRight
nmap b cjkWordHandler.cursorWordStartLeft nmap b cjkWordHandler.cursorWordStartLeft
@ -92,7 +94,8 @@ noremap <leader>fC workbench.action.openFolderSettingsFile
noremap <leader>fe workbench.view.explorer noremap <leader>fe workbench.view.explorer
noremap <leader>fo openInExternalApp.open noremap <leader>fo openInExternalApp.open
noremap <leader>fr workbench.action.showAllEditorsByMostRecentlyUsed noremap <leader>fr workbench.action.showAllEditorsByMostRecentlyUsed
noremap <leader>fR git.rename " Rename file " Can only rename tracked files
noremap <leader>fR git.rename
" noremap <leader>fs workbench.action.search.toggleQueryDetails " noremap <leader>fs workbench.action.search.toggleQueryDetails
noremap <leader>ft workbench.action.terminal.toggleTerminal noremap <leader>ft workbench.action.terminal.toggleTerminal
noremap <leader>fx workbench.view.extensions noremap <leader>fx workbench.view.extensions