Browse Source

nvim: surround+codewindow

dev_01_initial
Heiko Blobner 2 years ago
parent
commit
9091f905f1
  1. 4
      dot_files/.config/nvim/lua/core/config/options.lua
  2. 22
      dot_files/.config/nvim/lua/core/plugins/editor/codewindow.lua
  3. 33
      dot_files/.config/nvim/lua/core/plugins/editor/mini-surround.lua
  4. 13
      dot_files/.config/nvim/lua/core/plugins/editor/nvim-surround.lua

4
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.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.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.expandtab = true -- convert tabs to spaces
vim.opt.shiftwidth = 2 -- the number of spaces inserted for each indentation vim.opt.shiftwidth = 4 -- the number of spaces inserted for each indentation
vim.opt.tabstop = 2 -- insert 2 spaces for a tab vim.opt.tabstop = 4 -- insert 4 spaces for a tab
--vim.opt.cursorline = true -- highlight the current line --vim.opt.cursorline = true -- highlight the current line
vim.opt.relativenumber = true -- set numbered lines vim.opt.relativenumber = true -- set numbered lines
vim.opt.laststatus = 3 -- only the last window will always have a status line vim.opt.laststatus = 3 -- only the last window will always have a status line

22
dot_files/.config/nvim/lua/core/plugins/editor/codewindow.lua

@ -2,9 +2,9 @@
return { return {
'gorbit99/codewindow.nvim', 'gorbit99/codewindow.nvim',
version = '*', version = '*',
config = function() config = function(_, opts)
local codewindow = require('codewindow') local codewindow = require('codewindow')
codewindow.setup() codewindow.setup(opts)
codewindow.apply_default_keybinds() codewindow.apply_default_keybinds()
end, end,
dependencies = { 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 = { keys = {
{ "<leader>umo", function() require("codewindow").open_minimap() end, desc = "open the minimap" }, { "<leader>umo", function() require("codewindow").open_minimap() end, desc = "open the minimap" },
{ "<leader>umc", function() require("codewindow").close_minimap() end, desc = "close the minimap" }, { "<leader>umc", function() require("codewindow").close_minimap() end, desc = "close the minimap" },

33
dot_files/.config/nvim/lua/core/plugins/editor/mini-surround.lua

@ -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`
},
},
}

13
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
}
Loading…
Cancel
Save