From 3d26eee4d554af3d12eb022da897591aca72fbda Mon Sep 17 00:00:00 2001 From: Donovan Date: Thu, 24 Apr 2025 10:17:46 -0500 Subject: [PATCH] finish josean martinez tutorial --- lazy-lock.json | 27 +++++- lua/dkelly/lazy.lua | 15 +++- lua/dkelly/plugins/auto-session.lua | 16 ++++ lua/dkelly/plugins/autopair.lua | 30 +++++++ lua/dkelly/plugins/comment.lua | 19 ++++ lua/dkelly/plugins/conform.lua | 40 +++++++++ lua/dkelly/plugins/gitsigns.lua | 47 ++++++++++ lua/dkelly/plugins/lazygit.lua | 19 ++++ lua/dkelly/plugins/linter.lua | 30 +++++++ lua/dkelly/plugins/lsp/lspconfig.lua | 107 +++++++++++++++++++++++ lua/dkelly/plugins/lsp/mason.lua | 69 +++++++++++++++ lua/dkelly/plugins/lualine.lua | 71 +++++++++++++++ lua/dkelly/plugins/nvim-cmp.lua | 126 ++++++++++++++------------- lua/dkelly/plugins/telescope.lua | 2 +- lua/dkelly/plugins/todo-comments.lua | 21 +++++ lua/dkelly/plugins/treesitter.lua | 2 - lua/dkelly/plugins/trouble.lua | 15 ++++ 17 files changed, 586 insertions(+), 70 deletions(-) create mode 100644 lua/dkelly/plugins/auto-session.lua create mode 100644 lua/dkelly/plugins/autopair.lua create mode 100644 lua/dkelly/plugins/comment.lua create mode 100644 lua/dkelly/plugins/conform.lua create mode 100644 lua/dkelly/plugins/gitsigns.lua create mode 100644 lua/dkelly/plugins/lazygit.lua create mode 100644 lua/dkelly/plugins/linter.lua create mode 100644 lua/dkelly/plugins/lsp/lspconfig.lua create mode 100644 lua/dkelly/plugins/lsp/mason.lua create mode 100644 lua/dkelly/plugins/lualine.lua create mode 100644 lua/dkelly/plugins/todo-comments.lua create mode 100644 lua/dkelly/plugins/trouble.lua diff --git a/lazy-lock.json b/lazy-lock.json index 2034f90..6051b14 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,16 +1,39 @@ { + "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, + "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" }, + "auto-session": { "branch": "main", "commit": "00334ee24b9a05001ad50221c8daffbeedaa0842" }, + "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, "cmp-nvim-lsp": { "branch": "main", "commit": "a8912b88ce488f411177fc8aed358b04dc246d7b" }, + "cmp-path": { "branch": "main", "commit": "c6635aae33a50d6010bf1aa756ac2398a2d54c32" }, + "cmp-treesitter": { "branch": "master", "commit": "958fcfa0d8ce46d215e19cc3992c542f576c4123" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "conform.nvim": { "branch": "master", "commit": "372fc521f8421b7830ea6db4d6ea3bae1c77548c" }, + "friendly-snippets": { "branch": "main", "commit": "fc8f183479a472df60aa86f00e295462f2308178" }, + "gitsigns.nvim": { "branch": "main", "commit": "ee7e50dfbdf49e3acfa416fd3ad3abbdb658582c" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, - "lspkind-nvim": { "branch": "master", "commit": "d79a1c3299ad0ef94e255d045bed9fa26025dab6" }, + "lazygit.nvim": { "branch": "main", "commit": "b9eae3badab982e71abab96d3ee1d258f0c07961" }, + "lspkind.nvim": { "branch": "master", "commit": "d79a1c3299ad0ef94e255d045bed9fa26025dab6" }, + "lualine.nvim": { "branch": "master", "commit": "15884cee63a8c205334ab13ab1c891cd4d27101a" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "1a31f824b9cd5bc6f342fc29e9a53b60d74af245" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "1255518cb067e038a4755f5cb3e980f79b6ab89c" }, + "mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" }, + "neodev.nvim": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" }, + "nvim-autopairs": { "branch": "master", "commit": "4d74e75913832866aa7de35e4202463ddf6efd1b" }, "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, + "nvim-lint": { "branch": "master", "commit": "9dfb77ef6c5092a19502883c02dc5a02ec648729" }, + "nvim-lsp-file-operations": { "branch": "master", "commit": "9744b738183a5adca0f916527922078a965515ed" }, + "nvim-lspconfig": { "branch": "master", "commit": "8b0f47d851ee5343d38fe194a06ad16b9b9bd086" }, "nvim-tree.lua": { "branch": "master", "commit": "be5b788f2dc1522c73fb7afad9092331c8aebe80" }, "nvim-treesitter": { "branch": "master", "commit": "684eeac91ed8e297685a97ef70031d19ac1de25a" }, "nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" }, - "nvim-web-devicons": { "branch": "master", "commit": "855c97005c8eebcdd19846f2e54706bffd40ee96" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" }, + "nvim-web-devicons": { "branch": "master", "commit": "68f70df44652d310d2adedf181b174c33a693665" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" }, "telescope.nvim": { "branch": "master", "commit": "a4ed82509cecc56df1c7138920a1aeaf246c0ac5" }, + "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, + "trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" }, "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } } diff --git a/lua/dkelly/lazy.lua b/lua/dkelly/lazy.lua index 51ba3c8..e22dc2c 100644 --- a/lua/dkelly/lazy.lua +++ b/lua/dkelly/lazy.lua @@ -5,10 +5,19 @@ if not vim.loop.fs_stat(lazypath) then "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", - "--branch=stable", + "--branch=stable", -- latest stable release lazypath, }) end vim.opt.rtp:prepend(lazypath) - -require("lazy").setup("dkelly.plugins") + +require("lazy").setup({ { import = "dkelly.plugins" }, { import = "dkelly.plugins.lsp" } }, { + checker = { + enabled = true, + notify = false, + }, + change_detection = { + notify = false, + }, +}) + diff --git a/lua/dkelly/plugins/auto-session.lua b/lua/dkelly/plugins/auto-session.lua new file mode 100644 index 0000000..adeff79 --- /dev/null +++ b/lua/dkelly/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/dkelly/plugins/autopair.lua b/lua/dkelly/plugins/autopair.lua new file mode 100644 index 0000000..8ee54b3 --- /dev/null +++ b/lua/dkelly/plugins/autopair.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/dkelly/plugins/comment.lua b/lua/dkelly/plugins/comment.lua new file mode 100644 index 0000000..ecc93c4 --- /dev/null +++ b/lua/dkelly/plugins/comment.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/dkelly/plugins/conform.lua b/lua/dkelly/plugins/conform.lua new file mode 100644 index 0000000..53521ac --- /dev/null +++ b/lua/dkelly/plugins/conform.lua @@ -0,0 +1,40 @@ +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" }, + go = { "goimports", "gofmt" }, + }, + 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/dkelly/plugins/gitsigns.lua b/lua/dkelly/plugins/gitsigns.lua new file mode 100644 index 0000000..52c9244 --- /dev/null +++ b/lua/dkelly/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/dkelly/plugins/lazygit.lua b/lua/dkelly/plugins/lazygit.lua new file mode 100644 index 0000000..6055d12 --- /dev/null +++ b/lua/dkelly/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/dkelly/plugins/linter.lua b/lua/dkelly/plugins/linter.lua new file mode 100644 index 0000000..83ce090 --- /dev/null +++ b/lua/dkelly/plugins/linter.lua @@ -0,0 +1,30 @@ +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" }, + go = { "golangci-lint" }, + } + + 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/dkelly/plugins/lsp/lspconfig.lua b/lua/dkelly/plugins/lsp/lspconfig.lua new file mode 100644 index 0000000..cab9b89 --- /dev/null +++ b/lua/dkelly/plugins/lsp/lspconfig.lua @@ -0,0 +1,107 @@ +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, + ["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/dkelly/plugins/lsp/mason.lua b/lua/dkelly/plugins/lsp/mason.lua new file mode 100644 index 0000000..ef39da1 --- /dev/null +++ b/lua/dkelly/plugins/lsp/mason.lua @@ -0,0 +1,69 @@ +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({ + ensure_installed = { + -- LSP server names only + "bashls", -- Bash + "clangd", -- C/C++ + "cssls", -- CSS + "gopls", -- Go + "html", -- HTML + "tsserver", -- TypeScript/JavaScript + "jsonls", -- JSON + "lua_ls", -- Lua + "marksman", -- Markdown + "pyright", -- Python + "ruby_ls", -- Ruby + "rust_analyzer", -- Rust + "taplo", -- TOML + "yamlls", -- YAML + "dockerls", -- Docker + "graphql", -- GraphQL + "sqlls", -- SQL (or try "sqls") + "powershell_es", -- PowerShell + "perlnavigator", -- Perl + "vimls", -- Vim + "lemminx", -- XML + "cmake", -- CMake + -- Add others you use! + }, + automatic_installation = true, + }) + + mason_tool_installer.setup({ + ensure_installed = { + "prettier", -- prettier formatter + "stylua", -- lua formatter + "isort", -- python formatter + "black", -- python formatter + "goimports", -- golang formatter + "pylint", -- python linter + "eslint_d", -- js linter + "golangci-lint", -- golang linter + }, + }) + end, +} diff --git a/lua/dkelly/plugins/lualine.lua b/lua/dkelly/plugins/lualine.lua new file mode 100644 index 0000000..3698644 --- /dev/null +++ b/lua/dkelly/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/dkelly/plugins/nvim-cmp.lua b/lua/dkelly/plugins/nvim-cmp.lua index 48cb8b2..54e9091 100644 --- a/lua/dkelly/plugins/nvim-cmp.lua +++ b/lua/dkelly/plugins/nvim-cmp.lua @@ -1,84 +1,86 @@ return { - 'hrsh7th/nvim-cmp', + "hrsh7th/nvim-cmp", dependencies = { - -- Core completion sources - 'hrsh7th/cmp-nvim-lsp', - -- 'hrsh7th/cmp-treesitter', -- Uncomment if you have a cmp-treesitter source - -- Cmdline support - 'hrsh7th/cmp-cmdline', - -- Icons - 'onsails/lspkind-nvim', + -- basic sources + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + -- cmdline completion for `:` and `/` + "hrsh7th/cmp-cmdline", -- :contentReference[oaicite:0]{index=0} + -- LSP + "hrsh7th/cmp-nvim-lsp", -- :contentReference[oaicite:1]{index=1} + -- Treesitter source + "ray-x/cmp-treesitter", -- :contentReference[oaicite:2]{index=2} - -- Extras you can enable later: - -- 'windwp/nvim-autopairs', -- autopairs integration - -- 'lukas-reineke/cmp-under-comparator', -- fuzzy sorting + -- snippet engine & integration (optional) + { + "L3MON4D3/LuaSnip", + version = "v2.*", + build = "make install_jsregexp", + }, + "saadparwaiz1/cmp_luasnip", + "rafamadriz/friendly-snippets", + + -- icons + "onsails/lspkind.nvim", }, + config = function() - local cmp = require('cmp') - local lspkind = require('lspkind') + local cmp = require("cmp") + local luasnip = require("luasnip") + local lspkind = require("lspkind") + + -- load friendly-snippets + require("luasnip.loaders.from_vscode").lazy_load() + + -- nicer completions menu + vim.opt.completeopt = "menu,menuone,preview,noselect" cmp.setup({ - formatting = { - format = lspkind.cmp_format({ - mode = "symbol_text", -- or "symbol" for just icons, "text" for just text - maxwidth = 50, - }), - }, - snippet = { expand = function(args) - -- no-op, snippet engine not installed + luasnip.lsp_expand(args.body) end, }, - - mapping = { - [''] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), - [''] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.confirm({ select = true }), - [''] = cmp.mapping.abort(), + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = false }), + }), + sources = cmp.config.sources({ + { name = "luasnip" }, + { name = "nvim_lsp" }, + { name = "treesitter" }, + { name = "buffer" }, + { name = "path" }, + }), + formatting = { + format = lspkind.cmp_format({ + maxwidth = 50, + ellipsis_char = "...", + }), }, - - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, - -- { name = 'treesitter' }, -- Uncomment if you actually have cmp-treesitter - }), - - -- Extras you can enable later: - -- window = { - -- completion = cmp.config.window.bordered(), - -- documentation = cmp.config.window.bordered(), - -- }, - - -- experimental = { - -- ghost_text = true, - -- }, }) - -- Cmdline completion for : (commands & paths) - cmp.setup.cmdline(':', { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ - { name = 'path' }, - { name = 'cmdline' }, - }), - }) - - -- Search completion for / (buffer) - cmp.setup.cmdline('/', { + -- Command‐line “:” → cmdline + path + cmp.setup.cmdline(":", { mapping = cmp.mapping.preset.cmdline(), sources = { - { name = 'buffer' }, + { name = "path" }, + { name = "cmdline" }, }, }) - -- Autopairs integration (uncomment when you install nvim-autopairs) - -- require('nvim-autopairs').setup{} - -- local cmp_autopairs = require('nvim-autopairs.completion.cmp') - -- cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) - - -- Fuzzy sorting (uncomment when you install cmp-under-comparator) - -- table.insert(cmp.config.sorting.comparators, require('cmp-under-comparator').under) + -- Search “/” → buffer + cmp.setup.cmdline("/", { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "buffer" }, + }, + }) end, } diff --git a/lua/dkelly/plugins/telescope.lua b/lua/dkelly/plugins/telescope.lua index 8a1c1a5..eed577c 100644 --- a/lua/dkelly/plugins/telescope.lua +++ b/lua/dkelly/plugins/telescope.lua @@ -3,7 +3,7 @@ return { dependencies = { 'nvim-lua/plenary.nvim', {'nvim-telescope/telescope-fzf-native.nvim', build = 'make'}, - 'nvim-tree-/nvim-web-devicons', + 'nvim-tree/nvim-web-devicons', }, config = function () local telescope = require("telescope") diff --git a/lua/dkelly/plugins/todo-comments.lua b/lua/dkelly/plugins/todo-comments.lua new file mode 100644 index 0000000..f74baa9 --- /dev/null +++ b/lua/dkelly/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/dkelly/plugins/treesitter.lua b/lua/dkelly/plugins/treesitter.lua index 015ce39..28f7292 100644 --- a/lua/dkelly/plugins/treesitter.lua +++ b/lua/dkelly/plugins/treesitter.lua @@ -23,8 +23,6 @@ return { "terraform", "hcl", -- Scripting/misc "perl", "r", "powershell", "fish", - -- Documentation & web - "latex", "scss", -- System "cmake", "nix", -- Other Neovim-related diff --git a/lua/dkelly/plugins/trouble.lua b/lua/dkelly/plugins/trouble.lua new file mode 100644 index 0000000..6de76ac --- /dev/null +++ b/lua/dkelly/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" }, + }, +}