From 9091f905f114010a3bc4a87caef1414e355ff03a Mon Sep 17 00:00:00 2001 From: Heiko Blobner Date: Mon, 4 Sep 2023 12:32:46 +0200 Subject: [PATCH] nvim: surround+codewindow --- .../.config/nvim/lua/core/config/options.lua | 4 +-- .../lua/core/plugins/editor/codewindow.lua | 22 +++++++++++-- .../lua/core/plugins/editor/mini-surround.lua | 33 ------------------- .../lua/core/plugins/editor/nvim-surround.lua | 13 ++++++++ 4 files changed, 35 insertions(+), 37 deletions(-) delete mode 100644 dot_files/.config/nvim/lua/core/plugins/editor/mini-surround.lua create mode 100644 dot_files/.config/nvim/lua/core/plugins/editor/nvim-surround.lua diff --git a/dot_files/.config/nvim/lua/core/config/options.lua b/dot_files/.config/nvim/lua/core/config/options.lua index 3c6a955..a55f234 100644 --- a/dot_files/.config/nvim/lua/core/config/options.lua +++ b/dot_files/.config/nvim/lua/core/config/options.lua @@ -19,8 +19,8 @@ vim.opt.undofile = true -- enable persistent undo vim.opt.updatetime = 300 -- faster completion (4000ms default) vim.opt.writebackup = false -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited vim.opt.expandtab = true -- convert tabs to spaces -vim.opt.shiftwidth = 2 -- the number of spaces inserted for each indentation -vim.opt.tabstop = 2 -- insert 2 spaces for a tab +vim.opt.shiftwidth = 4 -- the number of spaces inserted for each indentation +vim.opt.tabstop = 4 -- insert 4 spaces for a tab --vim.opt.cursorline = true -- highlight the current line vim.opt.relativenumber = true -- set numbered lines vim.opt.laststatus = 3 -- only the last window will always have a status line diff --git a/dot_files/.config/nvim/lua/core/plugins/editor/codewindow.lua b/dot_files/.config/nvim/lua/core/plugins/editor/codewindow.lua index a905efe..3fc824a 100644 --- a/dot_files/.config/nvim/lua/core/plugins/editor/codewindow.lua +++ b/dot_files/.config/nvim/lua/core/plugins/editor/codewindow.lua @@ -2,9 +2,9 @@ return { 'gorbit99/codewindow.nvim', version = '*', - config = function() + config = function(_, opts) local codewindow = require('codewindow') - codewindow.setup() + codewindow.setup(opts) codewindow.apply_default_keybinds() end, dependencies = { @@ -18,6 +18,24 @@ return { }, }, }, + opts = { + active_in_terminals = false, -- Should the minimap activate for terminal buffers + auto_enable = true, -- Automatically open the minimap when entering a (non-excluded) buffer (accepts a table of filetypes) + exclude_filetypes = { 'help', 'neo-tree' }, -- Choose certain filetypes to not show minimap on + max_minimap_height = nil, -- The maximum height the minimap can take (including borders) + max_lines = 5000, -- If auto_enable is true, don't open the minimap for buffers which have more than this many lines. + minimap_width = 20, -- The width of the text part of the minimap + use_lsp = true, -- Use the builtin LSP to show errors and warnings + use_treesitter = true, -- Use nvim-treesitter to highlight the code + use_git = true, -- Show small dots to indicate git additions and deletions + width_multiplier = 4, -- How many characters one dot represents + z_index = 1, -- The z-index the floating window will be on + show_cursor = true, -- Show the cursor position in the minimap + screen_bounds = 'lines', -- How the visible area is displayed, "lines": lines above and below, "background": background color + window_border = 'single', -- The border style of the floating window (accepts all usual options) + relative = 'win', -- What will be the minimap be placed relative to, "win": the current window, "editor": the entire editor + events = { 'TextChanged', 'InsertLeave', 'DiagnosticChanged', 'FileWritePost' }, -- Events that update the code window + }, keys = { { "umo", function() require("codewindow").open_minimap() end, desc = "open the minimap" }, { "umc", function() require("codewindow").close_minimap() end, desc = "close the minimap" }, diff --git a/dot_files/.config/nvim/lua/core/plugins/editor/mini-surround.lua b/dot_files/.config/nvim/lua/core/plugins/editor/mini-surround.lua deleted file mode 100644 index 949ea8e..0000000 --- a/dot_files/.config/nvim/lua/core/plugins/editor/mini-surround.lua +++ /dev/null @@ -1,33 +0,0 @@ --- surround -return { - "echasnovski/mini.surround", - keys = function(_, keys) - -- Populate the keys based on the user's options - local plugin = require("lazy.core.config").spec.plugins["mini.surround"] - local opts = require("lazy.core.plugin").values(plugin, "opts", false) - local mappings = { - { opts.mappings.add, desc = "Add surrounding", mode = { "n", "v" } }, - { opts.mappings.delete, desc = "Delete surrounding" }, - { opts.mappings.find, desc = "Find right surrounding" }, - { opts.mappings.find_left, desc = "Find left surrounding" }, - { opts.mappings.highlight, desc = "Highlight surrounding" }, - { opts.mappings.replace, desc = "Replace surrounding" }, - { opts.mappings.update_n_lines, desc = "Update `MiniSurround.config.n_lines`" }, - } - mappings = vim.tbl_filter(function(m) - return m[1] and #m[1] > 0 - end, mappings) - return vim.list_extend(mappings, keys) - end, - opts = { - mappings = { - add = "gza", -- Add surrounding in Normal and Visual modes - delete = "gzd", -- Delete surrounding - find = "gzf", -- Find surrounding (to the right) - find_left = "gzF", -- Find surrounding (to the left) - highlight = "gzh", -- Highlight surrounding - replace = "gzr", -- Replace surrounding - update_n_lines = "gzn", -- Update `n_lines` - }, - }, -} diff --git a/dot_files/.config/nvim/lua/core/plugins/editor/nvim-surround.lua b/dot_files/.config/nvim/lua/core/plugins/editor/nvim-surround.lua new file mode 100644 index 0000000..3f7d205 --- /dev/null +++ b/dot_files/.config/nvim/lua/core/plugins/editor/nvim-surround.lua @@ -0,0 +1,13 @@ +-- surround +return { + "kylechui/nvim-surround", + version = "*", -- Use for stability; omit to use `main` branch for the latest features + event = "VeryLazy", + config = function() + require("nvim-surround").setup({ + keymaps = { + visual = "Y", + }, + }) + end +}