From df97b1979e3e7bc6933c4ce195ddb147c755cd3d Mon Sep 17 00:00:00 2001 From: km Date: Thu, 14 Nov 2024 16:22:23 +0000 Subject: [PATCH] position cursor at last position add colorschemes move keymaps to keymaps section disable undofile --- init.lua | 74 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 54 insertions(+), 20 deletions(-) diff --git a/init.lua b/init.lua index ddfaeb00..0050d6e8 100644 --- a/init.lua +++ b/init.lua @@ -102,7 +102,6 @@ vim.g.have_nerd_font = false -- You can also add relative line numbers, to help with jumping. vim.opt.number = false vim.opt.relativenumber = false -vim.keymap.set('n', 'n', ':set number!:set relativenumber!') -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' @@ -122,7 +121,7 @@ end) vim.opt.breakindent = true -- Save undo history -vim.opt.undofile = true +vim.opt.undofile = false -- Case-insensitive searching UNLESS \C or one or more capital letters in the search term vim.opt.ignorecase = true @@ -157,6 +156,23 @@ vim.opt.cursorline = true -- Minimal number of screen lines to keep above and below the cursor. vim.opt.scrolloff = 10 +-- Restore cursor position form last file open +vim.api.nvim_create_autocmd('BufRead', { + callback = function(opts) + vim.api.nvim_create_autocmd('BufWinEnter', { + once = true, + buffer = opts.buf, + callback = function() + local ft = vim.bo[opts.buf].filetype + local last_known_line = vim.api.nvim_buf_get_mark(opts.buf, '"')[1] + if not (ft:match 'commit' and ft:match 'rebase') and last_known_line > 1 and last_known_line <= vim.api.nvim_buf_line_count(opts.buf) then + vim.api.nvim_feedkeys([[g`"]], 'nx', false) + end + end, + }) + end, +}) + -- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` @@ -175,12 +191,6 @@ vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagn -- or just use to exit terminal mode vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) --- TIP: Disable arrow keys in normal mode --- vim.keymap.set('n', '', 'echo "Use h to move!!"') --- vim.keymap.set('n', '', 'echo "Use l to move!!"') --- vim.keymap.set('n', '', 'echo "Use k to move!!"') --- vim.keymap.set('n', '', 'echo "Use j to move!!"') - -- Keybinds to make split navigation easier. -- Use CTRL+ to switch between windows -- @@ -190,6 +200,12 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the right win vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) +-- Toggles +-- Line numbers +vim.keymap.set('n', 'n', ':set number!:set relativenumber!') +-- Gitsigns +vim.keymap.set('n', 'g', ':Gitsigns toggle_signs', { desc = 'Toggle Gitsigns' }) + -- [[ Basic Autocommands ]] -- See `:help lua-guide-autocommands` @@ -437,6 +453,12 @@ require('lazy').setup({ end, }, + { -- Lush colorscheme helper + 'rktjmp/lush.nvim', + -- if you wish to use your own colorscheme: + -- { dir = '/absolute/path/to/colorscheme', lazy = true }, + }, + -- LSP Plugins { -- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins @@ -833,24 +855,36 @@ require('lazy').setup({ end, }, - { -- You can easily change to a different colorscheme. - -- Change the name of the colorscheme plugin below, and then - -- change the command in the config to whatever the name of that colorscheme is. - -- - -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. + -- + -- COLORSCHEMES + -- + { -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. 'folke/tokyonight.nvim', priority = 1000, -- Make sure to load this before all the other start plugins. init = function() - -- Load the colorscheme here. - -- 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' - - -- You can configure highlights by doing something like: vim.cmd.hi 'Comment gui=none' + vim.cmd.colorscheme 'tokyonight' + end, + }, + + { 'zenbones-theme/zenbones.nvim', dependencies = 'rktjmp/lush.nvim', lazy = false, priority = 1000 }, + { 'catppuccin/nvim', name = 'catppuccin', priority = 1000 }, + { 'navarasu/onedark.nvim', name = 'onedark', priority = 1000 }, + { 'scottmckendry/cyberdream.nvim', lazy = false, priority = 1000 }, + + { + 'yorik1984/newpaper.nvim', + priority = 1000, + config = function() + vim.g.newpaper_style = 'light' end, }, + { + 'rebelot/kanagawa.nvim', + priority = 1000, + }, + -- Highlight todo, notes, etc in comments { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, @@ -937,7 +971,7 @@ require('lazy').setup({ -- This is the easiest way to modularize your config. -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, -- -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` -- Or use telescope!