feat: update nvim config
This commit is contained in:
@@ -2,6 +2,22 @@ if vim.loader then
|
|||||||
vim.loader.enable()
|
vim.loader.enable()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- 让 Mason / 健康检查能找到本仓库常用的本地 CLI(fd、lazygit、tree-sitter 等)
|
||||||
|
local _local_bin = vim.fn.expand("~/.local/bin")
|
||||||
|
if vim.fn.isdirectory(_local_bin) == 1 then
|
||||||
|
vim.env.PATH = _local_bin .. ":" .. vim.env.PATH
|
||||||
|
end
|
||||||
|
-- 全局 npm 包(如 mermaid-cli 的 `mmdc`)通常在 $(npm prefix -g)/bin
|
||||||
|
do
|
||||||
|
local ok, out = pcall(vim.fn.system, { "npm", "prefix", "-g" })
|
||||||
|
if ok and out and out ~= "" then
|
||||||
|
local npm_bin = vim.fn.trim(out) .. "/bin"
|
||||||
|
if vim.fn.isdirectory(npm_bin) == 1 then
|
||||||
|
vim.env.PATH = npm_bin .. ":" .. vim.env.PATH
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
vim.g.loaded_netrw = 1
|
vim.g.loaded_netrw = 1
|
||||||
vim.g.loaded_netrwPlugin = 1
|
vim.g.loaded_netrwPlugin = 1
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -34,14 +34,14 @@
|
|||||||
"noice.nvim": { "branch": "main", "commit": "7bfd942445fb63089b59f97ca487d605e715f155" },
|
"noice.nvim": { "branch": "main", "commit": "7bfd942445fb63089b59f97ca487d605e715f155" },
|
||||||
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
|
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
|
||||||
"nvim-cmp": { "branch": "main", "commit": "f17d9b4394027ff4442b298398dfcaab97e40c4f" },
|
"nvim-cmp": { "branch": "main", "commit": "f17d9b4394027ff4442b298398dfcaab97e40c4f" },
|
||||||
"nvim-dap": { "branch": "master", "commit": "2a8799ad91a1495c6bdf753f9b2179b3ff0f5bba" },
|
"nvim-dap": { "branch": "master", "commit": "4f5deb110d9ff8994d96c21df95e2271d11214f9" },
|
||||||
"nvim-dap-go": { "branch": "main", "commit": "b4421153ead5d726603b02743ea40cf26a51ed5f" },
|
"nvim-dap-go": { "branch": "main", "commit": "b4421153ead5d726603b02743ea40cf26a51ed5f" },
|
||||||
"nvim-dap-ui": { "branch": "master", "commit": "f5b6673f374626515401c5bc51b005f784a4f252" },
|
"nvim-dap-ui": { "branch": "master", "commit": "f5b6673f374626515401c5bc51b005f784a4f252" },
|
||||||
"nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" },
|
"nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" },
|
||||||
"nvim-lint": { "branch": "master", "commit": "4b03656c09c1561f89b6aa0665c15d292ba9499d" },
|
"nvim-lint": { "branch": "master", "commit": "4b03656c09c1561f89b6aa0665c15d292ba9499d" },
|
||||||
"nvim-lspconfig": { "branch": "master", "commit": "16812abf0e8d8175155f26143a8504e8253e92b0" },
|
"nvim-lspconfig": { "branch": "master", "commit": "16812abf0e8d8175155f26143a8504e8253e92b0" },
|
||||||
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
|
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
|
||||||
"nvim-tree.lua": { "branch": "master", "commit": "b548cfef00a79f0b3e3af24f91ae6bd14f22af95" },
|
"nvim-tree.lua": { "branch": "master", "commit": "4cbe79526f8bc0bdb1a500d261dc5cc1be4e77d5" },
|
||||||
"nvim-treesitter": { "branch": "main", "commit": "7caec274fd19c12b55902a5b795100d21531391f" },
|
"nvim-treesitter": { "branch": "main", "commit": "7caec274fd19c12b55902a5b795100d21531391f" },
|
||||||
"nvim-treesitter-textobjects": { "branch": "main", "commit": "93d60a475f0b08a8eceb99255863977d3a25f310" },
|
"nvim-treesitter-textobjects": { "branch": "main", "commit": "93d60a475f0b08a8eceb99255863977d3a25f310" },
|
||||||
"nvim-ts-autotag": { "branch": "main", "commit": "8e1c0a389f20bf7f5b0dd0e00306c1247bda2595" },
|
"nvim-ts-autotag": { "branch": "main", "commit": "8e1c0a389f20bf7f5b0dd0e00306c1247bda2595" },
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"extras": [
|
"extras": [
|
||||||
|
"lazyvim.plugins.extras.editor.snacks_picker",
|
||||||
"lazyvim.plugins.extras.test.core",
|
"lazyvim.plugins.extras.test.core",
|
||||||
"lazyvim.plugins.extras.lang.go",
|
"lazyvim.plugins.extras.lang.go",
|
||||||
"lazyvim.plugins.extras.lang.typescript",
|
"lazyvim.plugins.extras.lang.typescript",
|
||||||
|
|||||||
+114
-216
@@ -1,147 +1,99 @@
|
|||||||
|
|
||||||
local keymap = vim.keymap
|
local keymap = vim.keymap
|
||||||
local opts = { noremap = true, silent = true }
|
|
||||||
|
|
||||||
-- <Leader>a
|
|
||||||
keymap.set('n', "<Leader>aa", "<cmd>@:<cr>", {desc="execute last command again" })
|
|
||||||
|
|
||||||
-- <Leader>b for buffer
|
-- <Leader>b for buffer
|
||||||
keymap.set('n', "<Leader>bq", "<cmd>q<cr>", {desc="quit" })
|
keymap.set("n", "<Leader>bq", "<cmd>q<cr>", { desc = "quit" })
|
||||||
keymap.set('n', "<Leader>bs", "<cmd>w<cr>", {desc="save" })
|
keymap.set("n", "<Leader>bs", "<cmd>w<cr>", { desc = "save" })
|
||||||
keymap.set('n', "<Leader>br", "<cmd>e!<cr>", {desc="reload" })
|
keymap.set("n", "<Leader>br", "<cmd>e!<cr>", { desc = "reload" })
|
||||||
keymap.set('n', "<Leader>bd", "<cmd>BufferClose<cr>", {desc="close buffer" })
|
keymap.set("n", "<Leader>bd", "<cmd>BufferClose<cr>", { desc = "close buffer" })
|
||||||
keymap.set({'n','v'}, "<Leader>b/", "<cmd>CommentToggle<CR>", {desc="toggle comment" })
|
|
||||||
|
|
||||||
-- <Leader>c
|
-- <Leader>c
|
||||||
keymap.set('n', "<Leader>cs", "<cmd>SymbolsOutline<cr>", { desc = "Symbols Outline" })
|
keymap.set("n", "<Leader>cs", "<cmd>SymbolsOutline<cr>", { desc = "Symbols Outline" })
|
||||||
|
|
||||||
-- <Leader>D
|
-- <Leader>D for Trouble (v3 syntax)
|
||||||
keymap.set('n', "<Leader>Dt", "<cmd>TroubleToggle<cr>", {desc="trouble" })
|
keymap.set("n", "<Leader>Dt", "<cmd>Trouble diagnostics toggle<cr>", { desc = "trouble diagnostics" })
|
||||||
keymap.set('n', "<Leader>Dw", "<cmd>TroubleToggle lsp_workspace_diagnostics<cr>", {desc="workspace" })
|
keymap.set("n", "<Leader>Dd", "<cmd>Trouble diagnostics toggle filter.buf=0<cr>", { desc = "document diagnostics" })
|
||||||
keymap.set('n', "<Leader>Dd", "<cmd>TroubleToggle lsp_document_diagnostics<cr>", {desc= "document" })
|
keymap.set("n", "<Leader>Dq", "<cmd>Trouble qflist toggle<cr>", { desc = "quickfix" })
|
||||||
keymap.set('n', "<Leader>Dq", "<cmd>TroubleToggle quickfix<cr>", {desc= "quickfix" })
|
keymap.set("n", "<Leader>Dl", "<cmd>Trouble loclist toggle<cr>", { desc = "loclist" })
|
||||||
keymap.set('n', "<Leader>Dl", "<cmd>TroubleToggle loclist<cr>", {desc= "loclist" })
|
keymap.set("n", "<Leader>Dr", "<cmd>Trouble lsp_references toggle<cr>", { desc = "references" })
|
||||||
keymap.set('n', "<Leader>Dr", "<cmd>TroubleToggle lsp_references<cr>", {desc= "references" })
|
|
||||||
|
|
||||||
-- <Leader>d
|
|
||||||
keymap.set('n', "<Leader>dd", "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<cr>", {desc= "show diagnostics" })
|
|
||||||
keymap.set('n', "<Leader>dc", "<cmd>lua require'dap'.continue()<cr>", {desc= "continue" })
|
|
||||||
keymap.set('n', "<Leader>db", ':lua require"dap".toggle_breakpoint()<CR>', {desc= "Toggle Breadpoint" })
|
|
||||||
keymap.set('n', "<Leader>dj", ':lua require"dap".step_over()<CR>', {desc= "step over" })
|
|
||||||
keymap.set('n', "<Leader>dk", ':lua require"dap".step_out()<CR>', {desc= "step out" })
|
|
||||||
keymap.set('n', "<Leader>dl", ':lua require"dap".step_into()<CR>', {desc= "step into" })
|
|
||||||
keymap.set('n', "<Leader>du", ':lua require"dap".up()<CR>', {desc= "up" })
|
|
||||||
keymap.set('n', "<Leader>d_", ':lua require"dap".disconnect();require"dap".stop();require"dap".run_last()<CR>', {desc= "disconnect" })
|
|
||||||
keymap.set('n', "<Leader>di", ':lua require"dap.ui.variables".visual_hover()<CR>', {desc= "visual_hover" })
|
|
||||||
keymap.set('n', "<Leader>ds", ':lua local widgets=require"dap.ui.widgets";widgets.centered_float(widgets.scopes)<CR>', {desc= "centered_float" })
|
|
||||||
|
|
||||||
|
-- <Leader>d for debug
|
||||||
|
keymap.set("n", "<Leader>dd", "<cmd>lua vim.diagnostic.open_float()<cr>", { desc = "show diagnostics" })
|
||||||
|
keymap.set("n", "<Leader>dc", '<cmd>lua require("dap").continue()<cr>', { desc = "continue" })
|
||||||
|
keymap.set("n", "<Leader>db", '<cmd>lua require("dap").toggle_breakpoint()<cr>', { desc = "Toggle Breakpoint" })
|
||||||
|
keymap.set("n", "<Leader>dj", '<cmd>lua require("dap").step_over()<cr>', { desc = "step over" })
|
||||||
|
keymap.set("n", "<Leader>dk", '<cmd>lua require("dap").step_out()<cr>', { desc = "step out" })
|
||||||
|
keymap.set("n", "<Leader>dl", '<cmd>lua require("dap").step_into()<cr>', { desc = "step into" })
|
||||||
|
keymap.set("n", "<Leader>du", '<cmd>lua require("dap").up()<cr>', { desc = "up" })
|
||||||
|
keymap.set("n", "<Leader>d_", '<cmd>lua require("dap").disconnect();require("dap").stop();require("dap").run_last()<cr>', { desc = "disconnect" })
|
||||||
|
keymap.set("n", "<Leader>di", '<cmd>lua require("dap.ui.variables").visual_hover()<cr>', { desc = "visual hover" })
|
||||||
|
keymap.set("n", "<Leader>ds", '<cmd>lua local w=require("dap.ui.widgets");w.centered_float(w.scopes)<cr>', { desc = "scopes" })
|
||||||
|
|
||||||
-- <Leader>f
|
-- <Leader>f
|
||||||
keymap.set('n', "<Leader>fm", "<cmd>lua require'utils'.open_md()<cr>", {desc= "open a markdown file in vscode" })
|
keymap.set("n", "<Leader>fm", "<cmd>lua require('utils').open_md()<cr>", { desc = "open markdown in external app" })
|
||||||
keymap.set('n', "<Leader>fs", "<cmd>w<cr>", {desc= "save file" })
|
keymap.set("n", "<Leader>fs", "<cmd>w<cr>", { desc = "save file" })
|
||||||
keymap.set('n', "<Leader>ft", "<cmd>NvimTreeToggle<cr>", {desc= "toggle nvim tree" })
|
keymap.set("n", "<Leader>ft", "<cmd>NvimTreeToggle<cr>", { desc = "toggle nvim tree" })
|
||||||
keymap.set('n', "<Leader>fr", "<cmd>RnvimrToggle<cr>", {desc= "toggle rnvimr" })
|
keymap.set("n", "<Leader>fy", "<cmd>lua require('utils').yank_filepath()<cr>", { desc = "copy file path" })
|
||||||
keymap.set('n', "<Leader>fy", "<cmd>lua require'utils'.yank_filepath()<cr>", {desc= "copy the file path" })
|
keymap.set("n", "<Leader>fd", "<cmd>lua require('utils').yank_file_dir()<cr>", { desc = "copy dir path" })
|
||||||
keymap.set('n', "<Leader>fd", "<cmd>lua require'utils'.yank_file_dir()<cr>", {desc= "copy the file path" })
|
keymap.set("n", "<Leader>fl", "<cmd>NvimTreeFindFile<CR>", { desc = "find file in tree" })
|
||||||
keymap.set('n', "<Leader>fl", "<cmd>NvimTreeFindFile<CR>", {desc= "find file" })
|
|
||||||
|
|
||||||
|
|
||||||
-- <Leader>g
|
-- <Leader>g
|
||||||
keymap.set('n', "<Leader>gj", "<cmd>lua require 'gitsigns'.next_hunk()<cr>", {desc= "Next Hunk" })
|
keymap.set("n", "<Leader>gj", "<cmd>lua require('gitsigns').next_hunk()<cr>", { desc = "Next Hunk" })
|
||||||
keymap.set('n', "<Leader>gk", "<cmd>lua require 'gitsigns'.prev_hunk()<cr>", {desc= "Prev Hunk" })
|
keymap.set("n", "<Leader>gk", "<cmd>lua require('gitsigns').prev_hunk()<cr>", { desc = "Prev Hunk" })
|
||||||
keymap.set('n', "<Leader>gl", "<cmd>lua require 'gitsigns'.blame_line()<cr>", {desc= "Blame" })
|
keymap.set("n", "<Leader>gl", "<cmd>lua require('gitsigns').blame_line()<cr>", { desc = "Blame" })
|
||||||
keymap.set('n', "<Leader>gp", "<cmd>lua require 'gitsigns'.preview_hunk()<cr>", {desc= "Preview Hunk" })
|
keymap.set("n", "<Leader>gp", "<cmd>lua require('gitsigns').preview_hunk()<cr>", { desc = "Preview Hunk" })
|
||||||
keymap.set('n', "<Leader>gr", "<cmd>lua require 'gitsigns'.reset_hunk()<cr>", {desc= "Reset Hunk" })
|
keymap.set("n", "<Leader>gr", "<cmd>lua require('gitsigns').reset_hunk()<cr>", { desc = "Reset Hunk" })
|
||||||
keymap.set('n', "<Leader>gR", "<cmd>lua require 'gitsigns'.reset_buffer()<cr>", {desc= "Reset Buffer" })
|
keymap.set("n", "<Leader>gR", "<cmd>lua require('gitsigns').reset_buffer()<cr>", { desc = "Reset Buffer" })
|
||||||
keymap.set('n', "<Leader>gs", "<cmd>lua require 'gitsigns'.stage_hunk()<cr>", {desc= "Stage Hunk" })
|
keymap.set("n", "<Leader>gs", "<cmd>lua require('gitsigns').stage_hunk()<cr>", { desc = "Stage Hunk" })
|
||||||
keymap.set('n', "<Leader>gS", "<cmd>lua require 'gitsigns'.stage_buffer()<cr>", {desc= "Stage Buffer" })
|
keymap.set("n", "<Leader>gS", "<cmd>lua require('gitsigns').stage_buffer()<cr>", { desc = "Stage Buffer" })
|
||||||
keymap.set('n', "<Leader>gu", "<cmd>lua require 'gitsigns'.undo_stage_hunk()<cr>", {desc= "Undo Stage Hunk", })
|
keymap.set("n", "<Leader>gu", "<cmd>lua require('gitsigns').undo_stage_hunk()<cr>", { desc = "Undo Stage Hunk" })
|
||||||
keymap.set('n', "<Leader>go", "<cmd>Telescope git_status<cr>", {desc= "Open changed file" })
|
keymap.set("n", "<Leader>go", "<cmd>Telescope git_status<cr>", { desc = "Open changed file" })
|
||||||
keymap.set('n', "<Leader>gb", "<cmd>Telescope git_branches<cr>", {desc= "Checkout branch" })
|
keymap.set("n", "<Leader>gb", "<cmd>Telescope git_branches<cr>", { desc = "Checkout branch" })
|
||||||
keymap.set('n', "<Leader>gc", "<cmd>Telescope git_commits<cr>", {desc= "Checkout commit" })
|
keymap.set("n", "<Leader>gc", "<cmd>Telescope git_commits<cr>", { desc = "Checkout commit" })
|
||||||
keymap.set('n', "<Leader>gC", "<cmd>Telescope git_bcommits<cr>", {desc= "Checkout commit(for current file)", })
|
keymap.set("n", "<Leader>gC", "<cmd>Telescope git_bcommits<cr>", { desc = "Checkout commit(for current file)" })
|
||||||
keymap.set('n', "<Leader>gd", "<cmd>Gitsigns diffthis HEAD<cr>", {desc= "Git Diff", })
|
keymap.set("n", "<Leader>gd", "<cmd>Gitsigns diffthis HEAD<cr>", { desc = "Git Diff" })
|
||||||
|
|
||||||
-- <Leader>h
|
-- <Leader>h
|
||||||
keymap.set('n', '<Leader>h', ':set hlsearch!<CR>', { noremap = true, silent = true }) -- no hl
|
keymap.set("n", "<Leader>h", ":set hlsearch!<CR>", { noremap = true, silent = true, desc = "toggle hlsearch" })
|
||||||
|
|
||||||
-- <Leader>l for lsp
|
|
||||||
keymap.set('n', '<Leader>l', "", {desc="+Language"})
|
|
||||||
keymap.set({'n','v'}, '<Leader>la', "<cmd>lua vim.lsp.buf.code_action()<cr>", {desc="Code Action" })
|
|
||||||
--keymap.set('n', '<Leader>lA', "<cmd>Lspsaga range_code_action<cr>", {desc="Selected Action" })
|
|
||||||
keymap.set('n', '<Leader>ld', "<cmd>Telescope lsp_document_diagnostics<cr>", {desc="Document Diagnostics" })
|
|
||||||
keymap.set('n', '<Leader>lD', "<cmd>Telescope lsp_workspace_diagnostics<cr>", {desc="Workspace Diagnostics" })
|
|
||||||
keymap.set('n', '<Leader>lf', "<cmd>LspFormatting<cr>", {desc="Format" })
|
|
||||||
--keymap.set('n', '<Leader>lF', "<cmd>Lspsaga lsp_finder<cr>", {desc="LSP Finder" })
|
|
||||||
keymap.set('n', '<Leader>li', "<cmd>lua vim.lsp.buf.implementation()<cr>", {desc="implement" })
|
|
||||||
keymap.set('n', '<Leader>ln', "<cmd>lua vim.lsp.buf.hover()<cr>", {desc="hover" })
|
|
||||||
--keymap.set('n', '<Leader>lL', "<cmd>Lspsaga show_line_diagnostics<cr>", {desc="Line Diagnostics" })
|
|
||||||
keymap.set('n', '<Leader>lk', "<cmd>: LspRestart<cr>", {desc="restart lsp server" })
|
|
||||||
keymap.set('n', '<Leader>ll', "<cmd>lua vim.diagnostic.goto_next()<cr>", {desc="next diagnostic" })
|
|
||||||
keymap.set('n', '<Leader>lo', "<cmd>: SymbolsOutline<cr>", {desc="symbols outline" })
|
|
||||||
keymap.set('n', '<Leader>lp', "<cmd>lua vim.diagnostic.goto_prev()<cr>", {desc="prev diagnostic" })
|
|
||||||
--keymap.set('n', '<Leader>lP', "<cmd>Lspsaga preview_definition<cr>", {desc="Preview Definition" })
|
|
||||||
keymap.set('n', '<Leader>lq', "<cmd>Telescope quickfix<cr>", {desc="Quickfix" })
|
|
||||||
keymap.set('n', '<Leader>lr', "<cmd>lua vim.lsp.buf.references()<cr>", {desc="references" })
|
|
||||||
keymap.set('n', '<leader>lR', "<cmd>lua vim.lsp.buf.rename()<cr>", { desc = "Rename" })
|
|
||||||
--keymap.set('n', '<Leader>lR', "<cmd>Lspsaga rename<cr>", {desc="Rename" })
|
|
||||||
keymap.set('n', '<Leader>lt', "<cmd>LspTypeDefinition<cr>", {desc="Type Definition" })
|
|
||||||
keymap.set('n', '<Leader>lx', "<cmd>cclose<cr>", {desc="Close Quickfix" })
|
|
||||||
keymap.set('n', '<Leader>ls', "<cmd>Telescope lsp_document_symbols<cr>", {desc="Document Symbols" })
|
|
||||||
keymap.set('n', '<Leader>lS', "<cmd>Telescope lsp_dynamic_workspace_symbols<cr>", {desc="Workspace Symbols" })
|
|
||||||
keymap.set('n', '<Leader>lz', "<cmd>LspInfo<cr>", {desc="Info" })
|
|
||||||
keymap.set('n', '<Leader>l,', "<cmd>LspInstallInfo<cr>", {desc="LSP servers" })
|
|
||||||
|
|
||||||
-- <Leader>q
|
-- <Leader>q
|
||||||
keymap.set('n', "<Leader>qq", "<cmd>qall<cr>", {desc= "quit" })
|
keymap.set("n", "<Leader>qq", "<cmd>qall<cr>", { desc = "quit all" })
|
||||||
|
|
||||||
|
-- <Leader>s for search
|
||||||
-- <Leader>s
|
keymap.set("n", "<Leader>sb", "<cmd>Telescope git_branches<cr>", { desc = "Checkout branch" })
|
||||||
keymap.set('n', "<Leader>sb", "<cmd>Telescope git_branches<cr>", {desc= "Checkout branch" })
|
keymap.set("n", "<Leader>sc", "<cmd>nohl<cr>", { desc = "no highlight" })
|
||||||
keymap.set('n', "<Leader>sc", "<cmd>:nohl<cr>", {desc= "no highlight" })
|
keymap.set("n", "<Leader>sd", "<cmd>Telescope diagnostics bufnr=0<cr>", { desc = "Document Diagnostics" })
|
||||||
keymap.set('n', "<Leader>sd", "<cmd>Telescope lsp_document_diagnostics<cr>", {desc= "Document Diagnostics" })
|
keymap.set("n", "<Leader>sD", "<cmd>Telescope diagnostics<cr>", { desc = "Workspace Diagnostics" })
|
||||||
keymap.set('n', "<Leader>sD", "<cmd>Telescope lsp_workspace_diagnostics<cr>", {desc= "Workspace Diagnostics" })
|
keymap.set("n", "<Leader>sf", "<cmd>Telescope find_files<cr>", { desc = "Find File" })
|
||||||
keymap.set('n', "<Leader>sf", "<cmd>Telescope find_files<cr>", {desc= "Find File" })
|
keymap.set("n", "<Leader>sr", function()
|
||||||
keymap.set('n', "<Leader>sr", function() require("telescope.builtin").oldfiles({ cwd = vim.loop.cwd() }) end, {desc= "Old File" })
|
require("telescope.builtin").oldfiles({ cwd = vim.uv.cwd() })
|
||||||
keymap.set('n', "<Leader>sm", "<cmd>Telescope marks<cr>", {desc= "Marks" })
|
end, { desc = "Old File" })
|
||||||
keymap.set('n', "<Leader>sM", "<cmd>Telescope man_pages<cr>", {desc= "Man Pages" })
|
keymap.set("n", "<Leader>sm", "<cmd>Telescope marks<cr>", { desc = "Marks" })
|
||||||
keymap.set('n', "<Leader>sR", "<cmd>Telescope registers<cr>", {desc= "Registers" })
|
keymap.set("n", "<Leader>sM", "<cmd>Telescope man_pages<cr>", { desc = "Man Pages" })
|
||||||
keymap.set('n', "<Leader>st", "<cmd>Telescope live_grep<cr>", {desc= "Text" })
|
keymap.set("n", "<Leader>sR", "<cmd>Telescope registers<cr>", { desc = "Registers" })
|
||||||
keymap.set('n', "<Leader>sT", "<cmd>Telescope live_grep<cr>", {desc= "Text" })
|
keymap.set("n", "<Leader>st", "<cmd>Telescope live_grep<cr>", { desc = "Text" })
|
||||||
keymap.set('n', "<Leader>s,", function()
|
keymap.set("n", "<Leader>s,", function()
|
||||||
local ok, fzf_lua = pcall(require, "fzf-lua")
|
local ok, fzf_lua = pcall(require, "fzf-lua")
|
||||||
if ok then
|
if ok then
|
||||||
fzf_lua.grep_cword()
|
fzf_lua.grep_cword()
|
||||||
else
|
else
|
||||||
vim.notify("fzf-lua not available, falling back to Telescope", vim.log.levels.WARN)
|
|
||||||
require("telescope.builtin").grep_string({ word_match = "-w" })
|
require("telescope.builtin").grep_string({ word_match = "-w" })
|
||||||
end
|
end
|
||||||
end, {desc= "Search word under cursor" })
|
end, { desc = "Search word under cursor" })
|
||||||
|
|
||||||
-- <Leader>S
|
-- <Leader>t for test
|
||||||
keymap.set('n', "<Leader>Ss", "<cmd>SessionSave<cr>", {desc= "Save Session" })
|
keymap.set("n", "<Leader>tt", '<cmd>lua require("neotest").run.run()<cr>', { desc = "TestNearest" })
|
||||||
keymap.set('n', "<Leader>Sl", "<cmd>SessionLoad<cr>", {desc= "Load Session" })
|
keymap.set("n", "<Leader>tf", '<cmd>lua require("neotest").run.run(vim.fn.expand("%"))<cr>', { desc = "TestFile" })
|
||||||
|
keymap.set("n", "<Leader>tc", "<cmd>GoCover<cr>", { desc = "go coverage" })
|
||||||
-- <Leader>t
|
keymap.set("n", "<Leader>tC", "<cmd>GoCoverClear<cr>", { desc = "go coverage clear" })
|
||||||
keymap.set('n', "<Leader>ta", "<cmd>TestSuite -v -cover<cr>", {desc= "TestSuite" })
|
keymap.set("n", "<Leader>tb", '<cmd>lua require("dap").toggle_breakpoint()<cr>', { desc = "set break point" })
|
||||||
keymap.set('n', "<Leader>tt", "<cmd>lua require('neotest').run.run() <cr>", {desc= "TestNearest" })
|
keymap.set("n", "<Leader>tr", '<cmd>lua require("dap").continue()<cr>', { desc = "continue" })
|
||||||
keymap.set('n', "<Leader>tf", '<cmd>lua require("neotest").run.run(vim.fn.expand("%"))<cr>', {desc= "TestFile" })
|
|
||||||
keymap.set('n', "<Leader>tc", "<cmd>GoCover<cr>", {desc="go coverage" })
|
|
||||||
keymap.set('n', "<Leader>tC", "<cmd>GoCoverClear<cr>", {desc= "go coverage clear" })
|
|
||||||
keymap.set('n', "<Leader>tb", "<cmd>lua require'dap'.toggle_breakpoint()<cr>", {desc= "set break point" })
|
|
||||||
keymap.set('n', "<Leader>tr", "<cmd>lua require'dap'.continue()<cr>", {desc= "continue" })
|
|
||||||
keymap.set('n', "<Leader>zs", "<cmd>TZBottom<cr>", {desc="toggle status line" })
|
|
||||||
keymap.set('n', "<Leader>zt", "<cmd>TZTop<cr>", {desc= "toggle tab bar" })
|
|
||||||
keymap.set('n', "<Leader>zz", "<cmd>TZAtaraxis<cr>", {desc= "toggle zen" })
|
|
||||||
|
|
||||||
-- <Leader>;
|
-- <Leader>;
|
||||||
keymap.set('n', '<Leader>;', ':Dashboard<CR>', { noremap = true, silent = true })
|
keymap.set("n", "<Leader>;", "<cmd>Dashboard<CR>", { noremap = true, silent = true, desc = "Dashboard" })
|
||||||
|
|
||||||
-- Ctrl
|
-- Ctrl-p: find files with recent-first boost
|
||||||
keymap.set('n', '<C-p>', function()
|
keymap.set("n", "<C-p>", function()
|
||||||
local builtin = require("telescope.builtin")
|
local builtin = require("telescope.builtin")
|
||||||
|
|
||||||
-- 获取最近编辑的文件,创建路径映射
|
|
||||||
local recent_paths = {}
|
local recent_paths = {}
|
||||||
for _, file in ipairs(vim.v.oldfiles) do
|
for _, file in ipairs(vim.v.oldfiles) do
|
||||||
if vim.fn.filereadable(file) == 1 then
|
if vim.fn.filereadable(file) == 1 then
|
||||||
@@ -149,25 +101,13 @@ keymap.set('n', '<C-p>', function()
|
|||||||
local rel_path = vim.fn.fnamemodify(file, ":.")
|
local rel_path = vim.fn.fnamemodify(file, ":.")
|
||||||
recent_paths[abs_path] = true
|
recent_paths[abs_path] = true
|
||||||
recent_paths[rel_path] = true
|
recent_paths[rel_path] = true
|
||||||
-- 也添加文件名(不含路径)
|
recent_paths[vim.fn.fnamemodify(file, ":t")] = true
|
||||||
local filename = vim.fn.fnamemodify(file, ":t")
|
|
||||||
if not recent_paths[filename] then
|
|
||||||
recent_paths[filename] = true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
local ok, _ = pcall(require, "telescope._extensions.fzf")
|
||||||
-- 使用 find_files,fzf 扩展会自动提供基于频率的排序
|
if ok then
|
||||||
-- 如果没有 fzf,我们使用自定义排序器
|
builtin.find_files({ hidden = true, no_ignore = false })
|
||||||
local ok, fzf_ext = pcall(require, "telescope._extensions.fzf")
|
|
||||||
if ok and fzf_ext then
|
|
||||||
-- 使用 fzf 扩展,它会自动提供基于频率的排序
|
|
||||||
builtin.find_files({
|
|
||||||
hidden = true,
|
|
||||||
no_ignore = false,
|
|
||||||
})
|
|
||||||
else
|
else
|
||||||
-- 如果没有 fzf 扩展,使用自定义排序
|
|
||||||
local sorters = require("telescope.sorters")
|
local sorters = require("telescope.sorters")
|
||||||
builtin.find_files({
|
builtin.find_files({
|
||||||
hidden = true,
|
hidden = true,
|
||||||
@@ -177,106 +117,64 @@ keymap.set('n', '<C-p>', function()
|
|||||||
scoring_function = function(_, prompt, line, entry)
|
scoring_function = function(_, prompt, line, entry)
|
||||||
local score = 0
|
local score = 0
|
||||||
local path = entry.path or entry.value or line
|
local path = entry.path or entry.value or line
|
||||||
|
|
||||||
-- 检查是否在最近编辑的文件列表中
|
|
||||||
local abs_path = vim.fn.fnamemodify(path, ":p")
|
local abs_path = vim.fn.fnamemodify(path, ":p")
|
||||||
local rel_path = vim.fn.fnamemodify(path, ":.")
|
local rel_path = vim.fn.fnamemodify(path, ":.")
|
||||||
local filename = vim.fn.fnamemodify(path, ":t")
|
local filename = vim.fn.fnamemodify(path, ":t")
|
||||||
|
|
||||||
if recent_paths[abs_path] or recent_paths[rel_path] or recent_paths[filename] then
|
if recent_paths[abs_path] or recent_paths[rel_path] or recent_paths[filename] then
|
||||||
score = 1000 -- 提高分数,让最近的文件排在前面
|
score = 1000
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 添加基本的模糊匹配分数
|
|
||||||
if prompt and prompt ~= "" then
|
if prompt and prompt ~= "" then
|
||||||
local lower_path = path:lower()
|
if path:lower():find(prompt:lower(), 1, true) then
|
||||||
local lower_prompt = prompt:lower()
|
|
||||||
if lower_path:find(lower_prompt, 1, true) then
|
|
||||||
score = score + 100
|
score = score + 100
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return score
|
return score
|
||||||
end,
|
end,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end, { noremap = true, silent = true, desc = "Find Files (Recent First)" })
|
end, { noremap = true, silent = true, desc = "Find Files (Recent First)" })
|
||||||
-- better window movement
|
|
||||||
keymap.set('n', '<C-h>', '<C-w>h', { silent = true })
|
|
||||||
keymap.set('n', '<C-j>', '<C-w>j', { silent = true })
|
|
||||||
keymap.set('n', '<C-k>', '<C-w>k', { silent = true })
|
|
||||||
keymap.set('n', '<C-l>', '<C-w>l', { silent = true })
|
|
||||||
-- resize with arrows
|
|
||||||
keymap.set('n', '<C-Up>', ':resize -2<CR>', { silent = true })
|
|
||||||
keymap.set('n', '<C-Down>', ':resize +2<CR>', { silent = true })
|
|
||||||
keymap.set('n', '<C-Left>', ':vertical resize -2<CR>', { silent = true })
|
|
||||||
keymap.set('n', '<C-Right>', ':vertical resize +2<CR>', { silent = true })
|
|
||||||
|
|
||||||
keymap.set('n', '<C-q>', ':call QuickFixToggle()<CR>', { noremap = true, silent = true })
|
-- Window movement
|
||||||
|
keymap.set("n", "<C-h>", "<C-w>h", { silent = true })
|
||||||
|
keymap.set("n", "<C-j>", "<C-w>j", { silent = true })
|
||||||
|
keymap.set("n", "<C-k>", "<C-w>k", { silent = true })
|
||||||
|
keymap.set("n", "<C-l>", "<C-w>l", { silent = true })
|
||||||
|
|
||||||
-- Override two spaces (LazyVim default fzf) with Telescope live_grep
|
-- Resize with arrows
|
||||||
-- Search for keywords in file contents
|
keymap.set("n", "<C-Up>", ":resize -2<CR>", { silent = true })
|
||||||
keymap.set('n', ' ', function()
|
keymap.set("n", "<C-Down>", ":resize +2<CR>", { silent = true })
|
||||||
|
keymap.set("n", "<C-Left>", ":vertical resize -2<CR>", { silent = true })
|
||||||
|
keymap.set("n", "<C-Right>", ":vertical resize +2<CR>", { silent = true })
|
||||||
|
|
||||||
|
-- Quickfix toggle
|
||||||
|
keymap.set("n", "<C-q>", function()
|
||||||
|
for _, win in pairs(vim.fn.getwininfo()) do
|
||||||
|
if win.quickfix == 1 then
|
||||||
|
vim.cmd("cclose")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
vim.cmd("copen")
|
||||||
|
end, { noremap = true, silent = true, desc = "Toggle Quickfix" })
|
||||||
|
|
||||||
|
-- Two spaces → live_grep
|
||||||
|
keymap.set("n", " ", function()
|
||||||
require("telescope.builtin").live_grep()
|
require("telescope.builtin").live_grep()
|
||||||
end, { noremap = true, silent = true, desc = "Search in Files (two spaces)" })
|
end, { noremap = true, silent = true, desc = "Search in Files" })
|
||||||
|
|
||||||
-- LSP keymaps (gd, gD, K, gi, etc.)
|
-- Misc
|
||||||
-- Delete LazyVim's default mappings first to avoid conflicts
|
keymap.set("n", "Y", "y$", {})
|
||||||
-- Use vim.schedule to ensure this runs after LazyVim loads
|
keymap.set("v", "<", "<gv", { noremap = true, silent = true })
|
||||||
vim.schedule(function()
|
keymap.set("v", ">", ">gv", { noremap = true, silent = true })
|
||||||
vim.keymap.del('n', 'gd')
|
keymap.set("i", "jk", "<ESC>", { noremap = true, silent = true })
|
||||||
vim.keymap.del('n', 'gD')
|
keymap.set("i", "kj", "<ESC>", { noremap = true, silent = true })
|
||||||
vim.keymap.del('n', 'gi')
|
keymap.set("i", "jj", "<ESC>", { noremap = true, silent = true })
|
||||||
vim.keymap.del('n', 'K')
|
|
||||||
vim.keymap.del('n', 'gt')
|
|
||||||
vim.keymap.del('n', 'gr')
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Go to definition
|
-- Tab switch buffer (barbar)
|
||||||
keymap.set('n', 'gd', function()
|
keymap.set("n", "<TAB>", "<cmd>BufferNext<CR>", { noremap = true, silent = true })
|
||||||
vim.lsp.buf.definition()
|
keymap.set("n", "<S-TAB>", "<cmd>BufferPrevious<CR>", { noremap = true, silent = true })
|
||||||
end, { noremap = true, silent = true, desc = "Goto Definition" })
|
|
||||||
|
|
||||||
-- Go to declaration
|
|
||||||
keymap.set('n', 'gD', function()
|
|
||||||
vim.lsp.buf.declaration()
|
|
||||||
end, { noremap = true, silent = true, desc = "Goto Declaration" })
|
|
||||||
|
|
||||||
-- Go to implementation
|
|
||||||
keymap.set('n', 'gi', function()
|
|
||||||
vim.lsp.buf.implementation()
|
|
||||||
end, { noremap = true, silent = true, desc = "Goto Implementation" })
|
|
||||||
|
|
||||||
-- Hover
|
|
||||||
keymap.set('n', 'K', function()
|
|
||||||
vim.lsp.buf.hover()
|
|
||||||
end, { noremap = true, silent = true, desc = "Hover Documentation" })
|
|
||||||
|
|
||||||
-- Go to type definition
|
|
||||||
keymap.set('n', 'gt', function()
|
|
||||||
vim.lsp.buf.type_definition()
|
|
||||||
end, { noremap = true, silent = true, desc = "Goto Type Definition" })
|
|
||||||
|
|
||||||
-- References
|
|
||||||
keymap.set('n', 'gr', function()
|
|
||||||
vim.lsp.buf.references()
|
|
||||||
end, { noremap = true, silent = true, desc = "References" })
|
|
||||||
|
|
||||||
-- Other
|
|
||||||
-- better edit
|
|
||||||
keymap.set('n', 'Y', 'y$', {})
|
|
||||||
-- better indenting
|
|
||||||
keymap.set('v', '<', '<gv', { noremap = true, silent = true })
|
|
||||||
keymap.set('v', '>', '>gv', { noremap = true, silent = true })
|
|
||||||
-- I hate escape
|
|
||||||
keymap.set('i', 'jk', '<ESC>', { noremap = true, silent = true })
|
|
||||||
keymap.set('i', 'kj', '<ESC>', { noremap = true, silent = true })
|
|
||||||
keymap.set('i', 'jj', '<ESC>', { noremap = true, silent = true })
|
|
||||||
-- Tab switch buffer
|
|
||||||
keymap.set('n', '<TAB>', ':BufferNext<CR>', { noremap = true, silent = true })
|
|
||||||
keymap.set('n', '<S-TAB>', ':BufferPrevious<CR>', { noremap = true, silent = true })
|
|
||||||
-- Move selected line / block of text in visual mode
|
|
||||||
keymap.set('x', 'K', ':move \'<-2<CR>gv-gv', { noremap = true, silent = true })
|
|
||||||
keymap.set('x', 'J', ':move \'>+1<CR>gv-gv', { noremap = true, silent = true })
|
|
||||||
|
|
||||||
|
-- Move selected line / block in visual mode
|
||||||
|
keymap.set("x", "K", ":move '<-2<CR>gv-gv", { noremap = true, silent = true })
|
||||||
|
keymap.set("x", "J", ":move '>+1<CR>gv-gv", { noremap = true, silent = true })
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||||
if not vim.loop.fs_stat(lazypath) then
|
if not vim.uv.fs_stat(lazypath) then
|
||||||
-- bootstrap lazy.nvim
|
-- bootstrap lazy.nvim
|
||||||
-- stylua: ignore
|
-- stylua: ignore
|
||||||
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath })
|
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath })
|
||||||
@@ -14,6 +14,10 @@ require("lazy").setup({
|
|||||||
-- import/override with your plugins
|
-- import/override with your plugins
|
||||||
{ import = "plugins" },
|
{ import = "plugins" },
|
||||||
},
|
},
|
||||||
|
-- 本机未装 luarocks 时避免 Lazy 健康检查报 ERROR;需要 rocks 依赖的插件时再打开
|
||||||
|
rocks = {
|
||||||
|
enabled = false,
|
||||||
|
},
|
||||||
defaults = {
|
defaults = {
|
||||||
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
|
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
|
||||||
-- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
|
-- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
|
||||||
|
|||||||
+10
-20
@@ -1,6 +1,12 @@
|
|||||||
vim.g.autoformat = true
|
vim.g.autoformat = true
|
||||||
|
|
||||||
vim.cmd("set iskeyword+=-") -- treat dash separated words as a word text object"
|
-- 关闭不常用的远程宿主,减少 :checkhealth 里无意义的 WARNING
|
||||||
|
vim.g.loaded_perl_provider = 0
|
||||||
|
vim.g.loaded_ruby_provider = 0
|
||||||
|
-- 明确指向已安装 pynvim 的解释器
|
||||||
|
vim.g.python3_host_prog = "/usr/bin/python3"
|
||||||
|
|
||||||
|
vim.cmd("set iskeyword+=-") -- treat dash separated words as a word text object
|
||||||
vim.cmd("set shortmess+=c") -- Don't pass messages to |ins-completion-menu|.
|
vim.cmd("set shortmess+=c") -- Don't pass messages to |ins-completion-menu|.
|
||||||
vim.cmd("set inccommand=split") -- Make substitution work in realtime
|
vim.cmd("set inccommand=split") -- Make substitution work in realtime
|
||||||
vim.opt.hidden = true -- Required to keep multiple buffers open multiple buffers
|
vim.opt.hidden = true -- Required to keep multiple buffers open multiple buffers
|
||||||
@@ -10,53 +16,37 @@ vim.cmd('let &titleold="' .. TERMINAL .. '"')
|
|||||||
vim.opt.titlestring = "%<%F%=%l/%L - nvim"
|
vim.opt.titlestring = "%<%F%=%l/%L - nvim"
|
||||||
vim.wo.wrap = true -- Display long lines as just one line
|
vim.wo.wrap = true -- Display long lines as just one line
|
||||||
vim.cmd("set whichwrap+=<,>,[,],h,l") -- move to next line with theses keys
|
vim.cmd("set whichwrap+=<,>,[,],h,l") -- move to next line with theses keys
|
||||||
vim.cmd("syntax on") -- syntax highlighting
|
|
||||||
vim.opt.pumheight = 10 -- Makes popup menu smaller
|
vim.opt.pumheight = 10 -- Makes popup menu smaller
|
||||||
vim.opt.fileencoding = "utf-8" -- The encoding written to file
|
vim.opt.fileencoding = "utf-8" -- The encoding written to file
|
||||||
vim.opt.cmdheight = 2 -- More space for displaying messages
|
vim.opt.cmdheight = 2 -- More space for displaying messages
|
||||||
vim.cmd("set colorcolumn=99999") -- fix indentline for now
|
|
||||||
vim.opt.mouse = "a" -- Enable your mouse
|
vim.opt.mouse = "a" -- Enable your mouse
|
||||||
vim.opt.splitbelow = true -- Horizontal splits will automatically be below
|
vim.opt.splitbelow = true -- Horizontal splits will automatically be below
|
||||||
vim.opt.termguicolors = true -- set term gui colors most terminals support this
|
vim.opt.termguicolors = true -- set term gui colors most terminals support this
|
||||||
vim.opt.splitright = true -- Vertical splits will automatically be to the right
|
vim.opt.splitright = true -- Vertical splits will automatically be to the right
|
||||||
-- vim.opt.t_Co = "256" -- Support 256 colors
|
|
||||||
vim.opt.conceallevel = 0 -- So that I can see `` in markdown files
|
vim.opt.conceallevel = 0 -- So that I can see `` in markdown files
|
||||||
vim.o.tabstop = 4
|
vim.o.tabstop = 4
|
||||||
vim.opt.shiftwidth = 4
|
vim.opt.shiftwidth = 4
|
||||||
vim.opt.expandtab = true
|
vim.opt.expandtab = true
|
||||||
vim.bo.smartindent = true -- Makes indenting smart
|
vim.opt.smartindent = true -- Makes indenting smart
|
||||||
vim.wo.number = true -- set numbered lines
|
vim.wo.number = true -- set numbered lines
|
||||||
vim.wo.relativenumber = true -- set relative number
|
vim.wo.relativenumber = true -- set relative number
|
||||||
vim.wo.cursorline = true -- Enable highlighting of the current line
|
vim.wo.cursorline = true -- Enable highlighting of the current line
|
||||||
vim.opt.showtabline = 2 -- Always show tabs
|
vim.opt.showtabline = 2 -- Always show tabs
|
||||||
vim.opt.showmode = false -- We don't need to see things like -- INSERT -- anymore
|
vim.opt.showmode = false -- We don't need to see things like -- INSERT -- anymore
|
||||||
vim.opt.backup = false -- This is recommended by coc
|
vim.opt.backup = false
|
||||||
vim.opt.writebackup = false -- This is recommended by coc
|
vim.opt.writebackup = false
|
||||||
vim.wo.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time
|
vim.wo.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time
|
||||||
vim.opt.updatetime = 300 -- Faster completion
|
vim.opt.updatetime = 300 -- Faster completion
|
||||||
vim.opt.timeoutlen = 500 -- By default timeoutlen is 1000 ms
|
vim.opt.timeoutlen = 500 -- By default timeoutlen is 1000 ms
|
||||||
vim.opt.clipboard = "unnamedplus" -- Copy paste between vim and everything else
|
vim.opt.clipboard = "unnamedplus" -- Copy paste between vim and everything else
|
||||||
vim.cmd("filetype plugin on") -- filetype detection
|
|
||||||
-- vim.opt.guifont = "JetBrainsMono\\ Nerd\\ Font\\ Mono:h18"
|
|
||||||
-- vim.opt.guifont = "Hack\\ Nerd\\ Font\\ Mono"
|
|
||||||
-- vim.opt.guifont = "SauceCodePro Nerd Font:h17"
|
|
||||||
vim.opt.guifont = "FiraCode Nerd Font:h17"
|
vim.opt.guifont = "FiraCode Nerd Font:h17"
|
||||||
|
|
||||||
-- vim.opt.guifont = "JetBrains\\ Mono\\ Regular\\ Nerd\\ Font\\ Complete"
|
|
||||||
vim.g.vim_markdown_folding_disabled = 1
|
vim.g.vim_markdown_folding_disabled = 1
|
||||||
|
|
||||||
vim.g.vimspector_enable_mappings = "HUMAN"
|
|
||||||
vim.g["test#go#rspec#options"] = { nearest = "--v", suite = "--v" }
|
|
||||||
|
|
||||||
-- git blame
|
-- git blame
|
||||||
vim.cmd("highlight default link gitblame SpecialComment")
|
vim.cmd("highlight default link gitblame SpecialComment")
|
||||||
vim.g.gitblame_enabled = 0
|
vim.g.gitblame_enabled = 0
|
||||||
|
|
||||||
-- last position jump
|
|
||||||
vim.cmd([[
|
|
||||||
autocmd BufReadPost * if line("'\"") >= 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
|
|
||||||
]])
|
|
||||||
|
|
||||||
-- vim.cmd('let g:nvcode_termcolors=256')
|
-- vim.cmd('let g:nvcode_termcolors=256')
|
||||||
-- --local cc = 'gruvbox'
|
-- --local cc = 'gruvbox'
|
||||||
-- local cc = 'lunar'
|
-- local cc = 'lunar'
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
return {
|
return {
|
||||||
|
{ "akinsho/bufferline.nvim", enabled = false },
|
||||||
{
|
{
|
||||||
-- tabline
|
-- tabline
|
||||||
'romgrk/barbar.nvim',
|
'romgrk/barbar.nvim',
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ return {
|
|||||||
--"bashls",
|
--"bashls",
|
||||||
"shfmt",
|
"shfmt",
|
||||||
--"tailwindcss",
|
--"tailwindcss",
|
||||||
"tsserver", -- TypeScript/JavaScript LSP
|
"typescript-language-server", -- TypeScript/JavaScript LSP
|
||||||
"pylyzer",
|
"pylyzer",
|
||||||
--"cssls",
|
--"cssls",
|
||||||
"bufls", -- Protocol Buffers LSP
|
"buf", -- Protocol Buffers LSP
|
||||||
"gopls", -- Go LSP
|
"gopls", -- Go LSP
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ end
|
|||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"hrsh7th/nvim-cmp",
|
"hrsh7th/nvim-cmp",
|
||||||
enable = false,
|
enabled = false,
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"hrsh7th/cmp-emoji",
|
"hrsh7th/cmp-emoji",
|
||||||
'hrsh7th/vim-vsnip',
|
'hrsh7th/vim-vsnip',
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
return {
|
return {
|
||||||
"leoluz/nvim-dap-go",
|
"leoluz/nvim-dap-go",
|
||||||
keys = {
|
keys = {
|
||||||
{ "<F5>", function() require("dap").continue({ before = get_args }) end, desc = "Run with Args" },
|
{ "<F5>", function() require("dap").continue() end, desc = "Run/Continue" },
|
||||||
{ "<F6>",":lua require('dap-go').debug_test()<cr>", desc = "Debug Test" },
|
{ "<F6>",":lua require('dap-go').debug_test()<cr>", desc = "Debug Test" },
|
||||||
{ "<F9>", function() require("dap").toggle_breakpoint() end, desc = "Toggle Breakpoint" },
|
{ "<F9>", function() require("dap").toggle_breakpoint() end, desc = "Toggle Breakpoint" },
|
||||||
{ "<F10>", function() require("dap").step_over() end, desc = "Step Over" },
|
{ "<F10>", function() require("dap").step_over() end, desc = "Step Over" },
|
||||||
|
|||||||
@@ -1,15 +1,10 @@
|
|||||||
return {
|
return {
|
||||||
-- lsp servers
|
|
||||||
{
|
{
|
||||||
"mason-org/mason.nvim",
|
|
||||||
"mason-org/mason-lspconfig.nvim",
|
|
||||||
"neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
event = { "BufReadPre", "BufReadPost", "BufNewFile" },
|
|
||||||
opts = {
|
opts = {
|
||||||
inlay_hints = { enabled = false },
|
inlay_hints = { enabled = false },
|
||||||
---@type lspconfig.options
|
|
||||||
servers = {
|
servers = {
|
||||||
bufls = {}, -- Protocol Buffers LSP
|
buf_ls = {},
|
||||||
cssls = {},
|
cssls = {},
|
||||||
tailwindcss = {
|
tailwindcss = {
|
||||||
root_dir = function(...)
|
root_dir = function(...)
|
||||||
@@ -28,7 +23,7 @@ return {
|
|||||||
)(...)
|
)(...)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
tsserver = {
|
ts_ls = {
|
||||||
root_dir = function(...)
|
root_dir = function(...)
|
||||||
return require("lspconfig.util").root_pattern(
|
return require("lspconfig.util").root_pattern(
|
||||||
"tsconfig.json",
|
"tsconfig.json",
|
||||||
@@ -72,7 +67,6 @@ return {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
lua_ls = {
|
lua_ls = {
|
||||||
-- enabled = false,
|
|
||||||
single_file_support = true,
|
single_file_support = true,
|
||||||
settings = {
|
settings = {
|
||||||
Lua = {
|
Lua = {
|
||||||
@@ -83,11 +77,6 @@ return {
|
|||||||
workspaceWord = true,
|
workspaceWord = true,
|
||||||
callSnippet = "Both",
|
callSnippet = "Both",
|
||||||
},
|
},
|
||||||
misc = {
|
|
||||||
parameters = {
|
|
||||||
-- "--log-level=trace",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
hint = {
|
hint = {
|
||||||
enable = true,
|
enable = true,
|
||||||
setType = false,
|
setType = false,
|
||||||
@@ -104,7 +93,6 @@ return {
|
|||||||
},
|
},
|
||||||
diagnostics = {
|
diagnostics = {
|
||||||
disable = { "incomplete-signature-doc", "trailing-space" },
|
disable = { "incomplete-signature-doc", "trailing-space" },
|
||||||
-- enable = false,
|
|
||||||
groupSeverity = {
|
groupSeverity = {
|
||||||
strong = "Warning",
|
strong = "Warning",
|
||||||
strict = "Warning",
|
strict = "Warning",
|
||||||
@@ -137,7 +125,7 @@ return {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
gopls = {
|
gopls = {
|
||||||
cmd = { "gopls", "serve" }, -- use cmd in path, I can update it easily
|
cmd = { "gopls", "serve" },
|
||||||
settings = {
|
settings = {
|
||||||
gopls = {
|
gopls = {
|
||||||
analyses = {
|
analyses = {
|
||||||
@@ -151,9 +139,7 @@ return {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
pylsp = {
|
pylyzer = {
|
||||||
cmd = { "pylyzer", "--server" },
|
|
||||||
filetypes = { "python" },
|
|
||||||
settings = {
|
settings = {
|
||||||
python = {
|
python = {
|
||||||
checkOnType = false,
|
checkOnType = false,
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ return {
|
|||||||
ft = { "markdown", "mdx", "quarto", "rmd", "org" },
|
ft = { "markdown", "mdx", "quarto", "rmd", "org" },
|
||||||
---@module 'render-markdown'
|
---@module 'render-markdown'
|
||||||
---@type render.md.UserConfig
|
---@type render.md.UserConfig
|
||||||
opts = {},
|
opts = {
|
||||||
|
-- 未安装 tectonic/pdflatex 时关闭 LaTeX 公式渲染,减少健康检查噪音
|
||||||
|
latex = { enabled = false },
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
"folke/snacks.nvim",
|
||||||
|
opts = {
|
||||||
|
image = {
|
||||||
|
-- tmux / 部分终端不报 kitty graphics;避免 :checkhealth 里出现 ERROR(仍会 WARN)
|
||||||
|
force = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -15,17 +15,24 @@ return {
|
|||||||
"graphql",
|
"graphql",
|
||||||
"html",
|
"html",
|
||||||
"java",
|
"java",
|
||||||
|
"javascript",
|
||||||
"json",
|
"json",
|
||||||
"lua",
|
"latex",
|
||||||
"markdown", -- render-markdown.nvim
|
-- "lua", "vim", "vimdoc", "query", "markdown" 等由 Neovim 内置,
|
||||||
|
-- 不在此安装,避免 nvim-treesitter 装的新版 parser 与内置 query 不兼容。
|
||||||
|
"norg",
|
||||||
"php",
|
"php",
|
||||||
"proto", -- Protocol Buffers
|
"proto", -- Protocol Buffers
|
||||||
|
"regex",
|
||||||
"rust",
|
"rust",
|
||||||
"scss",
|
"scss",
|
||||||
"sql",
|
"sql",
|
||||||
"svelte",
|
"svelte",
|
||||||
"toml",
|
"toml",
|
||||||
"tsx",
|
"tsx",
|
||||||
|
"typescript",
|
||||||
|
"typst",
|
||||||
|
"vue",
|
||||||
"yaml",
|
"yaml",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ function M.get_loc()
|
|||||||
end
|
end
|
||||||
info = info or me
|
info = info or me
|
||||||
local source = info.source:sub(2)
|
local source = info.source:sub(2)
|
||||||
source = vim.loop.fs_realpath(source) or source
|
source = vim.uv.fs_realpath(source) or source
|
||||||
return source .. ":" .. info.linedefined
|
return source .. ":" .. info.linedefined
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ function M.dump(...)
|
|||||||
if vim.tbl_isempty(value) then
|
if vim.tbl_isempty(value) then
|
||||||
value = nil
|
value = nil
|
||||||
else
|
else
|
||||||
value = vim.tbl_islist(value) and vim.tbl_count(value) <= 1 and value[1] or value
|
value = vim.islist(value) and vim.tbl_count(value) <= 1 and value[1] or value
|
||||||
end
|
end
|
||||||
M._dump(value)
|
M._dump(value)
|
||||||
end
|
end
|
||||||
|
|||||||
+22
-203
@@ -1,212 +1,31 @@
|
|||||||
local lv_utils = {}
|
local M = {}
|
||||||
|
|
||||||
|
function M.yank_filepath()
|
||||||
-- copy current filepath to clipboard
|
local p = vim.fn.expand("%:p")
|
||||||
function lv_utils.yank_filepath()
|
local line = vim.fn.line(".")
|
||||||
local p = vim.fn.expand('%:p')
|
p = p .. ":" .. line
|
||||||
local line = vim.fn.line(".")
|
print(p)
|
||||||
p = p..":"..line
|
vim.fn.setreg("+", p)
|
||||||
print(p)
|
|
||||||
vim.fn.setreg('+',p)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function lv_utils.yank_file_dir()
|
function M.yank_file_dir()
|
||||||
local p = vim.fn.expand('%:p:h')
|
local p = vim.fn.expand("%:p:h")
|
||||||
print(p)
|
print(p)
|
||||||
vim.fn.setreg('+',p)
|
vim.fn.setreg("+", p)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.open_md()
|
||||||
function lv_utils.open_md()
|
local p = vim.fn.expand("%:p")
|
||||||
local p = vim.fn.expand('%:p')
|
vim.fn.system("open -a marktext " .. p)
|
||||||
vim.fn.system("open -a marktext "..p)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function lv_utils.define_augroups(definitions) -- {{{1
|
function M.file_exists(name)
|
||||||
-- Create autocommand groups based on the passed definitions
|
local f = io.open(name, "r")
|
||||||
--
|
if f ~= nil then
|
||||||
-- The key will be the name of the group, and each definition
|
io.close(f)
|
||||||
-- within the group should have:
|
return true
|
||||||
-- 1. Trigger
|
end
|
||||||
-- 2. Pattern
|
return false
|
||||||
-- 3. Text
|
|
||||||
-- just like how they would normally be defined from Vim itself
|
|
||||||
for group_name, definition in pairs(definitions) do
|
|
||||||
vim.cmd('augroup ' .. group_name)
|
|
||||||
vim.cmd('autocmd!')
|
|
||||||
|
|
||||||
for _, def in pairs(definition) do
|
|
||||||
local command = table.concat(vim.tbl_flatten {'autocmd', def}, ' ')
|
|
||||||
vim.cmd(command)
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.cmd('augroup END')
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- lsp
|
return M
|
||||||
|
|
||||||
function lv_utils.add_to_workspace_folder()
|
|
||||||
vim.lsp.buf.add_workspace_folder()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.clear_references()
|
|
||||||
vim.lsp.buf.clear_references()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.code_action()
|
|
||||||
vim.lsp.buf.code_action()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.declaration()
|
|
||||||
vim.lsp.buf.declaration()
|
|
||||||
vim.lsp.buf.clear_references()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.definition()
|
|
||||||
vim.lsp.buf.definition()
|
|
||||||
vim.lsp.buf.clear_references()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.document_highlight()
|
|
||||||
vim.lsp.buf.document_highlight()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.document_symbol()
|
|
||||||
vim.lsp.buf.document_symbol()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.formatting()
|
|
||||||
vim.lsp.buf.formatting()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.formatting_sync()
|
|
||||||
vim.lsp.buf.formatting_sync()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.hover()
|
|
||||||
vim.lsp.buf.hover()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.implementation()
|
|
||||||
vim.lsp.buf.implementation()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.incoming_calls()
|
|
||||||
vim.lsp.buf.incoming_calls()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.list_workspace_folders()
|
|
||||||
vim.lsp.buf.list_workspace_folders()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.outgoing_calls()
|
|
||||||
vim.lsp.buf.outgoing_calls()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.range_code_action()
|
|
||||||
vim.lsp.buf.range_code_action()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.range_formatting()
|
|
||||||
vim.lsp.buf.range_formatting()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.references()
|
|
||||||
vim.lsp.buf.references()
|
|
||||||
vim.lsp.buf.clear_references()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.remove_workspace_folder()
|
|
||||||
vim.lsp.buf.remove_workspace_folder()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.rename()
|
|
||||||
vim.lsp.buf.rename()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.signature_help()
|
|
||||||
vim.lsp.buf.signature_help()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.type_definition()
|
|
||||||
vim.lsp.buf.type_definition()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.workspace_symbol()
|
|
||||||
vim.lsp.buf.workspace_symbol()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- diagnostic
|
|
||||||
|
|
||||||
function lv_utils.get_all()
|
|
||||||
vim.lsp.diagnostic.get_all()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.get_next()
|
|
||||||
vim.lsp.diagnostic.get_next()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.get_prev()
|
|
||||||
vim.lsp.diagnostic.get_prev()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.goto_next()
|
|
||||||
vim.lsp.diagnostic.goto_next()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.goto_prev()
|
|
||||||
vim.lsp.diagnostic.goto_prev()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.show_line_diagnostics()
|
|
||||||
vim.lsp.diagnostic.show_line_diagnostics()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- git signs
|
|
||||||
|
|
||||||
function lv_utils.next_hunk()
|
|
||||||
require('gitsigns').next_hunk()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.prev_hunk()
|
|
||||||
require('gitsigns').prev_hunk()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.stage_hunk()
|
|
||||||
require('gitsigns').stage_hunk()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.undo_stage_hunk()
|
|
||||||
require('gitsigns').undo_stage_hunk()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.reset_hunk()
|
|
||||||
require('gitsigns').reset_hunk()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.reset_buffer()
|
|
||||||
require('gitsigns').reset_buffer()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.preview_hunk()
|
|
||||||
require('gitsigns').preview_hunk()
|
|
||||||
end
|
|
||||||
|
|
||||||
function lv_utils.blame_line()
|
|
||||||
require('gitsigns').blame_line()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- misc
|
|
||||||
function lv_utils.file_exists(name)
|
|
||||||
local f = io.open(name, "r")
|
|
||||||
if f ~= nil then
|
|
||||||
io.close(f)
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return lv_utils
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user