enc: cpp config default

This commit is contained in:
asep.komarudin 2024-06-28 20:34:43 +07:00
parent 1a91af074f
commit d3b57e0fa6
6 changed files with 57 additions and 53 deletions

View file

@ -4,12 +4,36 @@ local M = {}
if pcode.active_cpp_config then
M = {
{
"nvimtools/none-ls.nvim",
optional = true,
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
local nls = require("null-ls")
opts.sources = opts.sources or {}
table.insert(opts.sources, nls.builtins.formatting.clang_format.with({ filetypes = { "cpp", "c" } }))
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "cpp", "c" })
end,
},
{
"williamboman/mason-lspconfig.nvim",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "clangd" })
require("user.utils.masoncfg").try_install("clang-format")
end,
},
{
"jay-babu/mason-nvim-dap.nvim",
event = "VeryLazy",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "codelldb" })
end,
},
{
"stevearc/conform.nvim",
event = "VeryLazy",
opts = function(_, opts)
local package = "clang-format"
require("user.utils.masoncfg").try_install(package)
opts.formatters_by_ft.cpp = { package }
opts.formatters_by_ft.c = { package }
end,
},
{

View file

@ -42,38 +42,25 @@ if pcode.nvim_dap then
lazy = true,
event = "BufRead",
dependencies = { "williamboman/mason.nvim", "mfussenegger/nvim-dap" },
-- enabled = vim.fn.has("win32") == 0,
config = function()
require("user.mason_dap")
-- add diff langue vs filetype
local keymap = {
["c++"] = "cpp",
["c#"] = "cs",
["jsx"] = "javascriptreact",
}
opts = function(_, opts)
local dap_data = pcode.dap_ensure_installed or {}
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, dap_data)
opts.automatic_setup = true
opts.handlers = {
function(config)
-- all sources with no handler get passed here
local mason_reg = require("mason-registry")
local opts = {}
for _, pkg in pairs(mason_reg.get_installed_packages()) do
for _, type in pairs(pkg.spec.categories) do
if type == "DAP" then
for _, ft in pairs(pkg.spec.languages) do
local ftl = string.lower(ft)
local ready = mason_reg.get_package(pkg.spec.name):is_installed()
if ready then
if keymap[ftl] ~= nil then
ftl = keymap[ftl]
local require_ok, conf_opts = pcall(require, "user.dap.settings." .. ftl)
if require_ok then
opts = vim.tbl_deep_extend("force", conf_opts, opts)
end
require("dap").dapters[ftl] = opts
end
end
end
end
end
end
-- Keep original functionality
require("mason-nvim-dap").default_setup(config)
end,
}
return opts
end,
-- enabled = vim.fn.has("win32") == 0,
config = function(_, opts)
require("mason").setup()
require("mason-nvim-dap").setup(opts)
end,
},
}

View file

@ -102,11 +102,11 @@ if pcode.active_python_config then
end
-- run if cpp config true
if pcode.active_cpp_config then
table.insert(pcode.treesitter_ensure_installed, "cpp")
table.insert(pcode.treesitter_ensure_installed, "c")
table.insert(pcode.mason_ensure_installed, "clangd")
table.insert(pcode.null_ls_ensure_installed, "clang_format")
table.insert(pcode.dap_ensure_installed, "codelldb")
-- table.insert(pcode.treesitter_ensure_installed, "cpp")
-- table.insert(pcode.treesitter_ensure_installed, "c")
-- table.insert(pcode.mason_ensure_installed, "clangd")
-- table.insert(pcode.null_ls_ensure_installed, "clang_format")
-- table.insert(pcode.dap_ensure_installed, "codelldb")
pcode.nvim_dap = true
end
-- run if java config true