config lazyvim

This commit is contained in:
zack 2024-10-08 00:27:07 -04:00
parent 5ce32b345d
commit 07dcfdaedb
No known key found for this signature in database
GPG key ID: 5F873416BCF59F35
10 changed files with 391 additions and 52 deletions

View file

@ -0,0 +1,31 @@
{
"extras": [
"lazyvim.plugins.extras.coding.mini-comment",
"lazyvim.plugins.extras.coding.yanky",
"lazyvim.plugins.extras.dap.core",
"lazyvim.plugins.extras.editor.dial",
"lazyvim.plugins.extras.editor.inc-rename",
"lazyvim.plugins.extras.lang.angular",
"lazyvim.plugins.extras.lang.astro",
"lazyvim.plugins.extras.lang.cmake",
"lazyvim.plugins.extras.lang.docker",
"lazyvim.plugins.extras.lang.haskell",
"lazyvim.plugins.extras.lang.java",
"lazyvim.plugins.extras.lang.json",
"lazyvim.plugins.extras.lang.markdown",
"lazyvim.plugins.extras.lang.nix",
"lazyvim.plugins.extras.lang.sql",
"lazyvim.plugins.extras.lang.svelte",
"lazyvim.plugins.extras.lang.tailwind",
"lazyvim.plugins.extras.lang.tex",
"lazyvim.plugins.extras.lang.typescript",
"lazyvim.plugins.extras.test.core",
"lazyvim.plugins.extras.util.dot",
"lazyvim.plugins.extras.util.mini-hipatterns",
"lazyvim.plugins.extras.coding.luasnip"
],
"news": {
"NEWS.md": "6520"
},
"version": 6
}

View file

@ -3,32 +3,34 @@ require("lazy").setup({
-- add LazyVim and import its plugins
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
-- import/override with your plugins
{ import = "lazyvim.plugins.extras.lang.rust" },
{ import = "lazyvim.plugins.extras.lang.json" },
{ import = "lazyvim.plugins.extras.lang.astro" },
{ import = "lazyvim.plugins.extras.lang.git" },
{ import = "lazyvim.plugins.extras.lang.docker" },
{ import = "lazyvim.plugins.extras.lang.clangd" },
{ import = "lazyvim.plugins.extras.lang.cmake" },
{ import = "lazyvim.plugins.extras.lang.haskell" },
{ import = "lazyvim.plugins.extras.lang.java" },
{ import = "lazyvim.plugins.extras.lang.markdown" },
{ import = "lazyvim.plugins.extras.lang.nix" },
{ import = "lazyvim.plugins.extras.lang.sql" },
{ import = "lazyvim.plugins.extras.lang.svelte" },
{ import = "lazyvim.plugins.extras.lang.tailwind" },
{ import = "lazyvim.plugins.extras.lang.tex" },
{ import = "lazyvim.plugins.extras.lang.typescript" },
{ import = "lazyvim.plugins.extras.lang.toml" },
{ import = "lazyvim.plugins.extras.lang.angular" },
{ import = "lazyvim.plugins.extras.formatting.prettier" },
{ import = "lazyvim.plugins.extras.coding.luasnip" },
{ import = "lazyvim.plugins.extras.coding.yanky" },
{ import = "lazyvim.plugins.extras.dap.core" },
-- { import = "lazyvim.plugins.extras.lang.rust" },
-- { import = "lazyvim.plugins.extras.lang.json" },
-- { import = "lazyvim.plugins.extras.lang.astro" },
-- { import = "lazyvim.plugins.extras.lang.git" },
-- { import = "lazyvim.plugins.extras.lang.docker" },
-- { import = "lazyvim.plugins.extras.lang.clangd" },
-- { import = "lazyvim.plugins.extras.lang.cmake" },
-- { import = "lazyvim.plugins.extras.lang.haskell" },
-- { import = "lazyvim.plugins.extras.lang.java" },
-- { import = "lazyvim.plugins.extras.lang.markdown" },
-- { import = "lazyvim.plugins.extras.lang.nix" },
-- { import = "lazyvim.plugins.extras.lang.sql" },
-- { import = "lazyvim.plugins.extras.lang.svelte" },
-- { import = "lazyvim.plugins.extras.lang.tailwind" },
-- { import = "lazyvim.plugins.extras.lang.tex" },
-- { import = "lazyvim.plugins.extras.lang.typescript" },
-- { import = "lazyvim.plugins.extras.lang.toml" },
-- { import = "lazyvim.plugins.extras.lang.angular" },
--
-- { import = "lazyvim.plugins.extras.formatting.prettier" },
--
-- { import = "lazyvim.plugins.extras.coding.luasnip" },
-- { import = "lazyvim.plugins.extras.coding.yanky" },
--
-- { import = "lazyvim.plugins.extras.dap.core" },
{ import = "plugins" },
{ import = "plugins.extras.rust" },
-- { import = "plugins.extras.clangd" },
},
defaults = {
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.

View file

@ -13,4 +13,43 @@ return {
},
},
},
-- {
-- "saghen/blink.cmp",
-- lazy = false, -- lazy loading handled internally
-- -- optional: provides snippets for the snippet source
-- dependencies = "rafamadriz/friendly-snippets",
--
-- -- use a release tag to download pre-built binaries
-- version = "v0.*",
-- -- OR build from source, requires nightly: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust
-- -- build = 'cargo build --release',
--
-- opts = {
-- keymap = {
-- show = "<C-S-space>",
-- accept = "<Enter>",
-- select_prev = { "<S-Tab>", "<C-j>" },
-- select_next = { "<C-Tab>", "<C-k>" },
--
-- snippet_forward = "<Tab>",
-- snippet_backward = "<C-S-Tab>",
-- },
--
-- highlight = {
-- -- sets the fallback highlight groups to nvim-cmp's highlight groups
-- -- useful for when your theme doesn't support blink.cmp
-- -- will be removed in a future release, assuming themes add support
-- use_nvim_cmp_as_default = true,
-- },
-- -- set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
-- -- adjusts spacing to ensure icons are aligned
-- nerd_font_variant = "normal",
--
-- -- experimental auto-brackets support
-- -- accept = { auto_brackets = { enabled = true } }
--
-- -- experimental signature help support
-- -- trigger = { signature_help = { enabled = true } }
-- },
-- },
}

