From b1534ae67bf1db6b8c587dabd1f8d6d5ce26348d Mon Sep 17 00:00:00 2001 From: speedie Date: Wed, 7 Feb 2024 18:25:12 +0100 Subject: [PATCH] speedie-nvim | Add new config --- .config/nvim/init.lua | 121 +++++++++++++----------- .config/nvim/lua/setup.lua | 2 + .config/nvim/lua/swapbuffers_config.lua | 10 ++ .config/nvim/lua/whichkey_config.lua | 6 ++ 4 files changed, 83 insertions(+), 56 deletions(-) create mode 100644 .config/nvim/lua/swapbuffers_config.lua create mode 100644 .config/nvim/lua/whichkey_config.lua diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 07102a6..c7b579a 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -79,18 +79,20 @@ Plugins = { -- Plugins to use 'nvim-treesitter/nvim-treesitter', }, }, -- Indentation blankline - { 'folke/trouble.nvim' }, -- Display warnings and errors neatly { 'uga-rosa/translate.nvim' }, -- Built in translate + { 'folke/trouble.nvim' }, -- Display warnings and errors neatly { 'folke/noice.nvim', event = 'VeryLazy', dependencies = { 'MunifTanjim/nui.nvim', 'rcarriga/nvim-notify', }, }, -- Message boxes + { 'folke/which-key.nvim' }, -- Display possible keybinds { 'rainbowhxch/accelerated-jk.nvim' }, -- Accelerated movement { 'NvChad/nvim-colorizer.lua' }, -- Colorize #RRGGBB text { 'RRethy/vim-illuminate' }, -- Highlight other instances of the cursor position word { 'stevearc/aerial.nvim' }, -- Object viewer + { 'caenrique/swap-buffers.nvim' }, -- Swap buffers { 'LunarVim/bigfile.nvim' }, -- Disable heavy features if the file is big } @@ -98,6 +100,7 @@ require('bootstrap') -- Set up Lazy and plugins. opt.title = true -- Display title opt.spelllang = 'en_us' -- Use English (United States) as spellcheck language by default +opt.number = false -- Show line numbers opt.relativenumber = true -- Show relative line numbers opt.mouse = 'a' -- Enable mouse opt.clipboard = 'unnamedplus' -- Use system clipboard @@ -109,7 +112,9 @@ opt.hlsearch = false -- Don't highlight searches opt.smartindent = true -- Automatically indent the next line opt.autoindent = true -- Pretty much same for this one opt.expandtab = true -- Replace tabs with spaces automatically +opt.autoread = true -- Automatically reload a file if it has been modified. opt.swapfile = false -- Don't use a swapfile +opt.writebackup = true -- Back up, to prevent against potential crashes opt.cursorline = true -- Show the cursor line opt.undolevels = 10000 -- Allow up to 10000 undos opt.tabstop = 4 -- Display a tab (\t) as 4 spaces @@ -117,73 +122,77 @@ opt.softtabstop = 4 -- Display a tab (\t) as 4 spaces opt.shiftwidth = 4 -- Indents for << or >> opt.spellsuggest = 'best,5' -- Prefer the best suggestions opt.foldmethod = 'indent' -- Fold based on indents +opt.timeoutlen = 0 -- Show keybinds after this many milliseconds opt.termguicolors = true -- Enable true color opt.autochdir = true -- Automatically change directory to the file we're editing -opt.background = 'dark' -- Set background to dark -opt.fillchars = { +opt.fillchars = { -- Display tab indents using this character vert = '▏', } -- Keybinds for handling splits -keymap('n', '', 'h', defaultKeybindOptions) -keymap('n', '', 'j', defaultKeybindOptions) -keymap('n', '', 'k', defaultKeybindOptions) -keymap('n', '', 'l', defaultKeybindOptions) -keymap('n', '', 'split', defaultKeybindOptions) -keymap('n', '', 'vsplit', defaultKeybindOptions) -keymap('n', '', 'only', defaultKeybindOptions) -keymap('n', '', 'term', defaultKeybindOptions) -keymap('n', '', 'Telescope fd', defaultKeybindOptions) -keymap('n', 'H', 'vertical resize -10', defaultKeybindOptions) -keymap('n', 'J', 'resize -10', defaultKeybindOptions) -keymap('n', 'K', 'resize +10', defaultKeybindOptions) -keymap('n', 'L', 'vertical resize +10', defaultKeybindOptions) +keymap('n', '', 'h', defaultKeybindOptions) -- Move left +keymap('n', '', 'j', defaultKeybindOptions) -- Move down +keymap('n', '', 'k', defaultKeybindOptions) -- Move up +keymap('n', '', 'l', defaultKeybindOptions) -- Move right +keymap('n', '', 'split', defaultKeybindOptions) -- Split horizontally +keymap('n', '', 'vsplit', defaultKeybindOptions) -- Split vertically +keymap('n', '', 'only', defaultKeybindOptions) -- Close all buffers except selected +keymap('n', '', 'vertical resize -10', defaultKeybindOptions) -- Decrease size vertically by 10 +keymap('n', '', 'resize -10', defaultKeybindOptions) -- Decrease size horizontally by 10 +keymap('n', '', 'resize +10', defaultKeybindOptions) -- Increase size horizontally by 10 +keymap('n', '', 'vertical resize +10', defaultKeybindOptions) -- Increase size vertically by 10 +keymap('n', '', 'lua require("swap-buffers").swap_buffers("h")', defaultKeybindOptions) -- Decrease size vertically by 10 +keymap('n', '', 'lua require("swap-buffers").swap_buffers("j")', defaultKeybindOptions) -- Decrease size vertically by 10 +keymap('n', '', 'lua require("swap-buffers").swap_buffers("k")', defaultKeybindOptions) -- Decrease size vertically by 10 +keymap('n', '', 'lua require("swap-buffers").swap_buffers("l")', defaultKeybindOptions) -- Decrease size vertically by 10 +keymap('n', '', 'term', defaultKeybindOptions) -- Open a terminal emulator -- Keybinds for language/spell -keymap('n', '', 'set spell!', defaultKeybindOptions) -keymap('n', '', 'set spelllang=en_us', defaultKeybindOptions) -keymap('n', '', 'set spelllang=sv_se', defaultKeybindOptions) -keymap('n', '', 'silent execute "!setxkbmap us"', defaultKeybindOptions) -keymap('n', '', 'silent execute "!setxkbmap se"', defaultKeybindOptions) -keymap('n', 'ca', 'z=', defaultKeybindOptions) +keymap('n', '', 'set spell!', defaultKeybindOptions) -- Enable spell check +keymap('n', '', 'set spelllang=en_us', defaultKeybindOptions) -- Set spell check langauge to English (United States) +keymap('n', '', 'set spelllang=sv_se', defaultKeybindOptions) -- Set spell check language to Swedish +keymap('n', '', 'silent execute "!setxkbmap us"', defaultKeybindOptions) -- Set keyboard layout to English (United States) +keymap('n', '', 'silent execute "!setxkbmap se"', defaultKeybindOptions) -- Set keyboard layout to Swedish +keymap('n', 'ca', 'z=', defaultKeybindOptions) -- Suggest suitable spell check replacements -- Miscellanious -keymap('n', '', 'tab :new', defaultKeybindOptions) -keymap('n', 'j', '(accelerated_jk_j)', defaultKeybindOptions) -keymap('n', 'k', '(accelerated_jk_k)', defaultKeybindOptions) -keymap('n', 'gj', '(accelerated_jk_gj)', defaultKeybindOptions) -keymap('n', 'gk', '(accelerated_jk_gk)', defaultKeybindOptions) -keymap('n', 'd', '"_d', defaultKeybindOptions) -keymap('x', 'd', '"_d', defaultKeybindOptions) -keymap('x', 'p', '"_dP', defaultKeybindOptions) -keymap('n', 'c', '"_c', defaultKeybindOptions) -keymap('n', 'ZX', 'q!', defaultKeybindOptions) -keymap('n', 'Zz', 'w!', defaultKeybindOptions) -keymap('n', '', 'v/{%', defaultKeybindOptions) -keymap('n', '', 'NvimTreeToggle', defaultKeybindOptions) -keymap('n', '.', 'TroubleToggle', defaultKeybindOptions) -keymap('n', ',', 'AerialToggle', defaultKeybindOptions) -keymap('n', 'G', 'Neogit', defaultKeybindOptions) -keymap('n', 'gt', 'Gitsigns toggle_current_line_blame', defaultKeybindOptions) +keymap('n', '', 'tab :new', defaultKeybindOptions) -- Create new buffer +keymap('n', 'j', '(accelerated_jk_j)', defaultKeybindOptions) -- Move down +keymap('n', 'k', '(accelerated_jk_k)', defaultKeybindOptions) -- Move up +keymap('n', 'gj', '(accelerated_jk_gj)', defaultKeybindOptions) -- Move down (line wrapping) +keymap('n', 'gk', '(accelerated_jk_gk)', defaultKeybindOptions) -- Move up (line wrapping) +keymap('n', 'd', '"_d', defaultKeybindOptions) -- Delete without yanking +keymap('x', 'd', '"_d', defaultKeybindOptions) -- Delete without yanking +keymap('x', 'p', '"_dP', defaultKeybindOptions) -- Paste without clearing clipboard +keymap('n', 'c', '"_c', defaultKeybindOptions) -- Change without yanking +keymap('n', 'ZX', 'q!', defaultKeybindOptions) -- Quit without saving +keymap('n', 'Zz', 'w!', defaultKeybindOptions) -- Save +keymap('n', '', 'v/{%', defaultKeybindOptions) -- Select an entire function +keymap('n', '', 'NvimTreeToggle', defaultKeybindOptions) -- Toggle NvimTree +keymap('n', '.', 'TroubleToggle', defaultKeybindOptions) -- Toggle Trouble +keymap('n', ',', 'AerialToggle', defaultKeybindOptions) -- Toggle Aerial +keymap('n', 'G', 'Neogit', defaultKeybindOptions) -- Toggle Neogit +keymap('n', 'gt', 'Gitsigns toggle_current_line_blame', defaultKeybindOptions) -- Toggle current line blame +keymap('n', '', 'Telescope fd', defaultKeybindOptions) -- Toggle Telescope file opener -- Keybinds for handling tabs -keymap('n', '', 'BufferLineCyclePrev', defaultKeybindOptions) -keymap('n', '', 'BufferLineCycleNext', defaultKeybindOptions) -keymap('n', '', 'BufferLineCycleNext', defaultKeybindOptions) -keymap('n', '', 'BufferLineMovePrev', defaultKeybindOptions) -keymap('n', '>', 'BufferLineMoveNext', defaultKeybindOptions) -keymap('n', '', 'BufferLineGoToBuffer 1', defaultKeybindOptions) -keymap('n', '', 'BufferLineGoToBuffer 2', defaultKeybindOptions) -keymap('n', '', 'BufferLineGoToBuffer 3', defaultKeybindOptions) -keymap('n', '', 'BufferLineGoToBuffer 4', defaultKeybindOptions) -keymap('n', '', 'BufferLineGoToBuffer 5', defaultKeybindOptions) -keymap('n', '', 'BufferLineGoToBuffer 6', defaultKeybindOptions) -keymap('n', '', 'BufferLineGoToBuffer 7', defaultKeybindOptions) -keymap('n', '', 'BufferLineGoToBuffer 8', defaultKeybindOptions) -keymap('n', '', 'BufferLineGoToBuffer 9', defaultKeybindOptions) -keymap('n', '', 'BufferLineGoToBuffer -1', defaultKeybindOptions) -keymap('n', '', 'BufferLineTogglePin', defaultKeybindOptions) -keymap('n', '', 'bdelete', defaultKeybindOptions) +keymap('n', '', 'BufferLineCyclePrev', defaultKeybindOptions) -- Cycle previous +keymap('n', '', 'BufferLineCycleNext', defaultKeybindOptions) -- Cycle next +keymap('n', '', 'BufferLineCycleNext', defaultKeybindOptions) -- Also cycle next +keymap('n', '', 'BufferLineMovePrev', defaultKeybindOptions) -- Move to the previous tab +keymap('n', '>', 'BufferLineMoveNext', defaultKeybindOptions) -- Move to the next tab +keymap('n', '', 'BufferLineGoToBuffer 1', defaultKeybindOptions) -- Move to buffer 1 +keymap('n', '', 'BufferLineGoToBuffer 2', defaultKeybindOptions) -- Move to buffer 2 +keymap('n', '', 'BufferLineGoToBuffer 3', defaultKeybindOptions) -- Move to buffer 3 +keymap('n', '', 'BufferLineGoToBuffer 4', defaultKeybindOptions) -- Move to buffer 4 +keymap('n', '', 'BufferLineGoToBuffer 5', defaultKeybindOptions) -- Move to buffer 5 +keymap('n', '', 'BufferLineGoToBuffer 6', defaultKeybindOptions) -- Move to buffer 6 +keymap('n', '', 'BufferLineGoToBuffer 7', defaultKeybindOptions) -- Move to buffer 7 +keymap('n', '', 'BufferLineGoToBuffer 8', defaultKeybindOptions) -- Move to buffer 8 +keymap('n', '', 'BufferLineGoToBuffer 9', defaultKeybindOptions) -- Move to buffer 9 +keymap('n', '', 'BufferLineGoToBuffer -1', defaultKeybindOptions) -- Move to the last buffer +keymap('n', '', 'BufferLineTogglePin', defaultKeybindOptions) -- Toggle pin for a tab +keymap('n', '', 'bdelete', defaultKeybindOptions) -- Close a tab autocmd('BufWritePre', { -- Remove trailing spaces pattern = { '*' }, diff --git a/.config/nvim/lua/setup.lua b/.config/nvim/lua/setup.lua index f56d753..8769736 100644 --- a/.config/nvim/lua/setup.lua +++ b/.config/nvim/lua/setup.lua @@ -25,8 +25,10 @@ require('git_config') require('neogit_config') require('gitsigns_config') require('noice_config') +require('whichkey_config') require('colorizer_config') require('illuminate_config') +require('swapbuffers_config') require('aerial_config') require('bigfile_config') require('session_manager') diff --git a/.config/nvim/lua/swapbuffers_config.lua b/.config/nvim/lua/swapbuffers_config.lua new file mode 100644 index 0000000..5342bfd --- /dev/null +++ b/.config/nvim/lua/swapbuffers_config.lua @@ -0,0 +1,10 @@ +--[[ + speedie's neovim configuration + -- https://git.speedie.site/speedie/speedie-nvim -- +]]-- + +require('swap-buffers').setup({ + ignore_filetypes = { + 'NvimTree', + }, +}) diff --git a/.config/nvim/lua/whichkey_config.lua b/.config/nvim/lua/whichkey_config.lua new file mode 100644 index 0000000..2752b07 --- /dev/null +++ b/.config/nvim/lua/whichkey_config.lua @@ -0,0 +1,6 @@ +--[[ + speedie's neovim configuration + -- https://git.speedie.site/speedie/speedie-nvim -- +]]-- + +require('which-key').setup({})