init: initial commit

This commit is contained in:
ITQ
2026-03-08 16:23:50 +03:00
commit 02476899b4
22 changed files with 2257 additions and 0 deletions
+68
View File
@@ -0,0 +1,68 @@
return {
{ "L3MON4D3/LuaSnip", event = "InsertEnter" },
{ "rafamadriz/friendly-snippets", event = "InsertEnter" },
{
"hrsh7th/nvim-cmp",
event = "InsertEnter",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"saadparwaiz1/cmp_luasnip",
"L3MON4D3/LuaSnip",
"onsails/lspkind.nvim",
"windwp/nvim-autopairs",
"rafamadriz/friendly-snippets",
},
config = function()
local cmp = require("cmp")
local luasnip = require("luasnip")
local lspkind = require("lspkind")
require("luasnip.loaders.from_vscode").lazy_load()
cmp.setup({
snippet = {
expand = function(args) luasnip.lsp_expand(args.body) end,
},
formatting = {
format = lspkind.cmp_format({ mode = "symbol_text", maxwidth = 50 }),
},
mapping = cmp.mapping.preset.insert({
["<C-Space>"] = cmp.mapping.complete(),
["<CR>"] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "path" },
{ name = "buffer" },
}),
})
-- autopairs integration
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
end,
},
}
+14
View File
@@ -0,0 +1,14 @@
return {
{ "nvim-lua/plenary.nvim", lazy = true },
{ "folke/which-key.nvim", event = "VeryLazy", opts = {} },
{ "numToStr/Comment.nvim", event = "VeryLazy", opts = {} },
{ "kylechui/nvim-surround", event = "VeryLazy", opts = {} },
{ "windwp/nvim-autopairs", event = "InsertEnter", opts = {} },
{ "lewis6991/gitsigns.nvim", event = "VeryLazy", opts = {} },
}
+79
View File
@@ -0,0 +1,79 @@
local function lsp_keymaps(ev)
local buf = ev.buf
local map = function(mode, lhs, rhs, desc)
vim.keymap.set(mode, lhs, rhs, { buffer = buf, desc = desc })
end
map("n", "K", vim.lsp.buf.hover, "Hover")
map("n", "gd", vim.lsp.buf.definition, "Go to definition")
map("n", "gD", vim.lsp.buf.declaration, "Go to declaration")
map("n", "gr", vim.lsp.buf.references, "References")
map("n", "gi", vim.lsp.buf.implementation, "Implementation")
map("n", "<leader>rn", vim.lsp.buf.rename, "Rename")
map("n", "<leader>ca", vim.lsp.buf.code_action, "Code action")
if vim.lsp.inlay_hint then
pcall(vim.lsp.inlay_hint.enable, true, { bufnr = buf })
end
end
return {
{ "williamboman/mason.nvim", cmd = "Mason", opts = {} },
{
"williamboman/mason-lspconfig.nvim",
event = "VeryLazy",
dependencies = { "mason.nvim" },
opts = {
ensure_installed = { "clangd", "gopls", "pyright", "lua_ls" },
automatic_installation = true,
},
},
-- Keep nvim-lspconfig installed (it provides server definitions),
-- but DO NOT call require("lspconfig") anymore.
{
"neovim/nvim-lspconfig",
event = { "BufReadPre", "BufNewFile" },
dependencies = { "hrsh7th/cmp-nvim-lsp" },
config = function()
vim.api.nvim_create_autocmd("LspAttach", { callback = lsp_keymaps })
local caps = vim.lsp.protocol.make_client_capabilities()
local ok, cmp_lsp = pcall(require, "cmp_nvim_lsp")
if ok then
caps = cmp_lsp.default_capabilities(caps)
end
vim.lsp.config("clangd", {
capabilities = caps,
cmd = { "clangd", "--background-index", "--clang-tidy", "--header-insertion=iwyu" },
})
vim.lsp.config("gopls", {
capabilities = caps,
settings = {
gopls = {
staticcheck = true,
analyses = { unusedparams = true, nilness = true, shadow = true },
},
},
})
vim.lsp.config("pyright", { capabilities = caps })
vim.lsp.config("lua_ls", {
capabilities = caps,
settings = {
Lua = {
diagnostics = { globals = { "vim" } },
workspace = { checkThirdParty = false },
},
},
})
vim.lsp.enable({ "clangd", "gopls", "pyright", "lua_ls" })
end,
},
}
+46
View File
@@ -0,0 +1,46 @@
return {
-- formatting
{
"stevearc/conform.nvim",
event = { "BufReadPre", "BufNewFile" },
opts = {
format_on_save = { timeout_ms = 1500, lsp_fallback = true },
formatters_by_ft = {
c = { "clang_format" },
cpp = { "clang_format" },
go = { "gofmt", "goimports" },
python = { "isort", "black" },
lua = { "stylua" },
json = { "prettier" },
yaml = { "prettier" },
markdown = { "prettier" },
},
},
config = function(_, opts)
require("conform").setup(opts)
vim.keymap.set("n", "<leader>f", function()
require("conform").format({ lsp_fallback = true })
end, { desc = "Format buffer" })
end,
},
-- linting (optional but nice)
{
"mfussenegger/nvim-lint",
event = { "BufReadPost", "BufNewFile" },
config = function()
local lint = require("lint")
lint.linters_by_ft = {
python = { "flake8" },
go = { "golangcilint" },
}
vim.api.nvim_create_autocmd({ "BufWritePost", "InsertLeave" }, {
callback = function()
lint.try_lint()
end,
})
end,
},
}
+23
View File
@@ -0,0 +1,23 @@
return {
{
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
event = { "BufReadPost", "BufNewFile" },
opts = {
ensure_installed = {
"c", "cpp", "go", "python", "lua",
"bash", "json", "yaml", "toml",
"markdown", "markdown_inline",
"regex", "vim", "vimdoc",
},
auto_install = true,
sync_install = false,
highlight = { enable = true },
indent = { enable = true },
},
config = function(_, opts)
require("nvim-treesitter").setup(opts)
end,
},
}
+41
View File
@@ -0,0 +1,41 @@
return {
-- theme
{
"ellisonleao/gruvbox.nvim",
name = "gruvbox",
lazy = false,
priority = 1000,
opts = {
contrast = "hard", -- "hard", "soft", or "" (default medium)
transparent_mode = true,
},
config = function(_, opts)
require("gruvbox").setup(opts)
vim.cmd.colorscheme("gruvbox")
end,
},
-- statusline
{
"nvim-lualine/lualine.nvim",
event = "VeryLazy",
opts = {
options = { theme = "gruvbox", globalstatus = true },
sections = {
lualine_c = { "filename", "diff" },
lualine_x = { "diagnostics", "filetype" },
},
},
},
-- telescope
{
"nvim-telescope/telescope.nvim",
cmd = "Telescope",
dependencies = { "nvim-lua/plenary.nvim" },
opts = {
defaults = { borderchars = { "", "", "", "", "", "", "", "" } },
},
},
}