From 877b1d63034507d16c854c117df680ec00c8a9f1 Mon Sep 17 00:00:00 2001 From: histalek Date: Mon, 11 Sep 2023 12:32:48 +0200 Subject: [PATCH] feat(nvim): Set some keymaps and specify options --- .config/nvim/lua/config/keymaps.lua | 41 +++++++++++++++++++++++++- .config/nvim/lua/config/options.lua | 45 +++++++++++++++++++++++++++-- 2 files changed, 83 insertions(+), 3 deletions(-) diff --git a/.config/nvim/lua/config/keymaps.lua b/.config/nvim/lua/config/keymaps.lua index 2c134f7..95ef4f0 100644 --- a/.config/nvim/lua/config/keymaps.lua +++ b/.config/nvim/lua/config/keymaps.lua @@ -1,3 +1,42 @@ -- Keymaps are automatically loaded on the VeryLazy event --- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua +-- Default keymaps that are always set: +-- https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua -- Add any additional keymaps here + +-- copied from LazyVim +local function map(mode, lhs, rhs, opts) + local keys = require("lazy.core.handler").handlers.keys + ---@cast keys LazyKeysHandler + -- do not create the keymap if a lazy keys handler exists + if not keys.active[keys.parse({ lhs, mode = mode }).id] then + opts = opts or {} + opts.silent = opts.silent ~= false + if opts.remap and not vim.g.vscode then + opts.remap = nil + end + vim.keymap.set(mode, lhs, rhs, opts) + end +end + +-- I fatfinger these often, but i'm not using their functionality. Just NOP them +map("n", "Q", "") +map("n", "@", "") + +-- move when highlighted +map("v", "J", ":m '>+1gv=gv") +map("v", "K", ":m '<-2gv=gv") + +-- keep cursor in the middle while jumping +map("n", "", "zz") +map("n", "", "zz") +map("n", "n", "nzzzv") +map("n", "N", "Nzzzv") + +-- delete to void bindings +map("n", "d", '"_d') +map("v", "d", '"_d') + +-- yank and paste to system clipboard +map("n", "y", '"+y') +map("v", "y", '"+y') +map("n", "Y", '"+Y') diff --git a/.config/nvim/lua/config/options.lua b/.config/nvim/lua/config/options.lua index f6ce9dd..effa8f3 100644 --- a/.config/nvim/lua/config/options.lua +++ b/.config/nvim/lua/config/options.lua @@ -1,5 +1,46 @@ -- Options are automatically loaded before lazy.nvim startup -- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua -- Add any additional options here -vim.opt.wrap = true -vim.opt.langmap = "ü[,+]" + +local opt = vim.opt + +vim.g.loaded_perl_provider = 0 +vim.g.loaded_python3_provider = 0 +vim.g.loaded_node_provider = 0 +vim.g.loaded_ruby_provider = 0 + +-- just QWERTZ things +opt.langmap = "ü[,+]" + +-- don't use system clipboard by default (this is set in LazyVim's defaults) +opt.clipboard = "" + +opt.hlsearch = false +opt.incsearch = true + +opt.scrolloff = 8 + +-- disable mouse support, because i'm using it more accidentally then intentionally +-- TODO figure out how to disable mouse scrolling from terminal +opt.mouse = "" +opt.mousescroll = "ver:0,hor:0" + +-- I like 4 space indents +opt.tabstop = 4 +opt.softtabstop = 4 +opt.shiftwidth = 4 +opt.expandtab = true + +opt.swapfile = false +opt.backup = false +opt.undodir = os.getenv("HOME") .. "/.local/state/nvim/undodir" +opt.undofile = true + +-- In my current setup 100 characters line length means that i can have 2 windows side-by-side with +-- sway and still see all characters of that line. (110 would be the absolute maximum) +-- I want to rely on textwrap as few as possible +opt.colorcolumn = "100" +opt.wrap = true + +-- This allows '@' in filenames +opt.isfname:append("@-@")