Merge branch 'nvim-lua:master' into master

This commit is contained in:
Ajay 2023-06-03 21:23:24 -04:00 committed by GitHub
commit efde6fedb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 133 additions and 92 deletions

View File

@ -8,19 +8,21 @@ 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 -->
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce** ## Describe the bug
Steps to reproduce the behavior: <!-- A clear and concise description of what the bug is. -->
## To Reproduce
<!-- Steps to reproduce the behavior. -->
1. ... 1. ...
**Desktop (please complete the following information):** ## Desktop
<!-- 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

@ -11,35 +11,53 @@ A starting point for Neovim that is:
This repo is meant to be used as by **YOU** to begin your Neovim journey; remove the things you don't use and add what you miss. This repo is meant to be used as by **YOU** to begin your Neovim journey; remove the things you don't use and add what you miss.
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.
Distribution Alternatives: Distribution Alternatives:
- [LazyVim](https://www.lazyvim.org/): A delightful distribution maintained by @folke (the author of lazy.nvim, the package manager used here) - [LazyVim](https://www.lazyvim.org/): A delightful distribution maintained by @folke (the author of lazy.nvim, the package manager used here)
### Installation ### Installation
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. * Backup your previous configuration (if any exists)
* Backup your previous configuration ### Archive Installation
* (Recommended) Fork this repo (so that you have your own copy that you can modify). * On the home/landing page for the project find the blue "<> CODE" button click it and select Local > Download ZIP.
* Clone the kickstart repo into `$HOME/.config/nvim/` (Linux/Mac) or `~/AppData/Local/nvim/` (Windows) * Extract the archive to:
* If you don't want to include it as a git repo, you can just clone it and then move the files to this location `~/.config/nvim` (Linux)
* Start Neovim (`nvim`) and allow `lazy.nvim` to complete installation. `~/.config/nvim` (MacOS)
* Restart Neovim `%userprofile%\AppData\Local\nvim\` (Windows)
* Ensure your extraction method did not extract with a parent folder. For example in ~/.config/nvim you should have init.lua not another folder called kickstart.nvim.
### Git Clone Installation
* From a terminal cd/dir to:
`~/.config/nvim` (Linux)
`~/.config/nvim` (MacOS)
`%userprofile%\AppData\Local\nvim\` (Windows)
* run: `git clone https://github.com/nvim-lua/kickstart.nvim.git ~/.config/nvim` OR: `gh repo clone nvim-lua/kickstart.nvim`
* Run Neovim (from terminal or shortcut) and allow lazy.nvim to download files and set up the basics.
* Once the setup is complete, restart Neovim.
* **You're ready to go!** * **You're ready to go!**
* (Recommended/Optional) Fork this repo (so that you have your own copy that you can modify).
* Clone the kickstart repo into `$HOME/.config/nvim/` (Linux/Mac) or `%userprofile%\AppData\Local\nvim\` (Windows)
* If you don't want to include it as a git repo, you can just clone it and then move the files to this location
Additional system requirements: Additional system requirements:
- Make sure to review the readmes of the plugins if you are experiencing errors. In particular: - Make sure to review the readmes of the plugins if you are experiencing errors. In particular:
- [ripgrep](https://github.com/BurntSushi/ripgrep#installation) is required for multiple [telescope](https://github.com/nvim-telescope/telescope.nvim#suggested-dependencies) pickers. - [ripgrep](https://github.com/BurntSushi/ripgrep#installation) is required for multiple [telescope](https://github.com/nvim-telescope/telescope.nvim#suggested-dependencies) pickers.
- See as well [Windows Installation](#Windows-Installation) - See [Windows Installation](#Windows-Installation) if you have trouble with `telescope-fzf-native`
### Configuration And Extension ### Configuration And Extension
* Inside of your fork, feel free to modify any file you like! It's your fork! * Inside of your copy, feel free to modify any file you like! It's your copy!
* Then there are two primary configuration options available: * Feel free to change any of the default options in `init.lua` to better suit your needs.
* Include the `lua/kickstart/plugins/*` files in your configuration. * For adding plugins, there are 3 primary options:
* Add new configuration in `lua/custom/plugins/*` files, which will be auto sourced using `lazy.nvim` * Add new configuration in `lua/custom/plugins/*` files, which will be auto sourced using `lazy.nvim`
* NOTE: To enable this, you need to uncomment `{ import = 'custom.plugins' }` in your `init.lua` * Modify `init.lua` with additional plugins.
* Include the `lua/kickstart/plugins/*` files in your configuration.
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 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.
#### Example: Adding an autopairs plugin #### Example: Adding an autopairs plugin
@ -50,14 +68,23 @@ In the file: `lua/custom/plugins/autopairs.lua`, add:
return { return {
"windwp/nvim-autopairs", "windwp/nvim-autopairs",
-- Optional dependency
dependencies = { 'hrsh7th/nvim-cmp' },
config = function() config = function()
require("nvim-autopairs").setup {} 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, end,
} }
``` ```
This will automatically install `nvim-autopairs` and enable it on startup. For more information, see documentation for [lazy.nvim](https://github.com/folke/lazy.nvim). 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).
#### Example: Adding a file tree plugin #### Example: Adding a file tree plugin
@ -81,17 +108,7 @@ return {
} }
``` ```
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. 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.
#### Example: Adding a file to change default options
To change default options, you can add a file in the `/after/plugin/` folder (see `:help load-plugins`) to include your own options, keymaps, autogroups, and more. The following is an example `defaults.lua` file (located at `$HOME/.config/nvim/after/plugin/defaults.lua`).
```lua
vim.opt.relativenumber = true
vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' })
```
### Contribution ### Contribution
@ -112,13 +129,13 @@ Each PR, especially those which increase the line count, should have a descripti
* See [lazy.nvim uninstall](https://github.com/folke/lazy.nvim#-uninstalling) information * See [lazy.nvim uninstall](https://github.com/folke/lazy.nvim#-uninstalling) information
* Are there any cool videos about this plugin? * Are there any cool videos about this plugin?
* Current iteration of kickstart (coming soon) * Current iteration of kickstart (coming soon)
* Here is one about the previous iteration of kickstart: [video introduction to Kickstart.nvim](https://youtu.be/stqUbv-5u2s). * 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.
### Windows Installation ### Windows Installation
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` documention 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)
This requires: This requires:

View File

@ -7,8 +7,8 @@
Kickstart.nvim is *not* a distribution. Kickstart.nvim is *not* a distribution.
Kickstart.nvim is a template for your own configuration. Kickstart.nvim is a template for your own configuration.
The goal is that you can read every line of code, top-to-bottom, and understand The goal is that you can read every line of code, top-to-bottom, understand
what your configuration is doing. what your configuration is doing, and modify it to suit your needs.
Once you've done that, you should start exploring, configuring and tinkering to Once you've done that, you should start exploring, configuring and tinkering to
explore Neovim! explore Neovim!
@ -35,7 +35,6 @@ I hope you enjoy your Neovim journey,
P.S. You can delete this when you're done too. It's your config now :) P.S. You can delete this when you're done too. It's your config now :)
--]] --]]
-- Set <space> as the leader key -- Set <space> as the leader key
-- See `:help mapleader` -- See `:help mapleader`
-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used) -- NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
@ -84,11 +83,12 @@ require('lazy').setup({
-- NOTE: This is where your plugins related to LSP can be installed. -- NOTE: This is where your plugins related to LSP can be installed.
-- The configuration is done below. Search for lspconfig to find it below. -- The configuration is done below. Search for lspconfig to find it below.
{ -- LSP Configuration & Plugins {
-- LSP Configuration & Plugins
'neovim/nvim-lspconfig', 'neovim/nvim-lspconfig',
dependencies = { dependencies = {
-- Automatically install LSPs to stdpath for neovim -- Automatically install LSPs to stdpath for neovim
'williamboman/mason.nvim', { 'williamboman/mason.nvim', config = true },
'williamboman/mason-lspconfig.nvim', 'williamboman/mason-lspconfig.nvim',
-- Useful status updates for LSP -- Useful status updates for LSP
@ -100,14 +100,26 @@ require('lazy').setup({
}, },
}, },
{ -- Autocompletion {
-- Autocompletion
'hrsh7th/nvim-cmp', 'hrsh7th/nvim-cmp',
dependencies = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip' }, dependencies = {
-- Snippet Engine & its associated nvim-cmp source
'L3MON4D3/LuaSnip',
'saadparwaiz1/cmp_luasnip',
-- Adds LSP completion capabilities
'hrsh7th/cmp-nvim-lsp',
-- Adds a number of user-friendly snippets
'rafamadriz/friendly-snippets',
},
}, },
-- Useful plugin to show you pending keybinds. -- Useful plugin to show you pending keybinds.
{ 'folke/which-key.nvim', opts = {} }, { 'folke/which-key.nvim', opts = {} },
{ -- Adds git releated signs to the gutter, as well as utilities for managing changes {
-- Adds git releated signs to the gutter, as well as utilities for managing changes
'lewis6991/gitsigns.nvim', 'lewis6991/gitsigns.nvim',
opts = { opts = {
-- See `:help gitsigns.txt` -- See `:help gitsigns.txt`
@ -118,31 +130,22 @@ require('lazy').setup({
topdelete = { text = '' }, topdelete = { text = '' },
changedelete = { text = '~' }, changedelete = { text = '~' },
}, },
on_attach = function(bufnr)
vim.keymap.set('n', '[c', require('gitsigns').prev_hunk, { buffer = bufnr, desc = 'Go to Previous Hunk' })
vim.keymap.set('n', ']c', require('gitsigns').next_hunk, { buffer = bufnr, desc = 'Go to Next Hunk' })
vim.keymap.set('n', '<leader>ph', require('gitsigns').preview_hunk, { buffer = bufnr, desc = '[P]review [H]unk' })
end,
}, },
}, },
{ -- Theme inspired by Atom -- Theme related configs go here
'navarasu/onedark.nvim', require 'kickstart.plugins.theme',
priority = 1000,
config = function()
vim.cmd.colorscheme 'onedark'
end,
},
{ -- Set lualine as statusline -- Status line related configs go here
'nvim-lualine/lualine.nvim', require 'kickstart.plugins.statusline',
-- See `:help lualine.txt`
opts = {
options = {
icons_enabled = false,
theme = 'onedark',
component_separators = '|',
section_separators = '',
},
},
},
{ -- Add indentation guides even on blank lines {
-- Add indentation guides even on blank lines
'lukas-reineke/indent-blankline.nvim', 'lukas-reineke/indent-blankline.nvim',
-- Enable `lukas-reineke/indent-blankline.nvim` -- Enable `lukas-reineke/indent-blankline.nvim`
-- See `:help indent_blankline.txt` -- See `:help indent_blankline.txt`
@ -156,7 +159,7 @@ require('lazy').setup({
{ 'numToStr/Comment.nvim', opts = {} }, { 'numToStr/Comment.nvim', opts = {} },
-- Fuzzy Finder (files, lsp, etc) -- Fuzzy Finder (files, lsp, etc)
{ 'nvim-telescope/telescope.nvim', version = '*', dependencies = { 'nvim-lua/plenary.nvim' } }, { 'nvim-telescope/telescope.nvim', branch = '0.1.x', dependencies = { 'nvim-lua/plenary.nvim' } },
-- Fuzzy Finder Algorithm which requires local dependencies to be built. -- Fuzzy Finder Algorithm which requires local dependencies to be built.
-- Only load if `make` is available. Make sure you have the system -- Only load if `make` is available. Make sure you have the system
@ -171,12 +174,13 @@ require('lazy').setup({
end, end,
}, },
{ -- Highlight, edit, and navigate code {
-- Highlight, edit, and navigate code
'nvim-treesitter/nvim-treesitter', 'nvim-treesitter/nvim-treesitter',
dependencies = { dependencies = {
'nvim-treesitter/nvim-treesitter-textobjects', 'nvim-treesitter/nvim-treesitter-textobjects',
}, },
build = ":TSUpdate", build = ':TSUpdate',
}, },
-- 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
@ -190,14 +194,12 @@ require('lazy').setup({
-- up-to-date with whatever is in the kickstart repo. -- up-to-date with whatever is in the kickstart repo.
-- --
-- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins -- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins
--
-- An additional note is that if you only copied in the `init.lua`, you can just comment this line
-- to get rid of the warning telling you that there are not plugins in `lua/custom/plugins/`.
{ import = 'custom.plugins' }, { import = 'custom.plugins' },
}, {}) }, {})
-- [[ Setting options ]] -- [[ Setting options ]]
-- See `:help vim.o` -- See `:help vim.o`
-- NOTE: You can change these options as you wish!
-- Set highlight on search -- Set highlight on search
vim.o.hlsearch = false vim.o.hlsearch = false
@ -285,6 +287,7 @@ vim.keymap.set('n', '<leader>/', function()
}) })
end, { desc = '[/] Fuzzily search in current buffer' }) end, { desc = '[/] Fuzzily search in current buffer' })
vim.keymap.set('n', '<leader>gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' })
vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
@ -358,12 +361,12 @@ require('nvim-treesitter.configs').setup {
} }
-- Diagnostic keymaps -- Diagnostic keymaps
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = "Go to previous diagnostic message" }) vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = "Go to next diagnostic message" }) vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = "Open floating diagnostic message" }) vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = "Open diagnostics list" }) vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
-- LSP settings. -- [[ Configure LSP ]]
-- This function gets run when an LSP connects to a particular buffer. -- This function gets run when an LSP connects to a particular buffer.
local on_attach = function(_, bufnr) local on_attach = function(_, bufnr)
-- 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
@ -437,9 +440,6 @@ require("nvim-tree").setup()
local capabilities = vim.lsp.protocol.make_client_capabilities() local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
-- Setup mason so it can manage external tooling
require('mason').setup()
-- Ensure the servers above are installed -- Ensure the servers above are installed
local mason_lspconfig = require 'mason-lspconfig' local mason_lspconfig = require 'mason-lspconfig'
@ -457,10 +457,11 @@ mason_lspconfig.setup_handlers {
end, end,
} }
-- nvim-cmp setup -- [[ Configure nvim-cmp ]]
-- See `:help cmp`
local cmp = require 'cmp' local cmp = require 'cmp'
local luasnip = require 'luasnip' local luasnip = require 'luasnip'
require('luasnip.loaders.from_vscode').lazy_load()
luasnip.config.setup {} luasnip.config.setup {}
cmp.setup { cmp.setup {
@ -470,6 +471,8 @@ cmp.setup {
end, end,
}, },
mapping = cmp.mapping.preset.insert { mapping = cmp.mapping.preset.insert {
['<C-n>'] = cmp.mapping.select_next_item(),
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-d>'] = cmp.mapping.scroll_docs(-4), ['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4), ['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete {}, ['<C-Space>'] = cmp.mapping.complete {},
@ -480,7 +483,7 @@ cmp.setup {
['<Tab>'] = cmp.mapping(function(fallback) ['<Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then elseif luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump() luasnip.expand_or_jump()
else else
fallback() fallback()
@ -489,7 +492,7 @@ cmp.setup {
['<S-Tab>'] = cmp.mapping(function(fallback) ['<S-Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_prev_item() cmp.select_prev_item()
elseif luasnip.jumpable(-1) then elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1) luasnip.jump(-1)
else else
fallback() fallback()

View File

@ -5,6 +5,7 @@
return { return {
'neovim/nvim-lspconfig', 'neovim/nvim-lspconfig',
config = function() config = function()
-- Switch for controlling whether you want autoformatting. -- Switch for controlling whether you want autoformatting.
-- Use :KickstartFormatToggle to toggle autoformatting on or off -- Use :KickstartFormatToggle to toggle autoformatting on or off
@ -28,11 +29,9 @@ return {
return _augroups[client.id] return _augroups[client.id]
end end
-- Whenever an LSP attaches to a buffer, we will run this function.
--
-- See `:help LspAttach` for more information about this autocmd event.
vim.api.nvim_create_autocmd('LspAttach', { vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('kickstart-lsp-attach-format', { clear = true }), group = vim.api.nvim_create_augroup('kickstart-lsp-attach-format', { clear = true }),
-- This is where we attach the autoformatting for reasonable clients -- This is where we attach the autoformatting for reasonable clients
callback = function(args) callback = function(args)
local client_id = args.data.client_id local client_id = args.data.client_id
@ -50,8 +49,6 @@ return {
return return
end end
-- Create an autocmd that will run *before* we save the buffer.
-- Run the formatting command for the LSP that has just attached.
vim.api.nvim_create_autocmd('BufWritePre', { vim.api.nvim_create_autocmd('BufWritePre', {
group = get_augroup(client), group = get_augroup(client),
buffer = bufnr, buffer = bufnr,
@ -60,12 +57,7 @@ return {
return return
end end
vim.lsp.buf.format { vim.lsp.buf.format { async = false }
async = false,
filter = function(c)
return c.id == client.id
end,
}
end, end,
}) })
end, end,

View File

@ -69,10 +69,13 @@ return {
step_back = 'b', step_back = 'b',
run_last = '▶▶', run_last = '▶▶',
terminate = '', terminate = '',
disconnect = "",
}, },
}, },
} }
-- toggle to see last session result. Without this ,you can't see session output in case of unhandled exception.
vim.keymap.set("n", "<F7>", dapui.toggle)
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

View File

@ -0,0 +1,14 @@
return {
-- Set lualine as statusline
'nvim-lualine/lualine.nvim',
-- See `:help lualine.txt`
opts = {
options = {
icons_enabled = false,
theme = 'tokyonight',
component_separators = '|',
section_separators = '',
},
},
}

View File

@ -0,0 +1,10 @@
return {
"folke/tokyonight.nvim",
lazy = false,
priority = 1000,
opts = {},
config = function()
vim.cmd.colorscheme 'tokyonight-storm'
end,
}