From bd1c24e038ae86c12c6e2d717dd90e1a54edcd6a Mon Sep 17 00:00:00 2001 From: Richard <48971008+RichieCoding@users.noreply.github.com> Date: Sat, 13 Sep 2025 18:20:56 -0400 Subject: [PATCH] my init.lua config file --- init.lua | 70 +++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 62 insertions(+), 8 deletions(-) diff --git a/init.lua b/init.lua index 5cac3d14..6561b86f 100644 --- a/init.lua +++ b/init.lua @@ -99,10 +99,10 @@ vim.g.have_nerd_font = false -- For more options, you can see `:help option-list` -- Make line numbers default -vim.opt.number = true +-- vim.opt.number = true -- You can also add relative line numbers, to help with jumping. -- Experiment for yourself to see if you like it! --- vim.opt.relativenumber = true +vim.opt.relativenumber = true -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' @@ -189,6 +189,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' }) +-- Map 'jj' to in insert mode for quick exit from insert mode +vim.keymap.set('i', 'jj', '', { desc = 'Exit insert mode', noremap = true }) + +vim.keymap.set('v', 'J', ":m '>+1gv=gv") +vim.keymap.set('v', 'K', ":m '<-2gv=gv") + -- [[ Basic Autocommands ]] -- See `:help lua-guide-autocommands` @@ -203,6 +209,14 @@ vim.api.nvim_create_autocmd('TextYankPost', { end, }) +-- Key mapping to open init.lua +vim.api.nvim_set_keymap( + 'n', -- mode: normal + 'ev', -- key combination, e.g., \ev if your leader is \ + ':e ~/.config/nvim/init.lua', -- command to execute + { noremap = true, silent = true } -- options +) + -- [[ 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' @@ -230,6 +244,30 @@ 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 + 'tpope/vim-fugitive', + + { + 'windwp/nvim-autopairs', + -- Optional dependency + dependencies = { 'hrsh7th/nvim-cmp' }, + config = function() + require('nvim-autopairs').setup {} + -- If you want to automatically add `(` after selecting a function or method + local cmp_autopairs = require 'nvim-autopairs.completion.cmp' + local cmp = require 'cmp' + cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) + end, + }, + + { + 'stevearc/oil.nvim', + opts = {}, + dependencies = { { 'echasnovski/mini.icons', opts = {} } }, + -- dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if you prefer nvim-web-devicons + -- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations. + lazy = false, + }, + -- NOTE: Plugins can also be added by using a table, -- with the first argument being the link and the following -- keys can be used to configure plugin behavior/loading/etc. @@ -410,6 +448,11 @@ require('lazy').setup({ pcall(require('telescope').load_extension, 'fzf') pcall(require('telescope').load_extension, 'ui-select') + local function nextError() + vim.diagnostic.goto_next { severity = { vim.diagnostic.severity.ERROR, vim.diagnostic.severity.WARN } } + end + vim.keymap.set('n', ']e', nextError, { desc = 'Next Diagnostic' }) + -- See `:help telescope.builtin` local builtin = require 'telescope.builtin' vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) @@ -668,7 +711,8 @@ require('lazy').setup({ -- https://github.com/pmizio/typescript-tools.nvim -- -- But for many setups, the LSP (`ts_ls`) will work just fine - -- ts_ls = {}, + ts_ls = {}, + eslint = {}, -- lua_ls = { @@ -757,11 +801,21 @@ require('lazy').setup({ end, formatters_by_ft = { lua = { 'stylua' }, - -- Conform can also run multiple formatters sequentially - -- python = { "isort", "black" }, - -- - -- You can use 'stop_after_first' to run the first available formatter from the list - -- javascript = { "prettierd", "prettier", stop_after_first = true }, + javascript = { 'prettierd', 'prettier' }, + typescript = { 'prettierd', 'prettier' }, + javascriptreact = { 'prettierd', 'prettier' }, + typescriptreact = { 'prettierd', 'prettier' }, + json = { 'prettierd', 'prettier' }, + css = { 'prettierd', 'prettier' }, + html = { 'prettierd', 'prettier' }, + yaml = { 'prettierd', 'prettier' }, + markdown = { 'prettierd', 'prettier' }, + }, + formatters = { + prettier = { + -- makes it prefer the local project Prettier + prefer_local = 'node_modules/.bin', + }, }, }, },