From 7f4114cb84163c56b85f3e34b2c42042a944ebca Mon Sep 17 00:00:00 2001 From: Sergey Sychugin <40148988+sychugin@users.noreply.github.com> Date: Fri, 19 Jul 2024 19:52:46 +0300 Subject: [PATCH 1/6] Change NerdFonts option to true. Add LSPs: clangd, texlab, and pyright with options. --- init.lua | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index 624e23d87fe..7f82265dcbb 100644 --- a/init.lua +++ b/init.lua @@ -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` @@ -564,9 +564,20 @@ 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 = {}, + clangd = {}, + texlab = {}, + 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 -- From e7db0d487f413542803b2c3559f23fe8424cb7bc Mon Sep 17 00:00:00 2001 From: Sergey Sychugin <40148988+sychugin@users.noreply.github.com> Date: Fri, 19 Jul 2024 22:32:36 +0300 Subject: [PATCH 2/6] Keymaps for autocomplete, Setup of Format plugin, Tabs and etc --- init.lua | 132 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 94 insertions(+), 38 deletions(-) diff --git a/init.lua b/init.lua index 7f82265dcbb..b3c490645f5 100644 --- a/init.lua +++ b/init.lua @@ -154,6 +154,12 @@ 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 + -- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` @@ -161,6 +167,10 @@ vim.opt.scrolloff = 10 vim.opt.hlsearch = true vim.keymap.set('n', '', 'nohlsearch') +-- Move highlighted blocks with J and K +vim.keymap.set('v', 'J', ":m '>+1gv=gv") +vim.keymap.set('v', 'K', ":m '<-2gv=gv") + -- Diagnostic keymaps vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' }) vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' }) @@ -662,6 +672,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" }, -- @@ -714,6 +727,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) @@ -726,53 +745,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 - [''] = cmp.mapping.select_next_item(), - -- Select the [p]revious item - [''] = cmp.mapping.select_prev_item(), + -- mapping = cmp.mapping.preset.insert { + -- -- Select the [n]ext item + -- [''] = cmp.mapping.select_next_item(), + -- -- Select the [p]revious item + -- [''] = cmp.mapping.select_prev_item(), + -- + -- -- Scroll the documentation window [b]ack / [f]orward + -- [''] = cmp.mapping.scroll_docs(-4), + -- [''] = 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. + -- [''] = cmp.mapping.confirm { select = true }, + -- + -- -- If you prefer more traditional completion keymaps, + -- -- you can uncomment the following lines + -- --[''] = cmp.mapping.confirm { select = true }, + -- --[''] = cmp.mapping.select_next_item(), + -- --[''] = 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. + -- [''] = cmp.mapping.complete {}, + -- + -- -- Think of as moving to the right of your snippet expansion. + -- -- So if you have a snippet that's like: + -- -- function $name($args) + -- -- $body + -- -- end + -- -- + -- -- will move you to the right of each of the expansion locations. + -- -- is similar, except moving you backwards. + -- [''] = cmp.mapping(function() + -- if luasnip.expand_or_locally_jumpable() then + -- luasnip.expand_or_jump() + -- end + -- end, { 'i', 's' }), + -- [''] = 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 - [''] = cmp.mapping.scroll_docs(-4), - [''] = 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. - [''] = cmp.mapping.confirm { select = true }, - - -- If you prefer more traditional completion keymaps, - -- you can uncomment the following lines - --[''] = cmp.mapping.confirm { select = true }, - --[''] = cmp.mapping.select_next_item(), - --[''] = 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. - [''] = cmp.mapping.complete {}, - - -- Think of as moving to the right of your snippet expansion. - -- So if you have a snippet that's like: - -- function $name($args) - -- $body - -- end - -- - -- will move you to the right of each of the expansion locations. - -- is similar, except moving you backwards. - [''] = cmp.mapping(function() - if luasnip.expand_or_locally_jumpable() then + -- Прямой пробег по списку автодополнений + [''] = 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' }), - [''] = cmp.mapping(function() - if luasnip.locally_jumpable(-1) then + + -- Обратный пробег по списку автодополнений + [''] = 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 + -- Отмена автодополнения + [''] = cmp.mapping.abort(), + -- Подтверждение автодополнения + [''] = cmp.mapping.confirm { select = true }, + + -- Scroll the documentation window [b]ack / [f]orward + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), }, sources = { { name = 'nvim_lsp' }, From ce7f84540a16f528b4087a50f69e650d7fee5816 Mon Sep 17 00:00:00 2001 From: Sergey Sychugin <40148988+sychugin@users.noreply.github.com> Date: Sat, 20 Jul 2024 13:23:23 +0300 Subject: [PATCH 3/6] Add Neo-Tree and Autopairs plugins --- init.lua | 4 ++-- lua/kickstart/plugins/neo-tree.lua | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index b3c490645f5..ba11ddfc0be 100644 --- a/init.lua +++ b/init.lua @@ -942,8 +942,8 @@ 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` diff --git a/lua/kickstart/plugins/neo-tree.lua b/lua/kickstart/plugins/neo-tree.lua index c793b885bc6..3e0d8b9e445 100644 --- a/lua/kickstart/plugins/neo-tree.lua +++ b/lua/kickstart/plugins/neo-tree.lua @@ -14,8 +14,16 @@ return { { '\\', ':Neotree reveal', { desc = 'NeoTree reveal' } }, }, 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', }, From b92cdd60310353f1c2f60e860fb0efd1cfcb13a0 Mon Sep 17 00:00:00 2001 From: Sergey Sychugin <40148988+sychugin@users.noreply.github.com> Date: Thu, 22 Aug 2024 16:41:05 +0300 Subject: [PATCH 4/6] Add several small additions --- init.lua | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index f271787ea8e..ef961febc64 100644 --- a/init.lua +++ b/init.lua @@ -163,6 +163,10 @@ 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()` @@ -296,6 +300,7 @@ require('lazy').setup({ { 'w', group = '[W]orkspace' }, { 't', group = '[T]oggle' }, { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, + { 'l', group = '[L]aTeX' }, } end, }, @@ -426,8 +431,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 @@ -579,8 +585,13 @@ 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 = { + -- C/C++ LSP server clangd = {}, + + -- LaTeX LSP server texlab = {}, + + -- Python LSP server pyright = { settings = { python = { @@ -844,6 +855,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, @@ -868,7 +884,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', @@ -959,7 +980,7 @@ require('lazy').setup({ -- -- 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 From 2ac5714593991a7c490b1006576a377efaf1040c Mon Sep 17 00:00:00 2001 From: Sergey Sychugin <40148988+sychugin@users.noreply.github.com> Date: Thu, 22 Aug 2024 16:41:47 +0300 Subject: [PATCH 5/6] Add vimtex plugin --- lua/custom/plugins/vimtex.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 lua/custom/plugins/vimtex.lua diff --git a/lua/custom/plugins/vimtex.lua b/lua/custom/plugins/vimtex.lua new file mode 100644 index 00000000000..3768948599d --- /dev/null +++ b/lua/custom/plugins/vimtex.lua @@ -0,0 +1,10 @@ +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" + end, +} From 6ff988528ac237de69f2ce21b070529aa5731035 Mon Sep 17 00:00:00 2001 From: Sergey Sychugin <40148988+sychugin@users.noreply.github.com> Date: Mon, 16 Sep 2024 17:10:18 +0300 Subject: [PATCH 6/6] =?UTF-8?q?VimTeX:=20=D1=87=D0=B0=D1=81=D1=82=D0=B8?= =?UTF-8?q?=D1=87=D0=BD=D0=B0=D1=8F=20=D1=82=D0=B5=D1=81=D1=82=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D1=8F=20=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9=D0=BA?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- init.lua | 1 + lua/custom/plugins/vimtex.lua | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 7485d1965b0..f796498f73e 100644 --- a/init.lua +++ b/init.lua @@ -985,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' } }, }, diff --git a/lua/custom/plugins/vimtex.lua b/lua/custom/plugins/vimtex.lua index 3768948599d..8e293e400f4 100644 --- a/lua/custom/plugins/vimtex.lua +++ b/lua/custom/plugins/vimtex.lua @@ -4,7 +4,9 @@ return { init = function() vim.g.vimtex_view_method = 'skim' - vim.g.vimtex_syntax_enabled = 0 + -- vim.g.vimtex_syntax_enabled = 0 -- vim.g.vimtex_compiler_method = "latexmk" + + vim.g.vimtex_quickfix_mode = 0 end, }