diff --git a/init.lua b/init.lua index 577e4b2d..6d63e4e7 100644 --- a/init.lua +++ b/init.lua @@ -84,6 +84,9 @@ I hope you enjoy your Neovim journey, P.S. You can delete this when you're done too. It's your config now! :) --]] +-- Custom config. +require 'custom.keybindings' + -- Set as the leader key -- See `:help mapleader` -- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) @@ -197,10 +200,6 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the right win vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) --- Custom Keybinds. -vim.keymap.set('i', 'jk', '', { desc = 'escape' }) -vim.keymap.set('i', 'kj', '', { desc = 'escape' }) - -- [[ Basic Autocommands ]] -- See `:help lua-guide-autocommands` @@ -918,7 +917,8 @@ require('lazy').setup({ -- 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 {}, + -- [''] = cmp.mapping.complete {}, + [''] = cmp.mapping.complete {}, -- Think of as moving to the right of your snippet expansion. -- So if you have a snippet that's like: @@ -1065,7 +1065,7 @@ require('lazy').setup({ -- 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. - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, -- -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` -- Or use telescope! diff --git a/lua/custom/keybindings.lua b/lua/custom/keybindings.lua new file mode 100644 index 00000000..c15a9970 --- /dev/null +++ b/lua/custom/keybindings.lua @@ -0,0 +1,16 @@ +-- Custom Keybinds. + +vim.keymap.set('i', 'jk', '', { desc = 'escape' }) +vim.keymap.set('i', 'kj', '', { desc = 'escape' }) + +-- Перемещение между буферами +vim.keymap.set('n', '', 'BufferLineCycleNext') +vim.keymap.set('n', '', 'BufferLineCyclePrev') + +-- Закрыть буфер +vim.keymap.set('n', 'bd', 'Bdelete!') + +-- Переход к буферу по номеру (например, Alt+1, Alt+2...) +for i = 1, 9 do + vim.keymap.set('n', '', 'BufferLineGoToBuffer ' .. i .. '') +end diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index be0eb9d8..23f2215f 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -2,4 +2,68 @@ -- I promise not to create any merge conflicts in this directory :) -- -- See the kickstart.nvim README for more information -return {} +return { + { + 'akinsho/bufferline.nvim', + dependencies = 'nvim-tree/nvim-web-devicons', + + event = 'VeryLazy', + keys = { + { 'bp', 'BufferLineTogglePin', desc = 'Toggle Pin' }, + { 'bP', 'BufferLineGroupClose ungrouped', desc = 'Delete Non-Pinned Buffers' }, + { 'br', 'BufferLineCloseRight', desc = 'Delete Buffers to the Right' }, + { 'bl', 'BufferLineCloseLeft', desc = 'Delete Buffers to the Left' }, + { '', 'BufferLineCyclePrev', desc = 'Prev Buffer' }, + { '', 'BufferLineCycleNext', desc = 'Next Buffer' }, + { '[b', 'BufferLineCyclePrev', desc = 'Prev Buffer' }, + { ']b', 'BufferLineCycleNext', desc = 'Next Buffer' }, + { '[B', 'BufferLineMovePrev', desc = 'Move buffer prev' }, + { ']B', 'BufferLineMoveNext', desc = 'Move buffer next' }, + }, + opts = { + options = { + -- stylua: ignore + close_command = function(n) Snacks.bufdelete(n) end, + -- stylua: ignore + right_mouse_command = function(n) Snacks.bufdelete(n) end, + diagnostics = 'nvim_lsp', + always_show_bufferline = false, + diagnostics_indicator = function(_, _, diag) + local icons = LazyVim.config.icons.diagnostics + local ret = (diag.error and icons.Error .. diag.error .. ' ' or '') .. (diag.warning and icons.Warn .. diag.warning or '') + return vim.trim(ret) + end, + offsets = { + { + filetype = 'neo-tree', + text = 'Neo-tree', + highlight = 'Directory', + text_align = 'left', + }, + { + filetype = 'snacks_layout_box', + }, + }, + show_buffer_icons = true, + color_icons = true, + }, + }, + config = function(_, opts) + require('bufferline').setup(opts) + -- Fix bufferline when restoring a session + vim.api.nvim_create_autocmd({ 'BufAdd', 'BufDelete' }, { + callback = function() + vim.schedule(function() + pcall(nvim_bufferline) + end) + end, + }) + end, + }, + { + 'numToStr/Comment.nvim', + opts = { + -- add any options here + }, + }, +} diff --git a/lua/kickstart/plugins/neo-tree.lua b/lua/kickstart/plugins/neo-tree.lua index bd442269..6cb96f02 100644 --- a/lua/kickstart/plugins/neo-tree.lua +++ b/lua/kickstart/plugins/neo-tree.lua @@ -18,6 +18,12 @@ return { window = { mappings = { ['\\'] = 'close_window', + [''] = { + 'open', + config = { + open_command = 'tabnew', -- Альтернативный вариант параметра + }, + }, }, }, },