mirror of
https://github.com/Dichgrem/DCGOS.git
synced 2025-12-17 03:31:59 -05:00
chore:nvim_setting
feat:use biome fmt test:add copilot chore:let terminal just one fix:keymaps for close buffer fix:disable markdown view && fix conceallevel
This commit is contained in:
@@ -5,40 +5,31 @@
|
||||
local map = vim.keymap.set
|
||||
local opts = { noremap = true, silent = true }
|
||||
|
||||
-- === VSCode-like buffer/tab navigation ===
|
||||
-- === VSCode-like buffer/tab navigation ===
|
||||
map("n", "<C-Tab>", "<cmd>bnext<CR>", { desc = "Next buffer (like VSCode)" })
|
||||
map("n", "<C-S-Tab>", "<cmd>bprevious<CR>", { desc = "Previous buffer (like VSCode)" })
|
||||
|
||||
-- === Close buffer like Ctrl + W in VSCode ===
|
||||
vim.keymap.set("n", "<C-w>", "<cmd>BufferLinePickClose<CR>", { desc = "Close buffer (BufferLine)" })
|
||||
-- === Vscode-like Close buffer navigation ===
|
||||
vim.keymap.set("n", "<C-w>", function()
|
||||
local current = vim.api.nvim_get_current_buf()
|
||||
local buffers = vim.fn.getbufinfo({buflisted = 1})
|
||||
|
||||
vim.keymap.set("n", "<C-S-5>", function()
|
||||
if vim.bo.buftype == "terminal" then
|
||||
vim.cmd("vsplit | terminal")
|
||||
else
|
||||
vim.cmd("botright split | terminal")
|
||||
end
|
||||
end, { desc = "Split terminal" })
|
||||
local next_buf = nil
|
||||
for i, buf in ipairs(buffers) do
|
||||
if buf.bufnr == current then
|
||||
next_buf = buffers[i + 1] or buffers[i - 1]
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
-- 在终端模式下的快捷键
|
||||
vim.keymap.set("t", "<C-h>", "<C-\\><C-n><C-w>h", { desc = "Go to left window" })
|
||||
vim.keymap.set("t", "<C-j>", "<C-\\><C-n><C-w>j", { desc = "Go to lower window" })
|
||||
vim.keymap.set("t", "<C-k>", "<C-\\><C-n><C-w>k", { desc = "Go to upper window" })
|
||||
vim.keymap.set("t", "<C-l>", "<C-\\><C-n><C-w>l", { desc = "Go to right window" })
|
||||
if next_buf then
|
||||
vim.api.nvim_set_current_buf(next_buf.bufnr)
|
||||
end
|
||||
|
||||
vim.api.nvim_buf_delete(current, { force = true })
|
||||
end, { desc = "Close current buffer like VSCode" })
|
||||
|
||||
-- XDG Open
|
||||
vim.keymap.set("n", "<leader>xo", function()
|
||||
vim.fn.jobstart({ "xdg-open", vim.fn.expand("%:p") }, { detach = true })
|
||||
end, { desc = "使用系统默认应用程序打开当前文件" })
|
||||
|
||||
-- === Markdown priview ===
|
||||
vim.keymap.set("n", "<leader>mp", "<cmd>Markview<CR>", {
|
||||
desc = "Toggle Markview Inline Preview",
|
||||
})
|
||||
-- 开启对比预览
|
||||
vim.keymap.set("n", "<leader>mv", "<cmd>Markview splitToggle<CR>", {
|
||||
desc = "Toggle Markview Split Preview",
|
||||
})
|
||||
-- 关闭对比预览
|
||||
vim.keymap.set("n", "<leader>mc", "<cmd>Markview splitClose<CR>", {
|
||||
desc = "Close Markview Split Preview",
|
||||
})
|
||||
|
||||
@@ -1,4 +1,16 @@
|
||||
-- Options are automatically loaded before lazy.nvim startup
|
||||
-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua
|
||||
-- Add any additional options here
|
||||
vim.g.autoformat = false
|
||||
|
||||
-- Disable autoformat
|
||||
vim.g.autoformat = false
|
||||
-- Let terminal just one
|
||||
vim.g.root_spec = { "cwd" }
|
||||
-- Disable markdown views
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "markdown",
|
||||
callback = function()
|
||||
vim.opt_local.conceallevel = 0
|
||||
vim.opt_local.concealcursor = ""
|
||||
end,
|
||||
})
|
||||
|
||||
28
home/nvim/lua/plugins/copilot.lua
Normal file
28
home/nvim/lua/plugins/copilot.lua
Normal file
@@ -0,0 +1,28 @@
|
||||
return {
|
||||
{
|
||||
"zbirenbaum/copilot.lua",
|
||||
cmd = "Copilot",
|
||||
event = "InsertEnter",
|
||||
config = function()
|
||||
require("copilot").setup({
|
||||
suggestion = { enabled = true, auto_trigger = true },
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
{
|
||||
"CopilotC-Nvim/CopilotChat.nvim",
|
||||
branch = "main",
|
||||
dependencies = {
|
||||
{ "zbirenbaum/copilot.lua" },
|
||||
{ "nvim-lua/plenary.nvim" },
|
||||
},
|
||||
opts = {
|
||||
debug = false,
|
||||
},
|
||||
keys = {
|
||||
{ "<leader>cc", "<cmd>CopilotChatToggle<cr>", desc = "CopilotChat - Toggle" },
|
||||
{ "<leader>ce", "<cmd>CopilotChatExplain<cr>", mode = "v", desc = "CopilotChat - Explain code" },
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -34,11 +34,11 @@ return {
|
||||
-- Python
|
||||
opts.formatters_by_ft.python = { "black", "ruff_format" }
|
||||
-- JS/TS/Web
|
||||
opts.formatters_by_ft.javascript = { "prettierd" }
|
||||
opts.formatters_by_ft.typescript = { "prettierd" }
|
||||
opts.formatters_by_ft.javascriptreact = { "prettierd" }
|
||||
opts.formatters_by_ft.typescriptreact = { "prettierd" }
|
||||
opts.formatters_by_ft.vue = { "prettierd" }
|
||||
opts.formatters_by_ft.javascript = { "biome" }
|
||||
opts.formatters_by_ft.typescript = { "biome" }
|
||||
opts.formatters_by_ft.javascriptreact = { "biome" }
|
||||
opts.formatters_by_ft.typescriptreact = { "biome" }
|
||||
opts.formatters_by_ft.vue = { "biome" }
|
||||
-- JSON
|
||||
opts.formatters_by_ft.json = { "jq" }
|
||||
-- YAML
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
return {
|
||||
"OXY2DEV/markview.nvim",
|
||||
name = "markview.nvim",
|
||||
lazy = false,
|
||||
dependencies = {
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
},
|
||||
config = function()
|
||||
require("markview").setup({
|
||||
markdown = { enable = true },
|
||||
latex = {
|
||||
enable = true,
|
||||
inline = { enable = true },
|
||||
block = { enable = true },
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
Reference in New Issue
Block a user