Compare commits

..

1 Commits

Author SHA1 Message Date
Chris Patti
4649217f05
Revert "Use cmp-nvim-lua as nvim-cmp source for neovim Lua API (#696)"
This reverts commit d8a1dbc4b40fc018f254be3f060061d90ad35185.
2024-03-12 18:09:05 -04:00
10 changed files with 243 additions and 643 deletions

View File

@ -9,13 +9,6 @@ assignees: ''
<!-- Any bug report not following this template will be immediately closed. Thanks --> <!-- Any bug report not following this template will be immediately closed. Thanks -->
## 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 ## Describe the bug
<!-- A clear and concise description of what the bug is. --> <!-- A clear and concise description of what the bug is. -->
@ -25,8 +18,8 @@ assignees: ''
## Desktop ## Desktop
<!-- please complete the following information. --> <!-- please complete the following information. -->
- OS: - OS:
- Terminal: - Terminal:
## Neovim Version ## Neovim Version
<!-- Output of running `:version` from inside of neovim. --> <!-- Output of running `:version` from inside of neovim. -->

View File

@ -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.
**************************************************************************

205
README.md
View File

@ -21,57 +21,38 @@ If you are experiencing issues, please make sure you have the latest versions.
### Install External Dependencies ### Install External Dependencies
> **NOTE**
> [Backup](#FAQ) your previous configuration (if any exists)
External Requirements: External Requirements:
- Basic utils: `git`, `make`, `unzip`, C Compiler (`gcc`) - Basic utils: `git`, `make`, `unzip`, C Compiler (`gcc`)
- [ripgrep](https://github.com/BurntSushi/ripgrep#installation) - [ripgrep](https://github.com/BurntSushi/ripgrep#installation)
- Clipboard tool (xclip/xsel/win32yank or other depending on the platform)
- A [Nerd Font](https://www.nerdfonts.com/): optional, provides various icons - A [Nerd Font](https://www.nerdfonts.com/): optional, provides various icons
- if you have it set `vim.g.have_nerd_font` in `init.lua` to true - if you have it set `vim.g.have_nerd_font` in `init.lua` to true
- Language Setup: - Language Setup:
- If you want to write Typescript, you need `npm` - If want to write Typescript, you need `npm`
- If you want to write Golang, you will need `go` - If want to write Golang, you will need `go`
- etc. - etc.
> **NOTE** > **NOTE**
> See [Install Recipes](#Install-Recipes) for additional Windows and Linux specific notes > See [Windows Installation](#Windows-Installation) to double check any additional Windows notes
> and quick install snippets
### Install Kickstart
> **NOTE**
> [Backup](#FAQ) your previous configuration (if any exists)
Neovim's configurations are located under the following paths, depending on your OS: Neovim's configurations are located under the following paths, depending on your OS:
| OS | PATH | | OS | PATH |
| :- | :--- | | :- | :--- |
| Linux, MacOS | `$XDG_CONFIG_HOME/nvim`, `~/.config/nvim` | | Linux, MacOS | `$XDG_CONFIG_HOME/nvim`, `~/.config/nvim` |
| Windows (cmd)| `%localappdata%\nvim\` | | Windows (cmd)| `%userprofile%\AppData\Local\nvim\` |
| Windows (powershell)| `$env:LOCALAPPDATA\nvim\` | | Windows (powershell)| `$env:USERPROFILE\AppData\Local\nvim\` |
#### Recommended Step ### Install Kickstart
[Fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) this repo Clone kickstart.nvim:
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/<your_github_username>/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 `<your_github_username>` in the commands below
<details><summary> Linux and Mac </summary> <details><summary> Linux and Mac </summary>
```sh ```sh
git clone git@code.draft13.com:robert/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim
``` ```
</details> </details>
@ -81,13 +62,13 @@ git clone git@code.draft13.com:robert/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HO
If you're using `cmd.exe`: If you're using `cmd.exe`:
``` ```
git clone https://github.com/nvim-lua/kickstart.nvim.git "%localappdata%\nvim" git clone https://github.com/nvim-lua/kickstart.nvim.git %userprofile%\AppData\Local\nvim\
``` ```
If you're using `powershell.exe` If you're using `powershell.exe`
``` ```
git clone https://github.com/nvim-lua/kickstart.nvim.git "${env:LOCALAPPDATA}\nvim" git clone https://github.com/nvim-lua/kickstart.nvim.git $env:USERPROFILE\AppData\Local\nvim\
``` ```
</details> </details>
@ -101,61 +82,106 @@ nvim
``` ```
That's it! Lazy will install all the plugins you have. Use `:Lazy` to view 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. current plugin status.
#### Read The Friendly Documentation
Read through the `init.lua` file in your configuration folder for more Read through the `init.lua` file in your configuration folder for more
information about extending and exploring Neovim. That also includes information about extending and exploring Neovim.
examples of adding popularly requested plugins.
> [!NOTE]
> For more information about a particular plugin check its repository's documentation.
### Getting Started ### Getting Started
[The Only Video You Need to Get Started with Neovim](https://youtu.be/m8C0Cq9Uv9o) [The Only Video You Need to Get Started with Neovim](https://youtu.be/m8C0Cq9Uv9o)
### Recommended Steps
[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 install. You
can install it on your machine using the methods above.
> **NOTE**
> Your fork's url will be something like this: `https://github.com/<your_github_username>/kickstart.nvim.git`
#### Examples of adding popularly requested plugins
NOTE: You'll need to uncomment the line in the init.lua that turns on loading custom plugins.
<details>
<summary>Adding autopairs</summary>
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).
In the file: `lua/custom/plugins/autopairs.lua`, add:
```lua
-- File: lua/custom/plugins/autopairs.lua
return {
"windwp/nvim-autopairs",
-- Optional dependency
dependencies = { 'hrsh7th/nvim-cmp' },
config = function()
require("nvim-autopairs").setup {}
-- If you want to automatically add `(` after selecting a function or method
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
local cmp = require('cmp')
cmp.event:on(
'confirm_done',
cmp_autopairs.on_confirm_done()
)
end,
}
```
</details>
<details>
<summary>Adding a file tree plugin</summary>
This will install the tree plugin and add the command `:Neotree` for you. For more information, see the documentation at [neo-tree.nvim](https://github.com/nvim-neo-tree/neo-tree.nvim).
In the file: `lua/custom/plugins/filetree.lua`, add:
```lua
return {
"nvim-neo-tree/neo-tree.nvim",
version = "*",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
"MunifTanjim/nui.nvim",
},
config = function ()
require('neo-tree').setup {}
end,
}
```
</details>
### FAQ ### FAQ
* What should I do if I already have a pre-existing Neovim configuration? * What should I do if I already have a pre-existing neovim configuration?
* You should back it up and then delete all associated files. * You should back it up and then delete all associated files.
* This includes your existing init.lua and the Neovim files in `~/.local` * This includes your existing init.lua and the neovim files in `~/.local` which can be deleted with `rm -rf ~/.local/share/nvim/`
which can be deleted with `rm -rf ~/.local/share/nvim/`
* Can I keep my existing configuration in parallel to kickstart? * Can I keep my existing configuration in parallel to kickstart?
* Yes! You can use [NVIM_APPNAME](https://neovim.io/doc/user/starting.html#%24NVIM_APPNAME)`=nvim-NAME` * 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:
to maintain multiple configurations. For example, you can install the kickstart
configuration in `~/.config/nvim-kickstart` and create an alias:
``` ```
alias nvim-kickstart='NVIM_APPNAME="nvim-kickstart" nvim' alias nvim-kickstart='NVIM_APPNAME="nvim-kickstart" nvim'
``` ```
When you run Neovim using `nvim-kickstart` alias it will use the alternative 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.
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.
* What if I want to "uninstall" this configuration: * What if I want to "uninstall" this configuration:
* See [lazy.nvim uninstall](https://lazy.folke.io/usage#-uninstalling) information * See [lazy.nvim uninstall](https://github.com/folke/lazy.nvim#-uninstalling) information
* Why is the kickstart `init.lua` a single file? Wouldn't it make sense to split it into multiple files? * Why is the kickstart `init.lua` a single file? Wouldn't it make sense to split it into multiple files?
* The main purpose of kickstart is to serve as a teaching tool and a reference * The main purpose of kickstart is to serve as a teaching tool and a reference
configuration that someone can easily use to `git clone` as a basis for their own. configuration that someone can easily use to `git clone` as a basis for their own.
As you progress in learning Neovim and Lua, you might consider splitting `init.lua` As you progress in learning Neovim and Lua, you might consider splitting `init.lua`
into smaller parts. A fork of kickstart that does this while maintaining the into smaller parts. A fork of kickstart that does this while maintaining the
same functionality is available here: same functionality is available here:
* [kickstart-modular.nvim](https://github.com/dam9000/kickstart-modular.nvim) * [kickstart-modular.nvim](https://github.com/dam9000/kickstart-modular.nvim)
* Discussions on this topic can be found here: * Discussions on this topic can be found here:
* [Restructure the configuration](https://github.com/nvim-lua/kickstart.nvim/issues/218) * [Restructure the configuration](https://github.com/nvim-lua/kickstart.nvim/issues/218)
* [Reorganize init.lua into a multi-file setup](https://github.com/nvim-lua/kickstart.nvim/pull/473) * [Reorganize init.lua into a multi-file setup](https://github.com/nvim-lua/kickstart.nvim/pull/473)
### Install Recipes ### Windows Installation
Below you can find OS specific install instructions for Neovim and dependencies.
After installing all the dependencies continue with the [Install Kickstart](#Install-Kickstart) step.
#### Windows Installation
<details><summary>Windows with Microsoft C++ Build Tools and CMake</summary>
Installation may require installing build tools and updating the run command for `telescope-fzf-native` Installation may require installing build tools and updating the run command for `telescope-fzf-native`
See `telescope-fzf-native` documentation for [more details](https://github.com/nvim-telescope/telescope-fzf-native.nvim#installation) See `telescope-fzf-native` documentation for [more details](https://github.com/nvim-telescope/telescope-fzf-native.nvim#installation)
@ -167,8 +193,7 @@ This requires:
```lua ```lua
{'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' } {'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' }
``` ```
</details>
<details><summary>Windows with gcc/make using chocolatey</summary>
Alternatively, one can install gcc and make which don't require changing the config, Alternatively, one can install gcc and make which don't require changing the config,
the easiest way is to use choco: the easiest way is to use choco:
@ -179,60 +204,10 @@ run in cmd as **admin**:
winget install --accept-source-agreements chocolatey.chocolatey winget install --accept-source-agreements chocolatey.chocolatey
``` ```
2. install all requirements using choco, exit the previous cmd and 2. install all requirements using choco, exit previous cmd and
open a new one so that choco path is set, and run in cmd as **admin**: open a new one so that choco path is set, and run in cmd as **admin**:
``` ```
choco install -y neovim git ripgrep wget fd unzip gzip mingw make choco install -y neovim git ripgrep wget fd unzip gzip mingw make
``` ```
</details>
<details><summary>WSL (Windows Subsystem for Linux)</summary>
```
wsl --install
wsl
sudo add-apt-repository ppa:neovim-ppa/unstable -y
sudo apt update
sudo apt install make gcc ripgrep unzip git xclip neovim
```
</details>
#### Linux Install
<details><summary>Ubuntu Install Steps</summary>
```
sudo add-apt-repository ppa:neovim-ppa/unstable -y
sudo apt update
sudo apt install make gcc ripgrep unzip git xclip neovim
```
</details>
<details><summary>Debian Install Steps</summary>
```
sudo apt update
sudo apt install make gcc ripgrep unzip git xclip curl
# Now we install nvim
curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz
sudo rm -rf /opt/nvim-linux64
sudo mkdir -p /opt/nvim-linux64
sudo chmod a+rX /opt/nvim-linux64
sudo tar -C /opt -xzf nvim-linux64.tar.gz
# make it available in /usr/local/bin, distro installs to /usr/bin
sudo ln -sf /opt/nvim-linux64/bin/nvim /usr/local/bin/
```
</details>
<details><summary>Fedora Install Steps</summary>
```
sudo dnf install -y gcc make git ripgrep fd-find unzip neovim
```
</details>
<details><summary>Arch Install Steps</summary>
```
sudo pacman -S --noconfirm --needed gcc make git ripgrep fd unzip neovim
```
</details>
Then, continue with the [Install Kickstart](#Install-Kickstart) step.

405
init.lua
View File

@ -29,7 +29,7 @@ What is Kickstart?
what your configuration is doing, and modify it to suit your needs. what your configuration is doing, and modify it to suit your needs.
Once you've done that, you can start exploring, configuring and tinkering to Once you've done that, you can start exploring, configuring and tinkering to
make Neovim your own! That might mean leaving Kickstart just the way it is for a while make Neovim your own! That might mean leaving kickstart just the way it is for a while
or immediately breaking it into modular pieces. It's up to you! or immediately breaking it into modular pieces. It's up to you!
If you don't know anything about Lua, I recommend taking some time to read through If you don't know anything about Lua, I recommend taking some time to read through
@ -51,32 +51,32 @@ Kickstart Guide:
- Tutor - Tutor
- <enter key> - <enter key>
(If you already know the Neovim basics, you can skip this step.) (If you already know how the Neovim basics, you can skip this step)
Once you've completed that, you can continue working through **AND READING** the rest Once you've completed that, you can continue working through **AND READING** the rest
of the kickstart init.lua. of the kickstart init.lua
Next, run AND READ `:help`. Next, run AND READ `:help`.
This will open up a help window with some basic information This will open up a help window with some basic information
about reading, navigating and searching the builtin help documentation. about reading, navigating and searching the builtin help documentation.
This should be the first place you go to look when you're stuck or confused This should be the first place you go to look when you're stuck or confused
with something. It's one of my favorite Neovim features. with something. It's one of my favorite neovim features.
MOST IMPORTANTLY, we provide a keymap "<space>sh" to [s]earch the [h]elp documentation, MOST IMPORTANTLY, we provide a keymap "<space>sh" to [s]earch the [h]elp documentation,
which is very useful when you're not exactly sure of what you're looking for. which is very useful when you're not sure exactly what you're looking for.
I have left several `:help X` comments throughout the init.lua I have left several `:help X` comments throughout the init.lua
These are hints about where to find more information about the relevant settings, These are hints about where to find more information about the relevant settings,
plugins or Neovim features used in Kickstart. plugins or neovim features used in kickstart.
NOTE: Look for lines like this NOTE: Look for lines like this
Throughout the file. These are for you, the reader, to help you understand what is happening. Throughout the file. These are for you, the reader, to help understand what is happening.
Feel free to delete them once you know what you're doing, but they should serve as a guide Feel free to delete them once you know what you're doing, but they should serve as a guide
for when you are first encountering a few different constructs in your Neovim config. for when you are first encountering a few different constructs in your nvim config.
If you experience any errors while trying to install kickstart, run `:checkhealth` for more info. If you experience any errors while trying to install kickstart, run `:checkhealth` for more info
I hope you enjoy your Neovim journey, I hope you enjoy your Neovim journey,
- TJ - TJ
@ -90,7 +90,7 @@ P.S. You can delete this when you're done too. It's your config now! :)
vim.g.mapleader = ' ' vim.g.mapleader = ' '
vim.g.maplocalleader = ' ' vim.g.maplocalleader = ' '
-- Set to true if you have a Nerd Font installed and selected in the terminal -- Set to true if you have a Nerd Font installed
vim.g.have_nerd_font = false vim.g.have_nerd_font = false
-- [[ Setting options ]] -- [[ Setting options ]]
@ -100,23 +100,20 @@ vim.g.have_nerd_font = false
-- Make line numbers default -- Make line numbers default
vim.opt.number = true vim.opt.number = true
-- You can also add relative line numbers, to help with jumping. -- You can also add relative line numbers, for help with jumping.
-- Experiment for yourself to see if you like it! -- Experiment for yourself to see if you like it!
-- vim.opt.relativenumber = true -- vim.opt.relativenumber = true
-- Enable mouse mode, can be useful for resizing splits for example! -- Enable mouse mode, can be useful for resizing splits for example!
vim.opt.mouse = 'a' vim.opt.mouse = 'a'
-- Don't show the mode, since it's already in the status line -- Don't show the mode, since it's already in status line
vim.opt.showmode = false vim.opt.showmode = false
-- Sync clipboard between OS and Neovim. -- Sync clipboard between OS and Neovim.
-- Schedule the setting after `UiEnter` because it can increase startup-time.
-- Remove this option if you want your OS clipboard to remain independent. -- Remove this option if you want your OS clipboard to remain independent.
-- See `:help 'clipboard'` -- See `:help 'clipboard'`
vim.schedule(function() vim.opt.clipboard = 'unnamedplus'
vim.opt.clipboard = 'unnamedplus'
end)
-- Enable break indent -- Enable break indent
vim.opt.breakindent = true vim.opt.breakindent = true
@ -124,7 +121,7 @@ vim.opt.breakindent = true
-- Save undo history -- Save undo history
vim.opt.undofile = true vim.opt.undofile = true
-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term -- Case-insensitive searching UNLESS \C or capital in search
vim.opt.ignorecase = true vim.opt.ignorecase = true
vim.opt.smartcase = true vim.opt.smartcase = true
@ -133,15 +130,13 @@ vim.opt.signcolumn = 'yes'
-- Decrease update time -- Decrease update time
vim.opt.updatetime = 250 vim.opt.updatetime = 250
-- Decrease mapped sequence wait time
vim.opt.timeoutlen = 300 vim.opt.timeoutlen = 300
-- Configure how new splits should be opened -- Configure how new splits should be opened
vim.opt.splitright = true vim.opt.splitright = true
vim.opt.splitbelow = true vim.opt.splitbelow = true
-- Sets how neovim will display certain whitespace characters in the editor. -- Sets how neovim will display certain whitespace in the editor.
-- See `:help 'list'` -- See `:help 'list'`
-- and `:help 'listchars'` -- and `:help 'listchars'`
vim.opt.list = true vim.opt.list = true
@ -159,11 +154,14 @@ vim.opt.scrolloff = 10
-- [[ Basic Keymaps ]] -- [[ Basic Keymaps ]]
-- See `:help vim.keymap.set()` -- See `:help vim.keymap.set()`
-- Clear highlights on search when pressing <Esc> in normal mode -- Set highlight on search, but clear on pressing <Esc> in normal mode
-- See `:help hlsearch` vim.opt.hlsearch = true
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>') vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
-- Diagnostic keymaps -- Diagnostic keymaps
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' })
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' })
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' })
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier -- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
@ -206,12 +204,9 @@ vim.api.nvim_create_autocmd('TextYankPost', {
-- [[ Install `lazy.nvim` plugin manager ]] -- [[ Install `lazy.nvim` plugin manager ]]
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info -- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
if not (vim.uv or vim.loop).fs_stat(lazypath) then if not vim.loop.fs_stat(lazypath) then
local lazyrepo = 'https://github.com/folke/lazy.nvim.git' local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
if vim.v.shell_error ~= 0 then
error('Error cloning lazy.nvim:\n' .. out)
end
end ---@diagnostic disable-next-line: undefined-field end ---@diagnostic disable-next-line: undefined-field
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
@ -222,7 +217,7 @@ vim.opt.rtp:prepend(lazypath)
-- --
-- You can press `?` in this menu for help. Use `:q` to close the window -- You can press `?` in this menu for help. Use `:q` to close the window
-- --
-- To update plugins you can run -- To update plugins, you can run
-- :Lazy update -- :Lazy update
-- --
-- NOTE: Here is where you install your plugins. -- NOTE: Here is where you install your plugins.
@ -236,9 +231,14 @@ require('lazy').setup({
-- --
-- Use `opts = {}` to force a plugin to be loaded. -- Use `opts = {}` to force a plugin to be loaded.
-- --
-- This is equivalent to:
-- require('Comment').setup({})
-- "gc" to comment visual regions/lines
{ 'numToStr/Comment.nvim', opts = {} },
-- Here is a more advanced example where we pass configuration -- Here is a more advanced example where we pass configuration
-- options to `gitsigns.nvim`. This is equivalent to the following Lua: -- options to `gitsigns.nvim`. This is equivalent to the following lua:
-- require('gitsigns').setup({ ... }) -- require('gitsigns').setup({ ... })
-- --
-- See `:help gitsigns` to understand what the configuration keys do -- See `:help gitsigns` to understand what the configuration keys do
@ -255,7 +255,7 @@ require('lazy').setup({
}, },
}, },
-- NOTE: Plugins can also be configured to run Lua code when they are loaded. -- NOTE: Plugins can also be configured to run lua code when they are loaded.
-- --
-- This is often very useful to both group configuration, as well as handle -- This is often very useful to both group configuration, as well as handle
-- lazy loading plugins that don't need to be loaded immediately at startup. -- lazy loading plugins that don't need to be loaded immediately at startup.
@ -266,64 +266,25 @@ require('lazy').setup({
-- which loads which-key before all the UI elements are loaded. Events can be -- which loads which-key before all the UI elements are loaded. Events can be
-- normal autocommands events (`:help autocmd-events`). -- normal autocommands events (`:help autocmd-events`).
-- --
-- Then, because we use the `opts` key (recommended), the configuration runs -- Then, because we use the `config` key, the configuration only runs
-- after the plugin has been loaded as `require(MODULE).setup(opts)`. -- after the plugin has been loaded:
-- config = function() ... end
{ -- Useful plugin to show you pending keybinds. { -- Useful plugin to show you pending keybinds.
'folke/which-key.nvim', 'folke/which-key.nvim',
event = 'VimEnter', -- Sets the loading event to 'VimEnter' event = 'VimEnter', -- Sets the loading event to 'VimEnter'
opts = { config = function() -- This is the function that runs, AFTER loading
-- delay between pressing a key and opening which-key (milliseconds) require('which-key').setup()
-- this setting is independent of vim.opt.timeoutlen
delay = 0,
icons = {
-- set icon mappings to true if you have a Nerd Font
mappings = vim.g.have_nerd_font,
-- If you are using a Nerd Font: set icons.keys to an empty table which will use the
-- default which-key.nvim defined Nerd Font icons, otherwise define a string table
keys = vim.g.have_nerd_font and {} or {
Up = '<Up> ',
Down = '<Down> ',
Left = '<Left> ',
Right = '<Right> ',
C = '<C-…> ',
M = '<M-…> ',
D = '<D-…> ',
S = '<S-…> ',
CR = '<CR> ',
Esc = '<Esc> ',
ScrollWheelDown = '<ScrollWheelDown> ',
ScrollWheelUp = '<ScrollWheelUp> ',
NL = '<NL> ',
BS = '<BS> ',
Space = '<Space> ',
Tab = '<Tab> ',
F1 = '<F1>',
F2 = '<F2>',
F3 = '<F3>',
F4 = '<F4>',
F5 = '<F5>',
F6 = '<F6>',
F7 = '<F7>',
F8 = '<F8>',
F9 = '<F9>',
F10 = '<F10>',
F11 = '<F11>',
F12 = '<F12>',
},
},
-- Document existing key chains -- Document existing key chains
spec = { require('which-key').register {
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } }, ['<leader>c'] = { name = '[C]ode', _ = 'which_key_ignore' },
{ '<leader>d', group = '[D]ocument' }, ['<leader>d'] = { name = '[D]ocument', _ = 'which_key_ignore' },
{ '<leader>r', group = '[R]ename' }, ['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' },
{ '<leader>s', group = '[S]earch' }, ['<leader>s'] = { name = '[S]earch', _ = 'which_key_ignore' },
{ '<leader>w', group = '[W]orkspace' }, ['<leader>w'] = { name = '[W]orkspace', _ = 'which_key_ignore' },
{ '<leader>t', group = '[T]oggle' }, }
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } }, end,
},
},
}, },
-- NOTE: Plugins can specify dependencies. -- NOTE: Plugins can specify dependencies.
@ -339,7 +300,7 @@ require('lazy').setup({
branch = '0.1.x', branch = '0.1.x',
dependencies = { dependencies = {
'nvim-lua/plenary.nvim', 'nvim-lua/plenary.nvim',
{ -- If encountering errors, see telescope-fzf-native README for installation instructions { -- If encountering errors, see telescope-fzf-native README for install instructions
'nvim-telescope/telescope-fzf-native.nvim', 'nvim-telescope/telescope-fzf-native.nvim',
-- `build` is used to run some command when the plugin is installed/updated. -- `build` is used to run some command when the plugin is installed/updated.
@ -362,19 +323,19 @@ require('lazy').setup({
-- it can fuzzy find! It's more than just a "file finder", it can search -- it can fuzzy find! It's more than just a "file finder", it can search
-- many different aspects of Neovim, your workspace, LSP, and more! -- many different aspects of Neovim, your workspace, LSP, and more!
-- --
-- The easiest way to use Telescope, is to start by doing something like: -- The easiest way to use telescope, is to start by doing something like:
-- :Telescope help_tags -- :Telescope help_tags
-- --
-- After running this command, a window will open up and you're able to -- After running this command, a window will open up and you're able to
-- type in the prompt window. You'll see a list of `help_tags` options and -- type in the prompt window. You'll see a list of help_tags options and
-- a corresponding preview of the help. -- a corresponding preview of the help.
-- --
-- Two important keymaps to use while in Telescope are: -- Two important keymaps to use while in telescope are:
-- - Insert mode: <c-/> -- - Insert mode: <c-/>
-- - Normal mode: ? -- - Normal mode: ?
-- --
-- This opens a window that shows you all of the keymaps for the current -- This opens a window that shows you all of the keymaps for the current
-- Telescope picker. This is really useful to discover what Telescope can -- telescope picker. This is really useful to discover what Telescope can
-- do as well as how to actually do it! -- do as well as how to actually do it!
-- [[ Configure Telescope ]] -- [[ Configure Telescope ]]
@ -396,7 +357,7 @@ require('lazy').setup({
}, },
} }
-- Enable Telescope extensions if they are installed -- Enable telescope extensions, if they are installed
pcall(require('telescope').load_extension, 'fzf') pcall(require('telescope').load_extension, 'fzf')
pcall(require('telescope').load_extension, 'ui-select') pcall(require('telescope').load_extension, 'ui-select')
@ -415,14 +376,14 @@ require('lazy').setup({
-- Slightly advanced example of overriding default behavior and theme -- Slightly advanced example of overriding default behavior and theme
vim.keymap.set('n', '<leader>/', function() vim.keymap.set('n', '<leader>/', function()
-- You can pass additional configuration to Telescope to change the theme, layout, etc. -- You can pass additional configuration to telescope to change theme, layout, etc.
builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
winblend = 10, winblend = 10,
previewer = false, previewer = false,
}) })
end, { desc = '[/] Fuzzily search in current buffer' }) end, { desc = '[/] Fuzzily search in current buffer' })
-- It's also possible to pass additional configuration options. -- Also possible to pass additional configuration options.
-- See `:help telescope.builtin.live_grep()` for information about particular keys -- See `:help telescope.builtin.live_grep()` for information about particular keys
vim.keymap.set('n', '<leader>s/', function() vim.keymap.set('n', '<leader>s/', function()
builtin.live_grep { builtin.live_grep {
@ -431,53 +392,39 @@ require('lazy').setup({
} }
end, { desc = '[S]earch [/] in Open Files' }) end, { desc = '[S]earch [/] in Open Files' })
-- Shortcut for searching your Neovim configuration files -- Shortcut for searching your neovim configuration files
vim.keymap.set('n', '<leader>sn', function() vim.keymap.set('n', '<leader>sn', function()
builtin.find_files { cwd = vim.fn.stdpath 'config' } builtin.find_files { cwd = vim.fn.stdpath 'config' }
end, { desc = '[S]earch [N]eovim files' }) end, { desc = '[S]earch [N]eovim files' })
end, end,
}, },
-- LSP Plugins { -- LSP Configuration & Plugins
{
-- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins
-- used for completion, annotations and signatures of Neovim apis
'folke/lazydev.nvim',
ft = 'lua',
opts = {
library = {
-- Load luvit types when the `vim.uv` word is found
{ path = '${3rd}/luv/library', words = { 'vim%.uv' } },
},
},
},
{
-- Main LSP Configuration
'neovim/nvim-lspconfig', 'neovim/nvim-lspconfig',
dependencies = { dependencies = {
-- Automatically install LSPs and related tools to stdpath for Neovim -- Automatically install LSPs and related tools to stdpath for neovim
-- Mason must be loaded before its dependents so we need to set it up here. 'williamboman/mason.nvim',
-- NOTE: `opts = {}` is the same as calling `require('mason').setup({})`
{ 'williamboman/mason.nvim', opts = {} },
'williamboman/mason-lspconfig.nvim', 'williamboman/mason-lspconfig.nvim',
'WhoIsSethDaniel/mason-tool-installer.nvim', 'WhoIsSethDaniel/mason-tool-installer.nvim',
-- Useful status updates for LSP. -- Useful status updates for LSP.
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
{ 'j-hui/fidget.nvim', opts = {} }, { 'j-hui/fidget.nvim', opts = {} },
-- Allows extra capabilities provided by nvim-cmp -- `neodev` configures Lua LSP for your Neovim config, runtime and plugins
'hrsh7th/cmp-nvim-lsp', -- used for completion, annotations and signatures of Neovim apis
{ 'folke/neodev.nvim', opts = {} },
}, },
config = function() config = function()
-- Brief aside: **What is LSP?** -- Brief Aside: **What is LSP?**
-- --
-- LSP is an initialism you've probably heard, but might not understand what it is. -- LSP is an acronym you've probably heard, but might not understand what it is.
-- --
-- LSP stands for Language Server Protocol. It's a protocol that helps editors -- LSP stands for Language Server Protocol. It's a protocol that helps editors
-- and language tooling communicate in a standardized fashion. -- and language tooling communicate in a standardized fashion.
-- --
-- In general, you have a "server" which is some tool built to understand a particular -- In general, you have a "server" which is some tool built to understand a particular
-- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers -- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc). These Language Servers
-- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone -- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone
-- processes that communicate with some "client" - in this case, Neovim! -- processes that communicate with some "client" - in this case, Neovim!
-- --
@ -501,14 +448,14 @@ require('lazy').setup({
vim.api.nvim_create_autocmd('LspAttach', { vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }),
callback = function(event) callback = function(event)
-- NOTE: Remember that Lua is a real programming language, and as such it is possible -- NOTE: Remember that lua is a real programming language, and as such it is possible
-- to define small helper and utility functions so you don't have to repeat yourself. -- to define small helper and utility functions so you don't have to repeat yourself
-- many times.
-- --
-- In this case, we create a function that lets us more easily define mappings specific -- In this case, we create a function that lets us more easily define mappings specific
-- for LSP related items. It sets the mode, buffer and description for us each time. -- for LSP related items. It sets the mode, buffer and description for us each time.
local map = function(keys, func, desc, mode) local map = function(keys, func, desc)
mode = mode or 'n' vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
end end
-- Jump to the definition of the word under your cursor. -- Jump to the definition of the word under your cursor.
@ -532,20 +479,24 @@ require('lazy').setup({
-- Symbols are things like variables, functions, types, etc. -- Symbols are things like variables, functions, types, etc.
map('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') map('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
-- Fuzzy find all the symbols in your current workspace. -- Fuzzy find all the symbols in your current workspace
-- Similar to document symbols, except searches over your entire project. -- Similar to document symbols, except searches over your whole project.
map('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') map('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
-- Rename the variable under your cursor. -- Rename the variable under your cursor
-- Most Language Servers support renaming across files, etc. -- Most Language Servers support renaming across files, etc.
map('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame') map('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
-- Execute a code action, usually your cursor needs to be on top of an error -- Execute a code action, usually your cursor needs to be on top of an error
-- or a suggestion from your LSP for this to activate. -- or a suggestion from your LSP for this to activate.
map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' }) map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
-- Opens a popup that displays documentation about the word under your cursor
-- See `:help K` for why this keymap
map('K', vim.lsp.buf.hover, 'Hover Documentation')
-- WARN: This is not Goto Definition, this is Goto Declaration. -- WARN: This is not Goto Definition, this is Goto Declaration.
-- For example, in C this would take you to the header. -- For example, in C this would take you to the header
map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
-- The following two autocommands are used to highlight references of the -- The following two autocommands are used to highlight references of the
@ -554,53 +505,22 @@ require('lazy').setup({
-- --
-- When you move your cursor, the highlights will be cleared (the second autocommand). -- When you move your cursor, the highlights will be cleared (the second autocommand).
local client = vim.lsp.get_client_by_id(event.data.client_id) local client = vim.lsp.get_client_by_id(event.data.client_id)
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then if client and client.server_capabilities.documentHighlightProvider then
local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false })
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
buffer = event.buf, buffer = event.buf,
group = highlight_augroup,
callback = vim.lsp.buf.document_highlight, callback = vim.lsp.buf.document_highlight,
}) })
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
buffer = event.buf, buffer = event.buf,
group = highlight_augroup,
callback = vim.lsp.buf.clear_references, callback = vim.lsp.buf.clear_references,
}) })
vim.api.nvim_create_autocmd('LspDetach', {
group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }),
callback = function(event2)
vim.lsp.buf.clear_references()
vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf }
end,
})
end
-- The following code creates a keymap to toggle inlay hints in your
-- code, if the language server you are using supports them
--
-- This may be unwanted, since they displace some of your code
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then
map('<leader>th', function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf })
end, '[T]oggle Inlay [H]ints')
end end
end, end,
}) })
-- Change diagnostic symbols in the sign column (gutter)
-- if vim.g.have_nerd_font then
-- local signs = { ERROR = '', WARN = '', INFO = '', HINT = '' }
-- local diagnostic_signs = {}
-- for type, icon in pairs(signs) do
-- diagnostic_signs[vim.diagnostic.severity[type]] = icon
-- end
-- vim.diagnostic.config { signs = { text = diagnostic_signs } }
-- end
-- LSP servers and clients are able to communicate to each other what features they support. -- 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. -- By default, Neovim doesn't support everything that is in the LSP Specification.
-- When you add nvim-cmp, luasnip, etc. Neovim now has *more* 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. -- So, we create new capabilities with nvim cmp, and then broadcast that to the servers.
local capabilities = vim.lsp.protocol.make_client_capabilities() local capabilities = vim.lsp.protocol.make_client_capabilities()
@ -625,13 +545,13 @@ require('lazy').setup({
-- Some languages (like typescript) have entire language plugins that can be useful: -- Some languages (like typescript) have entire language plugins that can be useful:
-- https://github.com/pmizio/typescript-tools.nvim -- https://github.com/pmizio/typescript-tools.nvim
-- --
-- But for many setups, the LSP (`ts_ls`) will work just fine -- But for many setups, the LSP (`tsserver`) will work just fine
-- ts_ls = {}, -- tsserver = {},
-- --
lua_ls = { lua_ls = {
-- cmd = { ... }, -- cmd = {...},
-- filetypes = { ... }, -- filetypes { ...},
-- capabilities = {}, -- capabilities = {},
settings = { settings = {
Lua = { Lua = {
@ -646,21 +566,18 @@ require('lazy').setup({
} }
-- Ensure the servers and tools above are installed -- Ensure the servers and tools above are installed
-- -- To check the current status of installed tools and/or manually install
-- To check the current status of installed tools and/or manually install -- other tools, you can run
-- other tools, you can run
-- :Mason -- :Mason
-- --
-- You can press `g?` for help in this menu. -- You can press `g?` for help in this menu
-- require('mason').setup()
-- `mason` had to be setup earlier: to configure its options see the
-- `dependencies` table for `nvim-lspconfig` above.
--
-- You can add other tools here that you want Mason to install -- You can add other tools here that you want Mason to install
-- for you, so that they are available from within Neovim. -- for you, so that they are available from within Neovim.
local ensure_installed = vim.tbl_keys(servers or {}) local ensure_installed = vim.tbl_keys(servers or {})
vim.list_extend(ensure_installed, { vim.list_extend(ensure_installed, {
'stylua', -- Used to format Lua code 'stylua', -- Used to format lua code
}) })
require('mason-tool-installer').setup { ensure_installed = ensure_installed } require('mason-tool-installer').setup { ensure_installed = ensure_installed }
@ -670,7 +587,7 @@ require('lazy').setup({
local server = servers[server_name] or {} local server = servers[server_name] or {}
-- This handles overriding only values explicitly passed -- This handles overriding only values explicitly passed
-- by the server configuration above. Useful when disabling -- by the server configuration above. Useful when disabling
-- certain features of an LSP (for example, turning off formatting for ts_ls) -- certain features of an LSP (for example, turning off formatting for tsserver)
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
require('lspconfig')[server_name].setup(server) require('lspconfig')[server_name].setup(server)
end, end,
@ -681,43 +598,20 @@ require('lazy').setup({
{ -- Autoformat { -- Autoformat
'stevearc/conform.nvim', 'stevearc/conform.nvim',
event = { 'BufWritePre' },
cmd = { 'ConformInfo' },
keys = {
{
'<leader>f',
function()
require('conform').format { async = true, lsp_format = 'fallback' }
end,
mode = '',
desc = '[F]ormat buffer',
},
},
opts = { opts = {
notify_on_error = false, notify_on_error = false,
format_on_save = function(bufnr) format_on_save = {
-- Disable "format_on_save lsp_fallback" for languages that don't timeout_ms = 500,
-- have a well standardized coding style. You can add additional lsp_fallback = true,
-- languages here or re-enable it for the disabled ones. },
local disable_filetypes = { c = true, cpp = true }
local lsp_format_opt
if disable_filetypes[vim.bo[bufnr].filetype] then
lsp_format_opt = 'never'
else
lsp_format_opt = 'fallback'
end
return {
timeout_ms = 500,
lsp_format = lsp_format_opt,
}
end,
formatters_by_ft = { formatters_by_ft = {
lua = { 'stylua' }, lua = { 'stylua' },
-- Conform can also run multiple formatters sequentially -- Conform can also run multiple formatters sequentially
-- python = { "isort", "black" }, -- python = { "isort", "black" },
-- --
-- You can use 'stop_after_first' to run the first available formatter from the list -- You can use a sub-list to tell conform to run *until* a formatter
-- javascript = { "prettierd", "prettier", stop_after_first = true }, -- is found.
-- javascript = { { "prettierd", "prettier" } },
}, },
}, },
}, },
@ -730,25 +624,14 @@ require('lazy').setup({
{ {
'L3MON4D3/LuaSnip', 'L3MON4D3/LuaSnip',
build = (function() build = (function()
-- Build Step is needed for regex support in snippets. -- Build Step is needed for regex support in snippets
-- This step is not supported in many windows environments. -- This step is not supported in many windows environments
-- Remove the below condition to re-enable on windows. -- Remove the below condition to re-enable on windows
if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then
return return
end end
return 'make install_jsregexp' return 'make install_jsregexp'
end)(), 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,
-- },
},
}, },
'saadparwaiz1/cmp_luasnip', 'saadparwaiz1/cmp_luasnip',
@ -757,6 +640,12 @@ require('lazy').setup({
-- into multiple repos for maintenance purposes. -- into multiple repos for maintenance purposes.
'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-path', 'hrsh7th/cmp-path',
-- If you want to add a bunch of pre-configured snippets,
-- you can use this plugin to help you. It even has snippets
-- for various frameworks/libraries/etc. but you will have to
-- set up the ones that are useful for you.
-- 'rafamadriz/friendly-snippets',
}, },
config = function() config = function()
-- See `:help cmp` -- See `:help cmp`
@ -782,21 +671,11 @@ require('lazy').setup({
-- Select the [p]revious item -- Select the [p]revious item
['<C-p>'] = cmp.mapping.select_prev_item(), ['<C-p>'] = cmp.mapping.select_prev_item(),
-- Scroll the documentation window [b]ack / [f]orward
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
-- Accept ([y]es) the completion. -- Accept ([y]es) the completion.
-- This will auto-import if your LSP supports it. -- This will auto-import if your LSP supports it.
-- This will expand snippets if the LSP sent a snippet. -- This will expand snippets if the LSP sent a snippet.
['<C-y>'] = cmp.mapping.confirm { select = true }, ['<C-y>'] = cmp.mapping.confirm { select = true },
-- If you prefer more traditional completion keymaps,
-- you can uncomment the following lines
--['<CR>'] = cmp.mapping.confirm { select = true },
--['<Tab>'] = cmp.mapping.select_next_item(),
--['<S-Tab>'] = cmp.mapping.select_prev_item(),
-- Manually trigger a completion from nvim-cmp. -- Manually trigger a completion from nvim-cmp.
-- Generally you don't need this, because nvim-cmp will display -- Generally you don't need this, because nvim-cmp will display
-- completions whenever it has completion options available. -- completions whenever it has completion options available.
@ -820,16 +699,8 @@ require('lazy').setup({
luasnip.jump(-1) luasnip.jump(-1)
end end
end, { 'i', 's' }), 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 = { sources = {
{
name = 'lazydev',
-- set group index to 0 to skip loading LuaLS completions as lazydev recommends it
group_index = 0,
},
{ name = 'nvim_lsp' }, { name = 'nvim_lsp' },
{ name = 'luasnip' }, { name = 'luasnip' },
{ name = 'path' }, { name = 'path' },
@ -840,18 +711,18 @@ require('lazy').setup({
{ -- You can easily change to a different colorscheme. { -- You can easily change to a different colorscheme.
-- Change the name of the colorscheme plugin below, and then -- Change the name of the colorscheme plugin below, and then
-- change the command in the config to whatever the name of that colorscheme is. -- change the command in the config to whatever the name of that colorscheme is
-- --
-- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`
'folke/tokyonight.nvim', 'folke/tokyonight.nvim',
priority = 1000, -- Make sure to load this before all the other start plugins. priority = 1000, -- make sure to load this before all the other start plugins
init = function() init = function()
-- Load the colorscheme here. -- Load the colorscheme here.
-- Like many other themes, this one has different styles, and you could load -- Like many other themes, this one has different styles, and you could load
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
vim.cmd.colorscheme 'tokyonight-night' vim.cmd.colorscheme 'tokyonight-night'
-- You can configure highlights by doing something like: -- You can configure highlights by doing something like
vim.cmd.hi 'Comment gui=none' vim.cmd.hi 'Comment gui=none'
end, end,
}, },
@ -866,7 +737,7 @@ require('lazy').setup({
-- --
-- Examples: -- Examples:
-- - va) - [V]isually select [A]round [)]paren -- - va) - [V]isually select [A]round [)]paren
-- - yinq - [Y]ank [I]nside [N]ext [Q]uote -- - yinq - [Y]ank [I]nside [N]ext [']quote
-- - ci' - [C]hange [I]nside [']quote -- - ci' - [C]hange [I]nside [']quote
require('mini.ai').setup { n_lines = 500 } require('mini.ai').setup { n_lines = 500 }
@ -896,62 +767,54 @@ require('lazy').setup({
-- Check out: https://github.com/echasnovski/mini.nvim -- Check out: https://github.com/echasnovski/mini.nvim
end, end,
}, },
{ -- Highlight, edit, and navigate code { -- Highlight, edit, and navigate code
'nvim-treesitter/nvim-treesitter', 'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate', build = ':TSUpdate',
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
opts = { opts = {
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, ensure_installed = { 'bash', 'c', 'html', 'lua', 'markdown', 'vim', 'vimdoc' },
-- Autoinstall languages that are not installed -- Autoinstall languages that are not installed
auto_install = true, auto_install = true,
highlight = { highlight = { enable = true },
enable = true, indent = { enable = true },
-- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules.
-- If you are experiencing weird indenting issues, add the language to
-- the list of additional_vim_regex_highlighting and disabled languages for indent.
additional_vim_regex_highlighting = { 'ruby' },
},
indent = { enable = true, disable = { 'ruby' } },
}, },
-- There are additional nvim-treesitter modules that you can use to interact config = function(_, opts)
-- with nvim-treesitter. You should go explore a few and see what interests you: -- [[ Configure Treesitter ]] See `:help nvim-treesitter`
--
-- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod` ---@diagnostic disable-next-line: missing-fields
-- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context require('nvim-treesitter.configs').setup(opts)
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
-- 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:
--
-- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
-- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
end,
}, },
-- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the -- The following two 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 -- 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. -- put them in the right spots if you want.
-- NOTE: Next step on your Neovim journey: Add/Configure additional plugins for Kickstart -- NOTE: Next step on your Neovim journey: Add/Configure additional plugins for kickstart
-- --
-- Here are some example plugins that I've included in the Kickstart repository. -- 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). -- 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.indent_line', -- require 'kickstart.plugins.indent_line',
-- require 'kickstart.plugins.lint',
-- require 'kickstart.plugins.autopairs',
-- require 'kickstart.plugins.neo-tree',
-- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` -- 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. -- 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. -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
-- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins`
-- { 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 `<space>sh` then write `lazy.nvim-plugin`
-- you can continue same window with `<space>sr` which resumes last telescope search
}, { }, {
ui = { ui = {
-- If you are using a Nerd Font: set icons to an empty table which will use the -- If you have a Nerd Font, set icons to an empty table which will use the
-- default lazy.nvim defined Nerd Font icons, otherwise define a unicode icons table -- default lazy.nvim defined Nerd Font icons otherwise define a unicode icons table
icons = vim.g.have_nerd_font and {} or { icons = vim.g.have_nerd_font and {} or {
cmd = '', cmd = '',
config = '🛠', config = '🛠',

View File

@ -6,13 +6,13 @@
--]] --]]
local check_version = function() local check_version = function()
local verstr = tostring(vim.version()) local verstr = string.format('%s.%s.%s', vim.version().major, vim.version().minor, vim.version().patch)
if not vim.version.ge then if not vim.version.cmp then
vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr)) vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr))
return return
end end
if vim.version.ge(vim.version(), '0.10-dev') then if vim.version.cmp(vim.version(), { 0, 9, 4 }) >= 0 then
vim.health.ok(string.format("Neovim version is: '%s'", verstr)) vim.health.ok(string.format("Neovim version is: '%s'", verstr))
else else
vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr)) vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr))

View File

@ -1,16 +0,0 @@
-- autopairs
-- https://github.com/windwp/nvim-autopairs
return {
'windwp/nvim-autopairs',
event = 'InsertEnter',
-- Optional dependency
dependencies = { 'hrsh7th/nvim-cmp' },
config = function()
require('nvim-autopairs').setup {}
-- If you want to automatically add `(` after selecting a function or method
local cmp_autopairs = require 'nvim-autopairs.completion.cmp'
local cmp = require 'cmp'
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
end,
}

View File

@ -14,9 +14,6 @@ return {
-- Creates a beautiful debugger UI -- Creates a beautiful debugger UI
'rcarriga/nvim-dap-ui', 'rcarriga/nvim-dap-ui',
-- Required dependency for nvim-dap-ui
'nvim-neotest/nvim-nio',
-- Installs the debug adapters for you -- Installs the debug adapters for you
'williamboman/mason.nvim', 'williamboman/mason.nvim',
'jay-babu/mason-nvim-dap.nvim', 'jay-babu/mason-nvim-dap.nvim',
@ -24,59 +21,6 @@ return {
-- Add your own debuggers here -- Add your own debuggers here
'leoluz/nvim-dap-go', 'leoluz/nvim-dap-go',
}, },
keys = {
-- Basic debugging keymaps, feel free to change to your liking!
{
'<F5>',
function()
require('dap').continue()
end,
desc = 'Debug: Start/Continue',
},
{
'<F1>',
function()
require('dap').step_into()
end,
desc = 'Debug: Step Into',
},
{
'<F2>',
function()
require('dap').step_over()
end,
desc = 'Debug: Step Over',
},
{
'<F3>',
function()
require('dap').step_out()
end,
desc = 'Debug: Step Out',
},
{
'<leader>b',
function()
require('dap').toggle_breakpoint()
end,
desc = 'Debug: Toggle Breakpoint',
},
{
'<leader>B',
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.
{
'<F7>',
function()
require('dapui').toggle()
end,
desc = 'Debug: See last session result.',
},
},
config = function() config = function()
local dap = require 'dap' local dap = require 'dap'
local dapui = require 'dapui' local dapui = require 'dapui'
@ -84,7 +28,7 @@ return {
require('mason-nvim-dap').setup { require('mason-nvim-dap').setup {
-- Makes a best effort to setup the various debuggers with -- Makes a best effort to setup the various debuggers with
-- reasonable debug configurations -- reasonable debug configurations
automatic_installation = true, automatic_setup = true,
-- You can provide additional configuration to the handlers, -- You can provide additional configuration to the handlers,
-- see mason-nvim-dap README for more information -- see mason-nvim-dap README for more information
@ -98,6 +42,16 @@ return {
}, },
} }
-- Basic debugging keymaps, feel free to change to your liking!
vim.keymap.set('n', '<F5>', dap.continue, { desc = 'Debug: Start/Continue' })
vim.keymap.set('n', '<F1>', dap.step_into, { desc = 'Debug: Step Into' })
vim.keymap.set('n', '<F2>', dap.step_over, { desc = 'Debug: Step Over' })
vim.keymap.set('n', '<F3>', dap.step_out, { desc = 'Debug: Step Out' })
vim.keymap.set('n', '<leader>b', dap.toggle_breakpoint, { desc = 'Debug: Toggle Breakpoint' })
vim.keymap.set('n', '<leader>B', function()
dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ')
end, { desc = 'Debug: Set Breakpoint' })
-- Dap UI setup -- Dap UI setup
-- For more information, see |:help nvim-dap-ui| -- For more information, see |:help nvim-dap-ui|
dapui.setup { dapui.setup {
@ -120,29 +74,14 @@ return {
}, },
} }
-- Change breakpoint icons -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception.
-- vim.api.nvim_set_hl(0, 'DapBreak', { fg = '#e51400' }) vim.keymap.set('n', '<F7>', dapui.toggle, { desc = 'Debug: See last session result.' })
-- 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
dap.listeners.after.event_initialized['dapui_config'] = dapui.open dap.listeners.after.event_initialized['dapui_config'] = dapui.open
dap.listeners.before.event_terminated['dapui_config'] = dapui.close dap.listeners.before.event_terminated['dapui_config'] = dapui.close
dap.listeners.before.event_exited['dapui_config'] = dapui.close dap.listeners.before.event_exited['dapui_config'] = dapui.close
-- Install golang specific config -- Install golang specific config
require('dap-go').setup { 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,
},
}
end, end,
} }

View File

@ -1,61 +0,0 @@
-- Adds git related signs to the gutter, as well as utilities for managing changes
-- NOTE: gitsigns is already included in init.lua but contains only the base
-- config. This will add also the recommended keymaps.
return {
{
'lewis6991/gitsigns.nvim',
opts = {
on_attach = function(bufnr)
local gitsigns = require 'gitsigns'
local function map(mode, l, r, opts)
opts = opts or {}
opts.buffer = bufnr
vim.keymap.set(mode, l, r, opts)
end
-- Navigation
map('n', ']c', function()
if vim.wo.diff then
vim.cmd.normal { ']c', bang = true }
else
gitsigns.nav_hunk 'next'
end
end, { desc = 'Jump to next git [c]hange' })
map('n', '[c', function()
if vim.wo.diff then
vim.cmd.normal { '[c', bang = true }
else
gitsigns.nav_hunk 'prev'
end
end, { desc = 'Jump to previous git [c]hange' })
-- Actions
-- visual mode
map('v', '<leader>hs', function()
gitsigns.stage_hunk { vim.fn.line '.', vim.fn.line 'v' }
end, { desc = 'git [s]tage hunk' })
map('v', '<leader>hr', function()
gitsigns.reset_hunk { vim.fn.line '.', vim.fn.line 'v' }
end, { desc = 'git [r]eset hunk' })
-- normal mode
map('n', '<leader>hs', gitsigns.stage_hunk, { desc = 'git [s]tage hunk' })
map('n', '<leader>hr', gitsigns.reset_hunk, { desc = 'git [r]eset hunk' })
map('n', '<leader>hS', gitsigns.stage_buffer, { desc = 'git [S]tage buffer' })
map('n', '<leader>hu', gitsigns.undo_stage_hunk, { desc = 'git [u]ndo stage hunk' })
map('n', '<leader>hR', gitsigns.reset_buffer, { desc = 'git [R]eset buffer' })
map('n', '<leader>hp', gitsigns.preview_hunk, { desc = 'git [p]review hunk' })
map('n', '<leader>hb', gitsigns.blame_line, { desc = 'git [b]lame line' })
map('n', '<leader>hd', gitsigns.diffthis, { desc = 'git [d]iff against index' })
map('n', '<leader>hD', function()
gitsigns.diffthis '@'
end, { desc = 'git [D]iff against last commit' })
-- Toggles
map('n', '<leader>tb', gitsigns.toggle_current_line_blame, { desc = '[T]oggle git show [b]lame line' })
map('n', '<leader>tD', gitsigns.toggle_deleted, { desc = '[T]oggle git show [D]eleted' })
end,
},
},
}

View File

@ -1,60 +0,0 @@
return {
{ -- Linting
'mfussenegger/nvim-lint',
event = { 'BufReadPre', 'BufNewFile' },
config = function()
local lint = require 'lint'
lint.linters_by_ft = {
markdown = { 'markdownlint' },
}
-- 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 })
vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, {
group = lint_augroup,
callback = function()
-- 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.opt_local.modifiable:get() then
lint.try_lint()
end
end,
})
end,
},
}

View File

@ -1,25 +0,0 @@
-- Neo-tree is a Neovim plugin to browse the file system
-- https://github.com/nvim-neo-tree/neo-tree.nvim
return {
'nvim-neo-tree/neo-tree.nvim',
version = '*',
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended
'MunifTanjim/nui.nvim',
},
cmd = 'Neotree',
keys = {
{ '\\', ':Neotree reveal<CR>', desc = 'NeoTree reveal', silent = true },
},
opts = {
filesystem = {
window = {
mappings = {
['\\'] = 'close_window',
},
},
},
},
}