From 93eb0ef78a24ac4cb671d26cc8ace6e7e144d262 Mon Sep 17 00:00:00 2001 From: Carlos Date: Sun, 2 Feb 2025 12:26:38 -0500 Subject: [PATCH] Adding Changes --- kkk | 100 +++++++++++++++++++++ lazy-lock.json | 12 +++ lua/cargdev/core/function/openTerminal.lua | 48 ++++++++++ lua/cargdev/core/init.lua | 17 ++++ lua/cargdev/core/keymaps.lua | 26 +++++- lua/cargdev/plugins/alpha.lua | 87 +++++++++++++++--- lua/cargdev/plugins/bufferline.lua | 1 + lua/cargdev/plugins/buffertabs.lua | 12 +++ lua/cargdev/plugins/colorscheme.lua | 24 +++-- lua/cargdev/plugins/copilot.lua | 11 +++ lua/cargdev/plugins/dap.lua | 99 ++++++++++++++++++++ lua/cargdev/plugins/formatting.lua | 2 +- lua/cargdev/plugins/lsp/lspconfig.lua | 10 ++- lua/cargdev/plugins/noice.lua | 56 ++++++++++++ lua/cargdev/plugins/nvim-tree.lua | 45 +++++++++- lua/cargdev/plugins/tmux.lua | 4 + lua/cargdev/plugins/treesitter.lua | 4 + 17 files changed, 536 insertions(+), 22 deletions(-) create mode 100644 kkk create mode 100644 lua/cargdev/core/function/openTerminal.lua create mode 100644 lua/cargdev/plugins/buffertabs.lua create mode 100644 lua/cargdev/plugins/copilot.lua create mode 100644 lua/cargdev/plugins/dap.lua create mode 100644 lua/cargdev/plugins/noice.lua create mode 100644 lua/cargdev/plugins/tmux.lua diff --git a/kkk b/kkk new file mode 100644 index 0000000..1d725b2 --- /dev/null +++ b/kkk @@ -0,0 +1,100 @@ +return { + "nvim-tree/nvim-tree.lua", + dependencies = "nvim-tree/nvim-web-devicons", + config = function() + local nvimtree = require("nvim-tree") + + -- recommended settings from nvim-tree documentation + vim.g.loaded_netrw = 1 + vim.g.loaded_netrwPlugin = 1 + + nvimtree.setup({ + view = { + width = 35, + relativenumber = true, + }, + -- change folder arrow icons + renderer = { + indent_markers = { + enable = true, + }, + icons = { + glyphs = { + folder = { + arrow_closed = "", -- arrow when folder is closed + arrow_open = "", -- arrow when folder is open + }, + }, + }, + }, + -- disable window_picker for + -- explorer to work well with + -- window splits + actions = { + open_file = { + quit_on_open = true, + window_picker = { + enable = false, + }, + }, + }, + filters = { + custom = { ".DS_Store" }, + }, + git = { + ignore = false, + }, + on_attach = function(bufnr) -- Correct way to set keymaps + local api = require("nvim-tree.api") + local opts = { noremap = true, silent = true, nowait = true, buffer = bufnr } + + -- Open file in vertical split + vim.keymap.set("n", "s", api.node.open.vertical, opts) + + -- Open file in horizontal split + vim.keymap.set("n", "i", api.node.open.horizontal, opts) + + -- Open file in the current window + vim.keymap.set("n", "o", api.node.open.edit, opts) + -- File Management keybindings + vim.keymap.set("n", "a", function() -- Add a new file + vim.cmd("set modifiable") -- Ensure modifiable mode is on + api.fs.create() + end, opts) + + vim.keymap.set("n", "r", function() -- Rename file + vim.cmd("set modifiable") -- Ensure modifiable mode is on + api.fs.rename() + end, opts) + + vim.keymap.set("n", "d", function() -- Delete file + vim.cmd("set modifiable") -- Ensure modifiable mode is on + api.fs.remove() + end, opts) + + vim.keymap.set("n", "x", function() -- Cut (move) file + vim.cmd("set modifiable") -- Ensure modifiable mode is on + api.fs.cut() + end, opts) + + vim.keymap.set("n", "p", function() -- Paste file + vim.cmd("set modifiable") -- Ensure modifiable mode is on + api.fs.paste() + end, opts) + + vim.keymap.set("n", "y", function() -- Copy file + vim.cmd("set modifiable") -- Ensure modifiable mode is on + api.fs.copy() + end, opts) + end, + }) + + -- set keymaps + local keymap = vim.keymap -- for conciseness + + keymap.set("n", "ee", "NvimTreeToggle", { desc = "Toggle file explorer" }) -- toggle file explorer + keymap.set("n", "nt", "NvimTreeFindFileToggle", { desc = "Toggle file explorer on current file" }) -- toggle file explorer on current file + keymap.set("n", "ec", "NvimTreeCollapse", { desc = "Collapse file explorer" }) -- collapse file explorer + keymap.set("n", "er", "NvimTreeRefresh", { desc = "Refresh file explorer" }) -- refresh file explorer + end, +} diff --git a/lazy-lock.json b/lazy-lock.json index 040a54b..fd37a9b 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -9,6 +9,7 @@ "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, "conform.nvim": { "branch": "master", "commit": "363243c03102a531a8203311d4f2ae704c620d9b" }, + "copilot.vim": { "branch": "release", "commit": "87038123804796ca7af20d1b71c3428d858a9124" }, "dressing.nvim": { "branch": "master", "commit": "56ef6a969a4990d938c5fed40c370f65e125fc97" }, "friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" }, "gitsigns.nvim": { "branch": "main", "commit": "9b36d497495436c135659902054ee637e0ba6021" }, @@ -18,14 +19,23 @@ "lspkind.nvim": { "branch": "master", "commit": "d79a1c3299ad0ef94e255d045bed9fa26025dab6" }, "lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "f75e877f5266e87523eb5a18fcde2081820d087b" }, + "mason-nvim-dap.nvim": { "branch": "main", "commit": "8b9363d83b5d779813cdd2819b8308651cec2a09" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "374c78d3ebb5c53f43ea6bd906b6587b5e899b9e" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, "neodev.nvim": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" }, + "noice.nvim": { "branch": "main", "commit": "e3c68a4d2275a01268a52e2931bfccfbfb693d15" }, + "nui.nvim": { "branch": "main", "commit": "53e907ffe5eedebdca1cd503b00aa8692068ca46" }, "nvim-autopairs": { "branch": "master", "commit": "3d02855468f94bf435db41b661b58ec4f48a06b7" }, "nvim-cmp": { "branch": "main", "commit": "12509903a5723a876abd65953109f926f4634c30" }, + "nvim-dap": { "branch": "master", "commit": "b4f27d451c187de912fa8d3229025a952917eb9e" }, + "nvim-dap-python": { "branch": "master", "commit": "34282820bb713b9a5fdb120ae8dd85c2b3f49b51" }, + "nvim-dap-ui": { "branch": "master", "commit": "bc81f8d3440aede116f821114547a476b082b319" }, + "nvim-dap-virtual-text": { "branch": "master", "commit": "df66808cd78b5a97576bbaeee95ed5ca385a9750" }, "nvim-lint": { "branch": "master", "commit": "789b7ada1b4f00e08d026dffde410dcfa6a0ba87" }, "nvim-lsp-file-operations": { "branch": "master", "commit": "9744b738183a5adca0f916527922078a965515ed" }, "nvim-lspconfig": { "branch": "master", "commit": "f98fa715acc975c2dd5fb5ba7ceddeb1cc725ad2" }, + "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, + "nvim-notify": { "branch": "master", "commit": "22f29093eae7785773ee9d543f8750348b1a195c" }, "nvim-surround": { "branch": "main", "commit": "ae298105122c87bbe0a36b1ad20b06d417c0433e" }, "nvim-tree.lua": { "branch": "master", "commit": "d05881f65f0a653db8d830ccc4d2e07d6a720628" }, "nvim-treesitter": { "branch": "master", "commit": "4988b7068001b3a772c7cc738708341e612e3c26" }, @@ -35,11 +45,13 @@ "nvim-web-devicons": { "branch": "master", "commit": "402377242b04be3f4f0f3720bd952df86e946c30" }, "plenary.nvim": { "branch": "master", "commit": "3707cdb1e43f5cea73afb6037e6494e7ce847a66" }, "substitute.nvim": { "branch": "main", "commit": "97f49d16f8eea7967d41db4f657dd63af53eeba1" }, + "telescope-dap.nvim": { "branch": "master", "commit": "783366bd6c1e7fa0a5c59c07db37f49c805a28df" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "dae2eac9d91464448b584c7949a31df8faefec56" }, "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, "tokyonight.nvim": { "branch": "main", "commit": "dca4adba7dc5f09302a00b0e76078d54d82d2658" }, "trouble.nvim": { "branch": "main", "commit": "6f380b8826fb819c752c8fd7daaee9ef96d4c689" }, + "vim-buftabline": { "branch": "master", "commit": "73b9ef5dcb6cdf6488bc88adb382f20bc3e3262a" }, "vim-maximizer": { "branch": "master", "commit": "2e54952fe91e140a2e69f35f22131219fcd9c5f1" }, "vim-tmux-navigator": { "branch": "master", "commit": "d847ea942a5bb4d4fab6efebc9f30d787fd96e65" }, "which-key.nvim": { "branch": "main", "commit": "0e76a87ac51772569aec678dc74baa8e2a86100c" } diff --git a/lua/cargdev/core/function/openTerminal.lua b/lua/cargdev/core/function/openTerminal.lua new file mode 100644 index 0000000..b0e7f95 --- /dev/null +++ b/lua/cargdev/core/function/openTerminal.lua @@ -0,0 +1,48 @@ +vim.g.mapleader = " " + +local keymap = vim.keymap + +-- Function to open terminal +local function open_terminal() + -- Move to the rightmost buffer (equivalent to `` multiple times) + vim.cmd("wincmd l") + vim.cmd("wincmd l") + vim.cmd("wincmd l") + vim.cmd("wincmd l") + + -- Get current buffer number and type + local buf_num = vim.api.nvim_get_current_buf() + local buf_type = vim.api.nvim_buf_get_option(buf_num, "buftype") + + if buf_type == "terminal" then + -- If already in a terminal, close it + vim.cmd("q") + else + -- Open terminal in a vertical split + vim.cmd("vsp | term zsh") + + -- Disable line numbers in terminal + vim.cmd("setlocal nonumber norelativenumber") + + -- Auto-start insert mode in terminal + vim.api.nvim_create_autocmd({ "BufWinEnter", "WinEnter" }, { + buffer = 0, + command = "startinsert!", + }) + vim.api.nvim_create_autocmd("BufLeave", { + buffer = 0, + command = "stopinsert!", + }) + + -- Terminal key mappings + vim.keymap.set("t", "", "h", { buffer = true }) + vim.keymap.set("t", "", ":q", { buffer = true }) + vim.keymap.set("t", "", "", { buffer = true }) + + -- Start terminal in insert mode + vim.cmd("startinsert!") + end +end + +-- Keybinding to open terminal +keymap.set("n", "ter", open_terminal, { noremap = true, silent = true }) diff --git a/lua/cargdev/core/init.lua b/lua/cargdev/core/init.lua index 779524d..9f8be3c 100644 --- a/lua/cargdev/core/init.lua +++ b/lua/cargdev/core/init.lua @@ -1,2 +1,19 @@ require("cargdev.core.options") require("cargdev.core.keymaps") + +-- Load all Lua files inside `cargdev/core/function/` +local function load_functions() + local function_path = vim.fn.stdpath("config") .. "/lua/cargdev/core/function" + local scan = vim.fn.globpath(function_path, "*.lua", false, true) + + for _, file in ipairs(scan) do + local module_name = "cargdev.core.function." .. file:match("([^/]+)%.lua$") + local success, err = pcall(require, module_name) + + if not success then + vim.notify("Error loading function module: " .. module_name .. "\n" .. err, vim.log.levels.ERROR) + end + end +end + +load_functions() diff --git a/lua/cargdev/core/keymaps.lua b/lua/cargdev/core/keymaps.lua index cf0e5b2..a2cb19f 100644 --- a/lua/cargdev/core/keymaps.lua +++ b/lua/cargdev/core/keymaps.lua @@ -31,6 +31,30 @@ keymap.set("n", "tf", "tabnew %", { desc = "Open current buffer -- sintax fixer keymap.set("n", "sy", "gg=G", { desc = "Format current file" }) - keymap.set("n", "", "10", { noremap = true, silent = true }) keymap.set("n", "", "10", { noremap = true, silent = true }) + +-- close current file on buffer +keymap.set("n", "bd", ":bd", { desc = "Close current file on buffer" }) + +-- Set buftabline mappings +keymap.set("n", "", ":bnext", { noremap = true, silent = true }) +keymap.set("n", "", ":bprev", { noremap = true, silent = true }) + +-- Coding hacks +keymap.set( + "n", + "re", + "ggOimportReactfrom'react';0", + { desc = "Type import react from 'react' at the top of the file" } +) +keymap.set("n", ",", "$a,", { desc = "Adding ',' at the end of the line" }) +keymap.set("n", ";", "$a;", { desc = "Adding ';' at the end of the line" }) +keymap.set("n", "con", "oconsole.log()0w$h", { desc = "Adding console.log() on the line below" }) +keymap.set("n", "x", ":!node %", { desc = "Running current project using node" }) + +-- Move between Tmux and Neovim splits using Alt + Arrow keys +-- keymap.set("n", "", ":TmuxNavigateLeft", { noremap = true, silent = true }) +-- keymap.set("n", "", ":TmuxNavigateDown", { noremap = true, silent = true }) +-- keymap.set("n", "", ":TmuxNavigateUp", { noremap = true, silent = true }) +-- keymap.set("n", "", ":TmuxNavigateRight", { noremap = true, silent = true }) diff --git a/lua/cargdev/plugins/alpha.lua b/lua/cargdev/plugins/alpha.lua index 33ce78e..773f064 100644 --- a/lua/cargdev/plugins/alpha.lua +++ b/lua/cargdev/plugins/alpha.lua @@ -5,8 +5,15 @@ return { local alpha = require("alpha") local dashboard = require("alpha.themes.dashboard") - -- Set header + -- 🚀 Set header dashboard.section.header.val = { + " ██████╗ █████╗ ██████╗ ██████╗ ██████╗ ███████╗██╗ ██╗ ", + " █╔════╝██╔══██╗██╔══██╗██╔════╝ ██╔══██╗██╔════╝██║ ██║ ", + " █║ ███████║██████╔╝██║ ███╗██║ ██║█████╗ ██║ ██║ ", + " █║ ██╔══██║██╔══██╗██║ ██║██║ ██║██╔══╝ ╚██╗ ██╔╝ ", + " ██████╗██║ ██║██║ ██║╚██████╔╝██████╔╝███████╗ ╚████╔╝ ", + " ╚═════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═══╝ ", + " ", " ", " ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ ", " ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ ", @@ -15,22 +22,82 @@ return { " ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ ", " ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ", " ", + " ", + " 🚀 Welcome to CarGDev Neovim - Customize Your Flow! 🚀 ", } - -- Set menu + -- 📂 Set menu with improved icons dashboard.section.buttons.val = { - dashboard.button("e", " > New File", "ene"), - dashboard.button("SPC ee", " > Toggle file explorer", "NvimTreeToggle"), - dashboard.button("SPC ff", "󰱼 > Find File", "Telescope find_files"), - dashboard.button("SPC fs", " > Find Word", "Telescope live_grep"), - dashboard.button("SPC wr", "󰁯 > Restore Session For Current Directory", "SessionRestore"), - dashboard.button("q", " > Quit NVIM", "qa"), + dashboard.button("e", "📜 New File", "ene"), + dashboard.button("SPC ee", "📂 File Explorer", "NvimTreeToggle"), + dashboard.button("SPC ff", "🔎 Find File", "Telescope find_files"), + dashboard.button("SPC fs", "📝 Find Word", "Telescope live_grep"), + dashboard.button("SPC wr", "💾 Restore Session", "SessionRestore"), + dashboard.button("q", "❌ Quit NVIM", "qa"), } - -- Send config to alpha + -- 🎯 Function to center text within a width + local function center_text(text, width) + local padding = math.floor((width - #text) / 2) + return padding > 0 and string.rep(" ", padding) .. text or text + end + + -- 📌 Function to wrap text at a specific width + local function wrap_text(text, width) + local wrapped_lines = {} + for line in text:gmatch("[^\n]+") do + while #line > width do + local cut = line:sub(1, width) + table.insert(wrapped_lines, center_text(cut, width)) + line = line:sub(width + 1) + end + table.insert(wrapped_lines, center_text(line, width)) + end + return wrapped_lines + end + + -- 🖥 Set viewport width (adjust if necessary) + local viewport_width = 50 + + -- 📝 Get a fortune quote and wrap it + local handle = io.popen("fortune") + local quote = handle and handle:read("*a") or "💻 Code, Create, Conquer with CarGDev 🚀" + if handle then + handle:close() + end + local wrapped_quote = wrap_text(quote:gsub("\n", " "), viewport_width) + + -- 📝 Set the footer content with added spacing + dashboard.section.footer.val = { + "", + center_text("🔧 CarGDev - Innovating with Neovim! 🔧", viewport_width), + "", + } + + -- Add wrapped quote below separator + for _, line in ipairs(wrapped_quote) do + table.insert(dashboard.section.footer.val, line) + end + + -- Add branding line at the bottom + table.insert(dashboard.section.footer.val, "") + table.insert( + dashboard.section.footer.val, + center_text("🎯 Stay productive & code with passion! 🚀", viewport_width) + ) + table.insert(dashboard.section.footer.val, "") + + -- 🌈 Apply modern styling + dashboard.opts.opts = { + position = "center", + hl = "Statement", + spacing = 2, + } + + -- 🚀 Load dashboard config alpha.setup(dashboard.opts) - -- Disable folding on alpha buffer + -- 🔥 Disable folding on alpha buffer vim.cmd([[autocmd FileType alpha setlocal nofoldenable]]) end, } diff --git a/lua/cargdev/plugins/bufferline.lua b/lua/cargdev/plugins/bufferline.lua index 7e1a826..dc083b4 100644 --- a/lua/cargdev/plugins/bufferline.lua +++ b/lua/cargdev/plugins/bufferline.lua @@ -1,6 +1,7 @@ return { "akinsho/bufferline.nvim", dependencies = { "nvim-tree/nvim-web-devicons" }, + version = "*", opts = { options = { diff --git a/lua/cargdev/plugins/buffertabs.lua b/lua/cargdev/plugins/buffertabs.lua new file mode 100644 index 0000000..42a6027 --- /dev/null +++ b/lua/cargdev/plugins/buffertabs.lua @@ -0,0 +1,12 @@ +return { + "ap/vim-buftabline", + event = "VeryLazy", -- Loads when Neovim starts up + config = function() + -- Enable the buffer tabline + vim.g.buftabline_numbers = 2 -- Shows buffer numbers + vim.g.buftabline_separators = 1 -- Shows separators between tabs + vim.g.buftabline_indicators = 1 -- Show indicators for modified buffers + vim.g.buftabline_show = 1 -- 0: never, 1: always, 2: auto-hide when only one buffer + vim.g.buftabline_modified_indicator = "[+]" -- Custom indicator for modified buffers + end, +} diff --git a/lua/cargdev/plugins/colorscheme.lua b/lua/cargdev/plugins/colorscheme.lua index 21d6c48..2c1d558 100644 --- a/lua/cargdev/plugins/colorscheme.lua +++ b/lua/cargdev/plugins/colorscheme.lua @@ -4,15 +4,25 @@ return { config = function() local transparent = false -- set to true if you would like to enable transparency - local bg = "#011628" - local bg_dark = "#011423" - local bg_highlight = "#143652" - local bg_search = "#0A64AC" - local bg_visual = "#275378" - local fg = "#CBE0F0" + -- local bg = "#011628" + -- local bg_dark = "#011423" + -- local bg_highlight = "#143652" + -- local bg_search = "#0A64AC" + -- local bg_visual = "#275378" + -- local fg = "#CBE0F0" + -- local fg_dark = "#B4D0E9" + -- local fg_gutter = "#627E97" + -- local border = "#547998" + + local bg = "#1A1A2E" + local bg_dark = "#29294B" + local bg_highlight = "#4E4E50" + local bg_search = "#1A1743" + local bg_visual = "#70707E" + local fg = "#BFC5D2" local fg_dark = "#B4D0E9" local fg_gutter = "#627E97" - local border = "#547998" + local border = "#687494" require("tokyonight").setup({ style = "night", diff --git a/lua/cargdev/plugins/copilot.lua b/lua/cargdev/plugins/copilot.lua new file mode 100644 index 0000000..0925e4a --- /dev/null +++ b/lua/cargdev/plugins/copilot.lua @@ -0,0 +1,11 @@ +return { + "github/copilot.vim", + lazy = false, -- Force load on startup + config = function() + vim.g.copilot_no_tab_map = true -- Disable default Tab mapping + vim.api.nvim_set_keymap("i", "", 'copilot#Accept("")', { expr = true, silent = true }) + vim.api.nvim_set_keymap("i", "", "copilot#Next()", { expr = true, silent = true }) + vim.api.nvim_set_keymap("i", "", "copilot#Previous()", { expr = true, silent = true }) + vim.api.nvim_set_keymap("i", "", "copilot#Dismiss()", { expr = true, silent = true }) + end, +} diff --git a/lua/cargdev/plugins/dap.lua b/lua/cargdev/plugins/dap.lua new file mode 100644 index 0000000..865fd4d --- /dev/null +++ b/lua/cargdev/plugins/dap.lua @@ -0,0 +1,99 @@ +return { + "mfussenegger/nvim-dap", + dependencies = { + { "nvim-neotest/nvim-nio", lazy = false }, -- Ensure `nvim-nio` loads first + "rcarriga/nvim-dap-ui", + "jay-babu/mason-nvim-dap.nvim", + "mfussenegger/nvim-dap-python", + "theHamsta/nvim-dap-virtual-text", + "nvim-telescope/telescope-dap.nvim", + }, + config = function() + local dap = require("dap") + local dapui = require("dapui") + + -- UI Setup + dapui.setup() + + -- Mason Debugger Installer + require("mason-nvim-dap").setup({ + ensure_installed = { "node2", "chrome", "firefox" }, + automatic_setup = true, + }) + + -- Automatically open DAP UI when debugging starts + dap.listeners.after.event_initialized["dapui_config"] = function() + dapui.open() + end + dap.listeners.before.event_terminated["dapui_config"] = function() + dapui.close() + end + dap.listeners.before.event_exited["dapui_config"] = function() + dapui.close() + end + + -- Enable virtual text for debugging + require("nvim-dap-virtual-text").setup({}) + + -- Keymaps for debugging + local keymap = vim.keymap.set + keymap("n", "", function() + dap.continue() + end, { desc = "Start Debugging" }) + keymap("n", "", function() + dap.step_over() + end, { desc = "Step Over" }) + keymap("n", "", function() + dap.step_into() + end, { desc = "Step Into" }) + keymap("n", "", function() + dap.step_out() + end, { desc = "Step Out" }) + keymap("n", "db", function() + dap.toggle_breakpoint() + end, { desc = "Toggle Breakpoint" }) + keymap("n", "dB", function() + dap.set_breakpoint(vim.fn.input("Breakpoint condition: ")) + end, { desc = "Conditional Breakpoint" }) + keymap("n", "dr", function() + dap.repl.open() + end, { desc = "Open REPL" }) + keymap("n", "dl", function() + dap.run_last() + end, { desc = "Run Last Debug Session" }) + keymap("n", "du", function() + dapui.toggle() + end, { desc = "Toggle DAP UI" }) + + -- Node.js Adapter Configuration for NestJS + dap.adapters.node2 = { + type = "executable", + command = "node", + args = { os.getenv("HOME") .. "/.local/share/nvim/mason/packages/node-debug2-adapter/out/src/nodedebug.js" }, + } + + -- Debug Configuration for NestJS + dap.configurations.typescript = { + { + name = "Launch NestJS", + type = "node2", + request = "launch", + program = "${workspaceFolder}/node_modules/.bin/nest", + args = { "start", "--debug", "--watch" }, + console = "integratedTerminal", + outFiles = { "${workspaceFolder}/dist/**/*.js" }, + sourceMaps = true, + protocol = "inspector", + cwd = vim.fn.getcwd(), + restart = true, + runtimeArgs = { "--nolazy" }, + }, + { + name = "Attach to Process", + type = "node2", + request = "attach", + processId = require("dap.utils").pick_process, + }, + } + end, +} diff --git a/lua/cargdev/plugins/formatting.lua b/lua/cargdev/plugins/formatting.lua index 074c931..31c081b 100644 --- a/lua/cargdev/plugins/formatting.lua +++ b/lua/cargdev/plugins/formatting.lua @@ -28,7 +28,7 @@ return { }, }) - vim.keymap.set({ "n", "v" }, "mp", function() + vim.keymap.set({ "n", "v" }, "mm", function() conform.format({ lsp_fallback = true, async = false, diff --git a/lua/cargdev/plugins/lsp/lspconfig.lua b/lua/cargdev/plugins/lsp/lspconfig.lua index 9fa4f1a..7fa084e 100644 --- a/lua/cargdev/plugins/lsp/lspconfig.lua +++ b/lua/cargdev/plugins/lsp/lspconfig.lua @@ -80,9 +80,15 @@ return { mason_lspconfig.setup_handlers({ -- default handler for installed servers - function(server_name) - lspconfig[server_name].setup({ + ["eslint"] = function() + lspconfig["eslint"].setup({ capabilities = capabilities, + settings = { + experimental = { useFlatConfig = true }, -- ✅ Enables Flat Config Support + codeActionOnSave = { enable = true }, + format = { enable = true }, + }, + root_dir = lspconfig.util.root_pattern("eslint.config.js", "package.json"), }) end, ["svelte"] = function() diff --git a/lua/cargdev/plugins/noice.lua b/lua/cargdev/plugins/noice.lua new file mode 100644 index 0000000..b3b43d4 --- /dev/null +++ b/lua/cargdev/plugins/noice.lua @@ -0,0 +1,56 @@ +return { + "folke/noice.nvim", + event = "VeryLazy", + dependencies = { + "MunifTanjim/nui.nvim", + "rcarriga/nvim-notify", + }, + config = function() + require("noice").setup({ + cmdline = { + enabled = true, -- Enables floating command-line window + view = "cmdline_popup", -- Use floating popup instead of bottom bar + format = { + cmdline = { icon = ">" }, -- Custom icon for `:` + search_down = { icon = "🔍 " }, -- Custom icon for `/` + search_up = { icon = "🔍 " }, -- Custom icon for `?` + filter = { icon = "$" }, + lua = { icon = "" }, + help = { icon = "?" }, + }, + }, + messages = { + enabled = true, -- Show messages in floating windows + view = "notify", -- Use floating popup instead of bottom bar + }, + popupmenu = { + enabled = true, -- Floating completion menu + backend = "nui", + }, + lsp = { + progress = { + enabled = false, + }, + }, + views = { + notify = { + position = "top", -- Moves notifications to the bottom + win_options = { winblend = 10 }, -- Optional transparency + max_height = 2, -- Max height of the notification window + max_width = 50, -- Max width of the notification window + }, + mini = { + position = { + row = -2, -- Positions it closer to the bottom + col = "50%", + }, + }, + }, + presets = { + bottom_search = false, -- Disable default bottom search bar + command_palette = true, -- Make commands appear in the center + long_message_to_split = true, -- Long messages go to a split + }, + }) + end, +} diff --git a/lua/cargdev/plugins/nvim-tree.lua b/lua/cargdev/plugins/nvim-tree.lua index f1b19c0..1d725b2 100644 --- a/lua/cargdev/plugins/nvim-tree.lua +++ b/lua/cargdev/plugins/nvim-tree.lua @@ -44,6 +44,49 @@ return { git = { ignore = false, }, + on_attach = function(bufnr) -- Correct way to set keymaps + local api = require("nvim-tree.api") + local opts = { noremap = true, silent = true, nowait = true, buffer = bufnr } + + -- Open file in vertical split + vim.keymap.set("n", "s", api.node.open.vertical, opts) + + -- Open file in horizontal split + vim.keymap.set("n", "i", api.node.open.horizontal, opts) + + -- Open file in the current window + vim.keymap.set("n", "o", api.node.open.edit, opts) + -- File Management keybindings + vim.keymap.set("n", "a", function() -- Add a new file + vim.cmd("set modifiable") -- Ensure modifiable mode is on + api.fs.create() + end, opts) + + vim.keymap.set("n", "r", function() -- Rename file + vim.cmd("set modifiable") -- Ensure modifiable mode is on + api.fs.rename() + end, opts) + + vim.keymap.set("n", "d", function() -- Delete file + vim.cmd("set modifiable") -- Ensure modifiable mode is on + api.fs.remove() + end, opts) + + vim.keymap.set("n", "x", function() -- Cut (move) file + vim.cmd("set modifiable") -- Ensure modifiable mode is on + api.fs.cut() + end, opts) + + vim.keymap.set("n", "p", function() -- Paste file + vim.cmd("set modifiable") -- Ensure modifiable mode is on + api.fs.paste() + end, opts) + + vim.keymap.set("n", "y", function() -- Copy file + vim.cmd("set modifiable") -- Ensure modifiable mode is on + api.fs.copy() + end, opts) + end, }) -- set keymaps @@ -53,5 +96,5 @@ return { keymap.set("n", "nt", "NvimTreeFindFileToggle", { desc = "Toggle file explorer on current file" }) -- toggle file explorer on current file keymap.set("n", "ec", "NvimTreeCollapse", { desc = "Collapse file explorer" }) -- collapse file explorer keymap.set("n", "er", "NvimTreeRefresh", { desc = "Refresh file explorer" }) -- refresh file explorer - end + end, } diff --git a/lua/cargdev/plugins/tmux.lua b/lua/cargdev/plugins/tmux.lua new file mode 100644 index 0000000..2ee866a --- /dev/null +++ b/lua/cargdev/plugins/tmux.lua @@ -0,0 +1,4 @@ +return { + "christoomey/vim-tmux-navigator", + event = "VeryLazy", -- Loads only when needed +} diff --git a/lua/cargdev/plugins/treesitter.lua b/lua/cargdev/plugins/treesitter.lua index ef9e43a..469293e 100644 --- a/lua/cargdev/plugins/treesitter.lua +++ b/lua/cargdev/plugins/treesitter.lua @@ -13,6 +13,10 @@ return { treesitter.setup({ -- enable syntax highlighting highlight = { enable = true, + disable = function(lang, buf) + -- Prevent Treesitter from parsing Copilot files + return lang == "copilot" or vim.api.nvim_buf_get_name(buf):match("copilot.lua") + end, }, -- enable indentation indent = { enable = true },