View file

@ -0,0 +1,153 @@
return {
recommended = function()
return LazyVim.extras.wants({
ft = { "c", "cpp", "objc", "objcpp", "cuda", "proto" },
root = {
".clangd",
".clang-tidy",
".clang-format",
"compile_commands.json",
"compile_flags.txt",
"configure.ac", -- AutoTools
},
})
end,
-- Add C/C++ to treesitter
{
"nvim-treesitter/nvim-treesitter",
opts = { ensure_installed = { "cpp" } },
},
{
"p00f/clangd_extensions.nvim",
lazy = true,
config = function() end,
opts = {
inlay_hints = {
inline = false,
},
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 = "",
},
},
},
},
-- Correctly setup lspconfig for clangd 🚀
{
"neovim/nvim-lspconfig",
opts = {
servers = {
-- Ensure mason installs the server
clangd = {
keys = {
{ "<leader>ch", "<cmd>ClangdSwitchSourceHeader<cr>", desc = "Switch Source/Header (C/C++)" },
},
root_dir = function(fname)
return require("lspconfig.util").root_pattern(
"Makefile",
"configure.ac",
"configure.in",
"config.h.in",
"meson.build",
"meson_options.txt",
"build.ninja"
)(fname) or require("lspconfig.util").root_pattern("compile_commands.json", "compile_flags.txt")(
fname
) or require("lspconfig.util").find_git_ancestor(fname)
end,
capabilities = {
offsetEncoding = { "utf-16" },
},
cmd = {
"clangd",
"--background-index",
"--clang-tidy",
"--header-insertion=iwyu",
"--completion-style=detailed",
"--function-arg-placeholders",
"--fallback-style=llvm",
},
init_options = {
usePlaceholders = true,
completeUnimported = true,
clangdFileStatus = true,
},
},
},
setup = {
clangd = function(_, opts)
local clangd_ext_opts = LazyVim.opts("clangd_extensions.nvim")
require("clangd_extensions").setup(vim.tbl_deep_extend("force", clangd_ext_opts or {}, { server = opts }))
return false
end,
},
},
},
{
"nvim-cmp",
opts = function(_, opts)
table.insert(opts.sorting.comparators, 1, require("clangd_extensions.cmp_scores"))
end,
},
{
"mfussenegger/nvim-dap",
optional = true,
opts = function()
local dap = require("dap")
if not dap.adapters["codelldb"] then
require("dap").adapters["codelldb"] = {
type = "server",
host = "localhost",
port = "${port}",
executable = {
command = "codelldb",
args = {
"--port",
"${port}",
},
},
}
end
for _, lang in ipairs({ "c", "cpp" }) do
dap.configurations[lang] = {
{
type = "codelldb",
request = "launch",
name = "Launch file",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
end,
cwd = "${workspaceFolder}",
},
{
type = "codelldb",
request = "attach",
name = "Attach to process",
pid = require("dap.utils").pick_process,
cwd = "${workspaceFolder}",
},
}
end
end,
},
}

