From dbd430eac24bb54fe3ab309d7a56543d7a9831b4 Mon Sep 17 00:00:00 2001 From: Carlos Date: Sat, 1 Feb 2025 23:17:13 -0500 Subject: [PATCH] feat: initial commit --- .stylua.toml | 2 + init.lua | 2 + lazy-lock.json | 46 ++++++ lua/cargdev/core/init.lua | 2 + lua/cargdev/core/keymaps.lua | 36 +++++ lua/cargdev/core/options.lua | 39 +++++ lua/cargdev/lazy.lua | 22 +++ lua/cargdev/plugins/alpha.lua | 36 +++++ lua/cargdev/plugins/auto-session.lua | 16 +++ lua/cargdev/plugins/autopairs.lua | 30 ++++ lua/cargdev/plugins/bufferline.lua | 10 ++ lua/cargdev/plugins/colorscheme.lua | 45 ++++++ lua/cargdev/plugins/comments.lua | 19 +++ lua/cargdev/plugins/dressing.lua | 4 + lua/cargdev/plugins/formatting.lua | 39 +++++ lua/cargdev/plugins/gitsigns.lua | 47 ++++++ lua/cargdev/plugins/indent-blankline.lua | 8 ++ lua/cargdev/plugins/init.lua | 4 + lua/cargdev/plugins/lazygit.lua | 19 +++ lua/cargdev/plugins/linting.lua | 29 ++++ lua/cargdev/plugins/lsp/lspconfig.lua | 136 ++++++++++++++++++ lua/cargdev/plugins/lsp/mason.lua | 54 +++++++ lua/cargdev/plugins/lualine.lua | 71 +++++++++ lua/cargdev/plugins/nvim-cmp.lua | 63 ++++++++ lua/cargdev/plugins/nvim-tree.lua | 57 ++++++++ .../plugins/nvim-treesitter-text-objects.lua | 110 ++++++++++++++ lua/cargdev/plugins/substitute.lua | 17 +++ lua/cargdev/plugins/surround.lua | 6 + lua/cargdev/plugins/telescope.lua | 50 +++++++ lua/cargdev/plugins/todo-comments.lua | 21 +++ lua/cargdev/plugins/treesitter.lua | 58 ++++++++ lua/cargdev/plugins/trouble.lua | 15 ++ lua/cargdev/plugins/vim-maximizer.lua | 6 + lua/cargdev/plugins/which-key.lua | 13 ++ 34 files changed, 1132 insertions(+) create mode 100644 .stylua.toml create mode 100644 init.lua create mode 100644 lazy-lock.json create mode 100644 lua/cargdev/core/init.lua create mode 100644 lua/cargdev/core/keymaps.lua create mode 100644 lua/cargdev/core/options.lua create mode 100644 lua/cargdev/lazy.lua create mode 100644 lua/cargdev/plugins/alpha.lua create mode 100644 lua/cargdev/plugins/auto-session.lua create mode 100644 lua/cargdev/plugins/autopairs.lua create mode 100644 lua/cargdev/plugins/bufferline.lua create mode 100644 lua/cargdev/plugins/colorscheme.lua create mode 100644 lua/cargdev/plugins/comments.lua create mode 100644 lua/cargdev/plugins/dressing.lua create mode 100644 lua/cargdev/plugins/formatting.lua create mode 100644 lua/cargdev/plugins/gitsigns.lua create mode 100644 lua/cargdev/plugins/indent-blankline.lua create mode 100644 lua/cargdev/plugins/init.lua create mode 100644 lua/cargdev/plugins/lazygit.lua create mode 100644 lua/cargdev/plugins/linting.lua create mode 100644 lua/cargdev/plugins/lsp/lspconfig.lua create mode 100644 lua/cargdev/plugins/lsp/mason.lua create mode 100644 lua/cargdev/plugins/lualine.lua create mode 100644 lua/cargdev/plugins/nvim-cmp.lua create mode 100644 lua/cargdev/plugins/nvim-tree.lua create mode 100644 lua/cargdev/plugins/nvim-treesitter-text-objects.lua create mode 100644 lua/cargdev/plugins/substitute.lua create mode 100644 lua/cargdev/plugins/surround.lua create mode 100644 lua/cargdev/plugins/telescope.lua create mode 100644 lua/cargdev/plugins/todo-comments.lua create mode 100644 lua/cargdev/plugins/treesitter.lua create mode 100644 lua/cargdev/plugins/trouble.lua create mode 100644 lua/cargdev/plugins/vim-maximizer.lua create mode 100644 lua/cargdev/plugins/which-key.lua diff --git a/.stylua.toml b/.stylua.toml new file mode 100644 index 0000000..0435f67 --- /dev/null +++ b/.stylua.toml @@ -0,0 +1,2 @@ +indent_type = "Spaces" +indent_width = 2 diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..9d7c20a --- /dev/null +++ b/init.lua @@ -0,0 +1,2 @@ +require("cargdev.core") +require("cargdev.lazy") diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..040a54b --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,46 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, + "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" }, + "alpha-nvim": { "branch": "main", "commit": "de72250e054e5e691b9736ee30db72c65d560771" }, + "auto-session": { "branch": "main", "commit": "82630e2f70be140f8dcc75a12e2ee2839e8488c2" }, + "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "conform.nvim": { "branch": "master", "commit": "363243c03102a531a8203311d4f2ae704c620d9b" }, + "dressing.nvim": { "branch": "master", "commit": "56ef6a969a4990d938c5fed40c370f65e125fc97" }, + "friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" }, + "gitsigns.nvim": { "branch": "main", "commit": "9b36d497495436c135659902054ee637e0ba6021" }, + "indent-blankline.nvim": { "branch": "master", "commit": "e10626f7fcd51ccd56d7ffc00883ba7e0aa28f78" }, + "lazy.nvim": { "branch": "main", "commit": "7527af40ddd4a93a02911be570b32609b9d4ea53" }, + "lazygit.nvim": { "branch": "main", "commit": "77a0d42943d8265271e6e6beaed72da54eeb17e7" }, + "lspkind.nvim": { "branch": "master", "commit": "d79a1c3299ad0ef94e255d045bed9fa26025dab6" }, + "lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "f75e877f5266e87523eb5a18fcde2081820d087b" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "374c78d3ebb5c53f43ea6bd906b6587b5e899b9e" }, + "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, + "neodev.nvim": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" }, + "nvim-autopairs": { "branch": "master", "commit": "3d02855468f94bf435db41b661b58ec4f48a06b7" }, + "nvim-cmp": { "branch": "main", "commit": "12509903a5723a876abd65953109f926f4634c30" }, + "nvim-lint": { "branch": "master", "commit": "789b7ada1b4f00e08d026dffde410dcfa6a0ba87" }, + "nvim-lsp-file-operations": { "branch": "master", "commit": "9744b738183a5adca0f916527922078a965515ed" }, + "nvim-lspconfig": { "branch": "master", "commit": "f98fa715acc975c2dd5fb5ba7ceddeb1cc725ad2" }, + "nvim-surround": { "branch": "main", "commit": "ae298105122c87bbe0a36b1ad20b06d417c0433e" }, + "nvim-tree.lua": { "branch": "master", "commit": "d05881f65f0a653db8d830ccc4d2e07d6a720628" }, + "nvim-treesitter": { "branch": "master", "commit": "4988b7068001b3a772c7cc738708341e612e3c26" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "ad8f0a472148c3e0ae9851e26a722ee4e29b1595" }, + "nvim-ts-autotag": { "branch": "main", "commit": "1cca23c9da708047922d3895a71032bc0449c52d" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" }, + "nvim-web-devicons": { "branch": "master", "commit": "402377242b04be3f4f0f3720bd952df86e946c30" }, + "plenary.nvim": { "branch": "master", "commit": "3707cdb1e43f5cea73afb6037e6494e7ce847a66" }, + "substitute.nvim": { "branch": "main", "commit": "97f49d16f8eea7967d41db4f657dd63af53eeba1" }, + "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-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/init.lua b/lua/cargdev/core/init.lua new file mode 100644 index 0000000..779524d --- /dev/null +++ b/lua/cargdev/core/init.lua @@ -0,0 +1,2 @@ +require("cargdev.core.options") +require("cargdev.core.keymaps") diff --git a/lua/cargdev/core/keymaps.lua b/lua/cargdev/core/keymaps.lua new file mode 100644 index 0000000..cf0e5b2 --- /dev/null +++ b/lua/cargdev/core/keymaps.lua @@ -0,0 +1,36 @@ +vim.g.mapleader = " " + +local keymap = vim.keymap + +keymap.set("n", "u", "gg0vG$", { desc = "Select the whole file open" }) +keymap.set("n", "4", "0v$hy0o0p0kw", { desc = "Copy the entire line and paste just below" }) + +-- file management +keymap.set("n", "w", ":w", { desc = "Save the current file" }) +keymap.set("n", "xa", ":xa", { desc = "Save and close all the files" }) +keymap.set("n", "q", ":q", { desc = "Close all the files" }) +keymap.set("n", "so", ":source %", { desc = "Reload nvim" }) +keymap.set("n", "no", ":noh ", { desc = "Reset search a word" }) + +-- increment/decrement numbers +keymap.set("n", "+", "", { desc = "Increment number" }) -- increment +keymap.set("n", "-", "", { desc = "Decrement number" }) -- decrement + +-- window management +keymap.set("n", "sv", "v", { desc = "Split window vertically" }) -- split window vertically +keymap.set("n", "sh", "s", { desc = "Split window horizontally" }) -- split window horizontally +keymap.set("n", "se", "=", { desc = "Make splits equal size" }) -- make split windows equal width & height +keymap.set("n", "sx", "close", { desc = "Close current split" }) -- close current split window + +keymap.set("n", "to", "tabnew", { desc = "Open new tab" }) -- open new tab +keymap.set("n", "tx", "tabclose", { desc = "Close current tab" }) -- close current tab +keymap.set("n", "tn", "tabn", { desc = "Go to next tab" }) -- go to next tab +keymap.set("n", "tp", "tabp", { desc = "Go to previous tab" }) -- go to previous tab +keymap.set("n", "tf", "tabnew %", { desc = "Open current buffer in new tab" }) -- move current buffer to new tab + +-- 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 }) diff --git a/lua/cargdev/core/options.lua b/lua/cargdev/core/options.lua new file mode 100644 index 0000000..277db72 --- /dev/null +++ b/lua/cargdev/core/options.lua @@ -0,0 +1,39 @@ +vim.cmd("let g:netrw_liststyle = 3") + +local opt = vim.opt + +opt.relativenumber = true +opt.number = true + +-- tabs & indentation +opt.tabstop = 2 -- 2 spaces for tabs (prettier default) +opt.shiftwidth = 2 -- 2 spaces for indent width +opt.expandtab = true -- expand tab to spaces +opt.autoindent = true -- copy indent from current line when starting new one + +opt.wrap = false + +-- search settings +opt.ignorecase = true -- ignore case when searching +opt.smartcase = true -- if you include mixed case in your search, assumes you want case-sensitive + +opt.cursorline = true + +-- turn on termguicolors for tokyonight colorscheme to work +-- (have to use iterm2 or any other true color terminal) +opt.termguicolors = true +opt.background = "dark" -- colorschemes that can be light or dark will be made dark +opt.signcolumn = "yes" -- show sign column so that text doesn't shift + +-- backspace +opt.backspace = "indent,eol,start" -- allow backspace on indent, end of line or insert mode start position + +-- clipboard +opt.clipboard:append("unnamedplus") -- use system clipboard as default register + +-- split windows +opt.splitright = true -- split vertical window to the right +opt.splitbelow = true -- split horizontal window to the bottom + +-- turn off swapfile +opt.swapfile = false diff --git a/lua/cargdev/lazy.lua b/lua/cargdev/lazy.lua new file mode 100644 index 0000000..7c99456 --- /dev/null +++ b/lua/cargdev/lazy.lua @@ -0,0 +1,22 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +require("lazy").setup({ { import = "cargdev.plugins" }, { import = "cargdev.plugins.lsp" } }, { + checker = { + enabled = true, + notify = false, + }, + change_detection = { + notify = false, + }, +}) diff --git a/lua/cargdev/plugins/alpha.lua b/lua/cargdev/plugins/alpha.lua new file mode 100644 index 0000000..33ce78e --- /dev/null +++ b/lua/cargdev/plugins/alpha.lua @@ -0,0 +1,36 @@ +return { + "goolord/alpha-nvim", + event = "VimEnter", + config = function() + local alpha = require("alpha") + local dashboard = require("alpha.themes.dashboard") + + -- Set header + dashboard.section.header.val = { + " ", + " ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ ", + " ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ ", + " ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ ", + " ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ ", + " ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ ", + " ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ", + " ", + } + + -- Set menu + 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"), + } + + -- Send config to alpha + alpha.setup(dashboard.opts) + + -- Disable folding on alpha buffer + vim.cmd([[autocmd FileType alpha setlocal nofoldenable]]) + end, +} diff --git a/lua/cargdev/plugins/auto-session.lua b/lua/cargdev/plugins/auto-session.lua new file mode 100644 index 0000000..adeff79 --- /dev/null +++ b/lua/cargdev/plugins/auto-session.lua @@ -0,0 +1,16 @@ +return { + "rmagatti/auto-session", + config = function() + local auto_session = require("auto-session") + + auto_session.setup({ + auto_restore_enabled = false, + auto_session_suppress_dirs = { "~/", "~/Dev/", "~/Downloads", "~/Documents", "~/Desktop/" }, + }) + + local keymap = vim.keymap + + keymap.set("n", "wr", "SessionRestore", { desc = "Restore session for cwd" }) -- restore last workspace session for current directory + keymap.set("n", "ws", "SessionSave", { desc = "Save session for auto session root dir" }) -- save workspace session for current working directory + end, +} diff --git a/lua/cargdev/plugins/autopairs.lua b/lua/cargdev/plugins/autopairs.lua new file mode 100644 index 0000000..8ee54b3 --- /dev/null +++ b/lua/cargdev/plugins/autopairs.lua @@ -0,0 +1,30 @@ +return { + "windwp/nvim-autopairs", + event = { "InsertEnter" }, + dependencies = { + "hrsh7th/nvim-cmp", + }, + config = function() + -- import nvim-autopairs + local autopairs = require("nvim-autopairs") + + -- configure autopairs + autopairs.setup({ + check_ts = true, -- enable treesitter + ts_config = { + lua = { "string" }, -- don't add pairs in lua string treesitter nodes + javascript = { "template_string" }, -- don't add pairs in javscript template_string treesitter nodes + java = false, -- don't check treesitter on java + }, + }) + + -- import nvim-autopairs completion functionality + local cmp_autopairs = require("nvim-autopairs.completion.cmp") + + -- import nvim-cmp plugin (completions plugin) + local cmp = require("cmp") + + -- make autopairs and completion work together + cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) + end, +} diff --git a/lua/cargdev/plugins/bufferline.lua b/lua/cargdev/plugins/bufferline.lua new file mode 100644 index 0000000..7e1a826 --- /dev/null +++ b/lua/cargdev/plugins/bufferline.lua @@ -0,0 +1,10 @@ +return { + "akinsho/bufferline.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + version = "*", + opts = { + options = { + mode = "tabs", + }, + }, +} diff --git a/lua/cargdev/plugins/colorscheme.lua b/lua/cargdev/plugins/colorscheme.lua new file mode 100644 index 0000000..21d6c48 --- /dev/null +++ b/lua/cargdev/plugins/colorscheme.lua @@ -0,0 +1,45 @@ +return { + "folke/tokyonight.nvim", + priority = 1000, + 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 fg_dark = "#B4D0E9" + local fg_gutter = "#627E97" + local border = "#547998" + + require("tokyonight").setup({ + style = "night", + transparent = transparent, + styles = { + sidebars = transparent and "transparent" or "dark", + floats = transparent and "transparent" or "dark", + }, + on_colors = function(colors) + colors.bg = bg + colors.bg_dark = transparent and colors.none or bg_dark + colors.bg_float = transparent and colors.none or bg_dark + colors.bg_highlight = bg_highlight + colors.bg_popup = bg_dark + colors.bg_search = bg_search + colors.bg_sidebar = transparent and colors.none or bg_dark + colors.bg_statusline = transparent and colors.none or bg_dark + colors.bg_visual = bg_visual + colors.border = border + colors.fg = fg + colors.fg_dark = fg_dark + colors.fg_float = fg + colors.fg_gutter = fg_gutter + colors.fg_sidebar = fg_dark + end, + }) + + vim.cmd("colorscheme tokyonight") + end, +} diff --git a/lua/cargdev/plugins/comments.lua b/lua/cargdev/plugins/comments.lua new file mode 100644 index 0000000..ecc93c4 --- /dev/null +++ b/lua/cargdev/plugins/comments.lua @@ -0,0 +1,19 @@ +return { + "numToStr/Comment.nvim", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { + "JoosepAlviste/nvim-ts-context-commentstring", + }, + config = function() + -- import comment plugin safely + local comment = require("Comment") + + local ts_context_commentstring = require("ts_context_commentstring.integrations.comment_nvim") + + -- enable comment + comment.setup({ + -- for commenting tsx, jsx, svelte, html files + pre_hook = ts_context_commentstring.create_pre_hook(), + }) + end, +} diff --git a/lua/cargdev/plugins/dressing.lua b/lua/cargdev/plugins/dressing.lua new file mode 100644 index 0000000..105f7e5 --- /dev/null +++ b/lua/cargdev/plugins/dressing.lua @@ -0,0 +1,4 @@ +return { + "stevearc/dressing.nvim", + event = "VeryLazy", +} diff --git a/lua/cargdev/plugins/formatting.lua b/lua/cargdev/plugins/formatting.lua new file mode 100644 index 0000000..074c931 --- /dev/null +++ b/lua/cargdev/plugins/formatting.lua @@ -0,0 +1,39 @@ +return { + "stevearc/conform.nvim", + event = { "BufReadPre", "BufNewFile" }, + config = function() + local conform = require("conform") + + conform.setup({ + formatters_by_ft = { + javascript = { "prettier" }, + typescript = { "prettier" }, + javascriptreact = { "prettier" }, + typescriptreact = { "prettier" }, + svelte = { "prettier" }, + css = { "prettier" }, + html = { "prettier" }, + json = { "prettier" }, + yaml = { "prettier" }, + markdown = { "prettier" }, + graphql = { "prettier" }, + liquid = { "prettier" }, + lua = { "stylua" }, + python = { "isort", "black" }, + }, + format_on_save = { + lsp_fallback = true, + async = false, + timeout_ms = 1000, + }, + }) + + vim.keymap.set({ "n", "v" }, "mp", function() + conform.format({ + lsp_fallback = true, + async = false, + timeout_ms = 1000, + }) + end, { desc = "Format file or range (in visual mode)" }) + end, +} diff --git a/lua/cargdev/plugins/gitsigns.lua b/lua/cargdev/plugins/gitsigns.lua new file mode 100644 index 0000000..7daca01 --- /dev/null +++ b/lua/cargdev/plugins/gitsigns.lua @@ -0,0 +1,47 @@ +return { + "lewis6991/gitsigns.nvim", + event = { "BufReadPre", "BufNewFile" }, + opts = { + on_attach = function(bufnr) + local gs = package.loaded.gitsigns + + local function map(mode, l, r, desc) + vim.keymap.set(mode, l, r, { buffer = bufnr, desc = desc }) + end + + -- Navigation + map("n", "]h", gs.next_hunk, "Next Hunk") + map("n", "[h", gs.prev_hunk, "Prev Hunk") + + -- Actions + map("n", "hs", gs.stage_hunk, "Stage hunk") + map("n", "hr", gs.reset_hunk, "Reset hunk") + map("v", "hs", function() + gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) + end, "Stage hunk") + map("v", "hr", function() + gs.reset_hunk({ vim.fn.line("."), vim.fn.line("v") }) + end, "Reset hunk") + + map("n", "hS", gs.stage_buffer, "Stage buffer") + map("n", "hR", gs.reset_buffer, "Reset buffer") + + map("n", "hu", gs.undo_stage_hunk, "Undo stage hunk") + + map("n", "hp", gs.preview_hunk, "Preview hunk") + + map("n", "hb", function() + gs.blame_line({ full = true }) + end, "Blame line") + map("n", "hB", gs.toggle_current_line_blame, "Toggle line blame") + + map("n", "hd", gs.diffthis, "Diff this") + map("n", "hD", function() + gs.diffthis("~") + end, "Diff this ~") + + -- Text object + map({ "o", "x" }, "ih", ":Gitsigns select_hunk", "Gitsigns select hunk") + end, + }, +} diff --git a/lua/cargdev/plugins/indent-blankline.lua b/lua/cargdev/plugins/indent-blankline.lua new file mode 100644 index 0000000..572e0bd --- /dev/null +++ b/lua/cargdev/plugins/indent-blankline.lua @@ -0,0 +1,8 @@ +return { + "lukas-reineke/indent-blankline.nvim", + event = { "BufReadPre", "BufNewFile" }, + main = "ibl", + opts = { + indent = { char = "┊" }, + }, +} diff --git a/lua/cargdev/plugins/init.lua b/lua/cargdev/plugins/init.lua new file mode 100644 index 0000000..fee1d28 --- /dev/null +++ b/lua/cargdev/plugins/init.lua @@ -0,0 +1,4 @@ +return { + "nvim-lua/plenary.nvim", + "christoomey/vim-tmux-navigator", +} diff --git a/lua/cargdev/plugins/lazygit.lua b/lua/cargdev/plugins/lazygit.lua new file mode 100644 index 0000000..5d3f334 --- /dev/null +++ b/lua/cargdev/plugins/lazygit.lua @@ -0,0 +1,19 @@ +return { + "kdheepak/lazygit.nvim", + cmd = { + "LazyGit", + "LazyGitConfig", + "LazyGitCurrentFile", + "LazyGitFilter", + "LazyGitFilterCurrentFile", + }, + -- optional for floating window border decoration + dependencies = { + "nvim-lua/plenary.nvim", + }, + -- setting the keybinding for LazyGit with 'keys' is recommended in + -- order to load the plugin when the command is run for the first time + keys = { + { "lg", "LazyGit", desc = "Open lazy git" }, + }, +} diff --git a/lua/cargdev/plugins/linting.lua b/lua/cargdev/plugins/linting.lua new file mode 100644 index 0000000..e9fea9b --- /dev/null +++ b/lua/cargdev/plugins/linting.lua @@ -0,0 +1,29 @@ +return { + "mfussenegger/nvim-lint", + event = { "BufReadPre", "BufNewFile" }, + config = function() + local lint = require("lint") + + lint.linters_by_ft = { + javascript = { "eslint_d" }, + typescript = { "eslint_d" }, + javascriptreact = { "eslint_d" }, + typescriptreact = { "eslint_d" }, + svelte = { "eslint_d" }, + python = { "pylint" }, + } + + local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) + + vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { + group = lint_augroup, + callback = function() + lint.try_lint() + end, + }) + + vim.keymap.set("n", "l", function() + lint.try_lint() + end, { desc = "Trigger linting for current file" }) + end, +} diff --git a/lua/cargdev/plugins/lsp/lspconfig.lua b/lua/cargdev/plugins/lsp/lspconfig.lua new file mode 100644 index 0000000..9fa4f1a --- /dev/null +++ b/lua/cargdev/plugins/lsp/lspconfig.lua @@ -0,0 +1,136 @@ +return { + "neovim/nvim-lspconfig", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { + "hrsh7th/cmp-nvim-lsp", + { "antosha417/nvim-lsp-file-operations", config = true }, + { "folke/neodev.nvim", opts = {} }, + }, + config = function() + -- import lspconfig plugin + local lspconfig = require("lspconfig") + + -- import mason_lspconfig plugin + local mason_lspconfig = require("mason-lspconfig") + + -- import cmp-nvim-lsp plugin + local cmp_nvim_lsp = require("cmp_nvim_lsp") + + local keymap = vim.keymap -- for conciseness + + vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("UserLspConfig", {}), + callback = function(ev) + -- Buffer local mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local opts = { buffer = ev.buf, silent = true } + + -- set keybinds + opts.desc = "Show LSP references" + keymap.set("n", "gR", "Telescope lsp_references", opts) -- show definition, references + + opts.desc = "Go to declaration" + keymap.set("n", "gD", vim.lsp.buf.declaration, opts) -- go to declaration + + opts.desc = "Show LSP definitions" + keymap.set("n", "gd", "Telescope lsp_definitions", opts) -- show lsp definitions + + opts.desc = "Show LSP implementations" + keymap.set("n", "gi", "Telescope lsp_implementations", opts) -- show lsp implementations + + opts.desc = "Show LSP type definitions" + keymap.set("n", "gt", "Telescope lsp_type_definitions", opts) -- show lsp type definitions + + opts.desc = "See available code actions" + keymap.set({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts) -- see available code actions, in visual mode will apply to selection + + opts.desc = "Smart rename" + keymap.set("n", "rn", vim.lsp.buf.rename, opts) -- smart rename + + opts.desc = "Show buffer diagnostics" + keymap.set("n", "D", "Telescope diagnostics bufnr=0", opts) -- show diagnostics for file + + opts.desc = "Show line diagnostics" + keymap.set("n", "d", vim.diagnostic.open_float, opts) -- show diagnostics for line + + opts.desc = "Go to previous diagnostic" + keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) -- jump to previous diagnostic in buffer + + opts.desc = "Go to next diagnostic" + keymap.set("n", "]d", vim.diagnostic.goto_next, opts) -- jump to next diagnostic in buffer + + opts.desc = "Show documentation for what is under cursor" + keymap.set("n", "K", vim.lsp.buf.hover, opts) -- show documentation for what is under cursor + + opts.desc = "Restart LSP" + keymap.set("n", "rs", ":LspRestart", opts) -- mapping to restart lsp if necessary + end, + }) + + -- used to enable autocompletion (assign to every lsp server config) + local capabilities = cmp_nvim_lsp.default_capabilities() + + -- Change the Diagnostic symbols in the sign column (gutter) + -- (not in youtube nvim video) + local signs = { Error = " ", Warn = " ", Hint = "󰠠 ", Info = " " } + for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) + end + + mason_lspconfig.setup_handlers({ + -- default handler for installed servers + function(server_name) + lspconfig[server_name].setup({ + capabilities = capabilities, + }) + end, + ["svelte"] = function() + -- configure svelte server + lspconfig["svelte"].setup({ + capabilities = capabilities, + on_attach = function(client, bufnr) + vim.api.nvim_create_autocmd("BufWritePost", { + pattern = { "*.js", "*.ts" }, + callback = function(ctx) + -- Here use ctx.match instead of ctx.file + client.notify("$/onDidChangeTsOrJsFile", { uri = ctx.match }) + end, + }) + end, + }) + end, + ["graphql"] = function() + -- configure graphql language server + lspconfig["graphql"].setup({ + capabilities = capabilities, + filetypes = { "graphql", "gql", "svelte", "typescriptreact", "javascriptreact" }, + }) + end, + ["emmet_ls"] = function() + -- configure emmet language server + lspconfig["emmet_ls"].setup({ + capabilities = capabilities, + filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" }, + }) + end, + ["lua_ls"] = function() + -- configure lua server (with special settings) + lspconfig["lua_ls"].setup({ + capabilities = capabilities, + settings = { + Lua = { + -- make the language server recognize "vim" global + diagnostics = { + globals = { "vim" }, + }, + completion = { + callSnippet = "Replace", + }, + }, + }, + }) + end, + }) + end, +} diff --git a/lua/cargdev/plugins/lsp/mason.lua b/lua/cargdev/plugins/lsp/mason.lua new file mode 100644 index 0000000..748229c --- /dev/null +++ b/lua/cargdev/plugins/lsp/mason.lua @@ -0,0 +1,54 @@ +return { + "williamboman/mason.nvim", + dependencies = { + "williamboman/mason-lspconfig.nvim", + "WhoIsSethDaniel/mason-tool-installer.nvim", + }, + config = function() + -- import mason + local mason = require("mason") + + -- import mason-lspconfig + local mason_lspconfig = require("mason-lspconfig") + + local mason_tool_installer = require("mason-tool-installer") + + -- enable mason and configure icons + mason.setup({ + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗", + }, + }, + }) + + mason_lspconfig.setup({ + -- list of servers for mason to install + ensure_installed = { + "tsserver", + "html", + "cssls", + "tailwindcss", + "svelte", + "lua_ls", + "graphql", + "emmet_ls", + "prismals", + "pyright", + }, + }) + + mason_tool_installer.setup({ + ensure_installed = { + "prettier", -- prettier formatter + "stylua", -- lua formatter + "isort", -- python formatter + "black", -- python formatter + "pylint", + "eslint_d", + }, + }) + end, +} diff --git a/lua/cargdev/plugins/lualine.lua b/lua/cargdev/plugins/lualine.lua new file mode 100644 index 0000000..3698644 --- /dev/null +++ b/lua/cargdev/plugins/lualine.lua @@ -0,0 +1,71 @@ +return { + "nvim-lualine/lualine.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + local lualine = require("lualine") + local lazy_status = require("lazy.status") -- to configure lazy pending updates count + + local colors = { + blue = "#65D1FF", + green = "#3EFFDC", + violet = "#FF61EF", + yellow = "#FFDA7B", + red = "#FF4A4A", + fg = "#c3ccdc", + bg = "#112638", + inactive_bg = "#2c3043", + } + + local my_lualine_theme = { + normal = { + a = { bg = colors.blue, fg = colors.bg, gui = "bold" }, + b = { bg = colors.bg, fg = colors.fg }, + c = { bg = colors.bg, fg = colors.fg }, + }, + insert = { + a = { bg = colors.green, fg = colors.bg, gui = "bold" }, + b = { bg = colors.bg, fg = colors.fg }, + c = { bg = colors.bg, fg = colors.fg }, + }, + visual = { + a = { bg = colors.violet, fg = colors.bg, gui = "bold" }, + b = { bg = colors.bg, fg = colors.fg }, + c = { bg = colors.bg, fg = colors.fg }, + }, + command = { + a = { bg = colors.yellow, fg = colors.bg, gui = "bold" }, + b = { bg = colors.bg, fg = colors.fg }, + c = { bg = colors.bg, fg = colors.fg }, + }, + replace = { + a = { bg = colors.red, fg = colors.bg, gui = "bold" }, + b = { bg = colors.bg, fg = colors.fg }, + c = { bg = colors.bg, fg = colors.fg }, + }, + inactive = { + a = { bg = colors.inactive_bg, fg = colors.semilightgray, gui = "bold" }, + b = { bg = colors.inactive_bg, fg = colors.semilightgray }, + c = { bg = colors.inactive_bg, fg = colors.semilightgray }, + }, + } + + -- configure lualine with modified theme + lualine.setup({ + options = { + theme = my_lualine_theme, + }, + sections = { + lualine_x = { + { + lazy_status.updates, + cond = lazy_status.has_updates, + color = { fg = "#ff9e64" }, + }, + { "encoding" }, + { "fileformat" }, + { "filetype" }, + }, + }, + }) + end, +} diff --git a/lua/cargdev/plugins/nvim-cmp.lua b/lua/cargdev/plugins/nvim-cmp.lua new file mode 100644 index 0000000..0947011 --- /dev/null +++ b/lua/cargdev/plugins/nvim-cmp.lua @@ -0,0 +1,63 @@ +return { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + "hrsh7th/cmp-buffer", -- source for text in buffer + "hrsh7th/cmp-path", -- source for file system paths + { + "L3MON4D3/LuaSnip", + -- follow latest release. + version = "v2.*", -- Replace by the latest released major (first number of latest release) + -- install jsregexp (optional!). + build = "make install_jsregexp", + }, + "saadparwaiz1/cmp_luasnip", -- for autocompletion + "rafamadriz/friendly-snippets", -- useful snippets + "onsails/lspkind.nvim", -- vs-code like pictograms + }, + config = function() + local cmp = require("cmp") + + local luasnip = require("luasnip") + + local lspkind = require("lspkind") + + -- loads vscode style snippets from installed plugins (e.g. friendly-snippets) + require("luasnip.loaders.from_vscode").lazy_load() + + cmp.setup({ + completion = { + completeopt = "menu,menuone,preview,noselect", + }, + snippet = { -- configure how nvim-cmp interacts with snippet engine + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_prev_item(), -- previous suggestion + [""] = cmp.mapping.select_next_item(), -- next suggestion + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), -- show completion suggestions + [""] = cmp.mapping.abort(), -- close completion window + [""] = cmp.mapping.confirm({ select = false }), + }), + -- sources for autocompletion + sources = cmp.config.sources({ + { name = "nvim_lsp"}, + { name = "luasnip" }, -- snippets + { name = "buffer" }, -- text within current buffer + { name = "path" }, -- file system paths + }), + + -- configure lspkind for vs-code like pictograms in completion menu + formatting = { + format = lspkind.cmp_format({ + maxwidth = 50, + ellipsis_char = "...", + }), + }, + }) + end, +} diff --git a/lua/cargdev/plugins/nvim-tree.lua b/lua/cargdev/plugins/nvim-tree.lua new file mode 100644 index 0000000..f1b19c0 --- /dev/null +++ b/lua/cargdev/plugins/nvim-tree.lua @@ -0,0 +1,57 @@ +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, + }, + }) + + -- 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/lua/cargdev/plugins/nvim-treesitter-text-objects.lua b/lua/cargdev/plugins/nvim-treesitter-text-objects.lua new file mode 100644 index 0000000..68d5164 --- /dev/null +++ b/lua/cargdev/plugins/nvim-treesitter-text-objects.lua @@ -0,0 +1,110 @@ +return { + "nvim-treesitter/nvim-treesitter-textobjects", + lazy = true, + config = function() + require("nvim-treesitter.configs").setup({ + textobjects = { + select = { + enable = true, + + -- Automatically jump forward to textobj, similar to targets.vim + lookahead = true, + + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ["a="] = { query = "@assignment.outer", desc = "Select outer part of an assignment" }, + ["i="] = { query = "@assignment.inner", desc = "Select inner part of an assignment" }, + ["l="] = { query = "@assignment.lhs", desc = "Select left hand side of an assignment" }, + ["r="] = { query = "@assignment.rhs", desc = "Select right hand side of an assignment" }, + + -- works for javascript/typescript files (custom capture I created in after/queries/ecma/textobjects.scm) + ["a:"] = { query = "@property.outer", desc = "Select outer part of an object property" }, + ["i:"] = { query = "@property.inner", desc = "Select inner part of an object property" }, + ["l:"] = { query = "@property.lhs", desc = "Select left part of an object property" }, + ["r:"] = { query = "@property.rhs", desc = "Select right part of an object property" }, + + ["aa"] = { query = "@parameter.outer", desc = "Select outer part of a parameter/argument" }, + ["ia"] = { query = "@parameter.inner", desc = "Select inner part of a parameter/argument" }, + + ["ai"] = { query = "@conditional.outer", desc = "Select outer part of a conditional" }, + ["ii"] = { query = "@conditional.inner", desc = "Select inner part of a conditional" }, + + ["al"] = { query = "@loop.outer", desc = "Select outer part of a loop" }, + ["il"] = { query = "@loop.inner", desc = "Select inner part of a loop" }, + + ["af"] = { query = "@call.outer", desc = "Select outer part of a function call" }, + ["if"] = { query = "@call.inner", desc = "Select inner part of a function call" }, + + ["am"] = { query = "@function.outer", desc = "Select outer part of a method/function definition" }, + ["im"] = { query = "@function.inner", desc = "Select inner part of a method/function definition" }, + + ["ac"] = { query = "@class.outer", desc = "Select outer part of a class" }, + ["ic"] = { query = "@class.inner", desc = "Select inner part of a class" }, + }, + }, + swap = { + enable = true, + swap_next = { + ["na"] = "@parameter.inner", -- swap parameters/argument with next + ["n:"] = "@property.outer", -- swap object property with next + ["nm"] = "@function.outer", -- swap function with next + }, + swap_previous = { + ["pa"] = "@parameter.inner", -- swap parameters/argument with prev + ["p:"] = "@property.outer", -- swap object property with prev + ["pm"] = "@function.outer", -- swap function with previous + }, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + ["]f"] = { query = "@call.outer", desc = "Next function call start" }, + ["]m"] = { query = "@function.outer", desc = "Next method/function def start" }, + ["]c"] = { query = "@class.outer", desc = "Next class start" }, + ["]i"] = { query = "@conditional.outer", desc = "Next conditional start" }, + ["]l"] = { query = "@loop.outer", desc = "Next loop start" }, + + -- You can pass a query group to use query from `queries//.scm file in your runtime path. + -- Below example nvim-treesitter's `locals.scm` and `folds.scm`. They also provide highlights.scm and indent.scm. + ["]s"] = { query = "@scope", query_group = "locals", desc = "Next scope" }, + ["]z"] = { query = "@fold", query_group = "folds", desc = "Next fold" }, + }, + goto_next_end = { + ["]F"] = { query = "@call.outer", desc = "Next function call end" }, + ["]M"] = { query = "@function.outer", desc = "Next method/function def end" }, + ["]C"] = { query = "@class.outer", desc = "Next class end" }, + ["]I"] = { query = "@conditional.outer", desc = "Next conditional end" }, + ["]L"] = { query = "@loop.outer", desc = "Next loop end" }, + }, + goto_previous_start = { + ["[f"] = { query = "@call.outer", desc = "Prev function call start" }, + ["[m"] = { query = "@function.outer", desc = "Prev method/function def start" }, + ["[c"] = { query = "@class.outer", desc = "Prev class start" }, + ["[i"] = { query = "@conditional.outer", desc = "Prev conditional start" }, + ["[l"] = { query = "@loop.outer", desc = "Prev loop start" }, + }, + goto_previous_end = { + ["[F"] = { query = "@call.outer", desc = "Prev function call end" }, + ["[M"] = { query = "@function.outer", desc = "Prev method/function def end" }, + ["[C"] = { query = "@class.outer", desc = "Prev class end" }, + ["[I"] = { query = "@conditional.outer", desc = "Prev conditional end" }, + ["[L"] = { query = "@loop.outer", desc = "Prev loop end" }, + }, + }, + }, + }) + + local ts_repeat_move = require("nvim-treesitter.textobjects.repeatable_move") + + -- vim way: ; goes to the direction you were moving. + vim.keymap.set({ "n", "x", "o" }, ";", ts_repeat_move.repeat_last_move) + vim.keymap.set({ "n", "x", "o" }, ",", ts_repeat_move.repeat_last_move_opposite) + + -- Optionally, make builtin f, F, t, T also repeatable with ; and , + vim.keymap.set({ "n", "x", "o" }, "f", ts_repeat_move.builtin_f) + vim.keymap.set({ "n", "x", "o" }, "F", ts_repeat_move.builtin_F) + vim.keymap.set({ "n", "x", "o" }, "t", ts_repeat_move.builtin_t) + vim.keymap.set({ "n", "x", "o" }, "T", ts_repeat_move.builtin_T) + end, +} diff --git a/lua/cargdev/plugins/substitute.lua b/lua/cargdev/plugins/substitute.lua new file mode 100644 index 0000000..b5ff1b6 --- /dev/null +++ b/lua/cargdev/plugins/substitute.lua @@ -0,0 +1,17 @@ +return { + "gbprod/substitute.nvim", + event = { "BufReadPre", "BufNewFile" }, + config = function() + local substitute = require("substitute") + + substitute.setup() + + -- set keymaps + local keymap = vim.keymap -- for conciseness + + keymap.set("n", "s", substitute.operator, { desc = "Substitute with motion" }) + keymap.set("n", "ss", substitute.line, { desc = "Substitute line" }) + keymap.set("n", "S", substitute.eol, { desc = "Substitute to end of line" }) + keymap.set("x", "s", substitute.visual, { desc = "Substitute in visual mode" }) + end, +} diff --git a/lua/cargdev/plugins/surround.lua b/lua/cargdev/plugins/surround.lua new file mode 100644 index 0000000..77f5073 --- /dev/null +++ b/lua/cargdev/plugins/surround.lua @@ -0,0 +1,6 @@ +return { + "kylechui/nvim-surround", + event = { "BufReadPre", "BufNewFile" }, + version = "*", -- Use for stability; omit to use `main` branch for the latest features + config = true, +} diff --git a/lua/cargdev/plugins/telescope.lua b/lua/cargdev/plugins/telescope.lua new file mode 100644 index 0000000..59e80de --- /dev/null +++ b/lua/cargdev/plugins/telescope.lua @@ -0,0 +1,50 @@ +return { + "nvim-telescope/telescope.nvim", + branch = "0.1.x", + dependencies = { + "nvim-lua/plenary.nvim", + { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, + "nvim-tree/nvim-web-devicons", + "folke/todo-comments.nvim", + }, + config = function() + local telescope = require("telescope") + local actions = require("telescope.actions") + local transform_mod = require("telescope.actions.mt").transform_mod + + local trouble = require("trouble") + local trouble_telescope = require("trouble.sources.telescope") + + -- or create your custom action + local custom_actions = transform_mod({ + open_trouble_qflist = function(prompt_bufnr) + trouble.toggle("quickfix") + end, + }) + + telescope.setup({ + defaults = { + path_display = { "smart" }, + mappings = { + i = { + [""] = actions.move_selection_previous, -- move to prev result + [""] = actions.move_selection_next, -- move to next result + [""] = actions.send_selected_to_qflist + custom_actions.open_trouble_qflist, + [""] = trouble_telescope.open, + }, + }, + }, + }) + + telescope.load_extension("fzf") + + -- set keymaps + local keymap = vim.keymap -- for conciseness + + keymap.set("n", "ff", "Telescope find_files", { desc = "Fuzzy find files in cwd" }) + keymap.set("n", "fr", "Telescope oldfiles", { desc = "Fuzzy find recent files" }) + keymap.set("n", "fs", "Telescope live_grep", { desc = "Find string in cwd" }) + keymap.set("n", "fc", "Telescope grep_string", { desc = "Find string under cursor in cwd" }) + keymap.set("n", "ft", "TodoTelescope", { desc = "Find todos" }) + end, +} diff --git a/lua/cargdev/plugins/todo-comments.lua b/lua/cargdev/plugins/todo-comments.lua new file mode 100644 index 0000000..f74baa9 --- /dev/null +++ b/lua/cargdev/plugins/todo-comments.lua @@ -0,0 +1,21 @@ +return { + "folke/todo-comments.nvim", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + local todo_comments = require("todo-comments") + + -- set keymaps + local keymap = vim.keymap -- for conciseness + + keymap.set("n", "]t", function() + todo_comments.jump_next() + end, { desc = "Next todo comment" }) + + keymap.set("n", "[t", function() + todo_comments.jump_prev() + end, { desc = "Previous todo comment" }) + + todo_comments.setup() + end, +} diff --git a/lua/cargdev/plugins/treesitter.lua b/lua/cargdev/plugins/treesitter.lua new file mode 100644 index 0000000..ef9e43a --- /dev/null +++ b/lua/cargdev/plugins/treesitter.lua @@ -0,0 +1,58 @@ +return { + "nvim-treesitter/nvim-treesitter", + event = { "BufReadPre", "BufNewFile" }, + build = ":TSUpdate", + dependencies = { + "windwp/nvim-ts-autotag", + }, + config = function() + -- import nvim-treesitter plugin + local treesitter = require("nvim-treesitter.configs") + + -- configure treesitter + treesitter.setup({ -- enable syntax highlighting + highlight = { + enable = true, + }, + -- enable indentation + indent = { enable = true }, + -- enable autotagging (w/ nvim-ts-autotag plugin) + autotag = { + enable = true, + }, + -- ensure these language parsers are installed + ensure_installed = { + "json", + "javascript", + "typescript", + "java", + "tsx", + "yaml", + "html", + "css", + "prisma", + "markdown", + "markdown_inline", + "svelte", + "graphql", + "bash", + "lua", + "vim", + "dockerfile", + "gitignore", + "query", + "vimdoc", + "c", + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", + node_incremental = "", + scope_incremental = false, + node_decremental = "", + }, + }, + }) + end, +} diff --git a/lua/cargdev/plugins/trouble.lua b/lua/cargdev/plugins/trouble.lua new file mode 100644 index 0000000..6de76ac --- /dev/null +++ b/lua/cargdev/plugins/trouble.lua @@ -0,0 +1,15 @@ +return { + "folke/trouble.nvim", + dependencies = { "nvim-tree/nvim-web-devicons", "folke/todo-comments.nvim" }, + opts = { + focus = true, + }, + cmd = "Trouble", + keys = { + { "xw", "Trouble diagnostics toggle", desc = "Open trouble workspace diagnostics" }, + { "xd", "Trouble diagnostics toggle filter.buf=0", desc = "Open trouble document diagnostics" }, + { "xq", "Trouble quickfix toggle", desc = "Open trouble quickfix list" }, + { "xl", "Trouble loclist toggle", desc = "Open trouble location list" }, + { "xt", "Trouble todo toggle", desc = "Open todos in trouble" }, + }, +} diff --git a/lua/cargdev/plugins/vim-maximizer.lua b/lua/cargdev/plugins/vim-maximizer.lua new file mode 100644 index 0000000..869b8d7 --- /dev/null +++ b/lua/cargdev/plugins/vim-maximizer.lua @@ -0,0 +1,6 @@ +return { + "szw/vim-maximizer", + keys = { + { "sm", "MaximizerToggle", desc = "Maximize/minimize a split" }, + }, +} diff --git a/lua/cargdev/plugins/which-key.lua b/lua/cargdev/plugins/which-key.lua new file mode 100644 index 0000000..d004051 --- /dev/null +++ b/lua/cargdev/plugins/which-key.lua @@ -0,0 +1,13 @@ +return { + "folke/which-key.nvim", + event = "VeryLazy", + init = function() + vim.o.timeout = true + vim.o.timeoutlen = 500 + end, + opts = { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + }, +}