From d1a430248ac9dabf40f9d258ff12eb63f7f9a5ec Mon Sep 17 00:00:00 2001 From: ch1bs Date: Sun, 19 May 2024 23:59:17 +0300 Subject: [PATCH] add addons, some prefs --- README.md | 2 +- init.lua | 32 ++++++++++++++++----------- lua/custom/plugins/fugitive.lua | 38 +++++++++++++++++++++++++++++++++ lua/custom/plugins/undotree.lua | 7 ++++++ lua/custom/plugins/zenmode.lua | 32 +++++++++++++++++++++++++++ 5 files changed, 98 insertions(+), 13 deletions(-) create mode 100644 lua/custom/plugins/fugitive.lua create mode 100644 lua/custom/plugins/undotree.lua create mode 100644 lua/custom/plugins/zenmode.lua diff --git a/README.md b/README.md index f445b65e..2de4d4a0 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ git clone https://github.com/nvim-lua/kickstart.nvim.git %userprofile%\AppData\L If you're using `powershell.exe` ``` -git clone https://github.com/nvim-lua/kickstart.nvim.git $env:USERPROFILE\AppData\Local\nvim\ +gimv /home/user/oldname /home/user/newnamet clone https://github.com/nvim-lua/kickstart.nvim.git $env:USERPROFILE\AppData\Local\nvim\ ``` diff --git a/init.lua b/init.lua index 88658ef3..4c80c36d 100644 --- a/init.lua +++ b/init.lua @@ -91,7 +91,7 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = false +vim.g.have_nerd_font = true -- [[ Setting options ]] -- See `:help vim.opt` @@ -118,8 +118,15 @@ vim.opt.clipboard = 'unnamedplus' -- Enable break indent vim.opt.breakindent = true +-- My settings +vim.opt.smartindent = true +vim.opt.wrap = false +vim.opt.swapfile = false +vim.opt.backup = false + -- Save undo history vim.opt.undofile = true +vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" -- Case-insensitive searching UNLESS \C or one or more capital letters in the search term vim.opt.ignorecase = true @@ -238,7 +245,7 @@ require('lazy').setup({ -- require('Comment').setup({}) -- "gc" to comment visual regions/lines - { 'numToStr/Comment.nvim', opts = {} }, + { 'numToStr/Comment.nvim', opts = {} }, -- Here is a more advanced example where we pass configuration -- options to `gitsigns.nvim`. This is equivalent to the following Lua: @@ -273,7 +280,7 @@ require('lazy').setup({ -- after the plugin has been loaded: -- config = function() ... end - { -- Useful plugin to show you pending keybinds. + { -- Useful plugin to show you pending keybinds. 'folke/which-key.nvim', event = 'VimEnter', -- Sets the loading event to 'VimEnter' config = function() -- This is the function that runs, AFTER loading @@ -325,7 +332,7 @@ require('lazy').setup({ { 'nvim-telescope/telescope-ui-select.nvim' }, -- Useful for getting pretty icons, but requires a Nerd Font. - { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, + { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, }, config = function() -- Telescope is a fuzzy finder that comes with a lot of different things that @@ -418,11 +425,11 @@ require('lazy').setup({ -- Useful status updates for LSP. -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` - { 'j-hui/fidget.nvim', opts = {} }, + { 'j-hui/fidget.nvim', opts = {} }, -- `neodev` configures Lua LSP for your Neovim config, runtime and plugins -- used for completion, annotations and signatures of Neovim apis - { 'folke/neodev.nvim', opts = {} }, + { 'folke/neodev.nvim', opts = {} }, }, config = function() -- Brief aside: **What is LSP?** @@ -605,9 +612,9 @@ require('lazy').setup({ -- You can add other tools here that you want Mason to install -- for you, so that they are available from within Neovim. local ensure_installed = vim.tbl_keys(servers or {}) - vim.list_extend(ensure_installed, { - 'stylua', -- Used to format Lua code - }) + --vim.list_extend(ensure_installed, { + -- 'stylua', -- Used to format Lua code + --}) require('mason-tool-installer').setup { ensure_installed = ensure_installed } require('mason-lspconfig').setup { @@ -785,7 +792,8 @@ require('lazy').setup({ -- Like many other themes, this one has different styles, and you could load -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. vim.cmd.colorscheme 'tokyonight-night' - + vim.api.nvim_set_hl(0, "Normal", { bg = "none" }) + vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" }) -- You can configure highlights by doing something like: vim.cmd.hi 'Comment gui=none' end, @@ -835,7 +843,7 @@ require('lazy').setup({ 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc' }, + ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc', 'python' }, -- Autoinstall languages that are not installed auto_install = true, highlight = { @@ -885,7 +893,7 @@ require('lazy').setup({ -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, }, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the diff --git a/lua/custom/plugins/fugitive.lua b/lua/custom/plugins/fugitive.lua new file mode 100644 index 00000000..7104c7ac --- /dev/null +++ b/lua/custom/plugins/fugitive.lua @@ -0,0 +1,38 @@ +return { + "tpope/vim-fugitive", + config = function() + vim.keymap.set("n", "gs", vim.cmd.Git) + + local Chibs_Fugitive = vim.api.nvim_create_augroup("ThePrimeagen_Fugitive", {}) + + local autocmd = vim.api.nvim_create_autocmd + autocmd("BufWinEnter", { + group = Chibs_Fugitive, + pattern = "*", + callback = function() + if vim.bo.ft ~= "fugitive" then + return + end + + local bufnr = vim.api.nvim_get_current_buf() + local opts = { buffer = bufnr, remap = false } + vim.keymap.set("n", "p", function() + vim.cmd.Git('push') + end, opts) + + -- rebase always + vim.keymap.set("n", "P", function() + vim.cmd.Git({ 'pull', '--rebase' }) + end, opts) + + -- NOTE: It allows me to easily set the branch i am pushing and any tracking + -- needed if i did not set the branch up correctly + vim.keymap.set("n", "t", ":Git push -u origin ", opts); + end, + }) + + + vim.keymap.set("n", "gu", "diffget //2") + vim.keymap.set("n", "gh", "diffget //3") + end +} diff --git a/lua/custom/plugins/undotree.lua b/lua/custom/plugins/undotree.lua new file mode 100644 index 00000000..c2a46cdc --- /dev/null +++ b/lua/custom/plugins/undotree.lua @@ -0,0 +1,7 @@ +return { + "mbbill/undotree", + + config = function() + vim.keymap.set("n", "u", vim.cmd.UndotreeToggle) + end +} diff --git a/lua/custom/plugins/zenmode.lua b/lua/custom/plugins/zenmode.lua new file mode 100644 index 00000000..b1cfb470 --- /dev/null +++ b/lua/custom/plugins/zenmode.lua @@ -0,0 +1,32 @@ +return { + "folke/zen-mode.nvim", + config = function() + vim.keymap.set("n", "zz", function() + require("zen-mode").setup { + window = { + width = 90, + options = {} + }, + } + require("zen-mode").toggle() + vim.wo.wrap = false + vim.wo.number = true + vim.wo.rnu = true + end) + + + vim.keymap.set("n", "zZ", function() + require("zen-mode").setup { + window = { + width = 80, + options = {} + }, + } + require("zen-mode").toggle() + vim.wo.wrap = false + vim.wo.number = false + vim.wo.rnu = false + vim.opt.colorcolumn = "0" + end) + end +}