From 7c63964eb68b102e8b6f69d176120fad26f12baa Mon Sep 17 00:00:00 2001 From: "Christoph J. Scherr" Date: Fri, 19 Jan 2024 18:23:22 +0100 Subject: [PATCH] saner settings for me --- init.lua | 10 ++--- mappings.lua | 108 ++++++++++++++++++++++++++++++++++++++++++++++++--- plugins.lua | 60 +++++++++++++++++++++++++++- 3 files changed, 164 insertions(+), 14 deletions(-) diff --git a/init.lua b/init.lua index 608a8d9..aaaa68d 100644 --- a/init.lua +++ b/init.lua @@ -1,7 +1,3 @@ --- local autocmd = vim.api.nvim_create_autocmd - --- Auto resize panes when resizing nvim window --- autocmd("VimResized", { --- pattern = "*", --- command = "tabdo wincmd =", --- }) +local opt = vim.opt +local g = vim.g +g.maplocalleader = ";" diff --git a/mappings.lua b/mappings.lua index 29e23d7..c593ba3 100644 --- a/mappings.lua +++ b/mappings.lua @@ -1,21 +1,119 @@ ---@type MappingsTable -local M = {} +local M = { + n = { + [""] = "", + }, +} + +M.disabled = { + n = { + ["h"] = "", + [""] = "", + }, +} + +M.telescope = { + plugin = true, + + n = { + -- find + ["ff"] = { " Telescope find_files ", "Find files" }, + ["fa"] = { " Telescope find_files follow=true no_ignore=true hidden=true ", "Find all" }, + ["fw"] = { " Telescope live_grep ", "Live grep" }, + ["fb"] = { " Telescope buffers ", "Find buffers" }, + ["fh"] = { " Telescope help_tags ", "Help page" }, + ["fo"] = { " Telescope oldfiles ", "Find oldfiles" }, + ["fz"] = { " Telescope current_buffer_fuzzy_find ", "Find in current buffer" }, + + -- git + ["cm"] = { " Telescope git_commits ", "Git commits" }, + ["gt"] = { " Telescope git_status ", "Git status" }, + + -- pick a hidden term + ["pt"] = { " Telescope terms ", "Pick hidden term" }, + + -- theme switcher + ["th"] = { " Telescope themes ", "Nvchad themes" }, + + ["ma"] = { " Telescope marks ", "telescope bookmarks" }, + }, +} + +M.nvimtree = { + plugin = true, + + n = { + -- toggle + [""] = { " NvimTreeToggle ", "Toggle nvimtree" }, + [""] = { " NvimTreeToggle ", "Toggle nvimtree" }, + + -- focus + ["e"] = { " NvimTreeFocus ", "Focus nvimtree" }, + }, +} M.general = { + i = { + -- go to beginning and end + [""] = { "", "Beginning of line" }, + [""] = { "", "End of line" }, + + -- navigate within insert mode + [""] = { "", "Move left" }, + [""] = { "", "Move right" }, + [""] = { "", "Move down" }, + [""] = { "", "Move up" }, + }, n = { - [";"] = { ":", "enter command mode", opts = { nowait = true } }, + --big move + [""] = { "", "big step down"}, + [""] = { "", "big step down"}, + -- easy newline + ["OO"] = { "O", "insert a line above", opts = { nowait = true } }, + ["oo"] = { "o", "insert a line below", opts = { nowait = true } }, + + -- go to beginning and end + ["H"] = { "", "Beginning of line" }, + ["L"] = { "", "End of line" }, + + -- do something useful with the arrows + [""] = { "move-2==", "Move line up", opts = { expr = true } }, + [""] = { "move+==", "Move line down", opts = { expr = true } }, + [""] = { "<<", "Less indentation", opts = { expr = true } }, + [""] = { ">>", "More indentation", opts = { expr = true } }, -- format with conform - ["ff"] = { + ["fm"] = { function() require("conform").format() end, "formatting", - } + }, + ["tw"] = { + function() + vim.opt_local.wrap = not vim.wo.wrap + vim.opt_local.breakindent = not vim.wo.breakindent + + if vim.wo.colorcolumn == "" then + vim.opt_local.colorcolumn = tostring(vim.bo.textwidth) + else + vim.opt_local.colorcolumn = "" + end + end, + "toggle wrap", + }, }, v = { - [">"] = { ">gv", "indent"}, + -- go to beginning and end + ["H"] = { "", "Beginning of line" }, + ["L"] = { "", "End of line" }, + [""] = { ""] = { ">gv", "More indentation" }, + }, + x = { + [""] = { "move'<-2gv=gv", "Move line up", opts = { expr = true } }, + [""] = { "move'<-2gv=gv", "Move line down", opts = { expr = true } }, }, } diff --git a/plugins.lua b/plugins.lua index 822368c..189419a 100644 --- a/plugins.lua +++ b/plugins.lua @@ -1,4 +1,4 @@ -local overrides = require("custom.configs.overrides") +local overrides = require "custom.configs.overrides" ---@type NvPluginSpec[] local plugins = { @@ -16,7 +16,7 @@ local plugins = { -- override plugin configs { "williamboman/mason.nvim", - opts = overrides.mason + opts = overrides.mason, }, { @@ -46,6 +46,62 @@ local plugins = { require "custom.configs.conform" end, }, + { + -- NOTE: This is leap for selecting things! + "ggandor/flit.nvim", + config = function() + require("flit").setup { + keys = { f = "f", F = "F", t = "t", T = "T" }, + -- A string like "nv", "nvo", "o", etc. + labeled_modes = "nvo", + multiline = true, + -- Like `leap`s similar argument (call-specific overrides). + -- E.g.: opts = { equivalence_classes = {} } + opts = {}, + } + end, + enabled = true, + }, + { + "ggandor/leap.nvim", + -- stylua: ignore + keys = { + { 'gl', '(leap-forward-to)', mode = { 'n', 'x', 'o' }, desc = 'Leap forward to' }, + { 'gL', '(leap-backward-to)', mode = { 'n', 'x', 'o' }, desc = 'Leap backward to' }, + { 'wgl', '(leap-from-window)', mode = { 'n', 'x', 'o' }, desc = 'Leap to windows' }, + }, + config = function() + local leap = require "leap" + leap.opts.case_sensitive = false + leap.opts.safe_labels = { "f", "n", "u", "t", "g", "ö", "w", "b", "m" } + leap.opts.labels = { + "a", + "s", + "f", + "n", + "j", + "k", + "r", + "e", + "r", + "m", + "ö", + "b", + "v", + "u", + "z", + "w", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + } + end, + }, } return plugins