From 41c03f028bc38c0c7ee8d4acf583736a6334430a Mon Sep 17 00:00:00 2001 From: sadan <117494111+sadan4@users.noreply.github.com> Date: Sat, 13 Jul 2024 23:45:02 -0400 Subject: [PATCH] make things --- init.lua | 18 +++++++++++ lazy-lock.json | 11 +++++++ lua/keymap.lua | 81 +++++++++++++++++++++++++++++++++++++++++++++++++ lua/plugins.lua | 52 +++++++++++++++++++++++++++++++ lua/sets.lua | 12 ++++++++ lua/setup.lua | 2 ++ 6 files changed, 176 insertions(+) create mode 100644 init.lua create mode 100644 lazy-lock.json create mode 100644 lua/keymap.lua create mode 100644 lua/plugins.lua create mode 100644 lua/sets.lua create mode 100644 lua/setup.lua diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..f5689c1 --- /dev/null +++ b/init.lua @@ -0,0 +1,18 @@ +vim.g.mapleader = " " +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) +require"plugins" +require"setup" +require"keymap" +require"sets" + diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..a1611a7 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,11 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, + "eregex.vim": { "branch": "master", "commit": "09b444731e2ad806926a4a48d063bf54be1fd6a2" }, + "lazy.nvim": { "branch": "main", "commit": "b02c9eae6a250f98908c146d1dc1a891f5019f0a" }, + "nvim-autopairs": { "branch": "master", "commit": "78a4507bb9ffc9b00f11ae0ac48243d00cb9194d" }, + "nvim-treesitter": { "branch": "master", "commit": "7f4ac678770175cdf0d42c015f4a5b6e18b6cb33" }, + "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, + "suda.vim": { "branch": "master", "commit": "b97fab52f9cdeabe2bbb5eb98d82356899f30829" }, + "telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, + "tokyonight.nvim": { "branch": "main", "commit": "b357de8d1d8d0d90be0d7f7750c7aa7eb7f4b020" } +} \ No newline at end of file diff --git a/lua/keymap.lua b/lua/keymap.lua new file mode 100644 index 0000000..490a6da --- /dev/null +++ b/lua/keymap.lua @@ -0,0 +1,81 @@ +local tb = require("telescope.builtin") + +vim.g.mapleader = " " +-- find Files +vim.keymap.set("n", "f", tb.find_files, {}) +-- find Text +vim.keymap.set("n", "t", tb.live_grep, {}) +-- find Buffers +vim.keymap.set("n", "b", tb.buffers, {}) +-- find keyMaps +vim.keymap.set("n", "m", tb.keymaps, {}) +-- find Command +vim.keymap.set("n", "c", tb.commands, {}) +-- find Documentation +vim.keymap.set("n", "d", tb.man_pages, {}) +-- open tree +-- move and copy lines +vim.keymap.set({ "i", "n" }, "", function() + vim.api.nvim_feedkeys("ddkP", "x", false) +end, {}) +vim.keymap.set({ "i", "n" }, "", function() + vim.api.nvim_feedkeys("ddp", "x", false) +end, {}) +vim.keymap.set({ "i", "n" }, "", function() + vim.api.nvim_feedkeys("yyP", "x", false) +end, {}) +vim.keymap.set({ "i", "n" }, "", function() + vim.api.nvim_feedkeys("yyp", "x", false) +end, {}) +-- toggle function signature +-- format and vplit remaps +vim.keymap.set({ "n", "i" }, "", vim.cmd.Format, {}) +vim.keymap.set({ "i", "n" }, "", vim.cmd.vsplit, {}) +-- vscode fold and unfold +-- clangd switch source/header +-- goto mappings +vim.keymap.set("n", "gd", vim.lsp.buf.definition, {}) +vim.keymap.set("n", "gD", vim.lsp.buf.declaration, {}) +vim.keymap.set("n", "gi", vim.lsp.buf.implementation, {}) +vim.keymap.set("n", "", vim.lsp.buf.code_action, {}) +-- lsp rename +vim.keymap.set("n", "", vim.lsp.buf.rename, {}) +vim.keymap.set({ "n", "v" }, ";", ":") + +vim.keymap.set("n", "/", ":call eregex#toggle()", { + noremap = true, +}) +vim.keymap.set("n", "w", ":SudaWrite", { + noremap = true, +}) +vim.keymap.set("v", "h", ":S/", { + noremap = true, +}) +vim.keymap.set("n", "h", ":%S/", { + noremap = true, +}) +-- open command line with the path of current buffer already inserted +vim.keymap.set("n", "e", function() + -- print((":e " .. string.gsub(vim.fn.expand("%"), '(.*/)(.*)', '%1'))); + vim.api.nvim_feedkeys((":e " .. string.gsub(vim.fn.expand("%"), "(.*/)(.*)", "%1")), "L", false) +end) +-- training +vim.keymap.set("n", "", ':echoe "Use h"') +vim.keymap.set("n", "", ':echoe "Use l"') +vim.keymap.set("n", "", ':echoe "Use k"') +vim.keymap.set("n", "", ':echoe "Use j"') + +vim.keymap.set("i", "", ':echoe "Use h"i') +vim.keymap.set("i", "", ':echoe "Use l"i') +vim.keymap.set("i", "", ':echoe "Use k"i') +vim.keymap.set("i", "", ':echoe "Use j"i') +-- https://stackoverflow.com/questions/1841480/how-to-use-lowercase-marks-as-global-in-vim +-- Use lowercase for global marks and uppercase for local marks. +local low = function(i) return string.char(97+i) end +local upp = function(i) return string.char(65+i) end + +for i=0,25 do vim.keymap.set("n", "m"..low(i), "m"..upp(i)) end +for i=0,25 do vim.keymap.set("n", "m"..upp(i), "m"..low(i)) end +for i=0,25 do vim.keymap.set("n", "'"..low(i), "'"..upp(i)) end +for i=0,25 do vim.keymap.set("n", "'"..upp(i), "'"..low(i)) end + diff --git a/lua/plugins.lua b/lua/plugins.lua new file mode 100644 index 0000000..9ef7874 --- /dev/null +++ b/lua/plugins.lua @@ -0,0 +1,52 @@ +local plugins = { + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + }, + { + "windwp/nvim-autopairs", + event = "InsertEnter", + config = true, + -- use opts = {} for passing setup options + -- this is equalent to setup({}) function + opts = {}, + }, + { + "nvim-telescope/telescope.nvim", + tag = "0.1.5", + opts = { + extensions = { + fzf = { + fuzzy = true, -- false will only do exact matching + override_generic_sorter = true, -- override the generic sorter + override_file_sorter = true, -- override the file sorter + case_mode = "ignore_case", -- or "ignore_case" or "respect_case" or smart_case + -- the default case_mode is "smart_case" + }, + }, + }, + dependencies = { "nvim-lua/plenary.nvim" }, + }, + { + "numToStr/Comment.nvim", + opts = { + -- add any options here + }, + lazy = false, + }, + { + "sadan4/eregex.vim", + }, + { + "lambdalisue/suda.vim", + }, + { + "folke/tokyonight.nvim", + lazy = false, + priority = 1000, + opts = {}, + }, + +}; +local opts = {}; +require"lazy".setup(plugins, opts) diff --git a/lua/sets.lua b/lua/sets.lua new file mode 100644 index 0000000..3af8a73 --- /dev/null +++ b/lua/sets.lua @@ -0,0 +1,12 @@ +vim.opt.rnu = true +vim.opt.expandtab = true +vim.opt.tabstop = 4 +vim.opt.smarttab = true +vim.opt.shiftround = true +vim.opt.shiftwidth = 4 +vim.opt.smartcase = true +vim.opt.ignorecase = true +vim.opt.scrolloff = 6 +-- eregex.vim +vim.g.eregex_default_enable = 1 + diff --git a/lua/setup.lua b/lua/setup.lua new file mode 100644 index 0000000..e8cec13 --- /dev/null +++ b/lua/setup.lua @@ -0,0 +1,2 @@ +vim.cmd([[colorscheme tokyonight]]) +