This commit is contained in:
OpexHunter 2025-01-06 20:31:37 +03:00
commit cb1d8fc47c
13 changed files with 262 additions and 0 deletions

13
init.lua Normal file
View File

@ -0,0 +1,13 @@
require("config.lazy")
require("config.common-settings")
require("config.mason")
require("config.nvim-tree")
require("config.nvim-treesitter")
require("config.lualine")
require("config.nvim-cmp")
require("config.nvim-lspconfig")
require("config.bufferline")

15
lazy-lock.json Normal file
View File

@ -0,0 +1,15 @@
{
"bufferline.nvim": { "branch": "main", "commit": "5726c4e291224181903e960119a11e20ac677a0a" },
"cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" },
"cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "031e6ba70b0ad5eee49fd2120ff7a2e325b17fa7" },
"gruvbox": { "branch": "master", "commit": "f1ecde848f0cdba877acb0c740320568252cc482" },
"lazy.nvim": { "branch": "main", "commit": "72aa3a2624be5dc240646084f7b6a38eb99eb2ce" },
"lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" },
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
"nvim-cmp": { "branch": "main", "commit": "4c1ca8268569bfc6d487473cd17b167560e5bed2" },
"nvim-lspconfig": { "branch": "master", "commit": "8121483b8132b7053120fafd83728178fb3febf6" },
"nvim-tree.lua": { "branch": "master", "commit": "68fc4c20f5803444277022c681785c5edd11916d" },
"nvim-treesitter": { "branch": "master", "commit": "556ac68cd33973a38d3f2abac47f361432593fe2" },
"nvim-web-devicons": { "branch": "master", "commit": "5740b7382429d20b6ed0bbdb0694185af9507d44" },
"tokyonight.nvim": { "branch": "main", "commit": "7bb270adaa7692c2c33befc35f5567fc596a2504" }
}

12
lua/config/bufferline.lua Normal file
View File

@ -0,0 +1,12 @@
require("bufferline").setup{}
-- Настройка биндов узнать что действительно нажимается - перейти в режим вставки нажать <c-v> и потом необходимое сочетание
vim.keymap.set('n', '<A-;>', ':BufferLineCycleNext<CR>', { noremap = true, silent = true })
vim.keymap.set('n', '<A-j>', ':BufferLineCyclePrev<CR>', { noremap = true, silent = true })
vim.keymap.set('n', '<A-w>', ':bd!<CR>', { noremap = true, silent = true })
-- Настройка сочетаний клавиш для терминала
vim.keymap.set('t', '<A-;>', '<C-\\><C-N>:BufferLineCycleNext<CR>', { noremap = true, silent = true })
vim.keymap.set('t', '<A-j>', '<C-\\><C-N>:BufferLineCyclePrev<CR>', { noremap = true, silent = true })
vim.keymap.set('t', '<A-w>', '<C-\\><C-N>:bd!<CR>', { noremap = true, silent = true })
-- Добавление выхода из режима вставки в терминале
vim.keymap.set('t', '<A-i>', '<C-\\><C-N>', { noremap = true, silent = true })

View File

@ -0,0 +1,2 @@
-- Настройка lsp серверов в nvim-lsp config
-- Этот плагин необходим для совместной работы nvim с cmp и lsp сервера

View File

@ -0,0 +1,51 @@
vim.cmd("colorscheme gruvbox") --tokyonight
-- Установка клавиши Leader на пробел
vim.g.mapleader = " "
-- CUSTOM MOVE
-- NORMAL
vim.keymap.set('n', 'h', '<nop>', { noremap = true, silent = true })
vim.keymap.set('n', 'j', 'h', { noremap = true, silent = true })
vim.keymap.set('n', 'k', 'j', { noremap = true, silent = true })
vim.keymap.set('n', 'l', 'k', { noremap = true, silent = true })
vim.keymap.set('n', ';', 'l', { noremap = true, silent = true })
-- VISUAL
vim.keymap.set('v', 'h', '<nop>', { noremap = true, silent = true })
vim.keymap.set('v', 'j', 'h', { noremap = true, silent = true })
vim.keymap.set('v', 'k', 'j', { noremap = true, silent = true })
vim.keymap.set('v', 'l', 'k', { noremap = true, silent = true })
vim.keymap.set('v', ';', 'l', { noremap = true, silent = true })
-- Включение относительной нумерации строк
vim.opt.number = true -- Включить абсолютную нумерацию строк
vim.opt.relativenumber = true -- Включить относительную нумерацию строк
vim.cmd [[
autocmd TermOpen * setlocal nonumber norelativenumber
]]
vim.opt.cmdheight = 0
-- disable netrw at the very start of your init.lua
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
-- Функции для табуляции выделенной области
local function tab_selected()
vim.cmd('normal! >gv') -- Сдвиг вправо и возврат к выделению
end
local function shift_tab_selected()
vim.cmd('normal! <gv') -- Сдвиг влево и возврат к выделению
end
vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.shiftwidth = 4
-- Привязка клавиш
vim.keymap.set('v', '<Tab>', tab_selected, { noremap = true, silent = true })
vim.keymap.set('v', '<S-Tab>', shift_tab_selected, { noremap = true, silent = true })
-- Включаем поддержку цветовой схемы
vim.opt.termguicolors = true

