Skip to content
183 changes: 136 additions & 47 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ vim.g.mapleader = ' '
vim.g.maplocalleader = ' '

-- Set to true if you have a Nerd Font installed and selected in the terminal
vim.g.have_nerd_font = false
vim.g.have_nerd_font = true

-- [[ Setting options ]]
-- See `:help vim.opt`
Expand Down Expand Up @@ -157,13 +157,27 @@ vim.opt.cursorline = true
-- Minimal number of screen lines to keep above and below the cursor.
vim.opt.scrolloff = 10

-- Глобальные настройки табуляции
vim.o.tabstop = 2
vim.o.shiftwidth = 2
vim.o.expandtab = true
vim.o.softtabstop = 2

-- Отображать строку без переносов, как одну бесконечно длинную
-- (display lines as one long line)
-- vim.opt.wrap = false

-- [[ Basic Keymaps ]]
-- See `:help vim.keymap.set()`

-- Clear highlights on search when pressing <Esc> in normal mode
-- See `:help hlsearch`
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')

-- Move highlighted blocks with J and K
vim.keymap.set('v', 'J', ":m '>+1<CR>gv=gv")
vim.keymap.set('v', 'K', ":m '<-2<CR>gv=gv")

-- Diagnostic keymaps
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })

Expand Down Expand Up @@ -321,7 +335,8 @@ require('lazy').setup({
{ '<leader>w', group = '[W]orkspace' },
{ '<leader>t', group = '[T]oggle' },
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
},
{ '<leader>l', group = '[L]aTeX' },
}
},
},

Expand Down Expand Up @@ -451,8 +466,9 @@ require('lazy').setup({
},
},
{ 'Bilal2453/luvit-meta', lazy = true },

