mirror of
https://github.com/cap153/nvim.git
synced 2026-04-20 20:25:44 +08:00
增删一些插件
This commit is contained in:
parent
e4487aa27f
commit
996cfc643b
9 changed files with 145 additions and 46 deletions
|
|
@ -23,7 +23,6 @@ return {
|
|||
-- you can add other fields for setting up lsp server in this table
|
||||
})
|
||||
end
|
||||
require("ufo").setup()
|
||||
-- Option 3: treesitter as a main provider instead
|
||||
-- Only depend on `nvim-treesitter/queries/filetype/folds.scm`,
|
||||
-- performance and stability are better than `foldmethod=nvim_treesitter#foldexpr()`
|
||||
|
|
|
|||
|
|
@ -4,11 +4,19 @@ return {
|
|||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||
config = function()
|
||||
-- ctrl+t打开文件查找
|
||||
vim.keymap.set('n', '<c-t>', '<cmd>FzfLua files<cr>', {})
|
||||
vim.keymap.set('n', '<c-t>', function()
|
||||
-- 查找当前文件所在目录及其父目录下是否有 .git 文件夹
|
||||
local is_git = vim.fs.root(0, '.git')
|
||||
if is_git then
|
||||
require('fzf-lua').git_files()
|
||||
else
|
||||
require('fzf-lua').files()
|
||||
end
|
||||
end)
|
||||
-- ctrl+f打开字符串查找
|
||||
vim.keymap.set('n', '<c-f>', '<cmd>FzfLua grep<cr>', {})
|
||||
require("fzf-lua").setup({
|
||||
fzf_bin = "sk",
|
||||
-- fzf_bin = "sk",
|
||||
keymap = {
|
||||
fzf = {
|
||||
-- fzf '--bind=' options
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
return {
|
||||
"jonroosevelt/gemini-cli.nvim",
|
||||
dependencies = {},
|
||||
config = function()
|
||||
require("gemini").setup()
|
||||
end,
|
||||
}
|
||||
|
|
@ -6,6 +6,25 @@ return {
|
|||
'lewis6991/gitsigns.nvim',
|
||||
build = ':TSUpdate',
|
||||
config = function()
|
||||
require('gitsigns').setup()
|
||||
require('gitsigns').setup {
|
||||
on_attach = function(bufnr)
|
||||
local gitsigns = require('gitsigns')
|
||||
|
||||
local function map(mode, l, r, opts)
|
||||
opts = opts or {}
|
||||
opts.buffer = bufnr
|
||||
vim.keymap.set(mode, l, r, opts)
|
||||
end
|
||||
-- Navigation
|
||||
map('n', 't=', function()
|
||||
gitsigns.nav_hunk('next')
|
||||
end)
|
||||
map('n', 't-', function()
|
||||
gitsigns.nav_hunk('prev')
|
||||
end)
|
||||
-- show diff
|
||||
map('n', '<leader>hd', gitsigns.diffthis)
|
||||
end
|
||||
}
|
||||
end
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,36 @@
|
|||
-- 判断 CPU 架构
|
||||
local arch = jit and jit.arch or ""
|
||||
local is_arm = arch:match("arm") or arch:match("aarch64")
|
||||
|
||||
-- 需要安装的 LSP
|
||||
local servers = {
|
||||
"lua_ls",
|
||||
"rust_analyzer",
|
||||
"pylsp",
|
||||
-- "gopls",
|
||||
}
|
||||
|
||||
-- 如果不是 ARM 架构,则追加 LSP
|
||||
if not is_arm then
|
||||
local extra_servers = {
|
||||
"marksman",
|
||||
"ts_ls",
|
||||
"svelte",
|
||||
"cssls",
|
||||
"html",
|
||||
}
|
||||
vim.list_extend(servers, extra_servers)
|
||||
end
|
||||
|
||||
return {
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
-- 通过mason来自动安装语言服务器并启用
|
||||
{ "mason-org/mason.nvim", opts = {} },
|
||||
{ "mason-org/mason.nvim", opts = {} },
|
||||
{
|
||||
"mason-org/mason-lspconfig.nvim",
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"lua_ls",
|
||||
"rust_analyzer",
|
||||
"marksman",
|
||||
"pylsp",
|
||||
"ts_ls",
|
||||
"cssls",
|
||||
"html",
|
||||
-- "gopls",
|
||||
},
|
||||
ensure_installed = servers,
|
||||
automatic_enable = {
|
||||
exclude = {},
|
||||
},
|
||||
|
|
@ -25,18 +40,17 @@ return {
|
|||
},
|
||||
config = function()
|
||||
-- 快捷键的映射
|
||||
vim.keymap.set("n", "<leader>h", vim.lsp.buf.hover, opts) -- <space>h显示提示文档
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) -- gd跳转到定义
|
||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) -- gD跳转到声明(例如c语言中的头文件中的原型、一个变量的extern声明)
|
||||
vim.keymap.set("n", "go", vim.lsp.buf.type_definition, opts) -- go跳转到变量类型定义的位置(例如一些自定义类型)
|
||||
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) -- gr跳转到引用了对应变量或函数的位置
|
||||
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts) -- <space>rn变量重命名
|
||||
vim.keymap.set("n", "<leader>aw", vim.lsp.buf.code_action, opts) -- <space>aw可以在出现警告或错误的地方打开建议的修复方法
|
||||
vim.keymap.set("n", "<leader>d", vim.diagnostic.open_float, opts) -- <space>d浮动窗口显示所在行警告或错误信息
|
||||
vim.keymap.set("n", "<leader>-", vim.diagnostic.goto_prev, opts) -- <space>-跳转到上一处警告或错误的地方
|
||||
vim.keymap.set("n", "<leader>=", vim.diagnostic.goto_next, opts) -- <space>+跳转到下一处警告或错误的地方
|
||||
vim.keymap.set("n", "<leader>h", vim.lsp.buf.hover, opts) -- <space>h显示提示文档
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) -- gd跳转到定义
|
||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) -- gD跳转到声明(例如c语言中的头文件中的原型、一个变量的extern声明)
|
||||
vim.keymap.set("n", "go", vim.lsp.buf.type_definition, opts) -- go跳转到变量类型定义的位置(例如一些自定义类型)
|
||||
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) -- gr跳转到引用了对应变量或函数的位置
|
||||
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts) -- <space>rn变量重命名
|
||||
vim.keymap.set("n", "<leader>aw", vim.lsp.buf.code_action, opts) -- <space>aw可以在出现警告或错误的地方打开建议的修复方法
|
||||
vim.keymap.set("n", "<leader>d", vim.diagnostic.open_float, opts) -- <space>d浮动窗口显示所在行警告或错误信息
|
||||
vim.keymap.set("n", "<leader>-", vim.diagnostic.goto_prev, opts) -- <space>-跳转到上一处警告或错误的地方
|
||||
vim.keymap.set("n", "<leader>=", vim.diagnostic.goto_next, opts) -- <space>+跳转到下一处警告或错误的地方
|
||||
-- vim.keymap.set({ 'n', 'x' }, '<leader>f', function() vim.lsp.buf.format({ async = true }) end, opts) -- <space>f进行代码格式化
|
||||
|
||||
-- 诊断信息的图标
|
||||
vim.diagnostic.config({
|
||||
signs = {
|
||||
|
|
@ -49,12 +63,33 @@ vim.keymap.set("n", "<leader>=", vim.diagnostic.goto_next, opts) -- <space>+跳
|
|||
},
|
||||
})
|
||||
|
||||
-- uv隔离的虚拟环使用项目根目录下 .venv 里的 Python 解析器来分析代码
|
||||
vim.lsp.config("pylsp", {
|
||||
on_init = function(client)
|
||||
local root_dir = client.config.root_dir
|
||||
local venv_python = root_dir .. "/.venv/bin/python"
|
||||
if vim.fn.filereadable(venv_python) == 1 then
|
||||
client.config.settings.pylsp.plugins.jedi.environment = venv_python
|
||||
client.notify("workspace/didChangeConfiguration", { settings = client.config.settings })
|
||||
end
|
||||
return true
|
||||
end,
|
||||
settings = {
|
||||
pylsp = {
|
||||
plugins = {
|
||||
jedi = {
|
||||
environment = nil,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
-- 特定语言开启inlay-hints等自定义配置
|
||||
require("inlay-hints").setup()
|
||||
vim.lsp.config("lua_ls", {
|
||||
settings = {
|
||||
["Lua"] = {
|
||||
hint = { -- Lua开启hints
|
||||
hint = { -- Lua开启hints
|
||||
enable = true, -- necessary
|
||||
},
|
||||
diagnostics = {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ return {
|
|||
config = function()
|
||||
require("peek").setup({
|
||||
port = 9000,
|
||||
app = { "firefox-esr", "-private-window" },
|
||||
app = { "zen", "-private-window" },
|
||||
-- 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, {})
|
||||
|
|
|
|||
34
lua/lazy/plugins/television.lua
Normal file
34
lua/lazy/plugins/television.lua
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
return {
|
||||
"alexpasmantier/tv.nvim",
|
||||
config = function()
|
||||
vim.keymap.set('n', '<c-t>', function()
|
||||
if vim.fs.root(0, '.git') then
|
||||
vim.cmd('Tv git-files')
|
||||
else
|
||||
vim.cmd('Tv files')
|
||||
end
|
||||
end, { desc = "Smart Tv: git-files or files" })
|
||||
local h = require('tv').handlers
|
||||
require("tv").setup {
|
||||
channels = {
|
||||
["git-files"] = {
|
||||
handlers = {
|
||||
["<CR>"] = h.open_as_files,
|
||||
},
|
||||
},
|
||||
files = {
|
||||
handlers = {
|
||||
["<CR>"] = h.open_as_files, -- default: open selected files
|
||||
},
|
||||
},
|
||||
-- `text`: ripgrep search through file contents
|
||||
text = {
|
||||
keybinding = '<C-f>',
|
||||
handlers = {
|
||||
['<CR>'] = h.open_at_line, -- Jump to line:col in file
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
end,
|
||||
}
|
||||
|
|
@ -3,16 +3,24 @@
|
|||
-- ===
|
||||
|
||||
local map = require("core.keymap")
|
||||
-- 在标签之间移动
|
||||
-- 新建空缓冲区,貌似是neovim自带的
|
||||
map:cmd('tu', 'enew')
|
||||
-- 关闭当前缓冲区,貌似是neovim自带的,完整命令bdelete
|
||||
map:cmd('tq', 'bd')
|
||||
|
||||
-- 在缓冲区之间移动
|
||||
map:cmd('tn', 'BufferLineCyclePrev')
|
||||
map:cmd('ti', 'BufferLineCycleNext')
|
||||
|
||||
-- 移动标签的位置
|
||||
-- 移动缓冲区的位置
|
||||
map:cmd('tmn', 'BufferLineMovePrev')
|
||||
map:cmd('tmi', 'BufferLineMoveNext')
|
||||
|
||||
-- 关闭标签,貌似是neovim自带的,完整命令bdelete
|
||||
map:cmd('tq', 'bd')
|
||||
-- 关闭缓冲区
|
||||
map:cmd('tN', 'BufferLineCloseLeft')
|
||||
map:cmd('tI', 'BufferLineCloseRight')
|
||||
map:cmd('tQ', 'BufferLineCloseOthers')
|
||||
|
||||
return {
|
||||
"akinsho/bufferline.nvim",
|
||||
config = function()
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ return {
|
|||
config = function()
|
||||
vim.api.nvim_set_keymap('n', 'tr', "viw:Translate ZH -output=replace<CR>", { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap('v', 'tr', ":'<,'>Translate ZH -output=replace<CR>", { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap('n', 'te', "viw:Translate EN -output=replace<CR>", { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap('v', 'te', ":'<,'>Translate EN -output=replace<CR>", { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap('n', 'ts', "viw:Translate ZH<CR>", { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap('v', 'ts', ":'<,'>Translate ZH<CR>",
|
||||
{ noremap = true, silent = true })
|
||||
|
|
@ -10,13 +12,13 @@ return {
|
|||
default = {
|
||||
command = "translate_shell",
|
||||
},
|
||||
preset = {
|
||||
command = {
|
||||
translate_shell = {
|
||||
args = { "-e", "bing" }
|
||||
}
|
||||
}
|
||||
}
|
||||
-- preset = {
|
||||
-- command = {
|
||||
-- translate_shell = {
|
||||
-- args = { "-e", "bing" }
|
||||
-- }
|
||||
-- }
|
||||
-- }
|
||||
})
|
||||
end
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue