mirror of
https://github.com/cap153/nvim.git
synced 2026-01-07 11:37:23 +08:00
添加vscode neovim相关配置
This commit is contained in:
parent
59f0ba6a45
commit
d1f5f0a2c8
12 changed files with 217 additions and 57 deletions
|
|
@ -30,7 +30,7 @@ mapcmd("<leader><cr>", "nohlsearch")
|
|||
|
||||
-- 保存和退出
|
||||
mapkey("", "S", ":wall<cr>")
|
||||
mapkey("", "Q", ":q<cr>")
|
||||
mapkey("", "Q", ":qall<cr>")
|
||||
|
||||
-- 撤销与反撤销
|
||||
mapkey("", "l", "u")
|
||||
|
|
@ -209,7 +209,7 @@ vim.cmd([[
|
|||
au filetype dart noremap r :wall<cr>:Telescope flutter commands<cr>
|
||||
au filetype python noremap r :wall<cr>:set splitbelow<cr>:sp<cr>:term uv run %<cr>
|
||||
au filetype go noremap r :wall<cr>:set splitbelow<cr>:sp<cr>:term go run %<cr>
|
||||
au filetype markdown noremap r :MarkdownPreview<cr>
|
||||
au filetype markdown noremap r :PeekClose<cr>:PeekOpen<cr>
|
||||
au filetype rust noremap r :wall<cr>:set splitbelow<cr>:sp<cr>:term cargo run<cr>
|
||||
]])
|
||||
|
||||
|
|
|
|||
|
|
@ -17,12 +17,12 @@ vim.opt.rtp:prepend(vim.env.LAZY or lazypath)
|
|||
-- 启动Lazy插件管理快捷键
|
||||
vim.keymap.set("n", "<leader>l", ":Lazy<CR>", { noremap = true })
|
||||
require("lazy").setup({
|
||||
-- 用Neovim打开kitty滚动缓冲
|
||||
require("lazy.plugins.kittyscroll"),
|
||||
-- 自动补全插件
|
||||
require("lazy.plugins.blinkcmp"),
|
||||
-- lsp配置,全局的错误和警告提示,修复建议,重命名变量,格式化代码等等
|
||||
require("lazy.plugins.lspconfig"),
|
||||
-- neovim中调试代码debug dap
|
||||
require("lazy.plugins.dap"),
|
||||
-- 格式化代码
|
||||
require("lazy.plugins.formatter"),
|
||||
-- ai编程助手Fitten Code
|
||||
|
|
@ -31,12 +31,14 @@ require("lazy").setup({
|
|||
require("lazy.plugins.llm"),
|
||||
-- command line浮动弹窗noice
|
||||
require("lazy.plugins.cmdline"),
|
||||
-- 代码函数名称浏览时固定,`[c`可以跳转到上下文
|
||||
-- 代码函数名称浏览时固定
|
||||
require("lazy.plugins.stickyScroll"),
|
||||
-- fold折叠,根据treesitter来折叠,可以兼容我设置的<leader>o快捷键
|
||||
require("lazy.plugins.fold"),
|
||||
-- 缩进彩虹和高亮
|
||||
require("lazy.plugins.indentrainbow"),
|
||||
-- rainbow彩虹括号
|
||||
require("lazy.plugins.rainbowbracket"),
|
||||
-- 粘贴图片
|
||||
require("lazy.plugins.imgclip"),
|
||||
-- 图片预览
|
||||
|
|
@ -49,8 +51,6 @@ require("lazy").setup({
|
|||
require("lazy.plugins.outline"),
|
||||
-- treesitter语法高亮
|
||||
require("lazy.plugins.treesitter"),
|
||||
-- rainbow彩虹括号
|
||||
require("lazy.plugins.rainbowbracket"),
|
||||
-- tabular,使用:Tab /=来格式化等号之类,特使符号要转义如:Tabularize /\/
|
||||
require("lazy.plugins.tabular"),
|
||||
-- surround,各种对字符的包裹{} [] ''
|
||||
|
|
@ -85,13 +85,17 @@ require("lazy").setup({
|
|||
require("lazy.plugins.multicursor"),
|
||||
-- which-key使用多个字母快捷键停留时会提示
|
||||
require("lazy.plugins.whichkey"),
|
||||
-- 顶部的winbar,可以鼠标点击
|
||||
-- 顶部的winbar,可以鼠标点击,<scace>;选择,`[c`可以跳转到上下文开头,`]c`选择同级上下文
|
||||
require("lazy.plugins.winbar"),
|
||||
-- 用Neovim打开kitty滚动缓冲
|
||||
require("lazy.plugins.kittyscroll"),
|
||||
-- 像cursor一样使用neovim
|
||||
require("lazy.plugins.avante"),
|
||||
-- mcp server插件
|
||||
-- require("lazy.plugins.mcphub"),
|
||||
-- 用于改进在 Neovim 中查看 Markdown 文件的插件
|
||||
-- require("lazy.plugins.markview"),
|
||||
-- require("lazy.plugins.render-markdown"),
|
||||
-- mcp server插件
|
||||
-- require("lazy.plugins.mcphub"),
|
||||
-- 像cursor一样使用neovim
|
||||
require("lazy.plugins.avante"),
|
||||
-- 在浏览器中查看markdown preview
|
||||
require("lazy.plugins.markdownpreview"),
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
return {
|
||||
"saghen/blink.cmp",
|
||||
enabled = not vim.g.vscode, -- 在vscode-neovim禁用
|
||||
dependencies = {
|
||||
"rafamadriz/friendly-snippets",
|
||||
"Kaiser-Yang/blink-cmp-avante",
|
||||
|
|
@ -49,6 +50,12 @@ return {
|
|||
documentation = { auto_show = true, auto_show_delay_ms = 500 },
|
||||
-- 不预选第一个项目,选中后自动插入该项目文本
|
||||
list = { selection = { preselect = false, auto_insert = true } },
|
||||
-- 针对菜单的外观配置
|
||||
-- menu = {
|
||||
-- min_width = 15,
|
||||
-- max_height = 10,
|
||||
-- border = "single", -- Defaults to `vim.o.winborder` on nvim 0.11+
|
||||
-- },
|
||||
},
|
||||
-- 指定文件类型启用/禁用
|
||||
enabled = function()
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ return {
|
|||
lualine_b = { "branch", "diff", "diagnostics" },
|
||||
lualine_c = { "lsp_status" },
|
||||
lualine_x = {},
|
||||
lualine_y = { "encoding", "fileformat", "progress" },
|
||||
lualine_y = { "encoding", "progress" },
|
||||
lualine_z = { "location" },
|
||||
},
|
||||
},
|
||||
|
|
|
|||
125
lua/lazy/plugins/dap.lua
Normal file
125
lua/lazy/plugins/dap.lua
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
return {
|
||||
"mfussenegger/nvim-dap",
|
||||
dependencies = {
|
||||
{
|
||||
"igorlfs/nvim-dap-view",
|
||||
opts = {
|
||||
switchbuf = "useopen,uselast,newtab",
|
||||
-- 开启控制栏按钮
|
||||
winbar = {
|
||||
controls = {
|
||||
enabled = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
config = function()
|
||||
vim.keymap.set("n", "<F5>", function()
|
||||
require("dap").continue()
|
||||
end)
|
||||
vim.keymap.set("n", "<F10>", function()
|
||||
require("dap").step_over()
|
||||
end)
|
||||
vim.keymap.set("n", "<F11>", function()
|
||||
require("dap").step_into()
|
||||
end)
|
||||
vim.keymap.set("n", "<F12>", function()
|
||||
require("dap").step_out()
|
||||
end)
|
||||
vim.keymap.set("n", "<Leader>b", function()
|
||||
require("dap").toggle_breakpoint()
|
||||
end)
|
||||
vim.keymap.set("n", "<Leader>B", function()
|
||||
require("dap").set_breakpoint()
|
||||
end)
|
||||
vim.keymap.set("n", "<Leader>lp", function()
|
||||
require("dap").set_breakpoint(nil, nil, vim.fn.input("Log point message: "))
|
||||
end)
|
||||
vim.keymap.set("n", "<Leader>dr", function()
|
||||
require("dap").repl.open()
|
||||
end)
|
||||
vim.keymap.set("n", "<Leader>dl", function()
|
||||
require("dap").run_last()
|
||||
end)
|
||||
vim.keymap.set({ "n", "v" }, "<Leader>dh", function()
|
||||
require("dap.ui.widgets").hover()
|
||||
end)
|
||||
vim.keymap.set({ "n", "v" }, "<Leader>dp", function()
|
||||
require("dap.ui.widgets").preview()
|
||||
end)
|
||||
vim.keymap.set("n", "<Leader>df", function()
|
||||
local widgets = require("dap.ui.widgets")
|
||||
widgets.centered_float(widgets.frames)
|
||||
end)
|
||||
vim.keymap.set("n", "<Leader>ds", function()
|
||||
local widgets = require("dap.ui.widgets")
|
||||
widgets.centered_float(widgets.scopes)
|
||||
end)
|
||||
-- 自动切换和关闭
|
||||
local dap, dv = require("dap"), require("dap-view")
|
||||
dap.listeners.before.attach["dap-view-config"] = function()
|
||||
dv.open()
|
||||
end
|
||||
dap.listeners.before.launch["dap-view-config"] = function()
|
||||
dv.open()
|
||||
end
|
||||
dap.listeners.before.event_terminated["dap-view-config"] = function()
|
||||
dv.close()
|
||||
end
|
||||
dap.listeners.before.event_exited["dap-view-config"] = function()
|
||||
dv.close()
|
||||
end
|
||||
-- 在 nvim-dap-view 文件类型中将 q 映射为 quit
|
||||
vim.api.nvim_create_autocmd({ "FileType" }, {
|
||||
pattern = { "dap-view", "dap-view-term", "dap-repl" }, -- dap-repl is set by `nvim-dap`
|
||||
callback = function(evt)
|
||||
vim.keymap.set("n", "q", "<C-w>q", { buffer = evt.buf })
|
||||
end,
|
||||
})
|
||||
-- 如果没有窗口包含缓冲区,请创建一个新选项卡
|
||||
dap.defaults.fallback.switchbuf = "usevisible,usetab,newtab"
|
||||
dap.adapters.gdb = {
|
||||
type = "executable",
|
||||
command = "gdb",
|
||||
args = { "--interpreter=dap", "--eval-command", "set print pretty on" },
|
||||
}
|
||||
dap.configurations.c = {
|
||||
{
|
||||
name = "Launch",
|
||||
type = "gdb",
|
||||
request = "launch",
|
||||
program = function()
|
||||
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
|
||||
end,
|
||||
cwd = "${workspaceFolder}",
|
||||
stopAtBeginningOfMainSubprogram = false,
|
||||
},
|
||||
{
|
||||
name = "Select and attach to process",
|
||||
type = "gdb",
|
||||
request = "attach",
|
||||
program = function()
|
||||
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
|
||||
end,
|
||||
pid = function()
|
||||
local name = vim.fn.input("Executable name (filter): ")
|
||||
return require("dap.utils").pick_process({ filter = name })
|
||||
end,
|
||||
cwd = "${workspaceFolder}",
|
||||
},
|
||||
{
|
||||
name = "Attach to gdbserver :1234",
|
||||
type = "gdb",
|
||||
request = "attach",
|
||||
target = "localhost:1234",
|
||||
program = function()
|
||||
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
|
||||
end,
|
||||
cwd = "${workspaceFolder}",
|
||||
},
|
||||
}
|
||||
dap.configurations.cpp = dap.configurations.c
|
||||
dap.configurations.rust = dap.configurations.c
|
||||
end,
|
||||
}
|
||||
|
|
@ -1,9 +1,20 @@
|
|||
-- ===
|
||||
-- === explorer tree 文件列表
|
||||
-- ===
|
||||
|
||||
-- 判断当前环境是否是vscode映射不同命令打开yazi
|
||||
if vim.g.vscode then
|
||||
-- VSCode Neovim environment
|
||||
local vscode = require("vscode")
|
||||
vim.keymap.set("n", "tt", function()
|
||||
vscode.action("yazi-vscode.toggle")
|
||||
end, { noremap = true, silent = true, desc = "Toggle Yazi (VSCode)" })
|
||||
end
|
||||
|
||||
---@type LazySpec
|
||||
return {
|
||||
"mikavilpas/yazi.nvim",
|
||||
enabled = not vim.g.vscode,
|
||||
event = "VeryLazy",
|
||||
dependencies = {
|
||||
-- check the installation instructions at
|
||||
|
|
@ -34,17 +45,3 @@ return {
|
|||
vim.g.loaded_netrwPlugin = 1
|
||||
end,
|
||||
}
|
||||
-- return {
|
||||
-- "rolv-apneseth/tfm.nvim",
|
||||
-- event = "VeryLazy",
|
||||
-- opts = {
|
||||
-- enable_cmds = true,
|
||||
-- },
|
||||
-- keys = {
|
||||
-- {
|
||||
-- "tt",
|
||||
-- ":Tfm<CR>",
|
||||
-- desc = "TFM - new tab",
|
||||
-- },
|
||||
-- },
|
||||
-- }
|
||||
|
|
|
|||
|
|
@ -6,25 +6,24 @@ return {
|
|||
config = function()
|
||||
opts = {}
|
||||
local highlight = {
|
||||
"RainbowBlue",
|
||||
"RainbowViolet",
|
||||
"RainbowRed",
|
||||
"RainbowYellow",
|
||||
"RainbowBlue",
|
||||
"RainbowOrange",
|
||||
"RainbowGreen",
|
||||
"RainbowViolet",
|
||||
"RainbowOrange",
|
||||
"RainbowCyan",
|
||||
}
|
||||
|
||||
local hooks = require("ibl.hooks")
|
||||
-- create the highlight groups in the highlight setup hook, so they are reset
|
||||
-- every time the colorscheme changes
|
||||
hooks.register(hooks.type.HIGHLIGHT_SETUP, function()
|
||||
vim.api.nvim_set_hl(0, "RainbowRed", { fg = "#61AFEF" })
|
||||
vim.api.nvim_set_hl(0, "RainbowYellow", { fg = "#C678DD" })
|
||||
vim.api.nvim_set_hl(0, "RainbowBlue", { fg = "#E06C75" })
|
||||
vim.api.nvim_set_hl(0, "RainbowRed", { fg = "#E06C75" })
|
||||
vim.api.nvim_set_hl(0, "RainbowYellow", { fg = "#E5C07B" })
|
||||
vim.api.nvim_set_hl(0, "RainbowBlue", { fg = "#61AFEF" })
|
||||
vim.api.nvim_set_hl(0, "RainbowOrange", { fg = "#D19A66" })
|
||||
vim.api.nvim_set_hl(0, "RainbowGreen", { fg = "#98C379" })
|
||||
vim.api.nvim_set_hl(0, "RainbowViolet", { fg = "#E5C07B" })
|
||||
vim.api.nvim_set_hl(0, "RainbowViolet", { fg = "#C678DD" })
|
||||
vim.api.nvim_set_hl(0, "RainbowCyan", { fg = "#56B6C2" })
|
||||
end)
|
||||
|
||||
|
|
|
|||
14
lua/lazy/plugins/markdownpreview.lua
Normal file
14
lua/lazy/plugins/markdownpreview.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
return {
|
||||
"cap153/peek.nvim",
|
||||
event = { "VeryLazy" },
|
||||
build = "deno task --quiet build:fast",
|
||||
config = function()
|
||||
require("peek").setup({
|
||||
port = 9000,
|
||||
-- app = { "firefox-esr", "-private-window" },
|
||||
app = { "google-chrome-stable", "--app=http://localhost:9000/?theme=dark", "--incognito" },
|
||||
})
|
||||
vim.api.nvim_create_user_command("PeekOpen", require("peek").open, {})
|
||||
vim.api.nvim_create_user_command("PeekClose", require("peek").close, {})
|
||||
end,
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ map:cmd('<space>v', 'SymbolsOutline')
|
|||
|
||||
return {
|
||||
'simrat39/symbols-outline.nvim',
|
||||
enabled = not vim.g.vscode,
|
||||
config = function()
|
||||
require("symbols-outline").setup {
|
||||
width = 20,
|
||||
|
|
|
|||
|
|
@ -5,6 +5,16 @@
|
|||
return {
|
||||
"HiPhish/rainbow-delimiters.nvim",
|
||||
config = function()
|
||||
require("rainbow-delimiters.setup").setup({})
|
||||
require("rainbow-delimiters.setup").setup({
|
||||
highlight = {
|
||||
"RainbowDelimiterBlue",
|
||||
"RainbowDelimiterViolet",
|
||||
"RainbowDelimiterRed",
|
||||
"RainbowDelimiterYellow",
|
||||
"RainbowDelimiterGreen",
|
||||
"RainbowDelimiterOrange",
|
||||
"RainbowDelimiterCyan",
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
return {
|
||||
"nvim-treesitter/nvim-treesitter-context",
|
||||
config = function()
|
||||
vim.keymap.set("n", "[c", function()
|
||||
require("treesitter-context").go_to_context(vim.v.count1)
|
||||
end, { silent = true })
|
||||
-- 前往上下文开始处,winbar相同快捷键更细致
|
||||
-- vim.keymap.set("n", "[c", function()
|
||||
-- require("treesitter-context").go_to_context(vim.v.count1)
|
||||
-- end, { silent = true })
|
||||
require'treesitter-context'.setup{
|
||||
enable = true, -- Enable this plugin (Can be enabled/disabled later via commands)
|
||||
max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue