feat: move nvim configs to separate directory

This commit is contained in:
hhhh hgfh 2025-10-12 18:22:08 +03:00
parent fd9723504f
commit 46dc4bc8a1
13 changed files with 0 additions and 0 deletions

1
nvim/lua/autocmds.lua Normal file
View file

@ -0,0 +1 @@
require "nvchad.autocmds"

36
nvim/lua/chadrc.lua Normal file
View file

@ -0,0 +1,36 @@
-- This file needs to have same structure as nvconfig.lua
-- https://github.com/NvChad/ui/blob/v3.0/lua/nvconfig.lua
-- Please read that file to know all available options :(
---@type ChadrcConfig
local M = {}
M.base46 = {
theme = "darcula-dark",
-- hl_override = {
-- Comment = { italic = true },
-- ["@comment"] = { italic = true },
-- },
}
M.mason = {
opts ={
ensure_installed = {
"lua-language-server",
"stylua",
"clangd",
"clang-format",
"codelldb"
}
}
}
M.nvdash = { load_on_startup = true }
-- M.ui = {
-- tabufline = {
-- lazyload = false
-- }
-- }
return M

View file

@ -0,0 +1,15 @@
local options = {
formatters_by_ft = {
lua = { "stylua" },
cpp = { "clang-format" },
-- html = { "prettier" },
},
-- format_on_save = {
-- -- These options will be passed to conform.format()
-- timeout_ms = 500,
-- lsp_fallback = true,
-- },
}
return options

47
nvim/lua/configs/lazy.lua Normal file
View file

@ -0,0 +1,47 @@
return {
defaults = { lazy = true },
install = { colorscheme = { "nvchad" } },
ui = {
icons = {
ft = "",
lazy = "󰂠 ",
loaded = "",
not_loaded = "",
},
},
performance = {
rtp = {
disabled_plugins = {
"2html_plugin",
"tohtml",
"getscript",
"getscriptPlugin",
"gzip",
"logipat",
"netrw",
"netrwPlugin",
"netrwSettings",
"netrwFileHandlers",
"matchit",
"tar",
"tarPlugin",
"rrhelper",
"spellfile_plugin",
"vimball",
"vimballPlugin",
"zip",
"zipPlugin",
"tutor",
"rplugin",
"syntax",
"synmenu",
"optwin",
"compiler",
"bugreport",
"ftplugin",
},
},
},
}

View file

@ -0,0 +1,23 @@
require("nvchad.configs.lspconfig").defaults()
local on_attach = require("nvchad.configs.lspconfig").on_attach
local on_init = require("nvchad.configs.lspconfig").on_init
local capabilities = require("nvchad.configs.lspconfig").capabilities
-- Новый способ настройки LSP для Neovim 0.11+
vim.lsp.config('clangd', {
on_attach = on_attach,
on_init = on_init,
capabilities = capabilities,
cmd = {
"clangd",
"--background-index",
"--clang-tidy",
"--header-insertion=iwyu",
"--completion-style=detailed",
"--function-arg-placeholders=1",
},
filetypes = { "c", "cpp", "objc", "objcpp" },
})
vim.lsp.enable('clangd')

View file

@ -0,0 +1,78 @@
local M = {}
function M.setup()
local dap = require("dap")
local dapui = require("dapui")
-- Настройка адаптера codelldb для C/C++
dap.adapters.codelldb = {
type = 'server',
port = '${port}',
executable = {
command = vim.fn.stdpath("data") .. '/mason/bin/codelldb',
args = { '--port', '${port}' },
}
}
-- Конфигурации для C/C++
dap.configurations.cpp = {
{
name = "Launch file",
type = "codelldb",
request = "launch",
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = '${workspaceFolder}',
stopOnEntry = false,
args = {},
},
}
-- Используем те же конфигурации для C
dap.configurations.c = dap.configurations.cpp
-- Настройка dap-ui :cite[1]:cite[4]
dapui.setup({
layouts = {
{
elements = {
{ id = "scopes", size = 0.33 },
{ id = "breakpoints", size = 0.17 },
{ id = "stacks", size = 0.25 },
{ id = "watches", size = 0.25 },
},
size = 0.33,
position = "right",
},
{
elements = {
{ id = "repl", size = 0.45 },
{ id = "console", size = 0.55 },
},
size = 0.27,
position = "bottom",
},
},
})
-- Автоматическое открытие/закрытие UI :cite[1]:cite[9]
dap.listeners.after.event_initialized["dapui_config"] = function()
dapui.open({})
end
dap.listeners.before.event_terminated["dapui_config"] = function()
dapui.close({})
end
dap.listeners.before.event_exited["dapui_config"] = function()
dapui.close({})
end
-- Настройка значков для точек останова :cite[1]:cite[10]
vim.fn.sign_define("DapBreakpoint", { text = "🔴", texthl = "LspDiagnosticsSignError" })
vim.fn.sign_define("DapStopped", { text = "➡️", texthl = "LspDiagnosticsSignInformation" })
vim.fn.sign_define("DapBreakpointRejected", { text = "❌", texthl = "LspDiagnosticsSignHint" })
end
return M

7
nvim/lua/custom/init.lua Normal file
View file

@ -0,0 +1,7 @@
-- форматирование при сохранении для C/C++
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = { "*.c", "*.cpp", "*.h", "*.hpp" },
callback = function()
vim.lsp.buf.format()
end,
})

17
nvim/lua/mappings.lua Normal file
View file

@ -0,0 +1,17 @@
require "nvchad.mappings"
-- add yours here
local map = vim.keymap.set
map("n", ";", ":", { desc = "CMD enter command mode" })
map("i", "jk", "<ESC>")
-- map({ "n", "i", "v" }, "<C-s>", "<cmd> w <cr>")
-- Debbuger mappings
map('n', '<leader>db', '<cmd>DapToggleBreakpoint<CR>', { desc = 'Toggle breakpoint' })
map('n', '<leader>dr', '<cmd>DapContinue<CR>', { desc = 'Start/continue debug' })
map('n', '<leader>ds', '<cmd>DapStepOver<CR>', { desc = 'Step over' })
map('n', '<leader>di', '<cmd>DapStepInto<CR>', { desc = 'Step into' })
map('n', '<leader>do', '<cmd>DapStepOut<CR>', { desc = 'Step out' })
map('n', '<leader>dq', '<cmd>DapTerminate<CR>', { desc = 'Stop debug' })
map('n', '<leader>du', '<cmd>lua require("dapui").toggle()<CR>', { desc = 'Toggle DAP UI' })

6
nvim/lua/options.lua Normal file
View file

@ -0,0 +1,6 @@
require "nvchad.options"
-- add yours here!
-- local o = vim.o
-- o.cursorlineopt ='both' -- to enable cursorline!

51
nvim/lua/plugins/init.lua Normal file
View file

@ -0,0 +1,51 @@
return {
{
"stevearc/conform.nvim",
-- event = 'BufWritePre', -- uncomment for format on save
opts = require "configs.conform",
},
-- These are some examples, uncomment them if you want to see them work!
{
"neovim/nvim-lspconfig",
config = function()
require "configs.lspconfig"
end,
},
-- These are for C/C++ Debbuger
{
"nvim-neotest/nvim-nio",
event = "VeryLazy",
},
{
"mfussenegger/nvim-dap",
event = "VeryLazy",
config = function ()
require("configs.nvim-dap").setup()
end
},
{
"rcarriga/nvim-dap-ui",
event = "VeryLazy",
dependencies = "mfussenegger/nvim-dap",
},
{
"jay-babu/mason-nvim-dap.nvim",
event = "VeryLazy",
dependencies = {
"williamboman/mason.nvim",
"mfussenegger/nvim-dap",
},
opts = {
handlers = {}
},
},
{
"theHamsta/nvim-dap-virtual-text",
dependencies = "mfussenegger/nvim-dap",
config = function()
require("nvim-dap-virtual-text").setup()
end,
},
}