View file

@ -0,0 +1,118 @@
return {
recommended = function()
return LazyVim.extras.wants({
ft = "rust",
root = { "Cargo.toml", "rust-project.json" },
})
end,
-- Extend auto completion
{
"hrsh7th/nvim-cmp",
dependencies = {
{
"Saecki/crates.nvim",
event = { "BufRead Cargo.toml" },
opts = {
completion = {
cmp = { enabled = true },
},
},
},
},
---@param opts cmp.ConfigSchema
opts = function(_, opts)
opts.sources = opts.sources or {}
table.insert(opts.sources, { name = "crates" })
end,
},
-- Add Rust & related to treesitter
{
"nvim-treesitter/nvim-treesitter",
opts = { ensure_installed = { "rust", "ron" } },
},
{
"mrcjkb/rustaceanvim",
version = vim.fn.has("nvim-0.10.0") == 0 and "^4" or false,
ft = { "rust" },
opts = {
server = {
on_attach = function(_, bufnr)
vim.keymap.set("n", "<leader>cR", function()
vim.cmd.RustLsp("codeAction")
end, { desc = "Code Action", buffer = bufnr })
vim.keymap.set("n", "<leader>dr", function()
vim.cmd.RustLsp("debuggables")
end, { desc = "Rust Debuggables", buffer = bufnr })
end,
default_settings = {
-- rust-analyzer language server configuration
["rust-analyzer"] = {
cargo = {
allFeatures = true,
loadOutDirsFromCheck = true,
buildScripts = {
enable = true,
},
},
-- Add clippy lints for Rust.
checkOnSave = true,
procMacro = {
enable = true,
ignored = {
["async-trait"] = { "async_trait" },
["napi-derive"] = { "napi" },
["async-recursion"] = { "async_recursion" },
},
},
},
},
},
},
config = function(_, opts)
vim.g.rustaceanvim = vim.tbl_deep_extend("keep", vim.g.rustaceanvim or {}, opts or {})
if vim.fn.executable("rust-analyzer") == 0 then
LazyVim.error(
"**rust-analyzer** not found in PATH, please install it.\nhttps://rust-analyzer.github.io/",
{ title = "rustaceanvim" }
)
end
end,
},
-- Correctly setup lspconfig for Rust 🚀
{
"neovim/nvim-lspconfig",
opts = {
servers = {
taplo = {
keys = {
{
"K",
function()
if vim.fn.expand("%:t") == "Cargo.toml" and require("crates").popup_available() then
require("crates").show_popup()
else
vim.lsp.buf.hover()
end
end,
desc = "Show Crate Documentation",
},
},
},
},
},
},
{
"nvim-neotest/neotest",
optional = true,
opts = {
adapters = {
["rustaceanvim.neotest"] = {},
},
},
},
}