diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 86598b8dc98..00000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: '' -assignees: '' - ---- - - - -## Before Reporting an Issue -- I have read the kickstart.nvim README.md. -- I have read the appropriate plugin's documentation. -- I have searched that this issue has not been reported before. - -- [ ] **By checking this, I confirm that the above steps are completed. I understand leaving this unchecked will result in this report being closed immediately.** - -## Describe the bug - - -## To Reproduce - -1. ... - -## Desktop - -- OS: -- Terminal: - -## Neovim Version - - -``` -``` diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md deleted file mode 100644 index f401c9ffd9c..00000000000 --- a/.github/pull_request_template.md +++ /dev/null @@ -1,8 +0,0 @@ -*************************************************************************** -**NOTE** -Please verify that the `base repository` above has the intended destination! -Github by default opens Pull Requests against the parent of a forked repository. -If this is your personal fork and you didn't intend to open a PR for contribution -to the original project then adjust the `base repository` accordingly. -************************************************************************** - diff --git a/.gitignore b/.gitignore index 005b535b606..0bf768187c1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ +.metals tags test.sh .luarc.json nvim spell/ -lazy-lock.json +.DS_Store \ No newline at end of file diff --git a/README.md b/README.md index 4113950550d..68ff33b33b2 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,4 @@ -# kickstart.nvim - -## Introduction - -A starting point for Neovim that is: - -* Small -* Single-file -* Completely Documented - -**NOT** a Neovim distribution, but instead a starting point for your configuration. +# Florian Teichs fork of kickstart.nvim ## Installation @@ -53,28 +43,12 @@ Neovim's configurations are located under the following paths, depending on your #### Recommended Step -[Fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) this repo -so that you have your own copy that you can modify, then install by cloning the -fork to your machine using one of the commands below, depending on your OS. - -> [!NOTE] -> Your fork's URL will be something like this: -> `https://github.com//kickstart.nvim.git` - -You likely want to remove `lazy-lock.json` from your fork's `.gitignore` file -too - it's ignored in the kickstart repo to make maintenance easier, but it's -[recommended to track it in version control](https://lazy.folke.io/usage/lockfile). - #### Clone kickstart.nvim -> [!NOTE] -> If following the recommended step above (i.e., forking the repo), replace -> `nvim-lua` with `` in the commands below -
Linux and Mac ```sh -git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim +git clone https://github.com/FlorianTeich/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim ```
@@ -84,13 +58,13 @@ git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HO If you're using `cmd.exe`: ``` -git clone https://github.com/nvim-lua/kickstart.nvim.git "%localappdata%\nvim" +git clone https://github.com/FlorianTeich/kickstart.nvim.git "%localappdata%\nvim" ``` If you're using `powershell.exe` ``` -git clone https://github.com/nvim-lua/kickstart.nvim.git "${env:LOCALAPPDATA}\nvim" +git clone https://github.com/FlorianTeich/kickstart.nvim.git "${env:LOCALAPPDATA}\nvim" ``` @@ -106,20 +80,6 @@ nvim That's it! Lazy will install all the plugins you have. Use `:Lazy` to view the current plugin status. Hit `q` to close the window. -#### Read The Friendly Documentation - -Read through the `init.lua` file in your configuration folder for more -information about extending and exploring Neovim. That also includes -examples of adding popularly requested plugins. - -> [!NOTE] -> For more information about a particular plugin check its repository's documentation. - - -### Getting Started - -[The Only Video You Need to Get Started with Neovim](https://youtu.be/m8C0Cq9Uv9o) - ### FAQ * What should I do if I already have a pre-existing Neovim configuration? @@ -239,3 +199,48 @@ sudo pacman -S --noconfirm --needed gcc make git ripgrep fd unzip neovim ``` +## Keymaps + +| Mode | Keys | Action | Description | +| ------------ | ------------ | --------------------------- | ----------------------------- | +| **Normal** | `` | `:nohlsearch` | Clear search highlights | +| **Normal** | `q` | `vim.diagnostic.setloclist` | Open diagnostic quickfix list | +| **Terminal** | `` | `` | Exit terminal mode | +| **Normal** | `` | `` | Move focus to left split | +| **Normal** | `` | `` | Move focus to right split | +| **Normal** | `` | `` | Move focus to lower split | +| **Normal** | `` | `` | Move focus to upper split | + + +| Mode | Keys | Telescope Action | Description | +| ---------- | ------------------ | ---------------------------- | ------------------------------ | +| **Normal** | `sh` | `help_tags` | Search help | +| **Normal** | `sk` | `keymaps` | Search keymaps | +| **Normal** | `sf` | `find_files` | Search files | +| **Normal** | `ss` | `builtin` | Search Telescope pickers | +| **Normal** | `sw` | `grep_string` | Search word under cursor | +| **Normal** | `sg` | `live_grep` | Grep search | +| **Normal** | `sd` | `diagnostics` | Search diagnostics | +| **Normal** | `sr` | `resume` | Resume last Telescope search | +| **Normal** | `s.` | `oldfiles` | Search recent files | +| **Normal** | `` | `buffers` | Find buffers | +| **Normal** | `/` | `current_buffer_fuzzy_find` | Fuzzy find in current buffer | +| **Normal** | `s/` | Live grep open files | Grep through open files only | +| **Normal** | `sn` | `find_files` (Neovim config) | Search Neovim config directory | + +| Mode | Keys | Action | Description | +| ------------------- | ------------ | ------------------------------- | --------------------------------------- | +| **Normal** | `grn` | `vim.lsp.buf.rename` | Rename symbol | +| **Normal / Visual** | `gra` | `vim.lsp.buf.code_action` | Code actions | +| **Normal** | `grr` | `lsp_references` | Find references | +| **Normal** | `gri` | `lsp_implementations` | Go to implementation | +| **Normal** | `grd` | `lsp_definitions` | Go to definition | +| **Normal** | `grD` | `vim.lsp.buf.declaration` | Go to declaration | +| **Normal** | `gO` | `lsp_document_symbols` | Document symbols | +| **Normal** | `gW` | `lsp_dynamic_workspace_symbols` | Workspace symbols | +| **Normal** | `grt` | `lsp_type_definitions` | Go to type definition | +| **Normal** | `th` | Toggle inlay hints | Toggle LSP inlay hints (when supported) | + +| Mode | Keys | Action | Description | +| --------------------------- | ----------- | ---------------- | --------------------- | +| **All modes (`mode = ''`)** | `f` | `conform.format` | Format current buffer | diff --git a/doc/kickstart.txt b/doc/kickstart.txt deleted file mode 100644 index cb87ac3f1de..00000000000 --- a/doc/kickstart.txt +++ /dev/null @@ -1,24 +0,0 @@ -================================================================================ -INTRODUCTION *kickstart.nvim* - -Kickstart.nvim is a project to help you get started on your neovim journey. - - *kickstart-is-not* -It is not: -- Complete framework for every plugin under the sun -- Place to add every plugin that could ever be useful - - *kickstart-is* -It is: -- Somewhere that has a good start for the most common "IDE" type features: - - autocompletion - - goto-definition - - find references - - fuzzy finding - - and hinting at what more can be done :) -- A place to _kickstart_ your journey. - - You should fork this project and use/modify it so that it matches your - style and preferences. If you don't want to do that, there are probably - other projects that would fit much better for you (and that's great!)! - - vim:tw=78:ts=8:ft=help:norl: diff --git a/doc/tags b/doc/tags deleted file mode 100644 index 687ae7721d9..00000000000 --- a/doc/tags +++ /dev/null @@ -1,3 +0,0 @@ -kickstart-is kickstart.txt /*kickstart-is* -kickstart-is-not kickstart.txt /*kickstart-is-not* -kickstart.nvim kickstart.txt /*kickstart.nvim* diff --git a/init.lua b/init.lua index b98ffc6198a..f5d9dd6545b 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 ]] -- See `:help vim.o` @@ -102,7 +102,7 @@ vim.g.have_nerd_font = false vim.o.number = true -- You can also add relative line numbers, to help with jumping. -- Experiment for yourself to see if you like it! --- vim.o.relativenumber = true +vim.o.relativenumber = true -- Enable mouse mode, can be useful for resizing splits for example! vim.o.mouse = 'a' @@ -185,10 +185,10 @@ vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagn vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) -- TIP: Disable arrow keys in normal mode --- vim.keymap.set('n', '', 'echo "Use h to move!!"') --- vim.keymap.set('n', '', 'echo "Use l to move!!"') --- vim.keymap.set('n', '', 'echo "Use k to move!!"') --- vim.keymap.set('n', '', 'echo "Use j to move!!"') +vim.keymap.set('n', '', 'echo "Use h to move!!"') +vim.keymap.set('n', '', 'echo "Use l to move!!"') +vim.keymap.set('n', '', 'echo "Use k to move!!"') +vim.keymap.set('n', '', 'echo "Use j to move!!"') -- Keybinds to make split navigation easier. -- Use CTRL+ to switch between windows @@ -205,6 +205,8 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the upper win -- vim.keymap.set("n", "", "J", { desc = "Move window to the lower" }) -- vim.keymap.set("n", "", "K", { desc = "Move window to the upper" }) +vim.keymap.set('n', '', ':tabnew', { noremap = true, silent = true }) + -- [[ Basic Autocommands ]] -- See `:help lua-guide-autocommands` @@ -234,6 +236,14 @@ end local rtp = vim.opt.rtp rtp:prepend(lazypath) +local function toggle_diffview(cmd) + if next(require("diffview.lib").views) == nil then + vim.cmd(cmd) + else + vim.cmd("DiffviewClose") + end +end + -- [[ Configure and install plugins ]] -- -- To check the current status of your plugins, run @@ -428,7 +438,7 @@ require('lazy').setup({ local builtin = require 'telescope.builtin' vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) - vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) + vim.keymap.set('n', 'ff', builtin.find_files, { desc = '[S]earch [F]iles' }) vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) @@ -671,10 +681,49 @@ require('lazy').setup({ -- - 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 = {}, + clangd = { + cmd = { 'clangd', '--background-index', '--clang-tidy', '--completion-style=bundled' }, + filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'cuda' }, + }, -- gopls = {}, - -- pyright = {}, - -- rust_analyzer = {}, + rust_analyzer = { + settings = { + ['rust-analyzer'] = { + cargo = { + allFeatures = true, + }, + checkOnSave = { + command = 'clippy', + }, + }, + }, + }, + jdtls = { + settings = { + java = { + configuration = { + updateBuildConfiguration = 'interactive', + }, + completion = { + favoriteStaticMembers = { + 'org.hamcrest.MatcherAssert.assertThat', + 'org.hamcrest.Matchers.*', + 'org.hamcrest.CoreMatchers.*', + 'java.util.Objects.requireNonNull', + 'java.util.Objects.requireNonNullElse', + 'org.mockito.Mockito.*', + }, + }, + sources = { + organizeImports = { + starThreshold = 9999, + staticStarThreshold = 9999, + }, + }, + }, + }, + }, + -- Note: Scala is handled by nvim-metals plugin, not through Mason/lspconfig -- ... 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: @@ -736,6 +785,93 @@ require('lazy').setup({ end, }, + { + 'j-hui/fidget.nvim', + opts = {}, + }, + + { + "olimorris/codecompanion.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-treesitter/nvim-treesitter", + -- Optional but nice: + --"hrsh7th/nvim-cmp", -- for chat buffer completion + "nvim-telescope/telescope.nvim", -- for action palette + }, + opts = { + -- Global plugin options + opts = { + -- set to "DEBUG" or "TRACE" if you want verbose logs: + -- log_level = "DEBUG", + }, + + ---------------------------------------------------------------- + -- Use Ollama as default adapter + ---------------------------------------------------------------- + -- Ollama is supported out-of-the-box as an HTTP adapter. + -- This assumes `ollama serve` is running on 127.0.0.1:11434. + strategies = { + chat = { + adapter = "litellm", + }, + inline = { + adapter = "litellm", + }, + cmd = { + adapter = "litellm", + }, + }, + + -- Optional: customize the built-in Ollama adapter (e.g. default model) + adapters = { + http = { + litellm = function() + -- `openai_compatible` is meant exactly for gateways like LiteLLM + return require("codecompanion.adapters").extend("openai_compatible", { + env = { + -- URL of your LiteLLM proxy / gateway + -- (default Quickstart is http://0.0.0.0:4000) :contentReference[oaicite:0]{index=0} + url = "http://127.0.0.1:4000", + + -- Name of the ENV VAR that holds your LiteLLM API key + -- If your proxy accepts any key, you can do: + -- export LITELLM_API_KEY='anything' + api_key = "sk-1234", + + -- LiteLLM’s OpenAI-style chat endpoint + -- (by default it exposes `/chat/completions` for chat) :contentReference[oaicite:1]{index=1} + chat_url = "/chat/completions", + }, + + headers = { + ["Content-Type"] = "application/json", + -- `${api_key}` gets replaced with the resolved env value + ["Authorization"] = "Bearer ${api_key}", + }, + + -- Default model LiteLLM should route to + -- Must match the *model_name* you configured in litellm_config.yaml + -- e.g. "ollama/qwen2.5-coder" or "gpt-4o", etc. + schema = { + model = { + default = "ollama/gemma3:4b", + --default = "eu.anthropic.claude-3-7-sonnet-20250219-v1:0", + }, + }, + + -- Optional, but nice: force streaming + parameters = { + stream = true, + }, + }) + end, + }, + }, + }, + }, + + { -- Autoformat 'stevearc/conform.nvim', event = { 'BufWritePre' }, @@ -768,6 +904,11 @@ require('lazy').setup({ end, formatters_by_ft = { lua = { 'stylua' }, + cpp = { 'clang-format' }, + c = { 'clang-format' }, + rust = { 'rustfmt' }, + java = { 'google-java-format' }, + scala = { 'scalafmt' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- @@ -781,6 +922,7 @@ require('lazy').setup({ 'saghen/blink.cmp', event = 'VimEnter', version = '1.*', + build = 'cargo build --release', dependencies = { -- Snippet Engine { @@ -869,7 +1011,7 @@ require('lazy').setup({ -- the rust implementation via `'prefer_rust_with_warning'` -- -- See :h blink-cmp-config-fuzzy for more information - fuzzy = { implementation = 'lua' }, + fuzzy = { implementation = 'prefer_rust_with_warning' }, -- Shows a signature help window while you type arguments for a function signature = { enabled = true }, @@ -938,13 +1080,66 @@ require('lazy').setup({ -- Check out: https://github.com/echasnovski/mini.nvim end, }, + { + "sindrets/diffview.nvim", + command = "DiffviewOpen", + cond = is_git_root, + keys = { + { + "gd", + function() + toggle_diffview("DiffviewOpen") + end, + desc = "Diff Index", + }, + { + "gD", + function() + toggle_diffview("DiffviewOpen origin/main...HEAD") + end, + desc = "Diff main", + }, + { + "gf", + function() + toggle_diffview("DiffviewFileHistory %") + end, + desc = "Open diffs for current File", + }, + } + }, { -- Highlight, edit, and navigate code 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', main = 'nvim-treesitter.configs', -- Sets main module to use for opts -- [[ Configure Treesitter ]] See `:help nvim-treesitter` + dependencies = { + 'nvim-treesitter/nvim-treesitter-textobjects', + }, opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, + ensure_installed = { + 'bash', + 'c', + 'diff', + 'html', + 'lua', + 'luadoc', + 'markdown', + 'markdown_inline', + 'query', + 'vim', + 'vimdoc', + 'yaml', + 'java', + 'javascript', + 'json', + 'python', + 'rust', + 'scala', + 'typescript', + 'go', + 'cpp', + }, -- Autoinstall languages that are not installed auto_install = true, highlight = { @@ -955,6 +1150,18 @@ require('lazy').setup({ additional_vim_regex_highlighting = { 'ruby' }, }, indent = { enable = true, disable = { 'ruby' } }, + textobjects = { + select = { + enable = true, + lookahead = true, + keymaps = { + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + }, + }, + }, }, -- There are additional nvim-treesitter modules that you can use to interact -- with nvim-treesitter. You should go explore a few and see what interests you: @@ -964,6 +1171,8 @@ require('lazy').setup({ -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects }, + + -- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the -- init.lua. If you want these files, they are in the repository, so you can just download them and -- place them in the correct locations. @@ -973,13 +1182,76 @@ 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.debug', + require 'kickstart.plugins.copilot', -- require 'kickstart.plugins.indent_line', -- require 'kickstart.plugins.lint', -- require 'kickstart.plugins.autopairs', - -- require 'kickstart.plugins.neo-tree', + require 'kickstart.plugins.neo-tree', + require 'kickstart.plugins.iron', -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps + -- Scala language support + { + 'scalameta/nvim-metals', + dependencies = { + { + 'j-hui/fidget.nvim', + opts = {}, + }, + --{ 'hrsh7th/cmp-nvim-lsp' }, + -- IMPORTANT: no need to depend on nvim-dap here anymore + }, + ft = { 'scala', 'sbt', 'java' }, + opts = function() + local metals_config = require('metals').bare_config() + + metals_config.settings = { + showImplicitArguments = true, + gradleScript = vim.fn.getcwd() .. '/gradlew', + customProjectRoot = vim.fn.getcwd(), + excludedPackages = { 'akka.actor.typed.javadsl', 'com.github.swagger.akka.javadsl' }, + } + + metals_config.init_options.statusBarProvider = 'off' + local capabilities = vim.lsp.protocol.make_client_capabilities() + local ok, cmp_lsp = pcall(require, 'cmp_nvim_lsp') + if ok then + capabilities = cmp_lsp.default_capabilities(capabilities) + end + metals_config.capabilities = capabilities + + metals_config.on_attach = function(client, bufnr) + ------------------------------------------------------------------- + -- THIS LINE IS CRITICAL FOR DEBUGGING: + ------------------------------------------------------------------- + require('metals').setup_dap() + + -- your LSP mappings ... + local map = vim.keymap.set + map('n', 'gD', vim.lsp.buf.definition) + map('n', 'K', vim.lsp.buf.hover) + -- (rest of your mappings: gi, gr, gds, gws, etc…) + + -- you can now drop the old dap keymaps here, + -- since they live in your unified nvim-dap config + end + + return metals_config + end, + config = function(self, metals_config) + local nvim_metals_group = vim.api.nvim_create_augroup('nvim-metals', { clear = true }) + vim.api.nvim_create_autocmd('FileType', { + pattern = self.ft, + callback = function() + require('metals').initialize_or_attach(metals_config) + end, + group = nvim_metals_group, + }) + end, +} + + -- 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. -- @@ -1012,5 +1284,26 @@ require('lazy').setup({ }, }) +vim.lsp.enable('ty') + +vim.keymap.set('n', 'uc', function() + local start = vim.fn.line '.' + local finish = start + + -- extend upward + while start > 1 and vim.fn.getline(start - 1):match '^#' do + start = start - 1 + end + + -- extend downward + local last = vim.fn.line '$' + while finish < last and vim.fn.getline(finish + 1):match '^#' do + finish = finish + 1 + end + + -- Run Comment.nvim operator in normal mode over the range + vim.cmd(string.format('%d,%dnormal gc', start, finish)) +end, { desc = 'Toggle comment on contiguous # block' }) + -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et diff --git a/lua/kickstart/plugins/copilot.lua b/lua/kickstart/plugins/copilot.lua new file mode 100644 index 00000000000..319813bfeca --- /dev/null +++ b/lua/kickstart/plugins/copilot.lua @@ -0,0 +1,10 @@ +return { + 'github/copilot.vim', + { + 'olimorris/codecompanion.nvim', + opts = {}, + dependencies = { + 'nvim-lua/plenary.nvim', + }, + }, +} \ No newline at end of file diff --git a/lua/kickstart/plugins/debug.lua b/lua/kickstart/plugins/debug.lua index 8e332bf2ff9..1f547fd6933 100644 --- a/lua/kickstart/plugins/debug.lua +++ b/lua/kickstart/plugins/debug.lua @@ -1,17 +1,8 @@ --- debug.lua --- --- Shows how to use the DAP plugin to debug your code. --- --- Primarily focused on configuring the debugger for Go, but can --- be extended to other languages as well. That's why it's called --- kickstart.nvim and not kitchen-sink.nvim ;) - return { - -- NOTE: Yes, you can install new plugins here! + -- Main DAP plugin 'mfussenegger/nvim-dap', - -- NOTE: And you can specify dependencies as well dependencies = { - -- Creates a beautiful debugger UI + -- DAP UI 'rcarriga/nvim-dap-ui', -- Required dependency for nvim-dap-ui @@ -21,89 +12,40 @@ return { 'mason-org/mason.nvim', 'jay-babu/mason-nvim-dap.nvim', - -- Add your own debuggers here - 'leoluz/nvim-dap-go', + -- Python debugging support + 'mfussenegger/nvim-dap-python', }, keys = { - -- Basic debugging keymaps, feel free to change to your liking! - { - '', - function() - require('dap').continue() - end, - desc = 'Debug: Start/Continue', - }, - { - '', - function() - require('dap').step_into() - end, - desc = 'Debug: Step Into', - }, - { - '', - function() - require('dap').step_over() - end, - desc = 'Debug: Step Over', - }, - { - '', - function() - require('dap').step_out() - end, - desc = 'Debug: Step Out', - }, - { - 'b', - function() - require('dap').toggle_breakpoint() - end, - desc = 'Debug: Toggle Breakpoint', - }, - { - 'B', - function() + -- Unified keymaps for debugging (works for both Python & Scala) + { 'dc', function() require('dap').continue() end, desc = 'Debug: Start/Continue' }, + { 'dr', function() require('dap').repl.toggle() end, desc = 'Debug: Toggle REPL' }, + { 'dK', function() require('dap.ui.widgets').hover() end, desc = 'Debug: Hover Widget' }, + { 'dt', function() require('dap').toggle_breakpoint() end, desc = 'Debug: Toggle Breakpoint' }, + { 'dso', function() require('dap').step_over() end, desc = 'Debug: Step Over' }, + { 'dsi', function() require('dap').step_into() end, desc = 'Debug: Step Into' }, + { 'dl', function() require('dap').run_last() end, desc = 'Debug: Run Last' }, + { 'du', function() require('dapui').toggle() end, desc = 'Debug: Toggle DAP UI' }, + { 'dB', function() require('dap').set_breakpoint(vim.fn.input 'Breakpoint condition: ') end, - desc = 'Debug: Set Breakpoint', - }, - -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception. - { - '', - function() - require('dapui').toggle() - end, - desc = 'Debug: See last session result.', + desc = 'Debug: Set Conditional Breakpoint', }, }, config = function() local dap = require 'dap' local dapui = require 'dapui' + -- Mason DAP setup for automatic debugger installation require('mason-nvim-dap').setup { - -- Makes a best effort to setup the various debuggers with - -- reasonable debug configurations automatic_installation = true, - - -- You can provide additional configuration to the handlers, - -- see mason-nvim-dap README for more information handlers = {}, - - -- You'll need to check that you have the required things installed - -- online, please don't ask me how to install them :) ensure_installed = { - -- Update this to ensure that you have the debuggers for the langs you want - 'delve', + 'debugpy', -- Python debugger }, } - -- Dap UI setup - -- For more information, see |:help nvim-dap-ui| + -- DAP UI setup dapui.setup { - -- Set icons to characters that are more likely to work in every terminal. - -- Feel free to remove or use ones that you like more! :) - -- Don't feel like these are good choices. icons = { expanded = '▾', collapsed = '▸', current_frame = '*' }, controls = { icons = { @@ -120,29 +62,87 @@ return { }, } - -- Change breakpoint icons - -- vim.api.nvim_set_hl(0, 'DapBreak', { fg = '#e51400' }) - -- vim.api.nvim_set_hl(0, 'DapStop', { fg = '#ffcc00' }) - -- local breakpoint_icons = vim.g.have_nerd_font - -- and { Breakpoint = '', BreakpointCondition = '', BreakpointRejected = '', LogPoint = '', Stopped = '' } - -- or { Breakpoint = '●', BreakpointCondition = '⊜', BreakpointRejected = '⊘', LogPoint = '◆', Stopped = '⭔' } - -- for type, icon in pairs(breakpoint_icons) do - -- local tp = 'Dap' .. type - -- local hl = (type == 'Stopped') and 'DapStop' or 'DapBreak' - -- vim.fn.sign_define(tp, { text = icon, texthl = hl, numhl = hl }) - -- end - + -- Auto-open/close DAP UI dap.listeners.after.event_initialized['dapui_config'] = dapui.open dap.listeners.before.event_terminated['dapui_config'] = dapui.close dap.listeners.before.event_exited['dapui_config'] = dapui.close - -- Install golang specific config - require('dap-go').setup { - delve = { - -- On Windows delve must be run attached or it crashes. - -- See https://github.com/leoluz/nvim-dap-go/blob/main/README.md#configuring - detached = vim.fn.has 'win32' == 0, + --------------------------------------------------------------------------- + -- PYTHON DEBUGGING SETUP + --------------------------------------------------------------------------- + local function setup_python_debugging() + -- Function to find the best Python executable with debugpy + local function find_python_with_debugpy() + local python_candidates = { + '~/.config/nvim/.venv/bin/python', -- nvim config venv + vim.fn.exepath('python3'), -- system python3 + vim.fn.exepath('python'), -- system python + } + + for _, python_path in ipairs(python_candidates) do + if python_path and python_path ~= '' and vim.fn.executable(python_path) == 1 then + -- Test if this python has debugpy + local handle = io.popen(python_path .. ' -c "import debugpy; print(debugpy.__file__)" 2>/dev/null') + if handle then + local result = handle:read('*a') + handle:close() + if result and result:match('debugpy') then + return python_path + end + end + end + end + + -- Fallback to the nvim config venv + return '~/.config/nvim/.venv/bin/python' + end + + require('dap-python').setup(find_python_with_debugpy()) + + -- Add Python debugging configuration + dap.configurations.python = dap.configurations.python or {} + table.insert(dap.configurations.python, { + type = 'python', + request = 'launch', + name = 'Launch file', + program = '${file}', + pythonPath = function() + local cwd = vim.fn.getcwd() + if vim.fn.executable(cwd .. '/venv/bin/python') == 1 then + return cwd .. '/venv/bin/python' + elseif vim.fn.executable(cwd .. '/.venv/bin/python') == 1 then + return cwd .. '/.venv/bin/python' + else + return '/usr/bin/python' + end + end, + }) + end + + --------------------------------------------------------------------------- + -- SCALA DEBUGGING SETUP (from your Metals config) + --------------------------------------------------------------------------- + dap.configurations.scala = { + { + type = 'scala', + request = 'launch', + name = 'RunOrTest', + metals = { + runType = 'runOrTestFile', + -- args = { "firstArg", "secondArg", "thirdArg" }, -- example + }, + }, + { + type = 'scala', + request = 'launch', + name = 'Test Target', + metals = { + runType = 'testTarget', + }, }, } + + -- Initialize debugging support + setup_python_debugging() end, } diff --git a/lua/kickstart/plugins/iron.lua b/lua/kickstart/plugins/iron.lua new file mode 100644 index 00000000000..24fbd848420 --- /dev/null +++ b/lua/kickstart/plugins/iron.lua @@ -0,0 +1,65 @@ +return { + "Vigemus/iron.nvim", + config = function() + local iron = require("iron.core") + local view = require("iron.view") + local common = require("iron.fts.common") + + iron.setup({ + config = { + scratch_repl = true, + -- How the repl window will be displayed + repl_open_cmd = "botright 12 new | setlocal buftype=nofile", + -- Send selections to the DAP repl if an nvim-dap session is running. + dap_integration = true, + -- Choose your preferred REPL for each language: + repl_definition = { + sh = { + command = {"zsh"} + }, + python = { + command = {"python3"}, + format = common.bracketed_paste_python, + block_dividers = { "# %%", "#%%" }, + env = {PYTHON_BASIC_REPL = "1"} + }, + }, + }, + + keymaps = { + toggle_repl = "rr", -- toggles the repl open and closed. + -- If repl_open_command is a table as above, then the following keymaps are + -- available + -- toggle_repl_with_cmd_1 = "rv", + -- toggle_repl_with_cmd_2 = "rh", + restart_repl = "rR", -- calls `IronRestart` to restart the repl + send_motion = "sc", + visual_send = "sc", + send_file = "sf", + send_line = "sl", + send_paragraph = "sp", + send_until_cursor = "su", + send_mark = "sm", + send_code_block = "sb", + send_code_block_and_move = "sn", + mark_motion = "mc", + mark_visual = "mc", + remove_mark = "md", + cr = "s", + interrupt = "s", + exit = "sq", + clear = "cl", + }, + + highlight = { italic = true }, + ignore_blank_lines = true, + }) + + -- Optional: automatically open the REPL on first send + vim.keymap.set("n", "ro", function() + local ft = vim.bo.filetype + require("iron.core").repl_for(ft) + require("iron.core").focus_on(ft) + end) + end, +}