diff --git a/init.lua b/init.lua index a37dba98..b171f13c 100644 --- a/init.lua +++ b/init.lua @@ -86,7 +86,7 @@ require('lazy').setup({ -- Useful status updates for LSP -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` - { 'j-hui/fidget.nvim', tag = 'legacy', opts = {} }, + { 'j-hui/fidget.nvim', tag = 'legacy', opts = {} }, -- Additional lua configuration, makes nvim stuff amazing! 'folke/neodev.nvim', @@ -110,7 +110,7 @@ require('lazy').setup({ }, -- Useful plugin to show you pending keybinds. - { 'folke/which-key.nvim', opts = {} }, + { 'folke/which-key.nvim', opts = {} }, { -- Adds git related signs to the gutter, as well as utilities for managing changes 'lewis6991/gitsigns.nvim', @@ -128,16 +128,16 @@ require('lazy').setup({ -- don't override the built-in and fugitive keymaps local gs = package.loaded.gitsigns - vim.keymap.set({'n', 'v'}, ']c', function() + vim.keymap.set({ 'n', 'v' }, ']c', function() if vim.wo.diff then return ']c' end vim.schedule(function() gs.next_hunk() end) return '' - end, {expr=true, buffer = bufnr, desc = "Jump to next hunk"}) - vim.keymap.set({'n', 'v'}, '[c', function() + end, { expr = true, buffer = bufnr, desc = "Jump to next hunk" }) + vim.keymap.set({ 'n', 'v' }, '[c', function() if vim.wo.diff then return '[c' end vim.schedule(function() gs.prev_hunk() end) return '' - end, {expr=true, buffer = bufnr, desc = "Jump to previous hunk"}) + end, { expr = true, buffer = bufnr, desc = "Jump to previous hunk" }) end, }, }, @@ -151,19 +151,19 @@ require('lazy').setup({ -- end, -- }, - { - -- Set lualine as statusline - 'nvim-lualine/lualine.nvim', - -- See `:help lualine.txt` - opts = { - options = { - icons_enabled = false, - -- theme = 'onedark', - component_separators = '|', - section_separators = '', - }, - }, - }, + -- { + -- -- Set lualine as statusline + -- 'nvim-lualine/lualine.nvim', + -- -- See `:help lualine.txt` + -- opts = { + -- options = { + -- icons_enabled = false, + -- -- theme = 'onedark', + -- component_separators = '|', + -- section_separators = '', + -- }, + -- }, + -- }, { -- Add indentation guides even on blank lines @@ -212,7 +212,7 @@ require('lazy').setup({ -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart -- These are some example plugins that I've included in the kickstart repository. -- Uncomment any of the lines below to enable them. - -- require 'kickstart.plugins.autoformat', + require 'kickstart.plugins.autoformat', require 'kickstart.plugins.debug', -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` @@ -233,6 +233,7 @@ vim.o.hlsearch = false -- Make line numbers default vim.wo.number = true +vim.o.relativenumber = true -- Enable mouse mode vim.o.mouse = 'a' @@ -265,12 +266,44 @@ vim.o.completeopt = 'menuone,noselect' -- NOTE: You should make sure your terminal supports this vim.o.termguicolors = true +vim.o.tabstop = 4 +vim.o.softtabstop = 4 +vim.o.shiftwidth = 4 +vim.o.expandtab = true + +vim.o.smartindent = true +vim.o.incsearch = true + +-- disable netrw at the very start of your init.lua +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 + + +vim.o.updatetime = 50 + + -- [[ Basic Keymaps ]] -- Keymaps for better default experience -- See `:help vim.keymap.set()` vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) +vim.keymap.set("x", "p", [["_dP]], { desc = "Paste without writing current text into register" }) +vim.keymap.set("n", "x", '"_x', { desc = "Delete character but don't copy into register" }) + +vim.keymap.set("n", "", "zz", { desc = "Center screen when scrolling up" }) +vim.keymap.set("n", "", "zz", { desc = "Center screen when scrolling down" }) +vim.keymap.set("n", "n", "nzz", { desc = "Center screen when going to next search result" }) +vim.keymap.set("n", "N", "Nzz", { desc = "Center screen when going to previous search result" }) +vim.keymap.set("n", "t", "tzz", { desc = "Center screen when going until next search result" }) +vim.keymap.set("n", "T", "Tzz", { desc = "Center screen when going until previous search result" }) + + +-- Remap ESC key in different modes +vim.keymap.set("i", "kj", "", { desc = "Escape when in insert mode" }) +vim.keymap.set("v", "kj", "", { desc = "Escape when in visual mode" }) +vim.keymap.set("c", "kj", "", { desc = "Escape when in change mode" }) + -- Remap for dealing with word wrap vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) diff --git a/lua/custom/plugins/autopairs.lua b/lua/custom/plugins/autopairs.lua new file mode 100644 index 00000000..d271227f --- /dev/null +++ b/lua/custom/plugins/autopairs.lua @@ -0,0 +1,15 @@ +return { + "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, +} diff --git a/lua/custom/plugins/catppuccin.lua b/lua/custom/plugins/catppuccin.lua new file mode 100644 index 00000000..fbd49680 --- /dev/null +++ b/lua/custom/plugins/catppuccin.lua @@ -0,0 +1,8 @@ +return { + 'catppuccin/nvim', + name = 'catppuccin', + config = function() + vim.cmd.colorscheme 'catppuccin-frappe' + end, + priority = 1000, +} diff --git a/lua/custom/plugins/cheatsheet.lua b/lua/custom/plugins/cheatsheet.lua new file mode 100644 index 00000000..d4939263 --- /dev/null +++ b/lua/custom/plugins/cheatsheet.lua @@ -0,0 +1,8 @@ +return { + "sudormrfbin/cheatsheet.nvim", + dependencies = { + { "nvim-telescope/telescope.nvim" }, + { "nvim-lua/popup.nvim" }, + { "nvim-lua/plenary.nvim" }, + }, +} diff --git a/lua/custom/plugins/flash.lua b/lua/custom/plugins/flash.lua new file mode 100644 index 00000000..46eac0a5 --- /dev/null +++ b/lua/custom/plugins/flash.lua @@ -0,0 +1,33 @@ +return { + "folke/flash.nvim", + event = "VeryLazy", + ---@type Flash.Config + opts = {}, + -- stylua: ignore + keys = { + { + "s", + mode = { "n", "o", "x" }, + function() + require("flash").jump({ + search = { + mode = function(str) + return "\\<" .. str + end, + }, + }) + end, + desc = "Flash" + }, + { "S", mode = { "n", "o", "x" }, function() require("flash").treesitter() end, desc = "Flash Treesitter" }, + { "r", mode = "o", function() require("flash").remote() end, desc = "Remote Flash" }, + { "R", mode = { "o", "x" }, function() require("flash").treesitter_search() end, desc = "Treesitter Search" }, + { + "", + mode = { "c" }, + function() require("flash").toggle() end, + desc = + "Toggle Flash Search" + }, + }, +} diff --git a/lua/custom/plugins/harpoon.lua b/lua/custom/plugins/harpoon.lua new file mode 100644 index 00000000..9fb08cb8 --- /dev/null +++ b/lua/custom/plugins/harpoon.lua @@ -0,0 +1,31 @@ +return { + 'ThePrimeagen/harpoon', + config = function() + require("harpoon").setup() + vim.keymap.set("n", "ha", require("harpoon.mark").add_file, { desc = "[H]arpoon [A]dd file" }) + vim.keymap.set("n", "ht", require("harpoon.ui").toggle_quick_menu, + { desc = "[H]arpoon [T]oggle quick menu" }) + vim.keymap.set("n", "hn", require("harpoon.ui").nav_next, { desc = "[H]arpoon nav [N]ext" }) + vim.keymap.set("n", "hp", require("harpoon.ui").nav_prev, { desc = "[H]arpoon nav [P]revious" }) + vim.keymap.set("n", "h1", function() require("harpoon.ui").nav_file(1) end, + { desc = "[H]arpoon goto file [1]" }) + vim.keymap.set("n", "h2", function() require("harpoon.ui").nav_file(2) end, + { desc = "[H]arpoon goto file [2]" }) + vim.keymap.set("n", "h3", function() require("harpoon.ui").nav_file(3) end, + { desc = "[H]arpoon goto file [3]" }) + vim.keymap.set("n", "h4", function() require("harpoon.ui").nav_file(4) end, + { desc = "[H]arpoon goto file [4]" }) + vim.keymap.set("n", "hm1", function() require("harpoon.tmux").gotoTerminal(1) end, + { desc = "[H]arpoon goto {T]mux window [1]" }) + vim.keymap.set("n", "hm2", function() require("harpoon.tmux").gotoTerminal(2) end, + { desc = "[H]arpoon goto {T]mux window [2]" }) + vim.keymap.set("n", "hm3", function() require("harpoon.tmux").gotoTerminal(3) end, + { desc = "[H]arpoon goto {T]mux window [3]" }) + vim.keymap.set("n", "hm4", function() require("harpoon.tmux").gotoTerminal(4) end, + { desc = "[H]arpoon goto {T]mux window [4]" }) + end, + dependencies = { + "nvim-lua/plenary.nvim", + }, + +} diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index f10ba3d0..6a27a403 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -2,33 +2,15 @@ -- I promise not to create any merge conflicts in this directory :) -- -- See the kickstart.nvim README for more information - -vim.o.relativenumber = true - return { - { - 'catppuccin/nvim', - name = 'catppuccin', - priority = 1000, - config = function() - vim.cmd.colorscheme 'catppuccin-frappe' - end, + --[[ { + 'theprimeagen/harpoon', }, + ]] --[[ { + 'mbbill/undotree' + } ]] { - -- Set lualine as statusline - 'nvim-lualine/lualine.nvim', - -- See `:help lualine.txt` - dependencies = { - 'nvim-tree/nvim-web-devicons' - }, - opts = { - options = { - icons_enabled = true, - theme = 'auto', - component_separators = '|', - section_separators = '', - }, - }, - }, + 'nvim-web-devicons', + } } diff --git a/lua/custom/plugins/lualine.lua b/lua/custom/plugins/lualine.lua new file mode 100644 index 00000000..6dfff26e --- /dev/null +++ b/lua/custom/plugins/lualine.lua @@ -0,0 +1,44 @@ +local function lsp_name(msg) + msg = msg or "Inactive" + local buf_clients = vim.lsp.get_active_clients() + if next(buf_clients) == nil then + if type(msg) == "boolean" or #msg == 0 then + return "Inactive" + end + return msg + end + local buf_client_names = {} + + for _, client in pairs(buf_clients) do + if client.name ~= "null-ls" then + table.insert(buf_client_names, client.name) + end + end + + return table.concat(buf_client_names, ", ") +end + +return { + -- Set lualine as statusline + 'nvim-lualine/lualine.nvim', + -- See `:help lualine.txt` + dependencies = { + 'nvim-tree/nvim-web-devicons' + }, + opts = { + options = { + icons_enabled = true, + theme = 'auto', + component_separators = '|', + section_separators = '', + }, + sections = { + lualine_y = { + { + lsp_name, + icon = "", + }, + }, + } + }, +} diff --git a/lua/custom/plugins/neotree.lua b/lua/custom/plugins/neotree.lua new file mode 100644 index 00000000..64b093c2 --- /dev/null +++ b/lua/custom/plugins/neotree.lua @@ -0,0 +1,74 @@ +-- return { +-- "nvim-neo-tree/neo-tree.nvim", +-- branch = "v3.x", +-- dependencies = { +-- "nvim-lua/plenary.nvim", +-- "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended +-- "MunifTanjim/nui.nvim", +-- }, +-- opts = { +-- window = { +-- position = "left", +-- width = 40, +-- mapping_options = { +-- noremap = true, +-- nowait = true, +-- }, +-- }, +-- filesystem = { +-- filtered_items = { +-- visible = false, -- when true, they will just be displayed differently than normal items +-- hide_dotfiles = false, +-- hide_gitignored = true, +-- hide_hidden = true, -- only works on Windows for hidden files/directories +-- hide_by_name = { +-- "node_modules" +-- }, +-- hide_by_pattern = { -- uses glob style patterns +-- --"*.meta", +-- --"*/src/*/tsconfig.json", +-- }, +-- always_show = { -- remains visible even if other settings would normally hide it +-- --".gitignored", +-- }, +-- never_show = { -- remains hidden even if visible is toggled to true, this overrides always_show +-- --".DS_Store", +-- --"thumbs.db" +-- }, +-- never_show_by_pattern = { -- uses glob style patterns +-- --".null-ls_*", +-- }, +-- }, +-- follow_current_file = { +-- enabled = false, -- This will find and focus the file in the active buffer every time +-- -- -- the current file is changed while the tree is open. +-- leave_dirs_open = false, -- `false` closes auto expanded dirs, such as with `:Neotree reveal` +-- }, +-- group_empty_dirs = false, -- when true, empty folders will be grouped together +-- hijack_netrw_behavior = "open_default", -- netrw disabled, opening a directory opens neo-tree +-- }, +-- }, +-- config = function() +-- require("neo-tree").setup() +-- vim.keymap.set("n", "T", "Neotree toggle current reveal_force_cwd") +-- vim.keymap.set("n", "|", "Neotree reveal") +-- vim.keymap.set("n", "gd", ":Neotree float reveal_file= reveal_force_cwd") +-- vim.keymap.set("n", "Br", ":Neotree toggle show buffers right") +-- vim.keymap.set("n", "Gs", ":Neotree float git_status") +-- end +-- } +-- Unless you are still migrating, remove the deprecated commands from v1.x +vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]]) + +return { + "nvim-neo-tree/neo-tree.nvim", + version = "*", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended + "MunifTanjim/nui.nvim", + }, + config = function () + require('neo-tree').setup {} + end, +} diff --git a/lua/custom/plugins/nvim-tree.lua b/lua/custom/plugins/nvim-tree.lua new file mode 100644 index 00000000..dc198db1 --- /dev/null +++ b/lua/custom/plugins/nvim-tree.lua @@ -0,0 +1,9 @@ +return { + 'nvim-tree/nvim-tree.lua', + config = function() + require("nvim-tree").setup() + vim.keymap.set("n", "f", ":NvimTreeToggle", { desc = "Toggle NvimTree" }) + end, + -- cmd = { "NvimTreeToggle", "NvimTreeOpen", "NvimTreeFocus", "NvimTreeFindFileToggle" }, + -- event = "User DirOpened", +} diff --git a/lua/custom/plugins/toggleterm.lua b/lua/custom/plugins/toggleterm.lua new file mode 100644 index 00000000..c10ad334 --- /dev/null +++ b/lua/custom/plugins/toggleterm.lua @@ -0,0 +1,18 @@ +return { + 'akinsho/toggleterm.nvim', + version = "*", + config = function() + require('toggleterm').setup({ + open_mapping = "", + direction = "float", + }) + local terminal = require('toggleterm.terminal') + vim.keymap.set({ "n", "v", "t" }, "tt", "ToggleTerm direction=tab", { desc = "ToggleTerm tab" }); + vim.keymap.set({ "n", "v", "t" }, "th", "ToggleTerm direction=horizontal", + { desc = "ToggleTerm horizontal" }); + vim.keymap.set({ "n", "v", "t" }, "tv", "ToggleTerm direction=vertical", + { desc = "ToggleTerm vertical" }); + vim.keymap.set({ "n", "v", "t" }, "tn", function() terminal.Terminal:new():toggle() end, + { desc = "ToggleTerm new" }); + end +}