48
lua/config/lazy.lua Normal file
View File

@ -0,0 +1,48 @@
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
-- Make sure to setup `mapleader` and `maplocalleader` before
-- loading lazy.nvim so that mappings are correct.
-- This is also a good place to setup other settings (vim.opt)
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
-- Setup lazy.nvim
require("lazy").setup({
spec = {
-- import your plugins
{ import = "plugins" },
},
-- Configure any other settings here. See the documentation for more details.
-- colorscheme that will be used when installing plugins.
install = { colorscheme = { "habamax" } },
-- automatically check for plugin updates
checker = { enabled = true },
})
local function augroup(name)
return vim.api.nvim_create_augroup("lazyvim_" .. name, { clear = true })
end
vim.api.nvim_create_autocmd("VimEnter", {
group = augroup("autoupdate"),
callback = function()
if require("lazy.status").has_updates then
require("lazy").update({ show = false, })
end
end,
})

7
lua/config/lualine.lua Normal file
View File

@ -0,0 +1,7 @@
require('lualine').setup {
options = {
theme = 'gruvbox',
section_separators = '',
component_separators = '',
},
}

1
lua/config/mason.lua Normal file
View File

@ -0,0 +1 @@
require('mason').setup()

43
lua/config/nvim-cmp.lua Normal file
View File

@ -0,0 +1,43 @@
local cmp = require'cmp'
cmp.setup({
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
mapping = {
['<C-l>'] = cmp.mapping.select_prev_item(),
['<C-k>'] = cmp.mapping.select_next_item(),
['<C-;>'] = cmp.mapping.confirm({ select = true }),
['<CR>'] = cmp.mapping.confirm({ select = true }),
['<C-Space>'] = cmp.mapping.complete(),
['<C-j>'] = cmp.mapping.close(),
['<C-e>'] = cmp.mapping.close(),
},
sources = {
{ name = 'nvim_lsp' },
{ name = 'buffer' },
{ name = 'nvim_lsp_signature_help' },
},
-- другие настройки
})
-- Diagnostic
vim.keymap.set('n', '<Space>k', '<cmd>lua vim.diagnostic.open_float()<CR>', { noremap = true, silent = true })
vim.keymap.set('n', '<space>l', [[:lua YankDiagnosticError()<CR>]], { noremap = true, silent = true, desc = "Copy error" })
function YankDiagnosticError()
vim.diagnostic.open_float()
vim.diagnostic.open_float()
local win_id = vim.fn.win_getid() -- get the window ID of the floating window
vim.cmd("normal! j") -- move down one row
vim.cmd("normal! VG") -- select everything from that row down
vim.cmd("normal! \"+y") -- yank selected text
vim.api.nvim_win_close(win_id, true) -- close the floating window by its ID
end
vim.diagnostic.config({
signs = false, -- Отключает отображение знаков (иконок ошибок) слева
})

View File

@ -0,0 +1,30 @@
local capabilities = require('cmp_nvim_lsp').default_capabilities()
local lspconfig = require('lspconfig')
lspconfig.jdtls.setup{
cmd = { "jdtls" },
settings = {
java = {
signatureHelp = {
enabled = true,
},
},
},
}
lspconfig.clangd.setup{}
lspconfig.rust_analyzer.setup({
capabilities = capabilities,
settings = {
["rust-analyzer"] = {
cargo = {
allFeatures = true,
},
procMacro = {
enable = true,
},
},
},
})

21
lua/config/nvim-tree.lua Normal file
View File

@ -0,0 +1,21 @@
-- Настройка nvim-tree
require("nvim-tree").setup({
sort = {
sorter = "case_sensitive",
},
view = {
width = 30,
},
renderer = {
group_empty = true,
},
filters = {
dotfiles = true,
},
actions = {
open_file = {
quit_on_open = true, -- закрывать дерево при открытии файла
},
},
})
vim.keymap.set("n", "<Space>e", ":NvimTreeToggle<CR>", { noremap = true, silent = true })

View File

@ -0,0 +1,6 @@
require'nvim-treesitter.configs'.setup {
ensure_installed = { "lua", "python", "javascript", "html", "css" },
highlight = {
enable = true,
},
}

13
lua/plugins.lua Normal file
View File

@ -0,0 +1,13 @@
return {
{ "nvim-treesitter/nvim-treesitter", run = ":TSUpdate" },
{ "hrsh7th/nvim-cmp" },
{ "hrsh7th/cmp-nvim-lsp" }, -- Плагин для интеграции nvim-cmp с LSP
{ "nvim-lualine/lualine.nvim", requires = { "kyazdani42/nvim-web-devicons", opt = true } },
{ "morhetz/gruvbox" },
{ "folke/tokyonight.nvim" },
{ "neovim/nvim-lspconfig" }, -- Добавляем nvim-lspconfig
{ "kyazdani42/nvim-tree.lua", requires = { "nvim-tree/nvim-web-devicons" }},
{'akinsho/bufferline.nvim', version = "*", dependencies = 'nvim-tree/nvim-web-devicons'},
{"williamboman/mason.nvim"},
{'hrsh7th/cmp-nvim-lsp-signature-help'}
}