From 6f72a5fee2afdf05f5ef85705801125da41bfe9c Mon Sep 17 00:00:00 2001 From: Buliway Date: Tue, 7 Jan 2025 14:44:04 +0300 Subject: [PATCH] move and rename some files --- nvim/init.lua | 7 ++- nvim/lua/custom/plugins/terminal.lua | 58 ------------------- nvim/lua/custom/terminal.lua | 56 ++++++++++++++++++ .../plugins/{neo-tree.lua => file-tree.lua} | 6 +- 4 files changed, 64 insertions(+), 63 deletions(-) delete mode 100644 nvim/lua/custom/plugins/terminal.lua create mode 100644 nvim/lua/custom/terminal.lua rename nvim/lua/kickstart/plugins/{neo-tree.lua => file-tree.lua} (88%) diff --git a/nvim/init.lua b/nvim/init.lua index 292af60..9177d6e 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -1,6 +1,6 @@ -- [[ Базовые настройки. Не плагины ]] require 'kickstart.settings' -require 'custom.plugins.terminal' +require 'custom.terminal' -- [[ Install `lazy.nvim` plugin manager ]] -- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info @@ -77,7 +77,7 @@ require('lazy').setup({ require 'kickstart.plugins.autopairs', -- Browse the file system - require 'kickstart.plugins.neo-tree', + require 'kickstart.plugins.file-tree', ------------------------------------- -- Установил руками под свои нужды -- @@ -89,6 +89,9 @@ require('lazy').setup({ -- Feature-Rich Go Plugin for Neovim require 'custom.plugins.golang', + -- Automated session manager + require 'custom.plugins.sessions', + -- 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. -- diff --git a/nvim/lua/custom/plugins/terminal.lua b/nvim/lua/custom/plugins/terminal.lua deleted file mode 100644 index 9d69f20..0000000 --- a/nvim/lua/custom/plugins/terminal.lua +++ /dev/null @@ -1,58 +0,0 @@ -vim.keymap.set("t", "", "") - -local state = { - floating = { - buf = -1, - win = -1, - } -} - -local function create_floating_window(opts) - opts = opts or {} - local width = opts.width or math.floor(vim.o.columns * 0.8) - local height = opts.height or math.floor(vim.o.lines * 0.8) - - -- Calculate the position to center the window - local col = math.floor((vim.o.columns - width) / 2) - local row = math.floor((vim.o.lines - height) / 2) - - -- Create a buffer - local buf = nil - if vim.api.nvim_buf_is_valid(opts.buf) then - buf = opts.buf - else - buf = vim.api.nvim_create_buf(false, true) -- No file, scratch buffer - end - - -- Define window configuration - local win_config = { - relative = "editor", - width = width, - height = height, - col = col, - row = row, - style = "minimal", -- No borders or extra UI elements - border = "rounded", - } - - -- Create the floating window - local win = vim.api.nvim_open_win(buf, true, win_config) - - return { buf = buf, win = win } -end - -local toggle_terminal = function() - if not vim.api.nvim_win_is_valid(state.floating.win) then - state.floating = create_floating_window { buf = state.floating.buf } - if vim.bo[state.floating.buf].buftype ~= "terminal" then - vim.cmd.terminal() - end - else - vim.api.nvim_win_hide(state.floating.win) - end -end - --- Example usage: --- Create a floating window with default dimensions -vim.api.nvim_create_user_command("Floaterminal", toggle_terminal, {}) -vim.keymap.set({ "n", "t" }, "tt", toggle_terminal, { desc = '[T]oggle [T]erminal' }) diff --git a/nvim/lua/custom/terminal.lua b/nvim/lua/custom/terminal.lua new file mode 100644 index 0000000..08be5dc --- /dev/null +++ b/nvim/lua/custom/terminal.lua @@ -0,0 +1,56 @@ +local state = { + floating = { + buf = -1, + win = -1, + }, +} + +local function create_floating_window(opts) + opts = opts or {} + local width = opts.width or math.floor(vim.o.columns * 0.8) + local height = opts.height or math.floor(vim.o.lines * 0.8) + + -- Calculate the position to center the window + local col = math.floor((vim.o.columns - width) / 2) + local row = math.floor((vim.o.lines - height) / 2) + + -- Create a buffer + local buf = nil + if vim.api.nvim_buf_is_valid(opts.buf) then + buf = opts.buf + else + buf = vim.api.nvim_create_buf(false, true) -- No file, scratch buffer + end + + -- Define window configuration + local win_config = { + relative = 'editor', + width = width, + height = height, + col = col, + row = row, + style = 'minimal', -- No borders or extra UI elements + border = 'rounded', + } + + -- Create the floating window + local win = vim.api.nvim_open_win(buf, true, win_config) + + return { buf = buf, win = win } +end + +local toggle_terminal = function() + if not vim.api.nvim_win_is_valid(state.floating.win) then + state.floating = create_floating_window { buf = state.floating.buf } + if vim.bo[state.floating.buf].buftype ~= 'terminal' then + vim.cmd.terminal() + end + else + vim.api.nvim_win_hide(state.floating.win) + end +end + +-- Example usage: +-- Create a floating window with default dimensions +vim.api.nvim_create_user_command('Floaterminal', toggle_terminal, {}) +vim.keymap.set({ 'n', 't' }, 'tt', toggle_terminal, { desc = '[T]oggle [T]erminal' }) diff --git a/nvim/lua/kickstart/plugins/neo-tree.lua b/nvim/lua/kickstart/plugins/file-tree.lua similarity index 88% rename from nvim/lua/kickstart/plugins/neo-tree.lua rename to nvim/lua/kickstart/plugins/file-tree.lua index 3a35ff5..da9df01 100644 --- a/nvim/lua/kickstart/plugins/neo-tree.lua +++ b/nvim/lua/kickstart/plugins/file-tree.lua @@ -10,11 +10,11 @@ return { 'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended 'MunifTanjim/nui.nvim', { -- Optional image support in preview window: See `# Preview Mode` for more information - "3rd/image.nvim", + '3rd/image.nvim', build = false, -- so that it doesn't build the rock opts = { - backend = "ueberzug", -- or "kitty" - processor = "magick_cli", -- or "magick_rock" + backend = 'ueberzug', -- or "kitty" + processor = 'magick_cli', -- or "magick_rock" }, }, },