Update init.lua
This commit is contained in:
		
							parent
							
								
									bfaa12ad03
								
							
						
					
					
						commit
						9dee583a33
					
				
							
								
								
									
										204
									
								
								init.lua
								
								
								
								
							
							
						
						
									
										204
									
								
								init.lua
								
								
								
								
							| 
						 | 
				
			
			@ -87,19 +87,19 @@ I hope you enjoy your Neovim journey,
 | 
			
		|||
P.S. You can delete this when you're done too. It's your config now! :)
 | 
			
		||||
--]]
 | 
			
		||||
 | 
			
		||||
-- Set <space> as the leader key
 | 
			
		||||
-- See `:help mapleader`
 | 
			
		||||
--  NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
 | 
			
		||||
vim.g.mapleader = ' '
 | 
			
		||||
vim.g.maplocalleader = ' '
 | 
			
		||||
  -- Set <space> as the leader key
 | 
			
		||||
  -- See `:help mapleader`
 | 
			
		||||
  --  NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
 | 
			
		||||
  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 = true
 | 
			
		||||
 | 
			
		||||
-- [[ Setting options ]]
 | 
			
		||||
-- See `:help vim.opt`
 | 
			
		||||
-- NOTE: You can change these options as you wish!
 | 
			
		||||
--  For more options, you can see `:help option-list`
 | 
			
		||||
  -- [[ Setting options ]]
 | 
			
		||||
  -- See `:help vim.opt`
 | 
			
		||||
  -- NOTE: You can change these options as you wish!
 | 
			
		||||
  --  For more options, you can see `:help option-list`
 | 
			
		||||
 | 
			
		||||
  -- Make line numbers default
 | 
			
		||||
  vim.opt.number = true
 | 
			
		||||
| 
						 | 
				
			
			@ -107,25 +107,25 @@ vim.g.maplocalleader = ' '
 | 
			
		|||
  --  Experiment for yourself to see if you like it!
 | 
			
		||||
  vim.opt.relativenumber = true
 | 
			
		||||
 | 
			
		||||
-- Enable mouse mode, can be useful for resizing splits for example!
 | 
			
		||||
vim.opt.mouse = 'a'
 | 
			
		||||
  -- Enable mouse mode, can be useful for resizing splits for example!
 | 
			
		||||
  vim.opt.mouse = 'a'
 | 
			
		||||
 | 
			
		||||
-- Don't show the mode, since it's already in the status line
 | 
			
		||||
vim.opt.showmode = false
 | 
			
		||||
  -- Don't show the mode, since it's already in the status line
 | 
			
		||||
  vim.opt.showmode = false
 | 
			
		||||
 | 
			
		||||
-- Sync clipboard between OS and Neovim.
 | 
			
		||||
--  Schedule the setting after `UiEnter` because it can increase startup-time.
 | 
			
		||||
--  Remove this option if you want your OS clipboard to remain independent.
 | 
			
		||||
--  See `:help 'clipboard'`
 | 
			
		||||
vim.schedule(function()
 | 
			
		||||
  -- Sync clipboard between OS and Neovim.
 | 
			
		||||
  --  Schedule the setting after `UiEnter` because it can increase startup-time.
 | 
			
		||||
  --  Remove this option if you want your OS clipboard to remain independent.
 | 
			
		||||
  --  See `:help 'clipboard'`
 | 
			
		||||
  vim.schedule(function()
 | 
			
		||||
    vim.opt.clipboard = 'unnamedplus'
 | 
			
		||||
end)
 | 
			
		||||
  end)
 | 
			
		||||
 | 
			
		||||
  -- Enable break indent
 | 
			
		||||
  vim.opt.breakindent = true
 | 
			
		||||
 | 
			
		||||
-- Save undo history
 | 
			
		||||
