From 2826812d7f406c09234b8d51d4a33188fe7730cc Mon Sep 17 00:00:00 2001 From: eadu6 Date: Wed, 25 Jun 2025 21:28:37 -0700 Subject: [PATCH 01/19] Update nvim setup --- init.lua | 2 +- lua/custom/plugins/copilot-chat.lua | 245 ++++++++++++++++++++++++++++ lua/custom/plugins/copilot-vim.lua | 39 +++++ lua/custom/plugins/vim-floaterm.lua | 7 + lua/kickstart/plugins/lspconfig.lua | 13 +- lua/lazy-plugins.lua | 15 +- 6 files changed, 311 insertions(+), 10 deletions(-) create mode 100644 lua/custom/plugins/copilot-chat.lua create mode 100644 lua/custom/plugins/copilot-vim.lua create mode 100644 lua/custom/plugins/vim-floaterm.lua diff --git a/init.lua b/init.lua index 3784c1a18c9..6c6d42bd327 100644 --- a/init.lua +++ b/init.lua @@ -91,7 +91,7 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = false +vim.g.have_nerd_font = true -- [[ Setting options ]] require 'options' diff --git a/lua/custom/plugins/copilot-chat.lua b/lua/custom/plugins/copilot-chat.lua new file mode 100644 index 00000000000..036593c03e6 --- /dev/null +++ b/lua/custom/plugins/copilot-chat.lua @@ -0,0 +1,245 @@ +local IS_DEV = false + +local prompts = { + -- Code related prompts + Explain = 'Please explain how the following code works.', + Review = 'Please review the following code and provide suggestions for improvement.', + Tests = 'Please explain how the selected code works, then generate unit tests for it.', + Refactor = 'Please refactor the following code to improve its clarity and readability.', + FixCode = 'Please fix the following code to make it work as intended.', + FixError = 'Please explain the error in the following text and provide a solution.', + BetterNamings = 'Please provide better names for the following variables and functions.', + Documentation = 'Please provide documentation for the following code.', + SwaggerApiDocs = 'Please provide documentation for the following API using Swagger.', + SwaggerJsDocs = 'Please write JSDoc for the following API using Swagger.', + -- Text related prompts + Summarize = 'Please summarize the following text.', + Spelling = 'Please correct any grammar and spelling errors in the following text.', + Wording = 'Please improve the grammar and wording of the following text.', + Concise = 'Please rewrite the following text to make it more concise.', +} + +return { + { import = 'custom.plugins.copilot-chat' }, -- Or use { import = "lazyvim.plugins.extras.coding.copilot" }, + { + dir = IS_DEV and '~/Projects/research/CopilotChat.nvim' or nil, + 'CopilotC-Nvim/CopilotChat.nvim', + version = 'v2.11.0', + -- branch = "canary", -- Use the canary branch if you want to test the latest features but it might be unstable + -- Do not use branch and version together, either use branch or version + dependencies = { + { 'nvim-telescope/telescope.nvim' }, -- Use telescope for help actions + { 'nvim-lua/plenary.nvim' }, + }, + opts = { + question_header = '## User ', + answer_header = '## RoboCop ', + error_header = '## Error ', + prompts = prompts, + auto_follow_cursor = true, -- Don't follow the cursor after getting response + show_help = true, -- Show help in virtual text, set to true if that's 2st time using Copilot Chat + mappings = { + -- Use tab for completion + complete = { + detail = 'Use @ or / for options.', + insert = '', + }, + -- Close the chat + close = { + normal = 'q', + insert = '', + }, + -- Reset the chat buffer + reset = { + normal = '', + insert = '', + }, + -- Submit the prompt to Copilot + submit_prompt = { + normal = '', + insert = '', + }, + -- Accept the diff + accept_diff = { + normal = '', + insert = '', + }, + -- Yank the diff in the response to register + yank_diff = { + normal = 'gmy', + }, + -- Show the diff + show_diff = { + normal = 'gmd', + }, + -- Show the prompt + show_system_prompt = { + normal = 'gmp', + }, + -- Show the user selection + show_user_selection = { + normal = 'gms', + }, + }, + }, + config = function(_, opts) + local chat = require 'CopilotChat' + local select = require 'CopilotChat.select' + -- Use unnamed register for the selection + opts.selection = select.unnamed + + -- Override the git prompts message + opts.prompts.Commit = { + prompt = 'Write commit message for the change with commitizen convention', + selection = select.gitdiff, + } + opts.prompts.CommitStaged = { + prompt = 'Write commit message for the change with commitizen convention', + selection = function(source) + return select.gitdiff(source, true) + end, + } + + chat.setup(opts) + -- Setup the CMP integration + require('CopilotChat.integrations.cmp').setup() + + vim.api.nvim_create_user_command('CopilotChatVisual', function(args) + chat.ask(args.args, { selection = select.visual }) + end, { nargs = '*', range = true }) + + -- Inline chat with Copilot + vim.api.nvim_create_user_command('CopilotChatInline', function(args) + chat.ask(args.args, { + selection = select.visual, + window = { + layout = 'float', + relative = 'cursor', + width = 1, + height = 0.4, + row = 1, + }, + }) + end, { nargs = '*', range = true }) + + -- Restore CopilotChatBuffer + vim.api.nvim_create_user_command('CopilotChatBuffer', function(args) + chat.ask(args.args, { selection = select.buffer }) + end, { nargs = '*', range = true }) + + -- Custom buffer for CopilotChat + vim.api.nvim_create_autocmd('BufEnter', { + pattern = 'copilot-*', + callback = function() + vim.opt_local.relativenumber = true + vim.opt_local.number = true + + -- Get current filetype and set it to markdown if the current filetype is copilot-chat + local ft = vim.bo.filetype + if ft == 'copilot-chat' then + vim.bo.filetype = 'markdown' + end + end, + }) + + -- Add which-key mappings + local wk = require 'which-key' + wk.add { + { 'gm', group = '+Copilot Chat' }, -- group + { 'gmd', desc = 'Show diff' }, + { 'gmp', desc = 'System prompt' }, + { 'gms', desc = 'Show selection' }, + { 'gmy', desc = 'Yank diff' }, + } + end, + event = 'VeryLazy', + keys = { + -- Show help actions with telescope + { + 'ah', + function() + local actions = require 'CopilotChat.actions' + require('CopilotChat.integrations.telescope').pick(actions.help_actions()) + end, + desc = 'CopilotChat - Help actions', + }, + -- Show prompts actions with telescope + { + 'ap', + function() + local actions = require 'CopilotChat.actions' + require('CopilotChat.integrations.telescope').pick(actions.prompt_actions()) + end, + desc = 'CopilotChat - Prompt actions', + }, + { + 'ap', + ":lua require('CopilotChat.integrations.telescope').pick(require('CopilotChat.actions').prompt_actions({selection = require('CopilotChat.select').visual}))", + mode = 'x', + desc = 'CopilotChat - Prompt actions', + }, + -- Code related commands + { 'ae', 'CopilotChatExplain', desc = 'CopilotChat - Explain code' }, + { 'at', 'CopilotChatTests', desc = 'CopilotChat - Generate tests' }, + { 'ar', 'CopilotChatReview', desc = 'CopilotChat - Review code' }, + { 'aR', 'CopilotChatRefactor', desc = 'CopilotChat - Refactor code' }, + { 'an', 'CopilotChatBetterNamings', desc = 'CopilotChat - Better Naming' }, + -- Chat with Copilot in visual mode + { + 'av', + ':CopilotChatVisual', + mode = 'x', + desc = 'CopilotChat - Open in vertical split', + }, + { + 'ax', + ':CopilotChatInline', + mode = 'x', + desc = 'CopilotChat - Inline chat', + }, + -- Custom input for CopilotChat + { + 'ai', + function() + local input = vim.fn.input 'Ask Copilot: ' + if input ~= '' then + vim.cmd('CopilotChat ' .. input) + end + end, + desc = 'CopilotChat - Ask input', + }, + -- Generate commit message based on the git diff + { + 'am', + 'CopilotChatCommit', + desc = 'CopilotChat - Generate commit message for all changes', + }, + { + 'aM', + 'CopilotChatCommitStaged', + desc = 'CopilotChat - Generate commit message for staged changes', + }, + -- Quick chat with Copilot + { + 'aq', + function() + local input = vim.fn.input 'Quick Chat: ' + if input ~= '' then + vim.cmd('CopilotChatBuffer ' .. input) + end + end, + desc = 'CopilotChat - Quick chat', + }, + -- Debug + { 'ad', 'CopilotChatDebugInfo', desc = 'CopilotChat - Debug Info' }, + -- Fix the issue with diagnostic + { 'af', 'CopilotChatFixDiagnostic', desc = 'CopilotChat - Fix Diagnostic' }, + -- Clear buffer and chat history + { 'al', 'CopilotChatReset', desc = 'CopilotChat - Clear buffer and chat history' }, + -- Toggle Copilot Chat Vsplit + { 'av', 'CopilotChatToggle', desc = 'CopilotChat - Toggle' }, + -- Copilot Chat Models + { 'a?', 'CopilotChatModels', desc = 'CopilotChat - Select Models' }, + }, + }, +} diff --git a/lua/custom/plugins/copilot-vim.lua b/lua/custom/plugins/copilot-vim.lua new file mode 100644 index 00000000000..bca1ffcf98f --- /dev/null +++ b/lua/custom/plugins/copilot-vim.lua @@ -0,0 +1,39 @@ +-- NOTE: Only enable either copilot-vim or codeium-vim at the same time +return { + + -- Setup copilot.vim + { + 'github/copilot.vim', + event = 'VeryLazy', + config = function() + -- For copilot.vim + -- enable copilot for specific filetypes + vim.g.copilot_filetypes = { + ['TelescopePrompt'] = false, + } + + -- Set to true to assume that copilot is already mapped + vim.g.copilot_assume_mapped = true + -- Set workspace folders + vim.g.copilot_workspace_folders = '~/Projects' + + -- Setup keymaps + local keymap = vim.keymap.set + local opts = { silent = true } + + -- Set to accept copilot suggestion + keymap('i', '', 'copilot#Accept("\\")', { expr = true, replace_keycodes = false }) + + -- Set to accept line + keymap('i', '', '(copilot-accept-line)', opts) + + -- Set to next suggestion, to previous suggestion, to suggest + keymap('i', '', '(copilot-next)', opts) + keymap('i', '', '(copilot-previous)', opts) + keymap('i', '', '(copilot-suggest)', opts) + + -- Set to dismiss suggestion + keymap('i', '', '(copilot-dismiss)', opts) + end, + }, +} diff --git a/lua/custom/plugins/vim-floaterm.lua b/lua/custom/plugins/vim-floaterm.lua new file mode 100644 index 00000000000..1cab16d2337 --- /dev/null +++ b/lua/custom/plugins/vim-floaterm.lua @@ -0,0 +1,7 @@ +-- You can add your own plugins here or in other files in this directory! +-- I promise not to create any merge conflicts in this directory :) +-- +-- See the kickstart.nvim README for more information +return { + 'voldikss/vim-floaterm', +} diff --git a/lua/kickstart/plugins/lspconfig.lua b/lua/kickstart/plugins/lspconfig.lua index 6532757d872..40b276d58c0 100644 --- a/lua/kickstart/plugins/lspconfig.lua +++ b/lua/kickstart/plugins/lspconfig.lua @@ -208,17 +208,22 @@ return { -- - settings (table): Override the default settings passed when initializing the server. -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { - -- clangd = {}, - -- gopls = {}, - -- pyright = {}, - -- rust_analyzer = {}, + clangd = {}, -- C/C++ language server + gopls = {}, -- Go language server + pyright = {}, -- Python language server + rust_analyzer = {}, -- Rust language server -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- -- Some languages (like typescript) have entire language plugins that can be useful: -- https://github.com/pmizio/typescript-tools.nvim -- +<<<<<<< Updated upstream -- But for many setups, the LSP (`ts_ls`) will work just fine -- ts_ls = {}, +======= + -- But for many setups, the LSP (`tsserver`) will work just fine + tsserver = {}, -- TypeScript language server +>>>>>>> Stashed changes -- lua_ls = { diff --git a/lua/lazy-plugins.lua b/lua/lazy-plugins.lua index 9f3ca2acd73..f94fb0c8af7 100644 --- a/lua/lazy-plugins.lua +++ b/lua/lazy-plugins.lua @@ -52,22 +52,27 @@ require('lazy').setup({ -- Here are some example plugins that I've included in the Kickstart repository. -- Uncomment any of the lines below to enable them (you will need to restart nvim). -- - -- require 'kickstart.plugins.debug', - -- require 'kickstart.plugins.indent_line', - -- require 'kickstart.plugins.lint', - -- require 'kickstart.plugins.autopairs', - -- require 'kickstart.plugins.neo-tree', + require 'kickstart.plugins.debug', + require 'kickstart.plugins.indent_line', + require 'kickstart.plugins.lint', + require 'kickstart.plugins.autopairs', + require 'kickstart.plugins.neo-tree', -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` -- This is the easiest way to modularize your config. -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. +<<<<<<< Updated upstream -- { import = 'custom.plugins' }, -- -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` -- Or use telescope! -- In normal mode type `sh` then write `lazy.nvim-plugin` -- you can continue same window with `sr` which resumes last telescope search +======= + -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` + { import = 'custom.plugins' }, +>>>>>>> Stashed changes }, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the From c3dba1c88cf44a3b6589e88b9f0f36b707b78dbd Mon Sep 17 00:00:00 2001 From: eadu6 Date: Wed, 25 Jun 2025 21:48:30 -0700 Subject: [PATCH 02/19] Fix merge conflicts --- lua/kickstart/plugins/lspconfig.lua | 5 ----- lua/lazy-plugins.lua | 6 +----- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/lua/kickstart/plugins/lspconfig.lua b/lua/kickstart/plugins/lspconfig.lua index 40b276d58c0..db33552597d 100644 --- a/lua/kickstart/plugins/lspconfig.lua +++ b/lua/kickstart/plugins/lspconfig.lua @@ -217,13 +217,8 @@ return { -- Some languages (like typescript) have entire language plugins that can be useful: -- https://github.com/pmizio/typescript-tools.nvim -- -<<<<<<< Updated upstream - -- But for many setups, the LSP (`ts_ls`) will work just fine - -- ts_ls = {}, -======= -- But for many setups, the LSP (`tsserver`) will work just fine tsserver = {}, -- TypeScript language server ->>>>>>> Stashed changes -- lua_ls = { diff --git a/lua/lazy-plugins.lua b/lua/lazy-plugins.lua index f94fb0c8af7..6bcbf12fe8c 100644 --- a/lua/lazy-plugins.lua +++ b/lua/lazy-plugins.lua @@ -62,17 +62,13 @@ require('lazy').setup({ -- This is the easiest way to modularize your config. -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. -<<<<<<< Updated upstream - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, -- -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` -- Or use telescope! -- In normal mode type `sh` then write `lazy.nvim-plugin` -- you can continue same window with `sr` which resumes last telescope search -======= -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` - { import = 'custom.plugins' }, ->>>>>>> Stashed changes }, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the From a1361b5dc26898007c74fe41b95f09aca01ac319 Mon Sep 17 00:00:00 2001 From: eadu6 Date: Wed, 25 Jun 2025 22:03:37 -0700 Subject: [PATCH 03/19] Address merge conflicts --- lua/kickstart/plugins/blink-cmp.lua | 101 --------------------- lua/kickstart/plugins/lspconfig.lua | 21 +++-- lua/kickstart/plugins/nvim-cmp.lua | 134 ++++++++++++++++++++++++++++ lua/lazy-plugins.lua | 2 +- 4 files changed, 148 insertions(+), 110 deletions(-) delete mode 100644 lua/kickstart/plugins/blink-cmp.lua create mode 100644 lua/kickstart/plugins/nvim-cmp.lua diff --git a/lua/kickstart/plugins/blink-cmp.lua b/lua/kickstart/plugins/blink-cmp.lua deleted file mode 100644 index 2b2f32596c5..00000000000 --- a/lua/kickstart/plugins/blink-cmp.lua +++ /dev/null @@ -1,101 +0,0 @@ -return { - { -- Autocompletion - 'saghen/blink.cmp', - event = 'VimEnter', - version = '1.*', - dependencies = { - -- Snippet Engine - { - 'L3MON4D3/LuaSnip', - version = '2.*', - build = (function() - -- Build Step is needed for regex support in snippets. - -- This step is not supported in many windows environments. - -- Remove the below condition to re-enable on windows. - if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then - return - end - return 'make install_jsregexp' - end)(), - dependencies = { - -- `friendly-snippets` contains a variety of premade snippets. - -- See the README about individual language/framework/plugin snippets: - -- https://github.com/rafamadriz/friendly-snippets - -- { - -- 'rafamadriz/friendly-snippets', - -- config = function() - -- require('luasnip.loaders.from_vscode').lazy_load() - -- end, - -- }, - }, - opts = {}, - }, - 'folke/lazydev.nvim', - }, - --- @module 'blink.cmp' - --- @type blink.cmp.Config - opts = { - keymap = { - -- 'default' (recommended) for mappings similar to built-in completions - -- to accept ([y]es) the completion. - -- This will auto-import if your LSP supports it. - -- This will expand snippets if the LSP sent a snippet. - -- 'super-tab' for tab to accept - -- 'enter' for enter to accept - -- 'none' for no mappings - -- - -- For an understanding of why the 'default' preset is recommended, - -- you will need to read `:help ins-completion` - -- - -- No, but seriously. Please read `:help ins-completion`, it is really good! - -- - -- All presets have the following mappings: - -- /: move to right/left of your snippet expansion - -- : Open menu or open docs if already open - -- / or /: Select next/previous item - -- : Hide menu - -- : Toggle signature help - -- - -- See :h blink-cmp-config-keymap for defining your own keymap - preset = 'default', - - -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: - -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps - }, - - appearance = { - -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font' - -- Adjusts spacing to ensure icons are aligned - nerd_font_variant = 'mono', - }, - - completion = { - -- By default, you may press `` to show the documentation. - -- Optionally, set `auto_show = true` to show the documentation after a delay. - documentation = { auto_show = false, auto_show_delay_ms = 500 }, - }, - - sources = { - default = { 'lsp', 'path', 'snippets', 'lazydev' }, - providers = { - lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 }, - }, - }, - - snippets = { preset = 'luasnip' }, - - -- Blink.cmp includes an optional, recommended rust fuzzy matcher, - -- which automatically downloads a prebuilt binary when enabled. - -- - -- By default, we use the Lua implementation instead, but you may enable - -- the rust implementation via `'prefer_rust_with_warning'` - -- - -- See :h blink-cmp-config-fuzzy for more information - fuzzy = { implementation = 'lua' }, - - -- Shows a signature help window while you type arguments for a function - signature = { enabled = true }, - }, - }, -} --- vim: ts=2 sts=2 sw=2 et diff --git a/lua/kickstart/plugins/lspconfig.lua b/lua/kickstart/plugins/lspconfig.lua index db33552597d..0a68bb46388 100644 --- a/lua/kickstart/plugins/lspconfig.lua +++ b/lua/kickstart/plugins/lspconfig.lua @@ -26,8 +26,8 @@ return { -- Useful status updates for LSP. { 'j-hui/fidget.nvim', opts = {} }, - -- Allows extra capabilities provided by blink.cmp - 'saghen/blink.cmp', + -- Allows extra capabilities provided by nvim-cmp + 'hrsh7th/nvim-cmp', }, config = function() -- Brief aside: **What is LSP?** @@ -194,9 +194,9 @@ return { -- LSP servers and clients are able to communicate to each other what features they support. -- By default, Neovim doesn't support everything that is in the LSP specification. - -- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities. - -- So, we create new capabilities with blink.cmp, and then broadcast that to the servers. - local capabilities = require('blink.cmp').get_lsp_capabilities() + -- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities. + -- So, we create new capabilities with nvim-cmp, and then broadcast that to the servers. + local capabilities = require('cmp_nvim_lsp').default_capabilities() -- Enable the following language servers -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. @@ -250,10 +250,15 @@ return { -- -- You can add other tools here that you want Mason to install -- for you, so that they are available from within Neovim. - local ensure_installed = vim.tbl_keys(servers or {}) - vim.list_extend(ensure_installed, { + local ensure_installed = { 'stylua', -- Used to format Lua code - }) + 'typescript-language-server', -- TypeScript language server + 'clangd', -- C/C++ language server + 'gopls', -- Go language server + 'pyright', -- Python language server + 'rust-analyzer', -- Rust language server + 'lua-language-server', -- Lua language server + } require('mason-tool-installer').setup { ensure_installed = ensure_installed } require('mason-lspconfig').setup { diff --git a/lua/kickstart/plugins/nvim-cmp.lua b/lua/kickstart/plugins/nvim-cmp.lua new file mode 100644 index 00000000000..45ca9105c33 --- /dev/null +++ b/lua/kickstart/plugins/nvim-cmp.lua @@ -0,0 +1,134 @@ +return { + { -- Autocompletion + 'hrsh7th/nvim-cmp', + event = 'InsertEnter', + dependencies = { + -- Snippet Engine + { + 'L3MON4D3/LuaSnip', + version = '2.*', + build = (function() + -- Build Step is needed for regex support in snippets. + -- This step is not supported in many windows environments. + -- Remove the below condition to re-enable on windows. + if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then + return + end + return 'make install_jsregexp' + end)(), + dependencies = { + -- `friendly-snippets` contains a variety of premade snippets. + -- See the README about individual language/framework/plugin snippets: + -- https://github.com/rafamadriz/friendly-snippets + -- { + -- 'rafamadriz/friendly-snippets', + -- config = function() + -- require('luasnip.loaders.from_vscode').lazy_load() + -- end, + -- }, + }, + opts = {}, + }, + 'folke/lazydev.nvim', + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-path', + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-cmdline', + 'saadparwaiz1/cmp_luasnip', + }, + config = function() + local cmp = require 'cmp' + local luasnip = require 'luasnip' + + luasnip.config.setup {} + + cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + completion = { + completeopt = 'menu,menuone,noinsert', + }, + mapping = cmp.mapping.preset.insert { + -- Select the [n]ext item + [''] = cmp.mapping.select_next_item(), + -- Select the [p]revious item + [''] = cmp.mapping.select_prev_item(), + + -- Scroll the documentation window [b]ack / [f]orward + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + + -- Accept ([y]es) the completion. + -- This will auto-import if your LSP supports it. + -- This will expand snippets if the LSP sent a snippet. + [''] = cmp.mapping.confirm { select = true }, + + -- Manually trigger a completion from nvim-cmp. + -- Generally you don't need this, because nvim-cmp will display + -- completions whenever it has completion options available. + [''] = cmp.mapping.complete {}, + + -- Think of as moving to the right of your snippet expansion. + -- So if you have a snippet that's like: + -- function $name($args) + -- $body + -- end + -- + -- will move you to the right of each of the expansion locations. + -- is similar, except moving you backwards. + [''] = cmp.mapping(function() + if luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function() + if luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + end + end, { 'i', 's' }), + + -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: + -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'path' }, + { name = 'buffer' }, + { name = 'lazydev', group_index = 0 }, + }, + } + + -- Set configuration for specific filetype. + cmp.setup.filetype('gitcommit', { + sources = cmp.config.sources({ + { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git). + }, { + { name = 'buffer' }, + }), + }) + + -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline({ '/', '?' }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'buffer' }, + }, + }) + + -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = 'path' }, + }, { + { name = 'cmdline' }, + }), + }) + end, + }, +} +-- vim: ts=2 sts=2 sw=2 et diff --git a/lua/lazy-plugins.lua b/lua/lazy-plugins.lua index 6bcbf12fe8c..c7be7518744 100644 --- a/lua/lazy-plugins.lua +++ b/lua/lazy-plugins.lua @@ -33,7 +33,7 @@ require('lazy').setup({ require 'kickstart.plugins.conform', - require 'kickstart.plugins.blink-cmp', + require 'kickstart.plugins.nvim-cmp', require 'kickstart.plugins.tokyonight', From d553a43c3cb4b48d347584b2617f063d7f22ac2e Mon Sep 17 00:00:00 2001 From: eadu6 Date: Tue, 2 Dec 2025 12:08:25 -0800 Subject: [PATCH 04/19] chore: node path setup, typescript-tools, copilot lint fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add Node.js v20.19.3 path configuration in init.lua - Switch from tsserver to typescript-tools.nvim in lspconfig - Add markdownlint to Mason tools - Fix lint.lua to exclude CopilotChat buffers from linting 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- init.lua | 5 ++++- lua/kickstart/plugins/lint.lua | 3 ++- lua/kickstart/plugins/lspconfig.lua | 23 +++++++++++++++++++++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index 6c6d42bd327..76cf3f23d21 100644 --- a/init.lua +++ b/init.lua @@ -84,6 +84,9 @@ I hope you enjoy your Neovim journey, P.S. You can delete this when you're done too. It's your config now! :) --]] +-- Set environment variables for Node.js (ensure nvm version is used) +vim.env.PATH = vim.fn.expand('$HOME/.nvm/versions/node/v20.19.3/bin') .. ':' .. vim.env.PATH + -- Set as the leader key -- See `:help mapleader` -- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) @@ -106,4 +109,4 @@ require 'lazy-bootstrap' require 'lazy-plugins' -- The line beneath this is called `modeline`. See `:help modeline` --- vim: ts=2 sts=2 sw=2 et +-- vim: ts=2 sts=2 sw=2 et \ No newline at end of file diff --git a/lua/kickstart/plugins/lint.lua b/lua/kickstart/plugins/lint.lua index dec42f097c6..a1b4103798d 100644 --- a/lua/kickstart/plugins/lint.lua +++ b/lua/kickstart/plugins/lint.lua @@ -50,7 +50,8 @@ return { -- Only run the linter in buffers that you can modify in order to -- avoid superfluous noise, notably within the handy LSP pop-ups that -- describe the hovered symbol using Markdown. - if vim.bo.modifiable then + -- Also exclude CopilotChat buffers to avoid markdownlint errors + if vim.bo.modifiable and not vim.bo.filetype:match('copilot') then lint.try_lint() end end, diff --git a/lua/kickstart/plugins/lspconfig.lua b/lua/kickstart/plugins/lspconfig.lua index 0a68bb46388..ef5ca39b392 100644 --- a/lua/kickstart/plugins/lspconfig.lua +++ b/lua/kickstart/plugins/lspconfig.lua @@ -218,9 +218,8 @@ return { -- https://github.com/pmizio/typescript-tools.nvim -- -- But for many setups, the LSP (`tsserver`) will work just fine - tsserver = {}, -- TypeScript language server + -- tsserver = {}, -- TypeScript language server (removed in favor of typescript-tools.nvim) -- - lua_ls = { -- cmd = { ... }, -- filetypes = { ... }, @@ -258,6 +257,7 @@ return { 'pyright', -- Python language server 'rust-analyzer', -- Rust language server 'lua-language-server', -- Lua language server + 'markdownlint', -- Markdown linter } require('mason-tool-installer').setup { ensure_installed = ensure_installed } @@ -277,5 +277,24 @@ return { } end, }, + { + "pmizio/typescript-tools.nvim", + dependencies = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" }, + opts = {}, + config = function() + require("typescript-tools").setup { + settings = { + tsserver_file_preferences = { + includeInlayParameterNameHints = "all", + includeCompletionsForModuleExports = true, + }, + tsserver_format_options = { + allowIncompleteCompletions = true, + }, + }, + } + end, + ft = { "typescript", "typescriptreact", "javascript", "javascriptreact" }, + }, } -- vim: ts=2 sts=2 sw=2 et From 12281abe11617a989fe1445048e4fce0da8f7cde Mon Sep 17 00:00:00 2001 From: eadu6 Date: Tue, 2 Dec 2025 12:18:08 -0800 Subject: [PATCH 05/19] feat: modernize nvim config - add testing, claude ai, improve performance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Major improvements and additions: - Claude AI integration via avante.nvim (Cursor-like experience) - Testing framework via neotest (Python, Go, Jest support) - Enhanced git workflow via lazygit.nvim - Better diagnostics UI via trouble.nvim - Project-wide search/replace via nvim-spectre Performance & cleanup: - Removed hardcoded Node.js path from init.lua - Cleaned up commented code in lspconfig, nvim-cmp, telescope - Optimized lazy loading configurations Enhanced tooling: - Expanded formatters: black, isort, prettier, goimports, rustfmt - Expanded linters: ruff, mypy, golangci-lint, eslint, shellcheck - Added friendly-snippets for comprehensive snippet support - Enabled ghost_text experimental feature in nvim-cmp Files modified: - init.lua: Remove hardcoded paths - lspconfig.lua: Add all formatters/linters to Mason tools - conform.lua: Add formatters for all languages - lint.lua: Add linters for all languages - nvim-cmp.lua: Enable friendly-snippets and ghost text - telescope.lua: Clean up commented examples Files created: - lua/custom/plugins/avante.lua: Claude AI integration - lua/custom/plugins/neotest.lua: Testing framework - lua/custom/plugins/lazygit.lua: Git UI - lua/custom/plugins/trouble.lua: Diagnostics UI - lua/custom/plugins/spectre.lua: Search/replace UI 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- init.lua | 3 - lua/custom/plugins/avante.lua | 116 ++++++++++++++++++++ lua/custom/plugins/lazygit.lua | 20 ++++ lua/custom/plugins/neotest.lua | 102 ++++++++++++++++++ lua/custom/plugins/spectre.lua | 160 ++++++++++++++++++++++++++++ lua/custom/plugins/trouble.lua | 75 +++++++++++++ lua/kickstart/plugins/conform.lua | 19 +++- lua/kickstart/plugins/lint.lua | 41 ++----- lua/kickstart/plugins/lspconfig.lua | 27 ++--- lua/kickstart/plugins/nvim-cmp.lua | 22 ++-- lua/kickstart/plugins/telescope.lua | 9 -- 11 files changed, 522 insertions(+), 72 deletions(-) create mode 100644 lua/custom/plugins/avante.lua create mode 100644 lua/custom/plugins/lazygit.lua create mode 100644 lua/custom/plugins/neotest.lua create mode 100644 lua/custom/plugins/spectre.lua create mode 100644 lua/custom/plugins/trouble.lua diff --git a/init.lua b/init.lua index 76cf3f23d21..ad1f54cddb9 100644 --- a/init.lua +++ b/init.lua @@ -84,9 +84,6 @@ I hope you enjoy your Neovim journey, P.S. You can delete this when you're done too. It's your config now! :) --]] --- Set environment variables for Node.js (ensure nvm version is used) -vim.env.PATH = vim.fn.expand('$HOME/.nvm/versions/node/v20.19.3/bin') .. ':' .. vim.env.PATH - -- Set as the leader key -- See `:help mapleader` -- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) diff --git a/lua/custom/plugins/avante.lua b/lua/custom/plugins/avante.lua new file mode 100644 index 00000000000..64e657d0565 --- /dev/null +++ b/lua/custom/plugins/avante.lua @@ -0,0 +1,116 @@ +-- Avante.nvim - Claude AI integration (Cursor-like experience) +-- Requires: ANTHROPIC_API_KEY environment variable +return { + 'yetone/avante.nvim', + event = 'VeryLazy', + lazy = false, + version = false, + opts = { + provider = 'claude', + auto_suggestions_provider = 'claude', + claude = { + endpoint = 'https://api.anthropic.com', + model = 'claude-sonnet-4-20250514', + temperature = 0, + max_tokens = 4096, + }, + behaviour = { + auto_suggestions = false, + auto_set_highlight_group = true, + auto_set_keymaps = true, + auto_apply_diff_after_generation = false, + support_paste_from_clipboard = true, + }, + mappings = { + --- @class AvanteConflictMappings + diff = { + ours = 'co', + theirs = 'ct', + all_theirs = 'ca', + both = 'cb', + cursor = 'cc', + next = ']x', + prev = '[x', + }, + suggestion = { + accept = '', + next = '', + prev = '', + dismiss = '', + }, + jump = { + next = ']]', + prev = '[[', + }, + submit = { + normal = '', + insert = '', + }, + sidebar = { + apply_all = 'A', + apply_cursor = 'a', + switch_windows = '', + reverse_switch_windows = '', + }, + }, + hints = { enabled = true }, + windows = { + ---@type "right" | "left" | "top" | "bottom" + position = 'right', + wrap = true, + width = 30, + sidebar_header = { + enabled = true, + align = 'center', + rounded = true, + }, + }, + highlights = { + ---@type AvanteConflictHighlights + diff = { + current = 'DiffText', + incoming = 'DiffAdd', + }, + }, + }, + build = 'make', + dependencies = { + 'nvim-treesitter/nvim-treesitter', + 'stevearc/dressing.nvim', + 'nvim-lua/plenary.nvim', + 'MunifTanjim/nui.nvim', + --- Optional dependencies + 'nvim-tree/nvim-web-devicons', + 'zbirenbaum/copilot.lua', -- for providers='copilot' + { + 'HakonHarnes/img-clip.nvim', + event = 'VeryLazy', + opts = { + default = { + embed_image_as_base64 = false, + prompt_for_file_name = false, + drag_and_drop = { + insert_mode = true, + }, + use_absolute_path = true, + }, + }, + }, + { + 'MeanderingProgrammer/render-markdown.nvim', + opts = { + file_types = { 'markdown', 'Avante' }, + }, + ft = { 'markdown', 'Avante' }, + }, + }, + config = function(_, opts) + require('avante').setup(opts) + + -- Custom keymaps + vim.keymap.set('n', 'aa', 'AvanteToggle', { desc = '[A]vante Toggle' }) + vim.keymap.set('n', 'ar', 'AvanteRefresh', { desc = '[A]vante [R]efresh' }) + vim.keymap.set('v', 'ae', 'AvanteAsk', { desc = '[A]vante [E]dit Selection' }) + vim.keymap.set('n', 'ac', 'AvanteClear', { desc = '[A]vante [C]lear' }) + end, +} diff --git a/lua/custom/plugins/lazygit.lua b/lua/custom/plugins/lazygit.lua new file mode 100644 index 00000000000..4063bdf6d98 --- /dev/null +++ b/lua/custom/plugins/lazygit.lua @@ -0,0 +1,20 @@ +-- Lazygit integration - Terminal UI for git +-- Requires: lazygit binary installed (brew install lazygit on macOS) +return { + 'kdheepak/lazygit.nvim', + cmd = { + 'LazyGit', + 'LazyGitConfig', + 'LazyGitCurrentFile', + 'LazyGitFilter', + 'LazyGitFilterCurrentFile', + }, + dependencies = { + 'nvim-lua/plenary.nvim', + }, + keys = { + { 'gg', 'LazyGit', desc = 'LazyGit' }, + { 'gc', 'LazyGitCurrentFile', desc = 'LazyGit Current File' }, + { 'gf', 'LazyGitFilter', desc = 'LazyGit Filter' }, + }, +} diff --git a/lua/custom/plugins/neotest.lua b/lua/custom/plugins/neotest.lua new file mode 100644 index 00000000000..6242201c626 --- /dev/null +++ b/lua/custom/plugins/neotest.lua @@ -0,0 +1,102 @@ +-- Neotest - Modern testing framework for Neovim +-- Requires test frameworks: pytest (Python), go test (Go), jest (JS/TS) +return { + 'nvim-neotest/neotest', + dependencies = { + 'nvim-neotest/nvim-nio', + 'nvim-lua/plenary.nvim', + 'antoinemadec/FixCursorHold.nvim', + 'nvim-treesitter/nvim-treesitter', + -- Language adapters + 'nvim-neotest/neotest-python', + 'nvim-neotest/neotest-go', + 'nvim-neotest/neotest-jest', + }, + config = function() + require('neotest').setup { + adapters = { + require 'neotest-python' { + dap = { justMyCode = false }, + args = { '--log-level', 'DEBUG', '-vv' }, + runner = 'pytest', + }, + require 'neotest-go' { + experimental = { + test_table = true, + }, + args = { '-v', '-race', '-count=1' }, + }, + require 'neotest-jest' { + jestCommand = 'npm test --', + jestConfigFile = 'jest.config.js', + env = { CI = true }, + cwd = function() + return vim.fn.getcwd() + end, + }, + }, + discovery = { + enabled = true, + concurrent = 1, + }, + running = { + concurrent = true, + }, + summary = { + enabled = true, + animated = true, + follow = true, + expand_errors = true, + }, + output = { + enabled = true, + open_on_run = 'short', + }, + quickfix = { + enabled = true, + open = false, + }, + status = { + enabled = true, + signs = true, + virtual_text = true, + }, + icons = { + running_animated = { '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏' }, + passed = '', + running = '', + failed = '', + skipped = '', + unknown = '', + watching = '', + }, + } + + -- Keymaps + local neotest = require 'neotest' + vim.keymap.set('n', 'tt', function() + neotest.run.run() + end, { desc = '[T]est Run Nearest' }) + vim.keymap.set('n', 'tf', function() + neotest.run.run(vim.fn.expand '%') + end, { desc = '[T]est Run [F]ile' }) + vim.keymap.set('n', 'td', function() + neotest.run.run { strategy = 'dap' } + end, { desc = '[T]est [D]ebug Nearest' }) + vim.keymap.set('n', 'ts', function() + neotest.summary.toggle() + end, { desc = '[T]est [S]ummary Toggle' }) + vim.keymap.set('n', 'to', function() + neotest.output.open { enter = true, auto_close = true } + end, { desc = '[T]est [O]utput' }) + vim.keymap.set('n', 'tO', function() + neotest.output_panel.toggle() + end, { desc = '[T]est [O]utput Panel' }) + vim.keymap.set('n', 'tS', function() + neotest.run.stop() + end, { desc = '[T]est [S]top' }) + vim.keymap.set('n', 'tw', function() + neotest.watch.toggle() + end, { desc = '[T]est [W]atch' }) + end, +} diff --git a/lua/custom/plugins/spectre.lua b/lua/custom/plugins/spectre.lua new file mode 100644 index 00000000000..451c03d4bb5 --- /dev/null +++ b/lua/custom/plugins/spectre.lua @@ -0,0 +1,160 @@ +-- Spectre - Find and replace across project with preview +return { + 'nvim-pack/nvim-spectre', + dependencies = { + 'nvim-lua/plenary.nvim', + }, + cmd = 'Spectre', + opts = { + open_cmd = 'noswapfile vnew', + live_update = false, + line_sep_start = '┌-----------------------------------------', + result_padding = '¦ ', + line_sep = '└-----------------------------------------', + highlight = { + ui = 'String', + search = 'DiffChange', + replace = 'DiffDelete', + }, + mapping = { + ['toggle_line'] = { + map = 'dd', + cmd = "lua require('spectre').toggle_line()", + desc = 'toggle current item', + }, + ['enter_file'] = { + map = '', + cmd = "lua require('spectre.actions').select_entry()", + desc = 'goto current file', + }, + ['send_to_qf'] = { + map = 'q', + cmd = "lua require('spectre.actions').send_to_qf()", + desc = 'send all item to quickfix', + }, + ['replace_cmd'] = { + map = 'c', + cmd = "lua require('spectre.actions').replace_cmd()", + desc = 'input replace vim command', + }, + ['show_option_menu'] = { + map = 'o', + cmd = "lua require('spectre').show_options()", + desc = 'show option', + }, + ['run_current_replace'] = { + map = 'rc', + cmd = "lua require('spectre.actions').run_current_replace()", + desc = 'replace current line', + }, + ['run_replace'] = { + map = 'R', + cmd = "lua require('spectre.actions').run_replace()", + desc = 'replace all', + }, + ['change_view_mode'] = { + map = 'v', + cmd = "lua require('spectre').change_view()", + desc = 'change result view mode', + }, + ['change_replace_sed'] = { + map = 'trs', + cmd = "lua require('spectre').change_engine_replace('sed')", + desc = 'use sed to replace', + }, + ['change_replace_oxi'] = { + map = 'tro', + cmd = "lua require('spectre').change_engine_replace('oxi')", + desc = 'use oxi to replace', + }, + ['toggle_live_update'] = { + map = 'tu', + cmd = "lua require('spectre').toggle_live_update()", + desc = 'update change when vim write file', + }, + ['toggle_ignore_case'] = { + map = 'ti', + cmd = "lua require('spectre').change_options('ignore-case')", + desc = 'toggle ignore case', + }, + ['toggle_ignore_hidden'] = { + map = 'th', + cmd = "lua require('spectre').change_options('hidden')", + desc = 'toggle search hidden', + }, + ['resume_last_search'] = { + map = 'l', + cmd = "lua require('spectre').resume_last_search()", + desc = 'resume last search before close', + }, + }, + find_engine = { + ['rg'] = { + cmd = 'rg', + args = { + '--color=never', + '--no-heading', + '--with-filename', + '--line-number', + '--column', + }, + options = { + ['ignore-case'] = { + value = '--ignore-case', + icon = '[I]', + desc = 'ignore case', + }, + ['hidden'] = { + value = '--hidden', + desc = 'hidden file', + icon = '[H]', + }, + }, + }, + }, + replace_engine = { + ['sed'] = { + cmd = 'sed', + args = nil, + }, + options = { + ['ignore-case'] = { + value = '--ignore-case', + icon = '[I]', + desc = 'ignore case', + }, + }, + }, + default = { + find = { + cmd = 'rg', + options = { 'ignore-case' }, + }, + replace = { + cmd = 'sed', + }, + }, + replace_vim_cmd = 'cdo', + is_open_target_win = true, + is_insert_mode = false, + }, + keys = { + { 'S', 'lua require("spectre").toggle()', desc = '[S]pectre Toggle' }, + { + 'sw', + 'lua require("spectre").open_visual({select_word=true})', + desc = '[S]earch current [W]ord', + }, + { + 'sw', + 'lua require("spectre").open_visual()', + mode = 'v', + desc = '[S]earch current [W]ord', + }, + { + 'sp', + 'lua require("spectre").open_file_search({select_word=true})', + desc = '[S]earch in current file', + }, + }, +} diff --git a/lua/custom/plugins/trouble.lua b/lua/custom/plugins/trouble.lua new file mode 100644 index 00000000000..0e3a78c6e62 --- /dev/null +++ b/lua/custom/plugins/trouble.lua @@ -0,0 +1,75 @@ +-- Trouble.nvim - Pretty diagnostics, references, and quickfix list +return { + 'folke/trouble.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + cmd = 'Trouble', + opts = { + auto_close = false, + auto_open = false, + auto_preview = true, + auto_refresh = true, + focus = false, + follow = true, + indent_guides = true, + max_items = 200, + multiline = true, + pinned = false, + warn_no_results = true, + open_no_results = false, + win = { + type = 'split', + position = 'bottom', + size = 10, + }, + preview = { + type = 'main', + scratch = true, + }, + icons = { + indent = { + middle = '├╴', + last = '└╴', + top = '│ ', + ws = ' ', + }, + folder_closed = '', + folder_open = '', + kinds = { + Array = ' ', + Boolean = '󰨙 ', + Class = ' ', + Constant = '󰏿 ', + Constructor = ' ', + Enum = ' ', + EnumMember = ' ', + Event = ' ', + Field = ' ', + File = ' ', + Function = '󰊕 ', + Interface = ' ', + Key = ' ', + Method = '󰊕 ', + Module = ' ', + Namespace = '󰦮 ', + Null = ' ', + Number = '󰎠 ', + Object = ' ', + Operator = ' ', + Package = ' ', + Property = ' ', + String = ' ', + Struct = '󰆼 ', + TypeParameter = ' ', + Variable = '󰀫 ', + }, + }, + }, + keys = { + { 'xx', 'Trouble diagnostics toggle', desc = 'Diagnostics (Trouble)' }, + { 'xX', 'Trouble diagnostics toggle filter.buf=0', desc = 'Buffer Diagnostics (Trouble)' }, + { 'xs', 'Trouble symbols toggle focus=false', desc = 'Symbols (Trouble)' }, + { 'xl', 'Trouble lsp toggle focus=false win.position=right', desc = 'LSP Definitions / references / ... (Trouble)' }, + { 'xL', 'Trouble loclist toggle', desc = 'Location List (Trouble)' }, + { 'xq', 'Trouble qflist toggle', desc = 'Quickfix List (Trouble)' }, + }, +} diff --git a/lua/kickstart/plugins/conform.lua b/lua/kickstart/plugins/conform.lua index ca7c0c00b25..9785ad677a4 100644 --- a/lua/kickstart/plugins/conform.lua +++ b/lua/kickstart/plugins/conform.lua @@ -31,11 +31,20 @@ return { end, formatters_by_ft = { lua = { 'stylua' }, - -- Conform can also run multiple formatters sequentially - -- python = { "isort", "black" }, - -- - -- You can use 'stop_after_first' to run the first available formatter from the list - -- javascript = { "prettierd", "prettier", stop_after_first = true }, + python = { 'isort', 'black' }, + go = { 'goimports', 'gofmt' }, + rust = { 'rustfmt' }, + javascript = { 'prettier', stop_after_first = true }, + javascriptreact = { 'prettier', stop_after_first = true }, + typescript = { 'prettier', stop_after_first = true }, + typescriptreact = { 'prettier', stop_after_first = true }, + json = { 'prettier' }, + jsonc = { 'prettier' }, + yaml = { 'prettier' }, + markdown = { 'prettier' }, + html = { 'prettier' }, + css = { 'prettier' }, + scss = { 'prettier' }, }, }, }, diff --git a/lua/kickstart/plugins/lint.lua b/lua/kickstart/plugins/lint.lua index a1b4103798d..a3920a0498d 100644 --- a/lua/kickstart/plugins/lint.lua +++ b/lua/kickstart/plugins/lint.lua @@ -7,40 +7,17 @@ return { local lint = require 'lint' lint.linters_by_ft = { markdown = { 'markdownlint' }, + python = { 'ruff', 'mypy' }, + go = { 'golangci-lint' }, + javascript = { 'eslint' }, + javascriptreact = { 'eslint' }, + typescript = { 'eslint' }, + typescriptreact = { 'eslint' }, + sh = { 'shellcheck' }, + bash = { 'shellcheck' }, + zsh = { 'shellcheck' }, } - -- To allow other plugins to add linters to require('lint').linters_by_ft, - -- instead set linters_by_ft like this: - -- lint.linters_by_ft = lint.linters_by_ft or {} - -- lint.linters_by_ft['markdown'] = { 'markdownlint' } - -- - -- However, note that this will enable a set of default linters, - -- which will cause errors unless these tools are available: - -- { - -- clojure = { "clj-kondo" }, - -- dockerfile = { "hadolint" }, - -- inko = { "inko" }, - -- janet = { "janet" }, - -- json = { "jsonlint" }, - -- markdown = { "vale" }, - -- rst = { "vale" }, - -- ruby = { "ruby" }, - -- terraform = { "tflint" }, - -- text = { "vale" } - -- } - -- - -- You can disable the default linters by setting their filetypes to nil: - -- lint.linters_by_ft['clojure'] = nil - -- lint.linters_by_ft['dockerfile'] = nil - -- lint.linters_by_ft['inko'] = nil - -- lint.linters_by_ft['janet'] = nil - -- lint.linters_by_ft['json'] = nil - -- lint.linters_by_ft['markdown'] = nil - -- lint.linters_by_ft['rst'] = nil - -- lint.linters_by_ft['ruby'] = nil - -- lint.linters_by_ft['terraform'] = nil - -- lint.linters_by_ft['text'] = nil - -- Create autocommand which carries out the actual linting -- on the specified events. local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true }) diff --git a/lua/kickstart/plugins/lspconfig.lua b/lua/kickstart/plugins/lspconfig.lua index ef5ca39b392..b7d64bcadb7 100644 --- a/lua/kickstart/plugins/lspconfig.lua +++ b/lua/kickstart/plugins/lspconfig.lua @@ -214,23 +214,13 @@ return { rust_analyzer = {}, -- Rust language server -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- - -- Some languages (like typescript) have entire language plugins that can be useful: - -- https://github.com/pmizio/typescript-tools.nvim - -- - -- But for many setups, the LSP (`tsserver`) will work just fine - -- tsserver = {}, -- TypeScript language server (removed in favor of typescript-tools.nvim) - -- + -- Note: TypeScript uses typescript-tools.nvim plugin (configured below) instead of tsserver lua_ls = { - -- cmd = { ... }, - -- filetypes = { ... }, - -- capabilities = {}, settings = { Lua = { completion = { callSnippet = 'Replace', }, - -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings - -- diagnostics = { disable = { 'missing-fields' } }, }, }, }, @@ -250,14 +240,27 @@ return { -- You can add other tools here that you want Mason to install -- for you, so that they are available from within Neovim. local ensure_installed = { - 'stylua', -- Used to format Lua code + -- Language servers 'typescript-language-server', -- TypeScript language server 'clangd', -- C/C++ language server 'gopls', -- Go language server 'pyright', -- Python language server 'rust-analyzer', -- Rust language server 'lua-language-server', -- Lua language server + -- Formatters + 'stylua', -- Lua formatter + 'black', -- Python formatter + 'isort', -- Python import formatter + 'prettier', -- JS/TS/JSON/YAML/Markdown formatter + 'goimports', -- Go import formatter + 'rustfmt', -- Rust formatter + -- Linters 'markdownlint', -- Markdown linter + 'ruff', -- Python linter + 'mypy', -- Python type checker + 'golangci-lint', -- Go linter + 'eslint', -- JS/TS linter + 'shellcheck', -- Shell script linter } require('mason-tool-installer').setup { ensure_installed = ensure_installed } diff --git a/lua/kickstart/plugins/nvim-cmp.lua b/lua/kickstart/plugins/nvim-cmp.lua index 45ca9105c33..470e6433667 100644 --- a/lua/kickstart/plugins/nvim-cmp.lua +++ b/lua/kickstart/plugins/nvim-cmp.lua @@ -20,12 +20,12 @@ return { -- `friendly-snippets` contains a variety of premade snippets. -- See the README about individual language/framework/plugin snippets: -- https://github.com/rafamadriz/friendly-snippets - -- { - -- 'rafamadriz/friendly-snippets', - -- config = function() - -- require('luasnip.loaders.from_vscode').lazy_load() - -- end, - -- }, + { + 'rafamadriz/friendly-snippets', + config = function() + require('luasnip.loaders.from_vscode').lazy_load() + end, + }, }, opts = {}, }, @@ -51,6 +51,9 @@ return { completion = { completeopt = 'menu,menuone,noinsert', }, + experimental = { + ghost_text = true, + }, mapping = cmp.mapping.preset.insert { -- Select the [n]ext item [''] = cmp.mapping.select_next_item(), @@ -89,9 +92,6 @@ return { luasnip.jump(-1) end end, { 'i', 's' }), - - -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: - -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps }, sources = { { name = 'nvim_lsp' }, @@ -102,10 +102,10 @@ return { }, } - -- Set configuration for specific filetype. + -- Git commit completion cmp.setup.filetype('gitcommit', { sources = cmp.config.sources({ - { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git). + { name = 'git' }, }, { { name = 'buffer' }, }), diff --git a/lua/kickstart/plugins/telescope.lua b/lua/kickstart/plugins/telescope.lua index bb74bf10fcd..630a0178e6a 100644 --- a/lua/kickstart/plugins/telescope.lua +++ b/lua/kickstart/plugins/telescope.lua @@ -52,15 +52,6 @@ return { -- [[ Configure Telescope ]] -- See `:help telescope` and `:help telescope.setup()` require('telescope').setup { - -- You can put your default mappings / updates / etc. in here - -- All the info you're looking for is in `:help telescope.setup()` - -- - -- defaults = { - -- mappings = { - -- i = { [''] = 'to_fuzzy_refine' }, - -- }, - -- }, - -- pickers = {} extensions = { ['ui-select'] = { require('telescope.themes').get_dropdown(), From c1957b7d953a1beee2f26dfa6b30ebd4adacadd0 Mon Sep 17 00:00:00 2001 From: eadu6 Date: Tue, 2 Dec 2025 12:24:48 -0800 Subject: [PATCH 06/19] fix: switch from jest to vitest in neotest configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace neotest-jest with neotest-vitest adapter - Update configuration for vitest compatibility - Add node_modules filter for better performance 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- lua/custom/plugins/neotest.lua | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lua/custom/plugins/neotest.lua b/lua/custom/plugins/neotest.lua index 6242201c626..8975efb52f2 100644 --- a/lua/custom/plugins/neotest.lua +++ b/lua/custom/plugins/neotest.lua @@ -1,5 +1,5 @@ -- Neotest - Modern testing framework for Neovim --- Requires test frameworks: pytest (Python), go test (Go), jest (JS/TS) +-- Requires test frameworks: pytest (Python), go test (Go), vitest (JS/TS) return { 'nvim-neotest/neotest', dependencies = { @@ -10,7 +10,7 @@ return { -- Language adapters 'nvim-neotest/neotest-python', 'nvim-neotest/neotest-go', - 'nvim-neotest/neotest-jest', + 'marilari88/neotest-vitest', }, config = function() require('neotest').setup { @@ -26,12 +26,9 @@ return { }, args = { '-v', '-race', '-count=1' }, }, - require 'neotest-jest' { - jestCommand = 'npm test --', - jestConfigFile = 'jest.config.js', - env = { CI = true }, - cwd = function() - return vim.fn.getcwd() + require 'neotest-vitest' { + filter_dir = function(name, rel_path, root) + return name ~= 'node_modules' end, }, }, From 617b669677643205a66cdd47da370254a1a763c5 Mon Sep 17 00:00:00 2001 From: eadu6 Date: Tue, 2 Dec 2025 12:27:29 -0800 Subject: [PATCH 07/19] feat: add full interactive Jupyter notebook support via molten.nvim MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add comprehensive Jupyter notebook integration for data science workflows: New plugins: - molten.nvim: Execute code cells with inline output display - image.nvim: Render plots and images in terminal (Kitty support) - quarto-nvim: Support for Quarto documents (.qmd files) - jupytext.nvim: Edit notebooks as Python files with auto-sync Features: - Execute Python cells interactively in Neovim - Inline output display (text, plots, dataframes) - Multiple kernel support - Cell navigation and management - Works with .ipynb files and .py files (using # %% markers) - Image rendering in supported terminals Keybindings: - mi: Initialize kernel - me: Evaluate line/visual selection - mr: Re-evaluate cell - ]c / [c: Navigate cells - mo: Show output - mh: Hide output - mx: Interrupt kernel - mX: Restart kernel Configuration: - Auto-open output disabled by default (toggle with mo) - Virtual text output enabled - Kitty terminal backend for images - Max output height: 20 lines Files added: - lua/custom/plugins/molten.lua: Main molten configuration - lua/custom/plugins/notebook-utils.lua: Jupytext integration - JUPYTER_SETUP.md: Complete setup and usage guide Requirements (see JUPYTER_SETUP.md): - pip install jupyter ipython pynvim - Kitty terminal recommended for image rendering - Optional: cairosvg, plotly, kaleido for enhanced rendering 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- JUPYTER_SETUP.md | 173 ++++++++++++++++++++++++++ lua/custom/plugins/molten.lua | 121 ++++++++++++++++++ lua/custom/plugins/notebook-utils.lua | 26 ++++ 3 files changed, 320 insertions(+) create mode 100644 JUPYTER_SETUP.md create mode 100644 lua/custom/plugins/molten.lua create mode 100644 lua/custom/plugins/notebook-utils.lua diff --git a/JUPYTER_SETUP.md b/JUPYTER_SETUP.md new file mode 100644 index 00000000000..003738229a6 --- /dev/null +++ b/JUPYTER_SETUP.md @@ -0,0 +1,173 @@ +# Jupyter Notebook Setup Guide + +Your Neovim is now configured with **Molten.nvim** for full interactive Jupyter notebook support! + +## Prerequisites + +### 1. Install Python Packages + +```bash +# Required packages +pip install jupyter ipython pynvim + +# Optional but recommended for full functionality +pip install cairosvg plotly kaleido pnglatex pyperclip +pip install jupyter-console # For better REPL experience +``` + +### 2. Terminal Requirements + +For inline image rendering, you need a terminal that supports images: + +**Recommended terminals:** +- **Kitty** (best support) - `brew install --cask kitty` +- **iTerm2** with imgcat +- **WezTerm** +- **Alacritty** (with sixel support) + +If using macOS Terminal or other terminals, images will open in external viewers instead. + +### 3. Verify Installation + +```bash +# Check jupyter is installed +jupyter --version + +# Check ipython is installed +ipython --version + +# Check pynvim is available +python -c "import pynvim; print('pynvim OK')" +``` + +## Usage + +### Starting a Kernel + +1. Open a Python file or Jupyter notebook (`.ipynb`) +2. Press `mi` to initialize a kernel +3. Select kernel (usually "python3") + +### Working with Notebooks + +**Evaluate code:** +- `me` - Evaluate current line +- Visual mode + `me` - Evaluate selection +- `mr` - Re-evaluate current cell + +**Navigate cells:** +- `]c` - Next cell +- `[c` - Previous cell + +**Manage outputs:** +- `mo` - Show output +- `mh` - Hide output +- `md` - Delete cell + +**Kernel control:** +- `mx` - Interrupt kernel (stop execution) +- `mX` - Restart kernel +- `mq` - Quit/deinit kernel +- `mI` - Show kernel info + +**Import/Export:** +- `ms` - Save session +- `ml` - Load session +- `mE` - Export output + +### Working with .ipynb Files + +Molten works directly with `.ipynb` files. When you open a notebook: + +1. `:MoltenInit` to start a kernel +2. Navigate cells with `]c` and `[c` +3. Execute cells with `me` +4. View outputs inline or in floating windows + +### Working with Regular Python Files + +You can use Molten with regular `.py` files by marking code cells: + +```python +# %% +import numpy as np +import matplotlib.pyplot as plt + +# %% +x = np.linspace(0, 10, 100) +y = np.sin(x) +plt.plot(x, y) +plt.show() + +# %% +print("Results:", y.mean()) +``` + +The `# %%` markers define cells that can be executed independently. + +### Jupytext Integration + +Edit notebooks as Python files using Jupytext: + +```bash +# Open a notebook as Python file +nvim notebook.ipynb # Will open as .py file automatically +``` + +Jupytext syncs changes between `.ipynb` and `.py` formats. + +## Tips + +1. **Start simple:** Begin with `:MoltenInit` in a Python file +2. **Check output:** Use `mo` if output doesn't appear automatically +3. **Restart kernel:** Use `mX` if kernel gets stuck +4. **Cell markers:** Use `# %%` to create cells in `.py` files +5. **Virtual text:** Outputs can appear as virtual text inline (configurable) + +## Troubleshooting + +**"No kernel found" error:** +```bash +# Reinstall jupyter +pip install --upgrade jupyter ipython pynvim +``` + +**Images not showing:** +- Check you're using Kitty or supported terminal +- Set `vim.g.molten_image_provider = 'none'` to use external viewer +- Install image dependencies: `pip install cairosvg pillow` + +**Slow execution:** +- Interrupt kernel: `mx` +- Restart kernel: `mX` +- Check kernel process: `:MoltenInfo` + +**Plugin not loading:** +```bash +# In Neovim, update remote plugins +:UpdateRemotePlugins + +# Restart Neovim +``` + +## Advanced Configuration + +The configuration is in `lua/custom/plugins/molten.lua`. Key options: + +- `vim.g.molten_auto_open_output` - Auto-show output (default: false) +- `vim.g.molten_image_location` - 'float' or 'buffer' +- `vim.g.molten_output_win_max_height` - Max output window height + +## Integration with Neotest + +Molten works alongside neotest. Use: +- Neotest for running unit tests (`tt`) +- Molten for interactive data science work (`me`) + +## Resources + +- [Molten.nvim Documentation](https://github.com/benlubas/molten-nvim) +- [Image.nvim Documentation](https://github.com/3rd/image.nvim) +- [Jupytext Documentation](https://github.com/mwouts/jupytext) + +Enjoy your interactive Python notebooks in Neovim! 🚀 diff --git a/lua/custom/plugins/molten.lua b/lua/custom/plugins/molten.lua new file mode 100644 index 00000000000..4db62e37573 --- /dev/null +++ b/lua/custom/plugins/molten.lua @@ -0,0 +1,121 @@ +-- Molten.nvim - Interactive Jupyter notebooks in Neovim +-- Requires: jupyter, ipython, pynvim +-- Install: pip install jupyter ipython pynvim cairosvg plotly kaleido pnglatex pyperclip +return { + { + 'benlubas/molten-nvim', + version = '^1.0.0', + dependencies = { '3rd/image.nvim' }, + build = ':UpdateRemotePlugins', + init = function() + -- Configuration options + vim.g.molten_image_provider = 'image.nvim' + vim.g.molten_output_win_max_height = 20 + vim.g.molten_auto_open_output = false + vim.g.molten_wrap_output = true + vim.g.molten_virt_text_output = true + vim.g.molten_virt_lines_off_by_1 = true + vim.g.molten_output_show_more = true + vim.g.molten_output_win_border = { '', '━', '', '' } + vim.g.molten_output_win_cover_gutter = true + vim.g.molten_auto_image_popup = true + vim.g.molten_enter_output_behavior = 'open_then_enter' + vim.g.molten_use_border_highlights = true + vim.g.molten_limit_output_chars = 1000000 + vim.g.molten_tick_rate = 500 + vim.g.molten_image_location = 'float' + vim.g.molten_split_direction = 'right' + vim.g.molten_split_size = 40 + end, + keys = { + -- Initialize kernel + { 'mi', ':MoltenInit', desc = '[M]olten [I]nit Kernel', silent = true }, + { 'mI', ':MoltenInfo', desc = '[M]olten [I]nfo', silent = true }, + + -- Evaluate cells + { 'me', ':MoltenEvaluateLine', desc = '[M]olten [E]val Line', silent = true }, + { 'me', ':MoltenEvaluateVisualgv', mode = 'v', desc = '[M]olten [E]val Visual', silent = true }, + { 'mr', ':MoltenReevaluateCell', desc = '[M]olten [R]e-eval Cell', silent = true }, + { 'mc', ':MoltenEvaluateOperator', desc = '[M]olten Eval Operator', silent = true }, + + -- Navigate cells + { '[c', ':MoltenPrev', desc = 'Molten Prev Cell', silent = true }, + { ']c', ':MoltenNext', desc = 'Molten Next Cell', silent = true }, + + -- Output management + { 'mo', ':MoltenShowOutput', desc = '[M]olten Show [O]utput', silent = true }, + { 'mh', ':MoltenHideOutput', desc = '[M]olten [H]ide Output', silent = true }, + { 'md', ':MoltenDelete', desc = '[M]olten [D]elete Cell', silent = true }, + + -- Kernel management + { 'mx', ':MoltenInterrupt', desc = '[M]olten Interrupt Kernel', silent = true }, + { 'mX', ':MoltenRestart!', desc = '[M]olten Restart Kernel', silent = true }, + { 'mq', ':MoltenDeinit', desc = '[M]olten Quit Kernel', silent = true }, + + -- Import/Export + { 'ms', ':MoltenSave', desc = '[M]olten [S]ave', silent = true }, + { 'ml', ':MoltenLoad', desc = '[M]olten [L]oad', silent = true }, + { 'mE', ':MoltenExportOutput', desc = '[M]olten [E]xport Output', silent = true }, + }, + }, + { + '3rd/image.nvim', + opts = { + backend = 'kitty', + integrations = { + markdown = { + enabled = true, + clear_in_insert_mode = false, + download_remote_images = true, + only_render_image_at_cursor = false, + filetypes = { 'markdown', 'vimwiki', 'quarto' }, + }, + neorg = { + enabled = true, + clear_in_insert_mode = false, + download_remote_images = true, + only_render_image_at_cursor = false, + filetypes = { 'norg' }, + }, + html = { + enabled = false, + }, + css = { + enabled = false, + }, + }, + max_width = nil, + max_height = nil, + max_width_window_percentage = nil, + max_height_window_percentage = 50, + window_overlap_clear_enabled = false, + window_overlap_clear_ft_ignore = { 'cmp_menu', 'cmp_docs', '' }, + editor_only_render_when_focused = false, + tmux_show_only_in_active_window = false, + hijack_file_patterns = { '*.png', '*.jpg', '*.jpeg', '*.gif', '*.webp', '*.svg' }, + }, + }, + { + -- Quarto support (optional - for .qmd files) + 'quarto-dev/quarto-nvim', + ft = { 'quarto', 'markdown' }, + dev = false, + opts = { + lspFeatures = { + languages = { 'python', 'r', 'julia' }, + chunks = 'all', + diagnostics = { + enabled = true, + triggers = { 'BufWritePost' }, + }, + completion = { + enabled = true, + }, + }, + keymap = false, -- Use molten keymaps instead + }, + dependencies = { + 'jmbuhr/otter.nvim', + }, + }, +} diff --git a/lua/custom/plugins/notebook-utils.lua b/lua/custom/plugins/notebook-utils.lua new file mode 100644 index 00000000000..7a2e7d2ecee --- /dev/null +++ b/lua/custom/plugins/notebook-utils.lua @@ -0,0 +1,26 @@ +-- Notebook utilities and enhancements +return { + { + -- Jupytext for editing notebooks as Python files + 'GCBallesteros/jupytext.nvim', + config = function() + require('jupytext').setup { + style = 'markdown', + output_extension = 'md', + force_ft = 'markdown', + custom_language_formatting = { + python = { + extension = 'py', + style = 'light', + force_ft = 'python', + }, + r = { + extension = 'r', + style = 'light', + force_ft = 'r', + }, + }, + } + end, + }, +} From da3599d02275beeb46f037d850ea0eda2c2fbfb0 Mon Sep 17 00:00:00 2001 From: eadu6 Date: Tue, 2 Dec 2025 12:29:50 -0800 Subject: [PATCH 08/19] docs: clarify Ghostty terminal support for molten.nvim MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update JUPYTER_SETUP.md to explicitly list Ghostty as supported - Add comment in molten.lua clarifying Kitty protocol compatibility - Ghostty fully supports Kitty graphics protocol for inline images 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- JUPYTER_SETUP.md | 12 +++++++----- lua/custom/plugins/molten.lua | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/JUPYTER_SETUP.md b/JUPYTER_SETUP.md index 003738229a6..55f294bfdb6 100644 --- a/JUPYTER_SETUP.md +++ b/JUPYTER_SETUP.md @@ -17,13 +17,15 @@ pip install jupyter-console # For better REPL experience ### 2. Terminal Requirements -For inline image rendering, you need a terminal that supports images: +For inline image rendering, you need a terminal that supports the Kitty graphics protocol: -**Recommended terminals:** -- **Kitty** (best support) - `brew install --cask kitty` -- **iTerm2** with imgcat +**Fully Supported Terminals:** +- **Ghostty** ✅ (you're using this - perfect!) +- **Kitty** - `brew install --cask kitty` - **WezTerm** -- **Alacritty** (with sixel support) +- **iTerm2** with imgcat + +**Note:** Ghostty implements the Kitty graphics protocol, so inline images will work perfectly with your current terminal setup! If using macOS Terminal or other terminals, images will open in external viewers instead. diff --git a/lua/custom/plugins/molten.lua b/lua/custom/plugins/molten.lua index 4db62e37573..82da8ee9af1 100644 --- a/lua/custom/plugins/molten.lua +++ b/lua/custom/plugins/molten.lua @@ -61,7 +61,7 @@ return { { '3rd/image.nvim', opts = { - backend = 'kitty', + backend = 'kitty', -- Works with Kitty, Ghostty, WezTerm (Kitty graphics protocol) integrations = { markdown = { enabled = true, From 33f6ae5e131aa4dd21b405989609804a0c6206fd Mon Sep 17 00:00:00 2001 From: eadu6 Date: Tue, 2 Dec 2025 12:54:09 -0800 Subject: [PATCH 09/19] feat: add comprehensive Vim learning plugins for beginners MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add learning-accelerator plugins to help new Vim users master motions and develop good habits: New Plugins: 1. Precognition.nvim - Real-time motion hints - Shows ghost text for available motions (w, b, e, {, }) - Teaches efficient navigation while you work - Toggle: tp - Peek: pp 2. Hardtime.nvim - Break bad habits - Prevents repetitive hjkl usage (gentle mode) - Suggests better motions (w, b, }, { instead of jjjj) - Max 4 repetitions before hint (beginner-friendly) - Toggle: th - Report: hr 3. Flash.nvim - Enhanced navigation with labels - Jump anywhere with s + 2 chars + label (3 keystrokes) - Treesitter integration: S for code structures - Works with operators: d, c, y - Custom highlights for visibility 4. Treesitter Textobjects - Code-aware editing - Function: vif (select in), daf (delete), ]f/[f (navigate) - Class: vic, dac, ]c/[c - Parameter: via, cia, daa, sn/sp (swap) - Conditional: vii, vai, ]i/[i - Loop: vil, val, ]l/[l - Incremental selection: Configuration Philosophy: - Beginner-friendly (not too strict initially) - Hints over blocks (learning mode) - Disabled in special buffers (Telescope, Neo-tree, etc.) - Clear feedback and notifications - Easy toggle keybindings Files Added: - lua/custom/plugins/precognition.lua: Motion hint configuration - lua/custom/plugins/hardtime.lua: Habit-breaking settings - lua/custom/plugins/flash.lua: Enhanced navigation setup - LEARNING_GUIDE.md: Comprehensive 4-week learning path Files Modified: - lua/kickstart/plugins/treesitter.lua: Added textobjects + incremental selection Learning Path: Week 1: Basic motions (w, b, e, {, }) Week 2: Flash navigation (s + chars) Week 3: Textobjects (vif, daf, ]f) Week 4: Advanced combinations Key Keybindings: Navigation: - s - Flash jump - S - Treesitter select - ]f/[f - Next/prev function - ]c/[c - Next/prev class Textobjects: - vif/vaf - Select function - via/vaa - Select parameter - daf - Delete function - cia - Change parameter Learning: - tp - Toggle Precognition - th - Toggle Hardtime - hr - Hardtime report 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- LEARNING_GUIDE.md | 411 +++++++++++++++++++++++++++ lua/custom/plugins/flash.lua | 174 ++++++++++++ lua/custom/plugins/hardtime.lua | 100 +++++++ lua/custom/plugins/precognition.lua | 56 ++++ lua/kickstart/plugins/treesitter.lua | 81 +++++- 5 files changed, 815 insertions(+), 7 deletions(-) create mode 100644 LEARNING_GUIDE.md create mode 100644 lua/custom/plugins/flash.lua create mode 100644 lua/custom/plugins/hardtime.lua create mode 100644 lua/custom/plugins/precognition.lua diff --git a/LEARNING_GUIDE.md b/LEARNING_GUIDE.md new file mode 100644 index 00000000000..397eb4febcd --- /dev/null +++ b/LEARNING_GUIDE.md @@ -0,0 +1,411 @@ +# Vim/Neovim Learning Guide + +Your Neovim is now equipped with **learning-focused plugins** that will accelerate your Vim journey! This guide will help you master Vim efficiently. + +--- + +## 🎯 Learning Philosophy + +These plugins work together to teach you Vim the right way: +1. **Precognition** - Shows you what's possible +2. **Hardtime** - Prevents bad habits +3. **Flash** - Makes navigation intuitive +4. **Treesitter Textobjects** - Teaches code-aware editing + +--- + +## 📚 The Plugins + +### 1. Precognition - Your Motion Teacher + +**What it does:** Shows ghost hints for available motions as you navigate. + +**You'll see hints like:** +``` +function calculateTotal(items) { + ^ w w w e e +``` + +**Common hints you'll learn:** +- `w` = next word start +- `b` = previous word start +- `e` = end of word +- `^` = first non-blank character +- `$` = end of line +- `{` = previous paragraph +- `}` = next paragraph + +**Keybindings:** +- `tp` - Toggle precognition on/off +- `pp` - Peek at available motions + +**Learning tip:** Don't ignore the hints! When you see a hint, try using that motion. + +--- + +### 2. Hardtime - Break Bad Habits + +**What it does:** Gently reminds you to use better motions instead of repeating `hjkl`. + +**How it works:** +- Press `jjjjj` → Get hint: "Use } or 5j instead" +- Press `llllll` → Get hint: "Use w or 6l instead" +- After 4 repetitions, you'll see suggestions + +**Configuration:** +- **Currently set to:** Hint mode (gentle) +- **Max repetitions:** 4 (beginner-friendly) +- **Does NOT block** - just reminds you + +**Keybindings:** +- `th` - Toggle hardtime on/off +- `hr` - View hardtime report (see your patterns) + +**Learning tip:** Read the hints! They tell you exactly what motion to use instead. + +--- + +### 3. Flash - Enhanced Navigation + +**What it does:** Jump anywhere on screen with 2-3 keystrokes using labeled jumps. + +#### Basic Usage + +**Jump to any location:** +1. Press `s` +2. Type 2 characters (e.g., `fu` for "function") +3. Labels appear: `a`, `b`, `c`, etc. +4. Press the label letter to jump there + +**Example:** +``` +Before: +function calculateTotal(items) { + const total = items.reduce() +} + +Type: s + fu +Shows: +a +function calculateTotal(items) { + const total = items.reduce() +} + +Press: a +Cursor jumps to "function"! +``` + +#### Keybindings + +**Navigation:** +- `s` - Flash jump (2 chars + label) +- `S` - Treesitter jump (select function/class) +- `r` - Remote flash (use with operators like `d`, `c`) + +**In search:** +- `/search` then `` - Toggle flash in search results + +**With operators:** +- `dsfu` - Delete from cursor to "fu" match +- `csfu` - Change from cursor to "fu" match +- `ysfu` - Yank from cursor to "fu" match + +**Learning tip:** Use `s` instead of counting (`5w`) or searching (`/term`). It's faster once you get used to it! + +--- + +### 4. Treesitter Textobjects - Code-Aware Editing + +**What it does:** Adds code structure text objects (functions, classes, parameters). + +#### Text Object Selections + +**Functions:** +- `vaf` - Select entire function (including definition) +- `vif` - Select inside function (body only) +- `daf` - Delete entire function +- `yif` - Yank function body +- `cif` - Change function body + +**Classes:** +- `vac` - Select entire class +- `vic` - Select inside class + +**Parameters/Arguments:** +- `via` - Select inside parameter +- `vaa` - Select parameter including comma +- `cia` - Change parameter +- `daa` - Delete parameter + +**Conditionals (if/else):** +- `vii` - Select inside if block +- `vai` - Select entire if statement + +**Loops:** +- `vil` - Select inside loop +- `val` - Select entire loop + +**Comments:** +- `va/` - Select comment + +#### Navigation + +**Jump to next/previous:** +- `]f` / `[f` - Next/Previous function +- `]c` / `[c` - Next/Previous class +- `]a` / `[a` - Next/Previous parameter +- `]i` / `[i` - Next/Previous conditional +- `]l` / `[l` - Next/Previous loop + +**Jump to end:** +- `]F` - Next function end +- `[F` - Previous function end + +#### Parameter Swapping + +- `sn` - Swap parameter with next +- `sp` - Swap parameter with previous + +**Example:** +```javascript +function foo(first, second, third) { + // ^^^^^^ + // Cursor here, press sn +} + +// Becomes: +function foo(first, third, second) { +} +``` + +#### Incremental Selection + +- `` - Start/expand selection +- `` - Expand to scope +- `` - Shrink selection + +**Learning tip:** These become second nature after a week. Start with `vif`, `daf`, `]f`, `[f`. + +--- + +## 🚀 Learning Path (Week-by-Week) + +### Week 1: Basic Motions +**Focus:** Learn to use `w`, `b`, `e`, `{`, `}` + +**Practice:** +1. Watch Precognition hints - try every motion you see +2. Let Hardtime remind you when you use `hjkl` too much +3. Don't disable anything yet! + +**Goals:** +- Stop using arrow keys +- Use `w` instead of `lllll` +- Use `{`/`}` instead of `jjjjj` + +### Week 2: Flash Navigation +**Focus:** Master Flash for quick jumps + +**Practice:** +1. Use `s` + 2 chars to jump around +2. Try `S` to select functions/classes +3. Use Flash with operators: `dsfu` (delete to "fu") + +**Goals:** +- Jump to any visible text in 3 keystrokes +- Stop using `/search` for short jumps + +### Week 3: Text Objects +**Focus:** Learn function/class operations + +**Practice:** +1. Use `vif` to select function body +2. Use `daf` to delete entire functions +3. Navigate with `]f` and `[f` + +**Goals:** +- Think in code structures, not lines +- Delete/change functions without counting lines + +### Week 4: Advanced Combinations +**Focus:** Combine everything + +**Practice:** +1. `s` + label + `vif` - Jump and select function +2. `]f` then `daf` - Jump to next function and delete it +3. `via` + `cia` - Select and change parameters + +**Goals:** +- Edit code at the speed of thought +- Rarely use `hjkl` anymore + +--- + +## 💡 Quick Reference Card + +### Essential Motions (Learn These First) +``` +w - Next word start ]f - Next function +b - Previous word start [f - Previous function +e - End of word vif - Select in function +{ - Previous paragraph daf - Delete function +} - Next paragraph s - Flash jump +^ - Line start (non-blank) S - Treesitter select +$ - Line end +``` + +### Practice Exercises + +**Exercise 1: Navigation** +```javascript +function calculateTotal(items) { + const total = items.reduce((sum, item) => { + return sum + item.price + }, 0) + return total +} + +Tasks: +1. Jump to "reduce" using: sre