mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
Merge edaa8aeb98 into 81d798fdaa
This commit is contained in:
commit
2d7dd8ee26
3 changed files with 123 additions and 0 deletions
58
lua/lazyvim/plugins/extras/lang/clangd.lua
Normal file
58
lua/lazyvim/plugins/extras/lang/clangd.lua
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
return {
|
||||
|
||||
-- add c/c++ to treesitter
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = function(_, opts)
|
||||
vim.list_extend(opts.ensure_installed, { "c", "cpp" })
|
||||
end,
|
||||
},
|
||||
|
||||
-- correctly setup lspconfig
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
"p00f/clangd_extensions.nvim",
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
},
|
||||
},
|
||||
opts = {
|
||||
-- make sure mason installs the server
|
||||
servers = {
|
||||
clangd = {},
|
||||
},
|
||||
setup = {
|
||||
clangd = function(_, opts)
|
||||
require("clangd_extensions").setup({
|
||||
server = opts,
|
||||
extensions = {
|
||||
ast = {
|
||||
--These require codicons (https://github.com/microsoft/vscode-codicons)
|
||||
role_icons = {
|
||||
type = "",
|
||||
declaration = "",
|
||||
expression = "",
|
||||
specifier = "",
|
||||
statement = "",
|
||||
["template argument"] = "",
|
||||
},
|
||||
|
||||
kind_icons = {
|
||||
Compound = "",
|
||||
Recovery = "",
|
||||
TranslationUnit = "",
|
||||
PackExpansion = "",
|
||||
TemplateTypeParm = "",
|
||||
TemplateTemplateParm = "",
|
||||
TemplateParamObject = "",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
return true
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
64
lua/lazyvim/plugins/extras/lang/rust.lua
Normal file
64
lua/lazyvim/plugins/extras/lang/rust.lua
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
return {
|
||||
|
||||
-- add rust to treesitter
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = function(_, opts)
|
||||
table.insert(opts.ensure_installed, "rust")
|
||||
end,
|
||||
},
|
||||
|
||||
-- correctly setup lspconfig for Rust 🚀
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = { "simrat39/rust-tools.nvim" },
|
||||
opts = {
|
||||
servers = {
|
||||
rust_analyzer = {
|
||||
settings = {
|
||||
["rust-analyzer"] = {
|
||||
cargo = {
|
||||
allFeatures = true,
|
||||
},
|
||||
checkOnSave = {
|
||||
allFeatures = true,
|
||||
command = "clippy",
|
||||
extraArgs = { "--no-deps" },
|
||||
},
|
||||
procMacro = {
|
||||
ignored = {
|
||||
["async-trait"] = { "async_trait" },
|
||||
["napi-derive"] = { "napi" },
|
||||
["async-recursion"] = { "async_recursion" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
setup = {
|
||||
rust_analyzer = function(_, opts)
|
||||
require("lazyvim.util").on_attach(function(client, buffer)
|
||||
if client.name == "rust_analyzer" then
|
||||
-- stylua: ignore
|
||||
vim.keymap.set("n", "<leader>co", "RustHoverActions", { buffer = buffer, desc = "Hover Actions (Rust)" })
|
||||
vim.keymap.set("n", "<leader>cR", "RustCodeActionGroup", { buffer = buffer, desc = "Code Action (Rust)" })
|
||||
end
|
||||
end)
|
||||
local rust_opts = {
|
||||
server = vim.tbl_deep_extend("force", {}, opts, opts.server or {}),
|
||||
tools = { -- rust-tools options
|
||||
-- options same as lsp hover / vim.lsp.util.open_floating_preview()
|
||||
hover_actions = {
|
||||
-- whether the hover action window gets automatically focused
|
||||
auto_focus = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
require("rust-tools").setup(rust_opts)
|
||||
return true
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -70,6 +70,7 @@ return {
|
|||
|
||||
local servers = opts.servers
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
capabilities.offsetEncoding = { "utf-16" }
|
||||
|
||||
require("mason-lspconfig").setup({ ensure_installed = vim.tbl_keys(servers) })
|
||||
require("mason-lspconfig").setup_handlers({
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue