From 1955917e7cc4d21890695dbe259e77df25cb717a Mon Sep 17 00:00:00 2001 From: Luca Matei Pintilie Date: Thu, 11 Apr 2024 21:30:53 +0200 Subject: nvim: Add plain mode --- .config/nvim/lua/keybinds.lua | 97 ++++++++++++++++++++++++++++--------------- 1 file changed, 64 insertions(+), 33 deletions(-) diff --git a/.config/nvim/lua/keybinds.lua b/.config/nvim/lua/keybinds.lua index 69b2b8c..5669398 100644 --- a/.config/nvim/lua/keybinds.lua +++ b/.config/nvim/lua/keybinds.lua @@ -3,6 +3,7 @@ local wk = require("which-key") local ufo = require("ufo") local nt_api = require("nvim-tree.api") local spider = require("spider") +local lualine = require('lualine') vim.g.mapleader = " " @@ -21,7 +22,7 @@ vim.keymap.set("i", "", "") vim.keymap.set("n", "n", nt_api.tree.toggle) vim.keymap.set("n", "", vim.lsp.buf.code_action) vim.keymap.set("n", "K", vim.lsp.buf.hover) -vim.keymap.set({ "n"; "v" }, "F", vim.lsp.buf.format) +vim.keymap.set({ "n", "v" }, "F", vim.lsp.buf.format) vim.keymap.set("n", "d", vim.diagnostic.open_float) vim.keymap.set("n", "J", vim.lsp.buf.signature_help) @@ -44,44 +45,74 @@ vim.keymap.set("n", "]", ufo.closeAllFolds) vim.keymap.set("n", "r", vim.lsp.buf.rename) vim.keymap.set("n", "N", ":bnext") vim.keymap.set("n", "P", ":bprevious") +vim.keymap.set("n", "L", function() + vim.o.number = not (vim.o.number) + vim.o.relativenumber = not (vim.o.relativenumber) + vim.o.cursorline = not (vim.o.cursorline) + vim.o.list = not (vim.o.list) + vim.o.foldenable = not (vim.o.foldenable) + if vim.o.foldcolumn == "1" + then + vim.o.foldcolumn = "0" + else + vim.o.foldcolumn = "1" + end + if vim.g.__plain + then + lualine.hide({ unhide = true }) + vim.o.laststatus = 2 + vim.diagnostic.enable() + else + lualine.hide() + vim.o.laststatus = 0 + vim.diagnostic.disable() + end + vim.cmd [[ MarksToggleSigns ]] + vim.cmd [[ IBLToggle ]] + vim.cmd [[ BufferLineGroupToggle ungrouped ]] + vim.cmd [[ TSContextToggle ]] + + vim.g.__plain = not (vim.g.__plain) +end) local spider_opts = { skipInsignificantPunctuation = true } -vim.keymap.set({ "n"; "o"; "x" }, "", - function() spider.motion("w", spider_opts) end) -vim.keymap.set({ "n"; "o"; "x" }, "", - function() spider.motion("e", spider_opts) end) -vim.keymap.set({ "n"; "o"; "x" }, "", - function() spider.motion("b", spider_opts) end) -vim.keymap.set({ "n"; "o"; "x" }, "", - function() spider.motion("ge", spider_opts) end) +vim.keymap.set({ "n", "o", "x" }, "", + function() spider.motion("w", spider_opts) end) +vim.keymap.set({ "n", "o", "x" }, "", + function() spider.motion("e", spider_opts) end) +vim.keymap.set({ "n", "o", "x" }, "", + function() spider.motion("b", spider_opts) end) +vim.keymap.set({ "n", "o", "x" }, "", + function() spider.motion("ge", spider_opts) end) vim.keymap.set({ "t" }, "", "") vim.opt.whichwrap = "<,>,h,l,[,]" wk.register({ - [""] = "Quick Action"; - ["K"] = "Hover"; - ["D"] = "Definition"; - ["S"] = "Symbols"; - ["F"] = "Format"; - ["f"] = "Find files"; - [""] = "Show buffers"; - [","] = "Show errors"; - ["["] = "Open folds"; - ["]"] = "Close folds"; - ["r"] = "Rename"; - ["n"] = "Show file tree"; - ["m"] = "Toggle Minimap"; - ["b"] = "Blame line"; - ["h"] = "Preview hunk"; - ["d"] = "Show diagnostics"; - ["t"] = "Open terminal"; - ["s"] = "Save file"; - ["q"] = "Quit"; - ["R"] = "Show References"; - ["J"] = "Signature help"; - ["U"] = "Undo tree"; - ["N"] = "Next tab"; - ["P"] = "Previous tab"; + [""] = "Quick Action", + ["K"] = "Hover", + ["D"] = "Definition", + ["S"] = "Symbols", + ["F"] = "Format", + ["f"] = "Find files", + [""] = "Show buffers", + [","] = "Show errors", + ["["] = "Open folds", + ["]"] = "Close folds", + ["r"] = "Rename", + ["n"] = "Show file tree", + ["m"] = "Toggle Minimap", + ["b"] = "Blame line", + ["h"] = "Preview hunk", + ["d"] = "Show diagnostics", + ["t"] = "Open terminal", + ["s"] = "Save file", + ["q"] = "Quit", + ["R"] = "Show References", + ["J"] = "Signature help", + ["U"] = "Undo tree", + ["N"] = "Next tab", + ["P"] = "Previous tab", + ["L"] = "Toggle plain mode", }, { prefix = "" }); -- cgit v1.2.3