diff --git a/init.lua b/init.lua index 5d29c72dc94..7bc5ae84815 100644 --- a/init.lua +++ b/init.lua @@ -84,204 +84,154 @@ I hope you enjoy your Neovim journey, P.S. You can delete this when you're done too. It's your config now! :) --]] --- ============================================================ --- SECTION 1: FOUNDATION --- Core Neovim settings, leaders, options, basic keymaps, basic autocmds --- ============================================================ -do - -- Enable faster startup by caching compiled Lua modules - vim.loader.enable() - - -- Set 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 = false - - -- [[ Setting options ]] - -- See `:help vim.o` - -- NOTE: You can change these options as you wish! - -- For more options, you can see `:help option-list` - - -- Make line numbers default - vim.o.number = true - -- You can also add relative line numbers, to help with jumping. - -- Experiment for yourself to see if you like it! - -- vim.o.relativenumber = true - - -- Enable mouse mode, can be useful for resizing splits for example! - vim.o.mouse = 'a' - - -- Don't show the mode, since it's already in the status line - vim.o.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() vim.o.clipboard = 'unnamedplus' end) - - -- Enable break indent - vim.o.breakindent = true - - -- Enable undo/redo changes even after closing and reopening a file - vim.o.undofile = true - - -- Case-insensitive searching UNLESS \C or one or more capital letters in the search term - vim.o.ignorecase = true - vim.o.smartcase = true - - -- Keep signcolumn on by default - vim.o.signcolumn = 'yes' - - -- Decrease update time - vim.o.updatetime = 250 - - -- Decrease mapped sequence wait time - vim.o.timeoutlen = 300 - - -- Configure how new splits should be opened - vim.o.splitright = true - vim.o.splitbelow = true - - -- Sets how neovim will display certain whitespace characters in the editor. - -- See `:help 'list'` - -- and `:help 'listchars'` - -- - -- Notice listchars is set using `vim.opt` instead of `vim.o`. - -- It is very similar to `vim.o` but offers an interface for conveniently interacting with tables. - -- See `:help lua-options` - -- and `:help lua-guide-options` - vim.o.list = true - vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } - - -- Preview substitutions live, as you type! - vim.o.inccommand = 'split' - - -- Show which line your cursor is on - vim.o.cursorline = true - - -- Minimal number of screen lines to keep above and below the cursor. - vim.o.scrolloff = 10 - - -- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`), - -- instead raise a dialog asking if you wish to save the current file(s) - -- See `:help 'confirm'` - vim.o.confirm = true - - -- [[ Basic Keymaps ]] - -- See `:help vim.keymap.set()` - - -- Clear highlights on search when pressing in normal mode - -- See `:help hlsearch` - vim.keymap.set('n', '', 'nohlsearch') - - -- Diagnostic Config & Keymaps - -- See `:help vim.diagnostic.Opts` - vim.diagnostic.config { - update_in_insert = false, - severity_sort = true, - float = { border = 'rounded', source = 'if_many' }, - underline = { severity = { min = vim.diagnostic.severity.WARN } }, - - -- Can switch between these as you prefer - virtual_text = true, -- Text shows up at the end of the line - virtual_lines = false, -- Text shows up underneath the line, with virtual lines - - -- Auto open the float, so you can easily read the errors when jumping with `[d` and `]d` - jump = { - on_jump = function(_, bufnr) - vim.diagnostic.open_float { - bufnr = bufnr, - scope = 'cursor', - focus = false, - } - end, - }, - } - - vim.keymap.set('n', '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 , 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 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 - -- - -- See `:help wincmd` for a list of all window commands - vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) - vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) - vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) - vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) - - -- NOTE: Some terminals have colliding keymaps or are not able to send distinct keycodes - -- vim.keymap.set("n", "", "H", { desc = "Move window to the left" }) - -- vim.keymap.set("n", "", "L", { desc = "Move window to the right" }) - -- vim.keymap.set("n", "", "J", { desc = "Move window to the lower" }) - -- vim.keymap.set("n", "", "K", { desc = "Move window to the upper" }) - - -- [[ Basic Autocommands ]] - -- See `:help lua-guide-autocommands` - - -- Highlight when yanking (copying) text - -- Try it with `yap` in normal mode - -- See `:help vim.hl.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.hl.on_yank() end, - }) -end - --- ============================================================ --- SECTION 2: PLUGIN MANAGER INTRO --- vim.pack intro, build hooks --- ============================================================ -do - -- [[ Intro to `vim.pack` ]] - -- `vim.pack` is a new plugin manager built into Neovim, - -- which provides a Lua interface for installing and managing plugins. - -- - -- See `:help vim.pack`, `:help vim.pack-examples` or the - -- excellent blog post from the creator of vim.pack and mini.nvim: - -- https://echasnovski.com/blog/2026-03-13-a-guide-to-vim-pack - -- - -- To inspect plugin state and pending updates, run - -- :lua vim.pack.update(nil, { offline = true }) - -- - -- To update plugins, run - -- :lua vim.pack.update() - -- - -- - -- Throughout the rest of the config there will be examples - -- of how to install and configure plugins using `vim.pack`. - -- - -- In this section we set up some autocommands to run build - -- steps for certain plugins after they are installed or updated. - - local function run_build(name, cmd, cwd) - local result = vim.system(cmd, { cwd = cwd }):wait() - if result.code ~= 0 then - local stderr = result.stderr or '' - local stdout = result.stdout or '' - local output = stderr ~= '' and stderr or stdout - if output == '' then output = 'No output from build command.' end - vim.notify(('Build failed for %s:\n%s'):format(name, output), vim.log.levels.ERROR) - end +-- Set 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.o` +-- NOTE: You can change these options as you wish! +-- For more options, you can see `:help option-list` + +-- Make line numbers default +vim.o.number = true +-- You can also add relative line numbers, to help with jumping. +-- Experiment for yourself to see if you like it! +vim.o.relativenumber = true + +-- Enable mouse mode, can be useful for resizing splits for example! +vim.o.mouse = 'a' + +-- Don't show the mode, since it's already in the status line +vim.o.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() + vim.o.clipboard = 'unnamedplus' +end) + +-- Enable break indent +vim.o.breakindent = true + +-- Save undo history +vim.o.undofile = true + +-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term +vim.o.ignorecase = true +vim.o.smartcase = true + +-- Keep signcolumn on by default +vim.o.signcolumn = 'yes' + +-- Decrease update time +vim.o.updatetime = 250 + +-- Decrease mapped sequence wait time +vim.o.timeoutlen = 300 + +-- Configure how new splits should be opened +vim.o.splitright = true +vim.o.splitbelow = true + +-- Sets how neovim will display certain whitespace characters in the editor. +-- See `:help 'list'` +-- and `:help 'listchars'` +-- +-- Notice listchars is set using `vim.opt` instead of `vim.o`. +-- It is very similar to `vim.o` but offers an interface for conveniently interacting with tables. +-- See `:help lua-options` +-- and `:help lua-options-guide` +vim.o.list = true +vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } + +-- Preview substitutions live, as you type! +vim.o.inccommand = 'split' + +-- Show which line your cursor is on +vim.o.cursorline = true + +-- Minimal number of screen lines to keep above and below the cursor. +vim.o.scrolloff = 10 + +-- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`), +-- instead raise a dialog asking if you wish to save the current file(s) +-- See `:help 'confirm'` +vim.o.confirm = true + +-- [[ Basic Keymaps ]] +-- See `:help vim.keymap.set()` + +-- Clear highlights on search when pressing in normal mode +-- See `:help hlsearch` +vim.keymap.set('n', '', 'nohlsearch') + +-- CUSTOM KEYMAPS MOVE TO SEPERATE FILE PLEASE!!!!! +vim.keymap.set('i', 'kj', '') +vim.keymap.set('n', '-', 'Oil', { desc = 'Open Parent Directory' }) +vim.keymap.set('n', 'u', vim.cmd.UndotreeToggle) + +-- Diagnostic keymaps +vim.keymap.set('n', '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 , 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 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 +-- +-- See `:help wincmd` for a list of all window commands +vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) +vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) +vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) +vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) + +-- NOTE: Some terminals have colliding keymaps or are not able to send distinct keycodes +-- vim.keymap.set("n", "", "H", { desc = "Move window to the left" }) +-- vim.keymap.set("n", "", "L", { desc = "Move window to the right" }) +-- vim.keymap.set("n", "", "J", { desc = "Move window to the lower" }) +-- vim.keymap.set("n", "", "K", { desc = "Move window to the upper" }) + +-- [[ Basic Autocommands ]] +-- See `:help lua-guide-autocommands` + +-- Highlight when yanking (copying) text +-- Try it with `yap` in normal mode +-- See `:help vim.hl.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.hl.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 or vim.loop).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 -- This autocommand runs after a plugin is installed or updated and @@ -623,6 +573,41 @@ do -- NOTE: Remember that Lua is a real programming language, and as such it is possible -- to define small helper and utility functions so you don't have to repeat yourself. -- + -- Add any additional override configuration in the following tables. Available keys are: + -- - cmd (table): Override the default command used to start the server + -- - filetypes (table): Override the default list of associated filetypes for the server + -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. + -- - settings (table): Override the default settings passed when initializing the server. + -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ + local servers = { + -- clangd = {}, + -- gopls = {}, + -- pyright = {}, + rust_analyzer = {}, + -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs + -- + -- Some languages (like typescript) have entire language plugins that can be useful: + -- https://github.com/pmizio/typescript-tools.nvim + -- + -- But for many setups, the LSP (`ts_ls`) will work just fine + -- ts_ls = {}, + -- + + lua_ls = { + -- cmd = { ... }, + -- filetypes = { ... }, + -- capabilities = {}, + settings = { + Lua = { + completion = { + callSnippet = 'Replace', + }, + -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings + -- diagnostics = { disable = { 'missing-fields' } }, + }, + }, + }, + } -- In this case, we create a function that lets us more easily define mappings specific -- for LSP related items. It sets the mode, buffer and description for us each time. local map = function(keys, func, desc, mode) @@ -852,17 +837,25 @@ do -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps }, - appearance = { - -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font' - -- Adjusts spacing to ensure icons are aligned - nerd_font_variant = 'mono', - }, - - completion = { - -- By default, you may press `` to show the documentation. - -- Optionally, set `auto_show = true` to show the documentation after a delay. - documentation = { auto_show = false, auto_show_delay_ms = 500 }, - }, + { -- 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`. + 'rose-pine/neovim', + priority = 1000, -- Make sure to load this before all the other start plugins. + -- opts = { variant = 'auto', dark_variant = 'main' }, + + 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 'rose-pine-moon' + + -- You can configure highlights by doing something like: + vim.cmd.hi 'Comment gui=none' + end, + }, sources = { default = { 'lsp', 'path', 'snippets' }, @@ -960,18 +953,44 @@ do -- Here are some example plugins that I've included in the Kickstart repository. -- Uncomment any of the lines below to enable them (you will need to restart nvim). -- - -- require 'kickstart.plugins.debug' - -- require 'kickstart.plugins.indent_line' - -- require 'kickstart.plugins.lint' - -- require 'kickstart.plugins.autopairs' - -- require 'kickstart.plugins.neo-tree' - -- require 'kickstart.plugins.gitsigns' -- adds gitsigns recommended keymaps - - -- NOTE: You can add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` + -- require 'kickstart.plugins.debug', + require 'kickstart.plugins.indent_line', + -- require 'kickstart.plugins.lint', + require 'kickstart.plugins.autopairs', + -- require 'kickstart.plugins.neo-tree', + require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps + + -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` + -- 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. - -- require 'custom.plugins' -end + { import = 'custom.plugins' }, + -- + -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` + -- Or use telescope! + -- In normal mode type `sh` then write `lazy.nvim-plugin` + -- you can continue same window with `sr` which resumes last telescope search +}, { + ui = { + -- If you are using a Nerd Font: set icons to an empty table which will use the + -- default lazy.nvim defined Nerd Font icons, otherwise define a unicode icons table + icons = vim.g.have_nerd_font and {} or { + cmd = '⌘', + config = '🛠', + event = '📅', + ft = '📂', + init = '⚙', + keys = '🗝', + plugin = '🔌', + runtime = '💻', + require = '🌙', + source = '📄', + start = '🚀', + task = '📌', + lazy = '💤 ', + }, + }, +}) -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index c05db465ea5..5c0e8c12c56 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -2,6 +2,87 @@ -- I promise not to create any merge conflicts in this directory :) -- -- See the kickstart.nvim README for more information +return { + { + 'stevearc/oil.nvim', + opts = {}, + dependencies = { { 'echasnovski/mini.icons', opts = {} } }, + config = function() + require('oil').setup { + default_file_explorer = true, + view_options = { + show_hidden = true, + }, + } + end, + }, + { + 'christoomey/vim-tmux-navigator', + cmd = { + 'TmuxNavigateLeft', + 'TmuxNavigateDown', + 'TmuxNavigateUp', + 'TmuxNavigateRight', + 'TmuxNavigatePrevious', + 'TmuxNavigatorProcessList', + }, + keys = { + { '', 'TmuxNavigateLeft' }, + { '', 'TmuxNavigateDown' }, + { '', 'TmuxNavigateUp' }, + { '', 'TmuxNavigateRight' }, + { '', 'TmuxNavigatePrevious' }, + }, + }, + { + 'mbbill/undotree', + config = function() + local wk = require 'which-key' + wk.add { + { + 'u', + desc = 'Show undotree', + mode = 'n', + buffer = true, + }, + } + end, + }, + { + 'lervag/vimtex', + lazy = false, -- we don't want to lazy load VimTeX + -- tag = "v2.15", -- uncomment to pin to a specific release + init = function() + -- VimTeX configuration goes here, e.g. + vim.g.vimtex_view_method = 'zathura' + vim.g.vimtex_compiler_method = 'pdflatex' + end, + config = function() + local wk = require 'which-key' + vim.api.nvim_create_autocmd('FileType', { + pattern = { 'tex' }, + callback = function() + vim.keymap.set('n', 'm', 'i\\[\\]kA', { buffer = true }) + vim.keymap.set('n', 'p', 'i\\begin{pmatrix}\\end{pmatrix}kA', { buffer = true }) + end, + }) + wk.add { + { + 'm', + desc = 'Insert display math block', + mode = 'n', + buffer = true, + }, + { + 'p', + desc = 'Insert pmatrix block', + mode = 'n', + buffer = true, + }, + } + end, + }, +} -- Iterate over all Lua files in the plugins directory and load them local plugins_dir = vim.fs.joinpath(vim.fn.stdpath 'config', 'lua', 'custom', 'plugins')