├── .github ├── ISSUE_TEMPLATE │ └── bug_report.md └── workflows │ └── stylua.yml ├── .gitignore ├── .stylua.toml ├── LICENSE.md ├── README.md ├── doc ├── kickstart.txt └── tags ├── init.lua └── lua ├── custom └── plugins │ └── init.lua └── kickstart └── plugins ├── autoformat.lua └── debug.lua /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | 12 | ## Describe the bug 13 | 14 | 15 | ## To Reproduce 16 | 17 | 1. ... 18 | 19 | ## Desktop 20 | 21 | - OS: 22 | - Terminal: 23 | 24 | ## Neovim Version 25 | 26 | 27 | ``` 28 | ``` 29 | -------------------------------------------------------------------------------- /.github/workflows/stylua.yml: -------------------------------------------------------------------------------- 1 | # Check Lua Formatting 2 | name: Check Lua Formatting 3 | on: pull_request 4 | 5 | jobs: 6 | stylua-check: 7 | name: Stylua Check 8 | runs-on: ubuntu-latest 9 | steps: 10 | - name: Checkout Code 11 | uses: actions/checkout@v2 12 | - name: Stylua Check 13 | uses: JohnnyMorganz/stylua-action@v3 14 | with: 15 | token: ${{ secrets.GITHUB_TOKEN }} 16 | version: latest 17 | args: --check . 18 | 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | tags 2 | test.sh 3 | .luarc.json 4 | nvim 5 | -------------------------------------------------------------------------------- /.stylua.toml: -------------------------------------------------------------------------------- 1 | column_width = 160 2 | line_endings = "Unix" 3 | indent_type = "Spaces" 4 | indent_width = 2 5 | quote_style = "AutoPreferSingle" 6 | call_parentheses = "None" 7 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Neovim for Elixir 3 | 4 | [![Neovim for Elixir YouTube Video](https://img.youtube.com/vi/o7PnaiwPHiY/0.jpg)](https://www.youtube.com/watch?v=o7PnaiwPHiY) 5 | 6 | This is the GitHub repo of my example for kickstart.nvim + just a few plugins I use for Elixir. I think this is a very 7 | workable dev environment, and it's really mainly just kickstart out of the box. 8 | 9 | # kickstart.nvim 10 | 11 | ### Introduction 12 | 13 | A starting point for Neovim that is: 14 | 15 | * Small 16 | * Single-file (with examples of moving to multi-file) 17 | * Documented 18 | * Modular 19 | 20 | This repo is meant to be used by **YOU** to begin your Neovim journey; remove the things you don't use and add what you miss. 21 | 22 | Kickstart.nvim targets *only* the latest ['stable'](https://github.com/neovim/neovim/releases/tag/stable) and latest ['nightly'](https://github.com/neovim/neovim/releases/tag/nightly) of Neovim. If you are experiencing issues, please make sure you have the latest versions. 23 | 24 | Distribution Alternatives: 25 | - [LazyVim](https://www.lazyvim.org/): A delightful distribution maintained by @folke (the author of lazy.nvim, the package manager used here) 26 | 27 | ### Installation 28 | 29 | > **NOTE** 30 | > [Backup](#FAQ) your previous configuration (if any exists) 31 | 32 | Requirements: 33 | * Make sure to review the readmes of the plugins if you are experiencing errors. In particular: 34 | * [ripgrep](https://github.com/BurntSushi/ripgrep#installation) is required for multiple [telescope](https://github.com/nvim-telescope/telescope.nvim#suggested-dependencies) pickers. 35 | * See [Windows Installation](#Windows-Installation) if you have trouble with `telescope-fzf-native` 36 | 37 | Neovim's configurations are located under the following paths, depending on your OS: 38 | 39 | | OS | PATH | 40 | | :- | :--- | 41 | | Linux | `$XDG_CONFIG_HOME/nvim`, `~/.config/nvim` | 42 | | MacOS | `$XDG_CONFIG_HOME/nvim`, `~/.config/nvim` | 43 | | Windows (cmd)| `%userprofile%\AppData\Local\nvim\` | 44 | | Windows (powershell)| `$env:USERPROFILE\AppData\Local\nvim\` | 45 | 46 | Clone kickstart.nvim: 47 | 48 | - on Linux and Mac 49 | ```sh 50 | git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim 51 | ``` 52 | 53 | - on Windows (cmd) 54 | ``` 55 | git clone https://github.com/nvim-lua/kickstart.nvim.git %userprofile%\AppData\Local\nvim\ 56 | ``` 57 | 58 | - on Windows (powershell) 59 | ``` 60 | git clone https://github.com/nvim-lua/kickstart.nvim.git $env:USERPROFILE\AppData\Local\nvim\ 61 | ``` 62 | 63 | 64 | ### Post Installation 65 | 66 | Start Neovim 67 | 68 | ```sh 69 | nvim 70 | ``` 71 | 72 | The `Lazy` plugin manager will start automatically on the first run and install the configured plugins - as can be seen in the introduction video. After the installation is complete you can press `q` to close the `Lazy` UI and **you are ready to go**! Next time you run nvim `Lazy` will no longer show up. 73 | 74 | If you would prefer to hide this step and run the plugin sync from the command line, you can use: 75 | 76 | ```sh 77 | nvim --headless "+Lazy! sync" +qa 78 | ``` 79 | 80 | ### Recommended Steps 81 | 82 | [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) and then installing you can install to your machine using the methods above. 83 | 84 | > **NOTE** 85 | > Your fork's url will be something like this: `https://github.com//kickstart.nvim.git` 86 | 87 | ### Configuration And Extension 88 | 89 | * Inside of your copy, feel free to modify any file you like! It's your copy! 90 | * Feel free to change any of the default options in `init.lua` to better suit your needs. 91 | * For adding plugins, there are 3 primary options: 92 | * Add new configuration in `lua/custom/plugins/*` files, which will be auto sourced using `lazy.nvim` (uncomment the line importing the `custom/plugins` directory in the `init.lua` file to enable this) 93 | * Modify `init.lua` with additional plugins. 94 | * Include the `lua/kickstart/plugins/*` files in your configuration. 95 | 96 | You can also merge updates/changes from the repo back into your fork, to keep up-to-date with any changes for the default configuration. 97 | 98 | #### Example: Adding an autopairs plugin 99 | 100 | In the file: `lua/custom/plugins/autopairs.lua`, add: 101 | 102 | ```lua 103 | -- File: lua/custom/plugins/autopairs.lua 104 | 105 | return { 106 | "windwp/nvim-autopairs", 107 | -- Optional dependency 108 | dependencies = { 'hrsh7th/nvim-cmp' }, 109 | config = function() 110 | require("nvim-autopairs").setup {} 111 | -- If you want to automatically add `(` after selecting a function or method 112 | local cmp_autopairs = require('nvim-autopairs.completion.cmp') 113 | local cmp = require('cmp') 114 | cmp.event:on( 115 | 'confirm_done', 116 | cmp_autopairs.on_confirm_done() 117 | ) 118 | end, 119 | } 120 | ``` 121 | 122 | 123 | This will automatically install [windwp/nvim-autopairs](https://github.com/windwp/nvim-autopairs) and enable it on startup. For more information, see documentation for [lazy.nvim](https://github.com/folke/lazy.nvim). 124 | 125 | #### Example: Adding a file tree plugin 126 | 127 | In the file: `lua/custom/plugins/filetree.lua`, add: 128 | 129 | ```lua 130 | -- Unless you are still migrating, remove the deprecated commands from v1.x 131 | vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]]) 132 | 133 | return { 134 | "nvim-neo-tree/neo-tree.nvim", 135 | version = "*", 136 | dependencies = { 137 | "nvim-lua/plenary.nvim", 138 | "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended 139 | "MunifTanjim/nui.nvim", 140 | }, 141 | config = function () 142 | require('neo-tree').setup {} 143 | end, 144 | } 145 | ``` 146 | 147 | This will install the tree plugin and add the command `:Neotree` for you. You can explore the documentation at [neo-tree.nvim](https://github.com/nvim-neo-tree/neo-tree.nvim) for more information. 148 | 149 | ### Contribution 150 | 151 | Pull-requests are welcome. The goal of this repo is not to create a Neovim configuration framework, but to offer a starting template that shows, by example, available features in Neovim. Some things that will not be included: 152 | 153 | * Custom language server configuration (null-ls templates) 154 | * Theming beyond a default colorscheme necessary for LSP highlight groups 155 | 156 | Each PR, especially those which increase the line count, should have a description as to why the PR is necessary. 157 | 158 | ### FAQ 159 | 160 | * What should I do if I already have a pre-existing neovim configuration? 161 | * You should back it up, then delete all files associated with it. 162 | * This includes your existing init.lua and the neovim files in `~/.local` which can be deleted with `rm -rf ~/.local/share/nvim/` 163 | * You may also want to look at the [migration guide for lazy.nvim](https://github.com/folke/lazy.nvim#-migration-guide) 164 | * Can I keep my existing configuration in parallel to kickstart? 165 | * Yes! You can use [NVIM_APPNAME](https://neovim.io/doc/user/starting.html#%24NVIM_APPNAME)`=nvim-NAME` to maintain multiple configurations. For example you can install the kickstart configuration in `~/.config/nvim-kickstart` and create an alias: 166 | ``` 167 | alias nvim-kickstart='NVIM_APPNAME="nvim-kickstart" nvim' 168 | ``` 169 | When you run Neovim using `nvim-kickstart` alias it will use the alternative config directory and the matching local directory `~/.local/share/nvim-kickstart`. You can apply this approach to any Neovim distribution that you would like to try out. 170 | * What if I want to "uninstall" this configuration: 171 | * See [lazy.nvim uninstall](https://github.com/folke/lazy.nvim#-uninstalling) information 172 | * Are there any cool videos about this plugin? 173 | * Current iteration of kickstart (coming soon) 174 | * Here is one about the previous iteration of kickstart: [video introduction to Kickstart.nvim](https://youtu.be/stqUbv-5u2s). Note the install via init.lua no longer works as specified. Please follow the install instructions in this file instead as they're up to date. 175 | * Why is the kickstart `init.lua` a single file? Wouldn't it make sense to split it into multiple files? 176 | * The main purpose of kickstart is to serve as a teaching tool and a reference 177 | configuration that someone can easily `git clone` as a basis for their own. 178 | As you progress in learning Neovim and Lua, you might consider splitting `init.lua` 179 | into smaller parts. A fork of kickstart that does this while maintaining the exact 180 | same functionality is available here: 181 | * [kickstart-modular.nvim](https://github.com/dam9000/kickstart-modular.nvim) 182 | * Discussions on this topic can be found here: 183 | * [Restructure the configuration](https://github.com/nvim-lua/kickstart.nvim/issues/218) 184 | * [Reorganize init.lua into a multi-file setup](https://github.com/nvim-lua/kickstart.nvim/pull/473) 185 | 186 | ### Windows Installation 187 | 188 | Installation may require installing build tools, and updating the run command for `telescope-fzf-native` 189 | 190 | See `telescope-fzf-native` documentation for [more details](https://github.com/nvim-telescope/telescope-fzf-native.nvim#installation) 191 | 192 | This requires: 193 | 194 | - Install CMake, and the Microsoft C++ Build Tools on Windows 195 | 196 | ```lua 197 | {'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' } 198 | ``` 199 | 200 | -------------------------------------------------------------------------------- /doc/kickstart.txt: -------------------------------------------------------------------------------- 1 | ================================================================================ 2 | INTRODUCTION *kickstart.nvim* 3 | 4 | Kickstart.nvim is a project to help you get started on your neovim journey. 5 | 6 | *kickstart-is-not* 7 | It is not: 8 | - Complete framework for every plugin under the sun 9 | - Place to add every plugin that could ever be useful 10 | 11 | *kickstart-is* 12 | It is: 13 | - Somewhere that has a good start for the most common "IDE" type features: 14 | - autocompletion 15 | - goto-definition 16 | - find references 17 | - fuzzy finding 18 | - and hinting at what more can be done :) 19 | - A place to _kickstart_ your journey. 20 | - You should fork this project and use/modify it so that it matches your 21 | style and preferences. If you don't want to do that, there are probably 22 | other projects that would fit much better for you (and that's great!)! 23 | 24 | vim:tw=78:ts=8:ft=help:norl: 25 | -------------------------------------------------------------------------------- /doc/tags: -------------------------------------------------------------------------------- 1 | kickstart-is kickstart.txt /*kickstart-is* 2 | kickstart-is-not kickstart.txt /*kickstart-is-not* 3 | kickstart.nvim kickstart.txt /*kickstart.nvim* 4 | -------------------------------------------------------------------------------- /init.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | 3 | ===================================================================== 4 | ==================== READ THIS BEFORE CONTINUING ==================== 5 | ===================================================================== 6 | 7 | Kickstart.nvim is *not* a distribution. 8 | 9 | Kickstart.nvim is a template for your own configuration. 10 | The goal is that you can read every line of code, top-to-bottom, understand 11 | what your configuration is doing, and modify it to suit your needs. 12 | 13 | Once you've done that, you should start exploring, configuring and tinkering to 14 | explore Neovim! 15 | 16 | If you don't know anything about Lua, I recommend taking some time to read through 17 | a guide. One possible example: 18 | - https://learnxinyminutes.com/docs/lua/ 19 | 20 | 21 | And then you can explore or search through `:help lua-guide` 22 | - https://neovim.io/doc/user/lua-guide.html 23 | 24 | 25 | Kickstart Guide: 26 | 27 | I have left several `:help X` comments throughout the init.lua 28 | You should run that command and read that help section for more information. 29 | 30 | In addition, I have some `NOTE:` items throughout the file. 31 | These are for you, the reader to help understand what is happening. Feel free to delete 32 | them once you know what you're doing, but they should serve as a guide for when you 33 | are first encountering a few different constructs in your nvim config. 34 | 35 | I hope you enjoy your Neovim journey, 36 | - TJ 37 | 38 | P.S. You can delete this when you're done too. It's your config now :) 39 | --]] 40 | 41 | -- Set as the leader key 42 | -- See `:help mapleader` 43 | -- NOTE: Must happen before plugins are required (otherwise wrong leader will be used) 44 | vim.g.mapleader = ' ' 45 | vim.g.maplocalleader = ' ' 46 | 47 | -- [[ Install `lazy.nvim` plugin manager ]] 48 | -- https://github.com/folke/lazy.nvim 49 | -- `:help lazy.nvim.txt` for more info 50 | local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' 51 | if not vim.loop.fs_stat(lazypath) then 52 | vim.fn.system { 53 | 'git', 54 | 'clone', 55 | '--filter=blob:none', 56 | 'https://github.com/folke/lazy.nvim.git', 57 | '--branch=stable', -- latest stable release 58 | lazypath, 59 | } 60 | end 61 | vim.opt.rtp:prepend(lazypath) 62 | 63 | -- [[ Configure plugins ]] 64 | -- NOTE: Here is where you install your plugins. 65 | -- You can configure plugins using the `config` key. 66 | -- 67 | -- You can also configure plugins after the setup call, 68 | -- as they will be available in your neovim runtime. 69 | require('lazy').setup({ 70 | -- NOTE: First, some plugins that don't require any configuration 71 | 72 | -- Git related plugins 73 | 'tpope/vim-fugitive', 74 | 'tpope/vim-rhubarb', 75 | 76 | -- Detect tabstop and shiftwidth automatically 77 | 'tpope/vim-sleuth', 78 | 79 | -- NOTE: This is where your plugins related to LSP can be installed. 80 | -- The configuration is done below. Search for lspconfig to find it below. 81 | { 82 | -- LSP Configuration & Plugins 83 | 'neovim/nvim-lspconfig', 84 | dependencies = { 85 | -- Automatically install LSPs to stdpath for neovim 86 | { 'williamboman/mason.nvim', config = true }, 87 | 'williamboman/mason-lspconfig.nvim', 88 | 89 | -- Useful status updates for LSP 90 | -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` 91 | { 'j-hui/fidget.nvim', opts = {} }, 92 | 93 | -- Additional lua configuration, makes nvim stuff amazing! 94 | 'folke/neodev.nvim', 95 | }, 96 | }, 97 | 98 | { 99 | -- Autocompletion 100 | 'hrsh7th/nvim-cmp', 101 | dependencies = { 102 | -- Snippet Engine & its associated nvim-cmp source 103 | 'L3MON4D3/LuaSnip', 104 | 'saadparwaiz1/cmp_luasnip', 105 | 106 | -- Adds LSP completion capabilities 107 | 'hrsh7th/cmp-nvim-lsp', 108 | 'hrsh7th/cmp-path', 109 | 110 | -- Adds a number of user-friendly snippets 111 | 'rafamadriz/friendly-snippets', 112 | }, 113 | }, 114 | 115 | -- Useful plugin to show you pending keybinds. 116 | { 'folke/which-key.nvim', opts = {} }, 117 | { 118 | -- Adds git related signs to the gutter, as well as utilities for managing changes 119 | 'lewis6991/gitsigns.nvim', 120 | opts = { 121 | -- See `:help gitsigns.txt` 122 | signs = { 123 | add = { text = '+' }, 124 | change = { text = '~' }, 125 | delete = { text = '_' }, 126 | topdelete = { text = '‾' }, 127 | changedelete = { text = '~' }, 128 | }, 129 | on_attach = function(bufnr) 130 | local gs = package.loaded.gitsigns 131 | 132 | local function map(mode, l, r, opts) 133 | opts = opts or {} 134 | opts.buffer = bufnr 135 | vim.keymap.set(mode, l, r, opts) 136 | end 137 | 138 | -- Navigation 139 | map({ 'n', 'v' }, ']c', function() 140 | if vim.wo.diff then 141 | return ']c' 142 | end 143 | vim.schedule(function() 144 | gs.next_hunk() 145 | end) 146 | return '' 147 | end, { expr = true, desc = 'Jump to next hunk' }) 148 | 149 | map({ 'n', 'v' }, '[c', function() 150 | if vim.wo.diff then 151 | return '[c' 152 | end 153 | vim.schedule(function() 154 | gs.prev_hunk() 155 | end) 156 | return '' 157 | end, { expr = true, desc = 'Jump to previous hunk' }) 158 | 159 | -- Actions 160 | -- visual mode 161 | map('v', 'hs', function() 162 | gs.stage_hunk { vim.fn.line '.', vim.fn.line 'v' } 163 | end, { desc = 'stage git hunk' }) 164 | map('v', 'hr', function() 165 | gs.reset_hunk { vim.fn.line '.', vim.fn.line 'v' } 166 | end, { desc = 'reset git hunk' }) 167 | -- normal mode 168 | map('n', 'hs', gs.stage_hunk, { desc = 'git stage hunk' }) 169 | map('n', 'hr', gs.reset_hunk, { desc = 'git reset hunk' }) 170 | map('n', 'hS', gs.stage_buffer, { desc = 'git Stage buffer' }) 171 | map('n', 'hu', gs.undo_stage_hunk, { desc = 'undo stage hunk' }) 172 | map('n', 'hR', gs.reset_buffer, { desc = 'git Reset buffer' }) 173 | map('n', 'hp', gs.preview_hunk, { desc = 'preview git hunk' }) 174 | map('n', 'hb', function() 175 | gs.blame_line { full = false } 176 | end, { desc = 'git blame line' }) 177 | map('n', 'hd', gs.diffthis, { desc = 'git diff against index' }) 178 | map('n', 'hD', function() 179 | gs.diffthis '~' 180 | end, { desc = 'git diff against last commit' }) 181 | 182 | -- Toggles 183 | map('n', 'tb', gs.toggle_current_line_blame, { desc = 'toggle git blame line' }) 184 | map('n', 'td', gs.toggle_deleted, { desc = 'toggle git show deleted' }) 185 | 186 | -- Text object 187 | map({ 'o', 'x' }, 'ih', ':Gitsigns select_hunk', { desc = 'select git hunk' }) 188 | end, 189 | }, 190 | }, 191 | 192 | { 193 | -- Theme inspired by Atom 194 | 'navarasu/onedark.nvim', 195 | priority = 1000, 196 | config = function() 197 | vim.cmd.colorscheme 'onedark' 198 | end, 199 | }, 200 | 201 | { 202 | -- Set lualine as statusline 203 | 'nvim-lualine/lualine.nvim', 204 | -- See `:help lualine.txt` 205 | opts = { 206 | options = { 207 | icons_enabled = false, 208 | theme = 'onedark', 209 | component_separators = '|', 210 | section_separators = '', 211 | }, 212 | tabline = { 213 | lualine_a = { 'buffers' }, 214 | lualine_z = { 'tabs' } 215 | } 216 | }, 217 | }, 218 | 219 | { 220 | -- Add indentation guides even on blank lines 221 | 'lukas-reineke/indent-blankline.nvim', 222 | -- Enable `lukas-reineke/indent-blankline.nvim` 223 | -- See `:help ibl` 224 | main = 'ibl', 225 | opts = {}, 226 | }, 227 | 228 | -- "gc" to comment visual regions/lines 229 | { 'numToStr/Comment.nvim', opts = {} }, 230 | 231 | -- Fuzzy Finder (files, lsp, etc) 232 | { 233 | 'nvim-telescope/telescope.nvim', 234 | branch = '0.1.x', 235 | dependencies = { 236 | 'nvim-lua/plenary.nvim', 237 | -- Fuzzy Finder Algorithm which requires local dependencies to be built. 238 | -- Only load if `make` is available. Make sure you have the system 239 | -- requirements installed. 240 | { 241 | 'nvim-telescope/telescope-fzf-native.nvim', 242 | -- NOTE: If you are having trouble with this installation, 243 | -- refer to the README for telescope-fzf-native for more instructions. 244 | build = 'make', 245 | cond = function() 246 | return vim.fn.executable 'make' == 1 247 | end, 248 | }, 249 | }, 250 | }, 251 | 252 | { 253 | -- Highlight, edit, and navigate code 254 | 'nvim-treesitter/nvim-treesitter', 255 | dependencies = { 256 | 'nvim-treesitter/nvim-treesitter-textobjects', 257 | }, 258 | build = ':TSUpdate', 259 | }, 260 | 261 | -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart 262 | -- These are some example plugins that I've included in the kickstart repository. 263 | -- Uncomment any of the lines below to enable them. 264 | -- require 'kickstart.plugins.autoformat', 265 | -- require 'kickstart.plugins.debug', 266 | 267 | -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` 268 | -- You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping 269 | -- up-to-date with whatever is in the kickstart repo. 270 | -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. 271 | -- 272 | -- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins 273 | { import = 'custom.plugins' }, 274 | }, {}) 275 | 276 | -- [[ Setting options ]] 277 | -- See `:help vim.o` 278 | -- NOTE: You can change these options as you wish! 279 | 280 | -- Set highlight on search 281 | vim.o.hlsearch = false 282 | 283 | -- Make line numbers default 284 | vim.wo.number = true 285 | 286 | -- Enable mouse mode 287 | vim.o.mouse = 'a' 288 | 289 | -- Sync clipboard between OS and Neovim. 290 | -- Remove this option if you want your OS clipboard to remain independent. 291 | -- See `:help 'clipboard'` 292 | vim.o.clipboard = 'unnamedplus' 293 | 294 | -- Enable break indent 295 | vim.o.breakindent = true 296 | 297 | -- Save undo history 298 | vim.o.undofile = true 299 | 300 | -- Case-insensitive searching UNLESS \C or capital in search 301 | vim.o.ignorecase = true 302 | vim.o.smartcase = true 303 | 304 | -- Keep signcolumn on by default 305 | vim.wo.signcolumn = 'yes' 306 | 307 | -- Decrease update time 308 | vim.o.updatetime = 250 309 | vim.o.timeoutlen = 300 310 | 311 | -- Set completeopt to have a better completion experience 312 | vim.o.completeopt = 'menuone,noselect' 313 | 314 | -- NOTE: You should make sure your terminal supports this 315 | vim.o.termguicolors = true 316 | 317 | -- [[ Basic Keymaps ]] 318 | 319 | -- Keymaps for better default experience 320 | -- See `:help vim.keymap.set()` 321 | vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) 322 | 323 | -- Remap for dealing with word wrap 324 | vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) 325 | vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) 326 | 327 | -- Diagnostic keymaps 328 | vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) 329 | vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) 330 | vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) 331 | vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) 332 | 333 | -- My keymap suggestions 334 | vim.keymap.set('n', '', 'bn', { silent = true, desc = 'Next buffer' }) 335 | vim.keymap.set('n', '', 'bp', { silent = true, desc = 'Previous buffer' }) 336 | 337 | -- gF is a more useful default than gf 338 | vim.keymap.set('n', 'gf', 'gF', { silent = true, desc = 'Go to file' }) 339 | 340 | -- I like to turn search highlight on, and remove highlight whenever I press escape 341 | vim.o.hlsearch = true 342 | vim.keymap.set('n', '', 'noh', { silent = true }) 343 | 344 | -- I use J and K to go up and down quickly, while keeping jump list clean 345 | vim.keymap.set('n', '}', 'execute "keepjumps norm! " . v:count1 . "}"', { silent = true }) 346 | vim.keymap.set('n', '{', 'execute "keepjumps norm! " . v:count1 . "{"', { silent = true }) 347 | vim.keymap.set('n', 'J', '}', { silent = true }) 348 | vim.keymap.set('n', 'K', '{', { silent = true }) 349 | 350 | -- Remap for joining lines, since J is now a motion. But you can also leave this off and do :j as a command 351 | vim.keymap.set('n', 'gJ', 'join', { silent = true }) 352 | 353 | -- I have weird Emacs muscle memory, so you probably should use a different keybind for deleting buffers 354 | vim.keymap.set('n', '', 'bd', { silent = true }) 355 | 356 | -- I prefer cursor in the center 357 | vim.o.scrolloff = 999 358 | 359 | -- [[ Highlight on yank ]] 360 | -- See `:help vim.highlight.on_yank()` 361 | local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) 362 | vim.api.nvim_create_autocmd('TextYankPost', { 363 | callback = function() 364 | vim.highlight.on_yank() 365 | end, 366 | group = highlight_group, 367 | pattern = '*', 368 | }) 369 | 370 | -- [[ Configure Telescope ]] 371 | -- See `:help telescope` and `:help telescope.setup()` 372 | require('telescope').setup { 373 | defaults = { 374 | mappings = { 375 | i = { 376 | [''] = false, 377 | [''] = false, 378 | }, 379 | }, 380 | }, 381 | } 382 | 383 | -- Enable telescope fzf native, if installed 384 | pcall(require('telescope').load_extension, 'fzf') 385 | 386 | -- Telescope live_grep in git root 387 | -- Function to find the git root directory based on the current buffer's path 388 | local function find_git_root() 389 | -- Use the current buffer's path as the starting point for the git search 390 | local current_file = vim.api.nvim_buf_get_name(0) 391 | local current_dir 392 | local cwd = vim.fn.getcwd() 393 | -- If the buffer is not associated with a file, return nil 394 | if current_file == '' then 395 | current_dir = cwd 396 | else 397 | -- Extract the directory from the current file's path 398 | current_dir = vim.fn.fnamemodify(current_file, ':h') 399 | end 400 | 401 | -- Find the Git root directory from the current file's path 402 | local git_root = vim.fn.systemlist('git -C ' .. vim.fn.escape(current_dir, ' ') .. ' rev-parse --show-toplevel')[1] 403 | if vim.v.shell_error ~= 0 then 404 | print 'Not a git repository. Searching on current working directory' 405 | return cwd 406 | end 407 | return git_root 408 | end 409 | 410 | -- Custom live_grep function to search in git root 411 | local function live_grep_git_root() 412 | local git_root = find_git_root() 413 | if git_root then 414 | require('telescope.builtin').live_grep { 415 | search_dirs = { git_root }, 416 | } 417 | end 418 | end 419 | 420 | vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {}) 421 | 422 | -- See `:help telescope.builtin` 423 | vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) 424 | vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) 425 | vim.keymap.set('n', '/', function() 426 | -- You can pass additional configuration to telescope to change theme, layout, etc. 427 | require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { 428 | winblend = 10, 429 | previewer = false, 430 | }) 431 | end, { desc = '[/] Fuzzily search in current buffer' }) 432 | 433 | local function telescope_live_grep_open_files() 434 | require('telescope.builtin').live_grep { 435 | grep_open_files = true, 436 | prompt_title = 'Live Grep in Open Files', 437 | } 438 | end 439 | vim.keymap.set('n', 's/', telescope_live_grep_open_files, { desc = '[S]earch [/] in Open Files' }) 440 | vim.keymap.set('n', 'ss', require('telescope.builtin').builtin, { desc = '[S]earch [S]elect Telescope' }) 441 | vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) 442 | vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) 443 | vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) 444 | vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) 445 | vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) 446 | vim.keymap.set('n', 'sG', ':LiveGrepGitRoot', { desc = '[S]earch by [G]rep on Git Root' }) 447 | vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) 448 | vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' }) 449 | 450 | -- [[ Configure Treesitter ]] 451 | -- See `:help nvim-treesitter` 452 | -- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}' 453 | vim.defer_fn(function() 454 | require('nvim-treesitter.configs').setup { 455 | -- Add languages to be installed here that you want installed for treesitter 456 | ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim', 'bash', 'elixir', 'eex' }, 457 | 458 | -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) 459 | auto_install = true, 460 | 461 | highlight = { enable = true }, 462 | indent = { enable = true }, 463 | incremental_selection = { 464 | enable = true, 465 | keymaps = { 466 | init_selection = '', 467 | node_incremental = '', 468 | scope_incremental = '', 469 | node_decremental = '', 470 | }, 471 | }, 472 | textobjects = { 473 | select = { 474 | enable = true, 475 | lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim 476 | keymaps = { 477 | -- You can use the capture groups defined in textobjects.scm 478 | ['aa'] = '@parameter.outer', 479 | ['ia'] = '@parameter.inner', 480 | ['af'] = '@function.outer', 481 | ['if'] = '@function.inner', 482 | ['ac'] = '@class.outer', 483 | ['ic'] = '@class.inner', 484 | }, 485 | }, 486 | move = { 487 | enable = true, 488 | set_jumps = true, -- whether to set jumps in the jumplist 489 | goto_next_start = { 490 | [']m'] = '@function.outer', 491 | [']]'] = '@class.outer', 492 | }, 493 | goto_next_end = { 494 | [']M'] = '@function.outer', 495 | [']['] = '@class.outer', 496 | }, 497 | goto_previous_start = { 498 | ['[m'] = '@function.outer', 499 | ['[['] = '@class.outer', 500 | }, 501 | goto_previous_end = { 502 | ['[M'] = '@function.outer', 503 | ['[]'] = '@class.outer', 504 | }, 505 | }, 506 | swap = { 507 | enable = true, 508 | swap_next = { 509 | ['a'] = '@parameter.inner', 510 | }, 511 | swap_previous = { 512 | ['A'] = '@parameter.inner', 513 | }, 514 | }, 515 | }, 516 | } 517 | end, 0) 518 | 519 | -- [[ Configure LSP ]] 520 | -- This function gets run when an LSP connects to a particular buffer. 521 | local on_attach = function(_, bufnr) 522 | -- NOTE: Remember that lua is a real programming language, and as such it is possible 523 | -- to define small helper and utility functions so you don't have to repeat yourself 524 | -- many times. 525 | -- 526 | -- In this case, we create a function that lets us more easily define mappings specific 527 | -- for LSP related items. It sets the mode, buffer and description for us each time. 528 | local nmap = function(keys, func, desc) 529 | if desc then 530 | desc = 'LSP: ' .. desc 531 | end 532 | 533 | vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) 534 | end 535 | 536 | nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') 537 | nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') 538 | 539 | nmap('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') 540 | nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') 541 | nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') 542 | nmap('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') 543 | nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') 544 | nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') 545 | 546 | -- See `:help K` for why this keymap 547 | nmap('k', vim.lsp.buf.hover, 'Hover Documentation') 548 | nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') 549 | 550 | -- Lesser used LSP functionality 551 | nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') 552 | nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') 553 | nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') 554 | nmap('wl', function() 555 | print(vim.inspect(vim.lsp.buf.list_workspace_folders())) 556 | end, '[W]orkspace [L]ist Folders') 557 | 558 | -- Create a command `:Format` local to the LSP buffer 559 | vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) 560 | vim.lsp.buf.format() 561 | end, { desc = 'Format current buffer with LSP' }) 562 | end 563 | 564 | -- document existing key chains 565 | require('which-key').register { 566 | ['c'] = { name = '[C]ode', _ = 'which_key_ignore' }, 567 | ['d'] = { name = '[D]ocument', _ = 'which_key_ignore' }, 568 | ['g'] = { name = '[G]it', _ = 'which_key_ignore' }, 569 | ['h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' }, 570 | ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, 571 | ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, 572 | ['t'] = { name = '[T]oggle', _ = 'which_key_ignore' }, 573 | ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, 574 | } 575 | -- register which-key VISUAL mode 576 | -- required for visual hs (hunk stage) to work 577 | require('which-key').register({ 578 | [''] = { name = 'VISUAL ' }, 579 | ['h'] = { 'Git [H]unk' }, 580 | }, { mode = 'v' }) 581 | 582 | -- mason-lspconfig requires that these setup functions are called in this order 583 | -- before setting up the servers. 584 | require('mason').setup() 585 | require('mason-lspconfig').setup() 586 | 587 | -- Enable the following language servers 588 | -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. 589 | -- 590 | -- Add any additional override configuration in the following tables. They will be passed to 591 | -- the `settings` field of the server config. You must look up that documentation yourself. 592 | -- 593 | -- If you want to override the default filetypes that your language server will attach to you can 594 | -- define the property 'filetypes' to the map in question. 595 | local servers = { 596 | -- clangd = {}, 597 | -- gopls = {}, 598 | -- pyright = {}, 599 | -- rust_analyzer = {}, 600 | -- tsserver = {}, 601 | -- html = { filetypes = { 'html', 'twig', 'hbs'} }, 602 | elixirls = {}, 603 | lua_ls = { 604 | Lua = { 605 | workspace = { checkThirdParty = false }, 606 | telemetry = { enable = false }, 607 | -- NOTE: toggle below to ignore Lua_LS's noisy `missing-fields` warnings 608 | -- diagnostics = { disable = { 'missing-fields' } }, 609 | }, 610 | }, 611 | } 612 | 613 | -- Setup neovim lua configuration 614 | require('neodev').setup() 615 | 616 | -- nvim-cmp supports additional completion capabilities, so broadcast that to servers 617 | local capabilities = vim.lsp.protocol.make_client_capabilities() 618 | capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) 619 | 620 | -- Ensure the servers above are installed 621 | local mason_lspconfig = require 'mason-lspconfig' 622 | 623 | mason_lspconfig.setup { 624 | ensure_installed = vim.tbl_keys(servers), 625 | } 626 | 627 | mason_lspconfig.setup_handlers { 628 | function(server_name) 629 | require('lspconfig')[server_name].setup { 630 | capabilities = capabilities, 631 | on_attach = on_attach, 632 | settings = servers[server_name], 633 | filetypes = (servers[server_name] or {}).filetypes, 634 | } 635 | end, 636 | } 637 | 638 | -- [[ Configure nvim-cmp ]] 639 | -- See `:help cmp` 640 | local cmp = require 'cmp' 641 | local luasnip = require 'luasnip' 642 | require('luasnip.loaders.from_vscode').lazy_load() 643 | luasnip.config.setup {} 644 | 645 | cmp.setup { 646 | snippet = { 647 | expand = function(args) 648 | luasnip.lsp_expand(args.body) 649 | end, 650 | }, 651 | completion = { 652 | completeopt = 'menu,menuone,noinsert', 653 | }, 654 | mapping = cmp.mapping.preset.insert { 655 | [''] = cmp.mapping.select_next_item(), 656 | [''] = cmp.mapping.select_prev_item(), 657 | [''] = cmp.mapping.scroll_docs(-4), 658 | [''] = cmp.mapping.scroll_docs(4), 659 | [''] = cmp.mapping.complete {}, 660 | [''] = cmp.mapping.confirm { 661 | behavior = cmp.ConfirmBehavior.Replace, 662 | select = true, 663 | }, 664 | [''] = cmp.mapping(function(fallback) 665 | if cmp.visible() then 666 | cmp.select_next_item() 667 | elseif luasnip.expand_or_locally_jumpable() then 668 | luasnip.expand_or_jump() 669 | else 670 | fallback() 671 | end 672 | end, { 'i', 's' }), 673 | [''] = cmp.mapping(function(fallback) 674 | if cmp.visible() then 675 | cmp.select_prev_item() 676 | elseif luasnip.locally_jumpable(-1) then 677 | luasnip.jump(-1) 678 | else 679 | fallback() 680 | end 681 | end, { 'i', 's' }), 682 | }, 683 | sources = { 684 | { name = 'nvim_lsp' }, 685 | { name = 'luasnip' }, 686 | { name = 'path' }, 687 | }, 688 | } 689 | 690 | -- The line beneath this is called `modeline`. See `:help modeline` 691 | -- vim: ts=2 sts=2 sw=2 et 692 | -------------------------------------------------------------------------------- /lua/custom/plugins/init.lua: -------------------------------------------------------------------------------- 1 | -- You can add your own plugins here or in other files in this directory! 2 | -- I promise not to create any merge conflicts in this directory :) 3 | -- 4 | -- See the kickstart.nvim README for more information 5 | return { 6 | { 7 | "vim-test/vim-test", 8 | config = function() 9 | vim.cmd([[ 10 | function! BufferTermStrategy(cmd) 11 | exec 'te ' . a:cmd 12 | endfunction 13 | 14 | let g:test#custom_strategies = {'bufferterm': function('BufferTermStrategy')} 15 | let g:test#strategy = 'bufferterm' 16 | ]]) 17 | end, 18 | keys = { 19 | { "Tf", "TestFile", silent = true, desc = "Run this file" }, 20 | { "Tn", "TestNearest", silent = true, desc = "Run nearest test" }, 21 | { "Tl", "TestLast", silent = true, desc = "Run last test" }, 22 | }, 23 | }, 24 | { 25 | 'stevearc/oil.nvim', 26 | opts = {}, 27 | dependencies = { "nvim-tree/nvim-web-devicons" }, 28 | keys = { 29 | { "-", "Oil", desc = "Open parent directory" }, 30 | }, 31 | }, 32 | { 33 | "mfussenegger/nvim-lint", 34 | config = function() 35 | local lint = require("lint") 36 | 37 | lint.linters_by_ft = { 38 | elixir = { 'credo' } 39 | } 40 | 41 | local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) 42 | 43 | vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { 44 | group = lint_augroup, 45 | callback = function() 46 | lint.try_lint() 47 | end, 48 | }) 49 | end 50 | }, 51 | { 52 | "stevearc/conform.nvim", 53 | opts = { 54 | formatters_by_ft = { 55 | lua = { "lua_ls" }, 56 | javascript = { { "prettierd", "prettier" }, { "eslint_d", "eslint" } }, 57 | typescript = { { "prettierd", "prettier" }, { "eslint_d", "eslint" } }, 58 | }, 59 | format_on_save = { 60 | -- These options will be passed to conform.format() 61 | timeout_ms = 500, 62 | lsp_fallback = true, 63 | }, 64 | }, 65 | }, 66 | } 67 | -------------------------------------------------------------------------------- /lua/kickstart/plugins/autoformat.lua: -------------------------------------------------------------------------------- 1 | -- autoformat.lua 2 | -- 3 | -- Use your language server to automatically format your code on save. 4 | -- Adds additional commands as well to manage the behavior 5 | 6 | return { 7 | 'neovim/nvim-lspconfig', 8 | config = function() 9 | -- Switch for controlling whether you want autoformatting. 10 | -- Use :KickstartFormatToggle to toggle autoformatting on or off 11 | local format_is_enabled = true 12 | vim.api.nvim_create_user_command('KickstartFormatToggle', function() 13 | format_is_enabled = not format_is_enabled 14 | print('Setting autoformatting to: ' .. tostring(format_is_enabled)) 15 | end, {}) 16 | 17 | -- Create an augroup that is used for managing our formatting autocmds. 18 | -- We need one augroup per client to make sure that multiple clients 19 | -- can attach to the same buffer without interfering with each other. 20 | local _augroups = {} 21 | local get_augroup = function(client) 22 | if not _augroups[client.id] then 23 | local group_name = 'kickstart-lsp-format-' .. client.name 24 | local id = vim.api.nvim_create_augroup(group_name, { clear = true }) 25 | _augroups[client.id] = id 26 | end 27 | 28 | return _augroups[client.id] 29 | end 30 | 31 | -- Whenever an LSP attaches to a buffer, we will run this function. 32 | -- 33 | -- See `:help LspAttach` for more information about this autocmd event. 34 | vim.api.nvim_create_autocmd('LspAttach', { 35 | group = vim.api.nvim_create_augroup('kickstart-lsp-attach-format', { clear = true }), 36 | -- This is where we attach the autoformatting for reasonable clients 37 | callback = function(args) 38 | local client_id = args.data.client_id 39 | local client = vim.lsp.get_client_by_id(client_id) 40 | local bufnr = args.buf 41 | 42 | -- Only attach to clients that support document formatting 43 | if not client.server_capabilities.documentFormattingProvider then 44 | return 45 | end 46 | 47 | -- Tsserver usually works poorly. Sorry you work with bad languages 48 | -- You can remove this line if you know what you're doing :) 49 | if client.name == 'tsserver' then 50 | return 51 | end 52 | 53 | -- Create an autocmd that will run *before* we save the buffer. 54 | -- Run the formatting command for the LSP that has just attached. 55 | vim.api.nvim_create_autocmd('BufWritePre', { 56 | group = get_augroup(client), 57 | buffer = bufnr, 58 | callback = function() 59 | if not format_is_enabled then 60 | return 61 | end 62 | 63 | vim.lsp.buf.format { 64 | async = false, 65 | filter = function(c) 66 | return c.id == client.id 67 | end, 68 | } 69 | end, 70 | }) 71 | end, 72 | }) 73 | end, 74 | } 75 | -------------------------------------------------------------------------------- /lua/kickstart/plugins/debug.lua: -------------------------------------------------------------------------------- 1 | -- debug.lua 2 | -- 3 | -- Shows how to use the DAP plugin to debug your code. 4 | -- 5 | -- Primarily focused on configuring the debugger for Go, but can 6 | -- be extended to other languages as well. That's why it's called 7 | -- kickstart.nvim and not kitchen-sink.nvim ;) 8 | 9 | return { 10 | -- NOTE: Yes, you can install new plugins here! 11 | 'mfussenegger/nvim-dap', 12 | -- NOTE: And you can specify dependencies as well 13 | dependencies = { 14 | -- Creates a beautiful debugger UI 15 | 'rcarriga/nvim-dap-ui', 16 | 17 | -- Installs the debug adapters for you 18 | 'williamboman/mason.nvim', 19 | 'jay-babu/mason-nvim-dap.nvim', 20 | 21 | -- Add your own debuggers here 22 | 'leoluz/nvim-dap-go', 23 | }, 24 | config = function() 25 | local dap = require 'dap' 26 | local dapui = require 'dapui' 27 | 28 | require('mason-nvim-dap').setup { 29 | -- Makes a best effort to setup the various debuggers with 30 | -- reasonable debug configurations 31 | automatic_setup = true, 32 | 33 | -- You can provide additional configuration to the handlers, 34 | -- see mason-nvim-dap README for more information 35 | handlers = {}, 36 | 37 | -- You'll need to check that you have the required things installed 38 | -- online, please don't ask me how to install them :) 39 | ensure_installed = { 40 | -- Update this to ensure that you have the debuggers for the langs you want 41 | 'delve', 42 | }, 43 | } 44 | 45 | -- Basic debugging keymaps, feel free to change to your liking! 46 | vim.keymap.set('n', '', dap.continue, { desc = 'Debug: Start/Continue' }) 47 | vim.keymap.set('n', '', dap.step_into, { desc = 'Debug: Step Into' }) 48 | vim.keymap.set('n', '', dap.step_over, { desc = 'Debug: Step Over' }) 49 | vim.keymap.set('n', '', dap.step_out, { desc = 'Debug: Step Out' }) 50 | vim.keymap.set('n', 'b', dap.toggle_breakpoint, { desc = 'Debug: Toggle Breakpoint' }) 51 | vim.keymap.set('n', 'B', function() 52 | dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ') 53 | end, { desc = 'Debug: Set Breakpoint' }) 54 | 55 | -- Dap UI setup 56 | -- For more information, see |:help nvim-dap-ui| 57 | dapui.setup { 58 | -- Set icons to characters that are more likely to work in every terminal. 59 | -- Feel free to remove or use ones that you like more! :) 60 | -- Don't feel like these are good choices. 61 | icons = { expanded = '▾', collapsed = '▸', current_frame = '*' }, 62 | controls = { 63 | icons = { 64 | pause = '⏸', 65 | play = '▶', 66 | step_into = '⏎', 67 | step_over = '⏭', 68 | step_out = '⏮', 69 | step_back = 'b', 70 | run_last = '▶▶', 71 | terminate = '⏹', 72 | disconnect = '⏏', 73 | }, 74 | }, 75 | } 76 | 77 | -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception. 78 | vim.keymap.set('n', '', dapui.toggle, { desc = 'Debug: See last session result.' }) 79 | 80 | dap.listeners.after.event_initialized['dapui_config'] = dapui.open 81 | dap.listeners.before.event_terminated['dapui_config'] = dapui.close 82 | dap.listeners.before.event_exited['dapui_config'] = dapui.close 83 | 84 | -- Install golang specific config 85 | require('dap-go').setup() 86 | end, 87 | } 88 | --------------------------------------------------------------------------------