update dotfiles
This commit is contained in:
@@ -6,7 +6,7 @@ return {
|
||||
{
|
||||
"saghen/blink.cmp",
|
||||
version = "*",
|
||||
event = { "InsertEnter", "CmdlineEnter" },
|
||||
lazy = false, -- 立即加载,确保 LSP capabilities 可用
|
||||
opts = {
|
||||
keymap = {
|
||||
preset = "super-tab",
|
||||
|
||||
+64
-24
@@ -16,10 +16,11 @@ return {
|
||||
dependencies = { "williamboman/mason.nvim" },
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"lua_ls", -- Lua
|
||||
"bashls", -- Bash
|
||||
"clangd", -- C/C++
|
||||
"neocmake", -- CMake
|
||||
"lua_ls", -- Lua
|
||||
"bashls", -- Bash
|
||||
"clangd", -- C/C++
|
||||
"neocmake", -- CMake
|
||||
-- rust_analyzer 由 rustup 管理,不通过 Mason
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -34,6 +35,8 @@ return {
|
||||
"saghen/blink.cmp",
|
||||
},
|
||||
config = function()
|
||||
local caps = require("blink.cmp").get_lsp_capabilities()
|
||||
|
||||
-- LSP 附加时自动开启 inlay hints
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(args)
|
||||
@@ -54,47 +57,84 @@ return {
|
||||
end,
|
||||
})
|
||||
|
||||
local caps = require("blink.cmp").get_lsp_capabilities()
|
||||
|
||||
-- Lua
|
||||
vim.lsp.config("lua_ls", {
|
||||
cmd = { "lua-language-server" },
|
||||
vim.lsp.config['lua_ls'] = {
|
||||
cmd = { 'lua-language-server' },
|
||||
filetypes = { 'lua' },
|
||||
root_markers = { '.luarc.json', '.luarc.jsonc', '.git', 'init.lua' },
|
||||
capabilities = caps,
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = { version = "Lua5.5" },
|
||||
runtime = { version = "LuaJIT" },
|
||||
workspace = { checkThirdParty = false },
|
||||
diagnostics = { globals = { "vim" } },
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
-- Bash
|
||||
vim.lsp.config("bashls", {
|
||||
cmd = { "bash-language-server", "start" },
|
||||
vim.lsp.config['bashls'] = {
|
||||
cmd = { 'bash-language-server', 'start' },
|
||||
filetypes = { 'sh', 'bash' },
|
||||
root_markers = { '.git' },
|
||||
capabilities = caps,
|
||||
})
|
||||
}
|
||||
|
||||
-- C/C++ (clangd)
|
||||
vim.lsp.config("clangd", {
|
||||
cmd = { "clangd" },
|
||||
vim.lsp.config['clangd'] = {
|
||||
cmd = { 'clangd' },
|
||||
filetypes = { 'c', 'cpp', 'objc', 'objcpp' },
|
||||
root_markers = { '.clangd', 'compile_commands.json', '.git' },
|
||||
capabilities = caps,
|
||||
})
|
||||
}
|
||||
|
||||
-- CMake
|
||||
vim.lsp.config("neocmake", {
|
||||
cmd = { "neocmakelsp", "stdio" },
|
||||
filetypes = { "cmake" },
|
||||
root_dir = vim.fs.root(0, { ".git", "CMakeLists.txt" }),
|
||||
single_file_support = true,
|
||||
vim.lsp.config['neocmake'] = {
|
||||
cmd = { 'neocmakelsp', 'stdio' },
|
||||
filetypes = { 'cmake' },
|
||||
root_markers = { 'CMakeLists.txt', '.git' },
|
||||
capabilities = caps,
|
||||
init_options = {
|
||||
format = { enable = true },
|
||||
lint = { enable = true },
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
-- 启用所有 LSP(Rust 由 rustaceanvim 管理,不在此启用)
|
||||
vim.lsp.enable({ "lua_ls", "bashls", "clangd", "neocmake" })
|
||||
-- Rust (rust-analyzer)
|
||||
vim.lsp.config['rust_analyzer'] = {
|
||||
cmd = { 'rust-analyzer' }, -- 使用 rustup 的版本,更稳定
|
||||
filetypes = { 'rust' },
|
||||
root_markers = { 'Cargo.toml', '.git' },
|
||||
capabilities = caps,
|
||||
settings = {
|
||||
["rust-analyzer"] = {
|
||||
cargo = {
|
||||
allFeatures = true,
|
||||
loadOutDirsFromCheck = true,
|
||||
buildScripts = {
|
||||
enable = true,
|
||||
},
|
||||
},
|
||||
checkOnSave = true,
|
||||
diagnostics = {
|
||||
enable = true,
|
||||
},
|
||||
procMacro = {
|
||||
enable = true,
|
||||
},
|
||||
files = {
|
||||
exclude = {
|
||||
".direnv", ".git", ".jj", ".github", ".gitlab",
|
||||
"bin", "node_modules", "target", "venv", ".venv",
|
||||
},
|
||||
watcher = "client",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- 启用所有 LSP
|
||||
vim.lsp.enable({ 'lua_ls', 'bashls', 'clangd', 'neocmake', 'rust_analyzer' })
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,35 +1,5 @@
|
||||
-- ============================================================================
|
||||
-- Rust 工具 (rustaceanvim)
|
||||
-- Rust 全流程:LSP、调试、运行、测试、宏展开
|
||||
-- Rust 工具(通过 Mason + nvim-lspconfig 管理)
|
||||
-- ============================================================================
|
||||
|
||||
return {
|
||||
{
|
||||
"mrcjkb/rustaceanvim",
|
||||
version = "^6",
|
||||
lazy = false,
|
||||
ft = { "rust" },
|
||||
config = function()
|
||||
vim.g.rustaceanvim = {
|
||||
-- LSP 配置
|
||||
server = {
|
||||
default_settings = {
|
||||
["rust-analyzer"] = {
|
||||
cargo = { allFeatures = true },
|
||||
check = { command = "clippy" },
|
||||
},
|
||||
},
|
||||
},
|
||||
-- DAP 适配器(复用 Mason 安装的 codelldb)
|
||||
dap = {
|
||||
adapter = function()
|
||||
local codelldb_path = vim.fn.stdpath("data") .. "/mason/bin/codelldb"
|
||||
local library_path = vim.fn.stdpath("data")
|
||||
.. "/mason/packages/codelldb/extension/lldb/lib/liblldb.so"
|
||||
return require("rustaceanvim.config").get_codelldb_adapter(codelldb_path, library_path)
|
||||
end,
|
||||
},
|
||||
}
|
||||
end,
|
||||
},
|
||||
}
|
||||
return {}
|
||||
|
||||
+4
-5
@@ -24,7 +24,7 @@ function M.build()
|
||||
local project = M.detect()
|
||||
|
||||
if project == "rust" then
|
||||
vim.cmd("RustLsp runnables")
|
||||
vim.cmd("terminal cargo build")
|
||||
elseif project == "cmake" then
|
||||
vim.cmd("CMakeBuild")
|
||||
elseif project == "go" then
|
||||
@@ -44,7 +44,7 @@ function M.run()
|
||||
local project = M.detect()
|
||||
|
||||
if project == "rust" then
|
||||
vim.cmd("RustLsp runnables")
|
||||
vim.cmd("terminal cargo run")
|
||||
elseif project == "cmake" then
|
||||
vim.cmd("CMakeRun")
|
||||
elseif project == "go" then
|
||||
@@ -61,11 +61,10 @@ function M.debug()
|
||||
local project = M.detect()
|
||||
|
||||
if project == "rust" then
|
||||
vim.cmd("RustLsp debuggables")
|
||||
require("dap").continue()
|
||||
elseif project == "cmake" then
|
||||
vim.cmd("CMakeDebug")
|
||||
else
|
||||
-- 通用 DAP 启动
|
||||
require("dap").continue()
|
||||
end
|
||||
end
|
||||
@@ -75,7 +74,7 @@ function M.test()
|
||||
local project = M.detect()
|
||||
|
||||
if project == "rust" then
|
||||
vim.cmd("RustLsp testables")
|
||||
vim.cmd("terminal cargo test")
|
||||
elseif project == "cmake" then
|
||||
vim.cmd("CMakeBuild")
|
||||
vim.cmd("terminal ctest --test-dir build")
|
||||
|
||||
Reference in New Issue
Block a user