vim.opt.undofile = true
 | 
			
		||||
  -- Save undo history
 | 
			
		||||
  vim.opt.undofile = true
 | 
			
		||||
 | 
			
		||||
  -- Case-insensitive searching UNLESS \C or one or more capital letters in the search term
 | 
			
		||||
  vim.opt.ignorecase = true
 | 
			
		||||
| 
						 | 
				
			
			@ -150,11 +150,11 @@ vim.opt.undofile = true
 | 
			
		|||
  vim.opt.list = true
 | 
			
		||||
  vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' }
 | 
			
		||||
 | 
			
		||||
-- Preview substitutions live, as you type!
 | 
			
		||||
vim.opt.inccommand = 'split'
 | 
			
		||||
  -- Preview substitutions live, as you type!
 | 
			
		||||
  vim.opt.inccommand = 'split'
 | 
			
		||||
 | 
			
		||||
-- Show which line your cursor is on
 | 
			
		||||
vim.opt.cursorline = true
 | 
			
		||||
  -- Show which line your cursor is on
 | 
			
		||||
  vim.opt.cursorline = true
 | 
			
		||||
 | 
			
		||||
  -- Minimal number of screen lines to keep above and below the cursor.
 | 
			
		||||
  vim.opt.scrolloff = 999
 | 
			
		||||
| 
						 | 
				
			
			@ -177,67 +177,67 @@ vim.opt.cursorline = true
 | 
			
		|||
  vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' })
 | 
			
		||||
  vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
 | 
			
		||||
 | 
			
		||||
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
 | 
			
		||||
-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which
 | 
			
		||||
-- is not what someone will guess without a bit more experience.
 | 
			
		||||
--
 | 
			
		||||
-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping
 | 
			
		||||
-- or just use <C-\><C-n> to exit terminal mode
 | 
			
		||||
vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
 | 
			
		||||
  -- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
 | 
			
		||||
  -- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which
 | 
			
		||||
  -- is not what someone will guess without a bit more experience.
 | 
			
		||||
  --
 | 
			
		||||
  -- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping
 | 
			
		||||
  -- or just use <C-\><C-n> to exit terminal mode
 | 
			
		||||
  vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
 | 
			
		||||
 | 
			
		||||
-- TIP: Disable arrow keys in normal mode
 | 
			
		||||
-- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
 | 
			
		||||
-- vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
 | 
			
		||||
-- vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>')
 | 
			
		||||
-- vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>')
 | 
			
		||||
  -- TIP: Disable arrow keys in normal mode
 | 
			
		||||
  -- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
 | 
			
		||||
  -- vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
 | 
			
		||||
  -- vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>')
 | 
			
		||||
  -- vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>')
 | 
			
		||||
 | 
			
		||||
-- Keybinds to make split navigation easier.
 | 
			
		||||
--  Use CTRL+<hjkl> to switch between windows
 | 
			
		||||
--
 | 
			
		||||
--  See `:help wincmd` for a list of all window commands
 | 
			
		||||
vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
 | 
			
		||||
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
 | 
			
		||||
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
 | 
			
		||||
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
 | 
			
		||||
  -- Keybinds to make split navigation easier.
 | 
			
		||||
  --  Use CTRL+<hjkl> to switch between windows
 | 
			
		||||
  --
 | 
			
		||||
  --  See `:help wincmd` for a list of all window commands
 | 
			
		||||
  vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
 | 
			
		||||
  vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
 | 
			
		||||
  vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
 | 
			
		||||
  vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
 | 
			
		||||
 | 
			
		||||
-- [[ Basic Autocommands ]]
 | 
			
		||||
--  See `:help lua-guide-autocommands`
 | 
			
		||||
  -- [[ Basic Autocommands ]]
 | 
			
		||||
  --  See `:help lua-guide-autocommands`
 | 
			
		||||
 | 
			
		||||
-- Highlight when yanking (copying) text
 | 
			
		||||
--  Try it with `yap` in normal mode
 | 
			
		||||