-- Main LSP Configuration
{
-- Main LSP Configuration
'neovim/nvim-lspconfig',
dependencies = {
-- Automatically install LSPs and related tools to stdpath for Neovim
Expand Down Expand Up @@ -605,9 +621,25 @@ require('lazy').setup({
-- - settings (table): Override the default settings passed when initializing the server.
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
local servers = {
-- clangd = {},
-- C/C++ LSP server
clangd = {},

-- LaTeX LSP server
texlab = {},

-- Python LSP server
pyright = {
settings = {
python = {
pythonPath = '/opt/homebrew/Caskroom/miniconda/base/bin/python',
analysis = {
autoSearchPaths = true,
useLibraryCodeForTypes = true,
},
},
},
},
-- gopls = {},
-- pyright = {},
-- rust_analyzer = {},
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
--
Expand Down Expand Up @@ -699,6 +731,9 @@ require('lazy').setup({
end,
formatters_by_ft = {
lua = { 'stylua' },
python = { 'isort', 'black' },
cpp = { 'clang-format' },
texlab = { 'latexindent' },
-- Conform can also run multiple formatters sequentially
-- python = { "isort", "black" },
--
Expand Down Expand Up @@ -750,6 +785,12 @@ require('lazy').setup({
local luasnip = require 'luasnip'
luasnip.config.setup {}

local has_words_before = function()
unpack = unpack or table.unpack
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match '%s' == nil
end

cmp.setup {
snippet = {
expand = function(args)
Expand All @@ -762,53 +803,90 @@ require('lazy').setup({
-- chosen, you will need to read `:help ins-completion`
--
-- No, but seriously. Please read `:help ins-completion`, it is really good!
mapping = cmp.mapping.preset.insert {
-- Select the [n]ext item
['<C-n>'] = cmp.mapping.select_next_item(),
-- Select the [p]revious item
['<C-p>'] = cmp.mapping.select_prev_item(),
-- mapping = cmp.mapping.preset.insert {
-- -- Select the [n]ext item
-- ['<C-n>'] = cmp.mapping.select_next_item(),
-- -- Select the [p]revious item
-- ['<C-p>'] = cmp.mapping.select_prev_item(),
--
-- -- Scroll the documentation window [b]ack / [f]orward
-- ['<C-b>'] = cmp.mapping.scroll_docs(-4),
-- ['<C-f>'] = cmp.mapping.scroll_docs(4),
--
-- -- Accept ([y]es) the completion.
-- -- This will auto-import if your LSP supports it.
-- -- This will expand snippets if the LSP sent a snippet.
-- ['<C-y>'] = cmp.mapping.confirm { select = true },
--
-- -- If you prefer more traditional completion keymaps,
-- -- you can uncomment the following lines
-- --['<CR>'] = cmp.mapping.confirm { select = true },
-- --['<Tab>'] = cmp.mapping.select_next_item(),
-- --['<S-Tab>'] = cmp.mapping.select_prev_item(),
--
-- -- Manually trigger a completion from nvim-cmp.
-- -- Generally you don't need this, because nvim-cmp will display
-- -- completions whenever it has completion options available.
-- ['<C-Space>'] = cmp.mapping.complete {},
--
-- -- Think of <c-l> as moving to the right of your snippet expansion.
-- -- So if you have a snippet that's like:
-- -- function $name($args)
-- -- $body
-- -- end
-- --
-- -- <c-l> will move you to the right of each of the expansion locations.
-- -- <c-h> is similar, except moving you backwards.
-- ['<C-l>'] = cmp.mapping(function()
-- if luasnip.expand_or_locally_jumpable() then
-- luasnip.expand_or_jump()
-- end
-- end, { 'i', 's' }),
-- ['<C-h>'] = cmp.mapping(function()
-- if luasnip.locally_jumpable(-1) then
-- luasnip.jump(-1)
-- end
-- end, { 'i', 's' }),
--
-- -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
-- -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
-- },

-- Scroll the documentation window [b]ack / [f]orward
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
-- Настройки горячих клавиш для автодополнения от Александра Романова
mapping = cmp.mapping.preset.insert {

-- Accept ([y]es) the completion.
-- This will auto-import if your LSP supports it.
-- This will expand snippets if the LSP sent a snippet.
['<C-y>'] = cmp.mapping.confirm { select = true },

-- If you prefer more traditional completion keymaps,
-- you can uncomment the following lines
--['<CR>'] = cmp.mapping.confirm { select = true },
--['<Tab>'] = cmp.mapping.select_next_item(),
--['<S-Tab>'] = cmp.mapping.select_prev_item(),

-- Manually trigger a completion from nvim-cmp.
-- Generally you don't need this, because nvim-cmp will display
-- completions whenever it has completion options available.
['<C-Space>'] = cmp.mapping.complete {},

-- Think of <c-l> as moving to the right of your snippet expansion.
-- So if you have a snippet that's like:
-- function $name($args)
-- $body
-- end
--
-- <c-l> will move you to the right of each of the expansion locations.
-- <c-h> is similar, except moving you backwards.
['<C-l>'] = cmp.mapping(function()
if luasnip.expand_or_locally_jumpable() then
-- Прямой пробег по списку автодополнений
['<Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { 'i', 's' }),
['<C-h>'] = cmp.mapping(function()
if luasnip.locally_jumpable(-1) then

-- Обратный пробег по списку автодополнений
['<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' }),

-- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
-- Отмена автодополнения
['<C-e>'] = cmp.mapping.abort(),
-- Подтверждение автодополнения
['<CR>'] = cmp.mapping.confirm { select = true },

-- Scroll the documentation window [b]ack / [f]orward
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
},
sources = {
{
Expand All @@ -819,6 +897,11 @@ require('lazy').setup({
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'path' },
{ name = 'buffer' },
},
window = {
completion = cmp.config.window.bordered(),
-- documentation = cmp.config.window.bordered(),
},
}
end,
Expand All @@ -843,7 +926,12 @@ require('lazy').setup({
},

-- Highlight todo, notes, etc in comments
{ 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } },
{
'folke/todo-comments.nvim',
event = 'VimEnter',
dependencies = { 'nvim-lua/plenary.nvim' },
opts = { signs = false },
},

{ -- Collection of various small independent plugins/modules
'echasnovski/mini.nvim',
Expand Down Expand Up @@ -897,6 +985,7 @@ require('lazy').setup({
-- If you are experiencing weird indenting issues, add the language to
-- the list of additional_vim_regex_highlighting and disabled languages for indent.
additional_vim_regex_highlighting = { 'ruby' },
disable = { 'latex' },
},
indent = { enable = true, disable = { 'ruby' } },
},
Expand All @@ -920,16 +1009,16 @@ require('lazy').setup({
-- require 'kickstart.plugins.debug',
-- require 'kickstart.plugins.indent_line',
-- require 'kickstart.plugins.lint',
-- require 'kickstart.plugins.autopairs',
-- require 'kickstart.plugins.neo-tree',
require 'kickstart.plugins.autopairs',
require 'kickstart.plugins.neo-tree',
-- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps

-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
-- This is the easiest way to modularize your config.
--
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
-- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins`
-- { import = 'custom.plugins' },
{ import = 'custom.plugins' },
}, {
ui = {
-- If you are using a Nerd Font: set icons to an empty table which will use the
Expand Down
12 changes: 12 additions & 0 deletions lua/custom/plugins/vimtex.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
return {
'lervag/vimtex',
lazy = false, -- we don't want to lazy load VimTeX
init = function()
vim.g.vimtex_view_method = 'skim'

-- vim.g.vimtex_syntax_enabled = 0
-- vim.g.vimtex_compiler_method = "latexmk"

vim.g.vimtex_quickfix_mode = 0
end,
}
8 changes: 8 additions & 0 deletions lua/kickstart/plugins/neo-tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,16 @@ return {
{ '\\', ':Neotree reveal<CR>', desc = 'NeoTree reveal', silent = true },
},
opts = {
close_if_last_window = true, -- Закрывать Neo-tree, если это последнее окно
popup_border_style = 'rounded', -- Закругленные углы у всплывающих окон

enable_git_status = true, -- Показ статусов Git
enable_diagnostics = true, -- Показ диагностик

filesystem = {
window = {
width = 30, -- Ширина окна
position = 'left',
mappings = {
['\\'] = 'close_window',
},
Expand Down
Loading