--  See `:help vim.highlight.on_yank()`
 | 
			
		||||
vim.api.nvim_create_autocmd('TextYankPost', {
 | 
			
		||||
  -- Highlight when yanking (copying) text
 | 
			
		||||
  --  Try it with `yap` in normal mode
 | 
			
		||||
  --  See `:help vim.highlight.on_yank()`
 | 
			
		||||
  vim.api.nvim_create_autocmd('TextYankPost', {
 | 
			
		||||
    desc = 'Highlight when yanking (copying) text',
 | 
			
		||||
    group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
 | 
			
		||||
    callback = function()
 | 
			
		||||
      vim.highlight.on_yank()
 | 
			
		||||
    end,
 | 
			
		||||
})
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
-- [[ Install `lazy.nvim` plugin manager ]]
 | 
			
		||||
--    See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
 | 
			
		||||
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
 | 
			
		||||
if not vim.uv.fs_stat(lazypath) then
 | 
			
		||||
  -- [[ Install `lazy.nvim` plugin manager ]]
 | 
			
		||||
  --    See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
 | 
			
		||||
  local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
 | 
			
		||||
  if not vim.uv.fs_stat(lazypath) then
 | 
			
		||||
    local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
 | 
			
		||||
    local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
 | 
			
		||||
    if vim.v.shell_error ~= 0 then
 | 
			
		||||
      error('Error cloning lazy.nvim:\n' .. out)
 | 
			
		||||
    end
 | 
			
		||||
end ---@diagnostic disable-next-line: undefined-field
 | 
			
		||||
vim.opt.rtp:prepend(lazypath)
 | 
			
		||||
  end ---@diagnostic disable-next-line: undefined-field
 | 
			
		||||
  vim.opt.rtp:prepend(lazypath)
 | 
			
		||||
 | 
			
		||||
-- [[ Configure and install plugins ]]
 | 
			
		||||
--
 | 
			
		||||
--  To check the current status of your plugins, run
 | 
			
		||||
--    :Lazy
 | 
			
		||||
--
 | 
			
		||||
--  You can press `?` in this menu for help. Use `:q` to close the window
 | 
			
		||||
--
 | 
			
		||||
--  To update plugins you can run
 | 
			
		||||
--    :Lazy update
 | 
			
		||||
--
 | 
			
		||||
-- NOTE: Here is where you install your plugins.
 | 
			
		||||
require('lazy').setup({
 | 
			
		||||
  -- [[ Configure and install plugins ]]
 | 
			
		||||
  --
 | 
			
		||||
  --  To check the current status of your plugins, run
 | 
			
		||||
  --    :Lazy
 | 
			
		||||
  --
 | 
			
		||||
  --  You can press `?` in this menu for help. Use `:q` to close the window
 | 
			
		||||
  --
 | 
			
		||||
  --  To update plugins you can run
 | 
			
		||||
  --    :Lazy update
 | 
			
		||||
  --
 | 
			
		||||
  -- NOTE: Here is where you install your plugins.
 | 
			
		||||
  require('lazy').setup({
 | 
			
		||||
    -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link).
 | 
			
		||||
    'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -699,8 +699,8 @@ require('lazy').setup({
 | 
			
		|||
      },
 | 
			
		||||
      opts = {
 | 
			
		||||
        notify_on_error = false,
 | 
			
		||||
        -- format_on_save = function(bufnr)
 | 
			
		||||
        format_on_save = false,
 | 
			
		||||
        format_on_save = function(bufnr)
 | 
			
		||||
          -- format_on_save = false,
 | 
			
		||||
          -- Disable "format_on_save lsp_fallback" for languages that don't
 | 
			
		||||
          -- have a well standardized coding style. You can add additional
 | 
			
		||||
          -- languages here or re-enable it for the disabled ones.
 | 
			
		||||
| 
						 | 
				
			
			@ -919,6 +919,56 @@ require('lazy').setup({
 | 
			
		|||
        -- - sr)'  - [S]urround [R]eplace [)] [']
 | 
			
		||||
        require('mini.surround').setup()
 | 
			
		||||
 | 
			
		||||
        require('mini.animate').setup {
 | 
			
		||||
          opts = function()
 | 
			
		||||
            -- don't use animate when scrolling with the mouse
 | 
			
		||||
            local mouse_scrolled = false
 | 
			
		||||
            for _, scroll in ipairs { 'Up', 'Down' } do
 | 
			
		||||
              local key = '<ScrollWheel' .. scroll .. '>'
 | 
			
		||||
              vim.keymap.set({ '', 'i' }, key, function()
 | 
			
		||||
                mouse_scrolled = true
 | 
			
		||||
                return key
 | 
			
		||||
              end, { expr = true })
 | 
			
		||||
            end
 | 
			
		||||
 | 
			
		||||
            vim.api.nvim_create_autocmd('FileType', {
 | 
			
		||||
              pattern = 'grug-far',
 | 
			
		||||
              callback = function()
 | 
			
		||||
                vim.b.minianimate_disable = true
 | 
			
		||||
              end,
 | 
			
		||||
            })
 | 
			
		||||
 | 
			
		||||
            LazyVim.toggle.map('<leader>ua', {
 | 
			
		||||
              name = 'Mini Animate',
 | 
			
		||||
              get = function()
 | 
			
		||||
                return not vim.g.minianimate_disable
 | 
			
		||||
              end,
 | 
			
		||||
              set = function(state)
 | 
			
		||||
                vim.g.minianimate_disable = not state
 | 
			
		||||
              end,
 | 
			
		||||
            })
 | 
			
		||||
 | 
			
		||||
            local animate = require 'mini.animate'
 | 
			
		||||
            return {
 | 
			
		||||
              resize = {
 | 
			
		||||
                timing = animate.gen_timing.linear { duration = 50, unit = 'total' },
 | 
			
		||||
              },
 | 
			
		||||
              scroll = {
 | 
			
		||||
                timing = animate.gen_timing.linear { duration = 100, unit = 'total' },
 | 
			
		||||
                subscroll = animate.gen_subscroll.equal {
 | 
			
		||||
                  predicate = function(total_scroll)
 | 
			
		||||
                    if mouse_scrolled then
 | 
			
		||||
                      mouse_scrolled = false
 | 
			
		||||
                      return false
 | 
			
		||||
                    end
 | 
			
		||||
                    return total_scroll > 1
 | 
			
		||||
                  end,
 | 
			
		||||
                },
 | 
			
		||||
              },
 | 
			
		||||
            }
 | 
			
		||||
          end,
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        -- Simple and easy statusline.
 | 
			
		||||
        --  You could remove this setup call if you don't like it,
 | 
			
		||||
        --  and try some other statusline plugin
 | 
			
		||||
| 
						 | 
				
			
			@ -1346,8 +1396,8 @@ require('lazy').setup({
 | 
			
		|||
    },
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
-- Function to justify all lines to the right
 | 
			
		||||
function justify_right()
 | 
			
		||||
  -- Function to justify all lines to the right
 | 
			
		||||
  function justify_right()
 | 
			
		||||
    -- Get the current buffer
 | 
			
		||||
    local buf = vim.api.nvim_get_current_buf()
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1370,8 +1420,8 @@ function justify_right()
 | 
			
		|||
 | 
			
		||||
    -- Set the lines back to the buffer
 | 
			
		||||
    vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines)
 | 
			
		||||
end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
-- Create a command to call the function
 | 
			
		||||
vim.api.nvim_create_user_command('JustifyRight', justify_right, {})
 | 
			
		||||
  -- Create a command to call the function
 | 
			
		||||
  vim.api.nvim_create_user_command('JustifyRight', justify_right, {})
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue