mirror of
https://github.com/nvim-lua/kickstart.nvim.git
synced 2026-05-14 08:23:48 +00:00
Split into sections
This commit is contained in:
parent
a42ed30a09
commit
2e8d5b17cb
184
init.lua
184
init.lua
@ -84,6 +84,11 @@ 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! :)
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
|
-- ============================================================
|
||||||
|
-- SECTION 1: FOUNDATION
|
||||||
|
-- Core Neovim settings, leaders, options, basic keymaps, basic autocmds
|
||||||
|
-- ============================================================
|
||||||
|
do
|
||||||
-- Enable faster startup by caching compiled Lua modules
|
-- Enable faster startup by caching compiled Lua modules
|
||||||
vim.loader.enable()
|
vim.loader.enable()
|
||||||
|
|
||||||
@ -232,7 +237,13 @@ vim.api.nvim_create_autocmd('TextYankPost', {
|
|||||||
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
|
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
|
||||||
callback = function() vim.hl.on_yank() end,
|
callback = function() vim.hl.on_yank() end,
|
||||||
})
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ============================================================
|
||||||
|
-- SECTION 2: PLUGIN MANAGER
|
||||||
|
-- vim.pack, build hooks, install/update plugins, plugin specs
|
||||||
|
-- ============================================================
|
||||||
|
do
|
||||||
-- [[ Install plugins with `vim.pack` ]]
|
-- [[ Install plugins with `vim.pack` ]]
|
||||||
-- See `:help vim.pack`, `:help vim.pack-examples` or the
|
-- See `:help vim.pack`, `:help vim.pack-examples` or the
|
||||||
-- excellent blog post from the creator of vim.pack and mini.nvim:
|
-- excellent blog post from the creator of vim.pack and mini.nvim:
|
||||||
@ -318,7 +329,13 @@ if vim.g.have_nerd_font then table.insert(plugins, gh 'nvim-tree/nvim-web-devico
|
|||||||
|
|
||||||
-- NOTE: Here is where the plugins are actually installed and added to the path
|
-- NOTE: Here is where the plugins are actually installed and added to the path
|
||||||
vim.pack.add(plugins)
|
vim.pack.add(plugins)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ============================================================
|
||||||
|
-- SECTION 3: UI / CORE UX PLUGINS
|
||||||
|
-- guess-indent, gitsigns, which-key, colorscheme, todo-comments, mini modules
|
||||||
|
-- ============================================================
|
||||||
|
do
|
||||||
-- [[ Configure plugins ]]
|
-- [[ Configure plugins ]]
|
||||||
-- For most plugins you need to call their `.setup()` to start them
|
-- For most plugins you need to call their `.setup()` to start them
|
||||||
--
|
--
|
||||||
@ -354,6 +371,74 @@ require('which-key').setup {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- [[ Colorscheme ]]
|
||||||
|
-- You can easily change to a different colorscheme.
|
||||||
|
-- Change the name of the colorscheme plugin below, and then
|
||||||
|
-- change the command under that to load whatever the name of that colorscheme is.
|
||||||
|
--
|
||||||
|
-- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`.
|
||||||
|
---@diagnostic disable-next-line: missing-fields
|
||||||
|
require('tokyonight').setup {
|
||||||
|
styles = {
|
||||||
|
comments = { italic = false }, -- Disable italics in comments
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Load the colorscheme here.
|
||||||
|
-- Like many other themes, this one has different styles, and you could load
|
||||||
|
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
|
||||||
|
vim.cmd.colorscheme 'tokyonight-night'
|
||||||
|
|
||||||
|
-- Highlight todo, notes, etc in comments
|
||||||
|
require('todo-comments').setup { signs = false }
|
||||||
|
|
||||||
|
-- [[ mini.nvim ]]
|
||||||
|
-- A collection of various small independent plugins/modules
|
||||||
|
|
||||||
|
-- Better Around/Inside textobjects
|
||||||
|
--
|
||||||
|
-- Examples:
|
||||||
|
-- - va) - [V]isually select [A]round [)]paren
|
||||||
|
-- - yiiq - [Y]ank [I]nside [I]+1 [Q]uote
|
||||||
|
-- - ci' - [C]hange [I]nside [']quote
|
||||||
|
require('mini.ai').setup {
|
||||||
|
-- NOTE: Avoid conflicts with the built-in incremental selection mappings on Neovim>=0.12 (see `:help treesitter-incremental-selection`)
|
||||||
|
mappings = {
|
||||||
|
around_next = 'aa',
|
||||||
|
inside_next = 'ii',
|
||||||
|
},
|
||||||
|
n_lines = 500,
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Add/delete/replace surroundings (brackets, quotes, etc.)
|
||||||
|
--
|
||||||
|
-- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren
|
||||||
|
-- - sd' - [S]urround [D]elete [']quotes
|
||||||
|
-- - sr)' - [S]urround [R]eplace [)] [']
|
||||||
|
require('mini.surround').setup()
|
||||||
|
|
||||||
|
-- Simple and easy statusline.
|
||||||
|
-- You could remove this setup call if you don't like it,
|
||||||
|
-- and try some other statusline plugin
|
||||||
|
local statusline = require 'mini.statusline'
|
||||||
|
-- Set `use_icons` to true if you have a Nerd Font
|
||||||
|
statusline.setup { use_icons = vim.g.have_nerd_font }
|
||||||
|
|
||||||
|
-- You can configure sections in the statusline by overriding their
|
||||||
|
-- default behavior. For example, here we set the section for
|
||||||
|
-- cursor location to LINE:COLUMN
|
||||||
|
---@diagnostic disable-next-line: duplicate-set-field
|
||||||
|
statusline.section_location = function() return '%2l:%-2v' end
|
||||||
|
|
||||||
|
-- ... and there is more!
|
||||||
|
-- Check out: https://github.com/nvim-mini/mini.nvim
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ============================================================
|
||||||
|
-- SECTION 4: SEARCH & NAVIGATION
|
||||||
|
-- Telescope setup, keymaps, LSP picker mappings
|
||||||
|
-- ============================================================
|
||||||
|
do
|
||||||
-- [[ Fuzzy Finder (files, lsp, etc) ]]
|
-- [[ Fuzzy Finder (files, lsp, etc) ]]
|
||||||
--
|
--
|
||||||
-- Telescope is a fuzzy finder that comes with a lot of different things that
|
-- Telescope is a fuzzy finder that comes with a lot of different things that
|
||||||
@ -471,7 +556,13 @@ vim.keymap.set(
|
|||||||
|
|
||||||
-- Shortcut for searching your Neovim configuration files
|
-- Shortcut for searching your Neovim configuration files
|
||||||
vim.keymap.set('n', '<leader>sn', function() builtin.find_files { cwd = vim.fn.stdpath 'config' } end, { desc = '[S]earch [N]eovim files' })
|
vim.keymap.set('n', '<leader>sn', function() builtin.find_files { cwd = vim.fn.stdpath 'config' } end, { desc = '[S]earch [N]eovim files' })
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ============================================================
|
||||||
|
-- SECTION 5: LSP
|
||||||
|
-- LSP keymaps, server configuration, Mason tools installations
|
||||||
|
-- ============================================================
|
||||||
|
do
|
||||||
-- [[ LSP Configuration ]]
|
-- [[ LSP Configuration ]]
|
||||||
-- Brief aside: **What is LSP?**
|
-- Brief aside: **What is LSP?**
|
||||||
--
|
--
|
||||||
@ -643,7 +734,13 @@ for name, server in pairs(servers) do
|
|||||||
vim.lsp.config(name, server)
|
vim.lsp.config(name, server)
|
||||||
vim.lsp.enable(name)
|
vim.lsp.enable(name)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ============================================================
|
||||||
|
-- SECTION 6: FORMATTING
|
||||||
|
-- conform.nvim setup and keymap
|
||||||
|
-- ============================================================
|
||||||
|
do
|
||||||
-- [[ Formatting ]]
|
-- [[ Formatting ]]
|
||||||
require('conform').setup {
|
require('conform').setup {
|
||||||
notify_on_error = false,
|
notify_on_error = false,
|
||||||
@ -674,10 +771,14 @@ require('conform').setup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vim.keymap.set({ 'n', 'v' }, '<leader>f', function() require('conform').format { async = true } end, { desc = '[F]ormat buffer' })
|
vim.keymap.set({ 'n', 'v' }, '<leader>f', function() require('conform').format { async = true } end, { desc = '[F]ormat buffer' })
|
||||||
|
end
|
||||||
|
|
||||||
-- [[ Autocompletion Configuration ]]
|
-- ============================================================
|
||||||
|
-- SECTION 7: AUTOCOMPLETE & SNIPPETS
|
||||||
-- Snippet Engine
|
-- blink.cmp and luasnip setup
|
||||||
|
-- ============================================================
|
||||||
|
do
|
||||||
|
-- [[ Snippet Engine ]]
|
||||||
require('luasnip').setup {}
|
require('luasnip').setup {}
|
||||||
|
|
||||||
-- `friendly-snippets` contains a variety of premade snippets.
|
-- `friendly-snippets` contains a variety of premade snippets.
|
||||||
@ -687,7 +788,7 @@ require('luasnip').setup {}
|
|||||||
-- vim.pack.add { gh 'rafamadriz/friendly-snippets' }
|
-- vim.pack.add { gh 'rafamadriz/friendly-snippets' }
|
||||||
-- require('luasnip.loaders.from_vscode').lazy_load()
|
-- require('luasnip.loaders.from_vscode').lazy_load()
|
||||||
|
|
||||||
-- The autocomplete engine
|
-- [[ Autocomplete Engine ]]
|
||||||
require('blink.cmp').setup {
|
require('blink.cmp').setup {
|
||||||
keymap = {
|
keymap = {
|
||||||
-- 'default' (recommended) for mappings similar to built-in completions
|
-- 'default' (recommended) for mappings similar to built-in completions
|
||||||
@ -747,69 +848,13 @@ require('blink.cmp').setup {
|
|||||||
-- Shows a signature help window while you type arguments for a function
|
-- Shows a signature help window while you type arguments for a function
|
||||||
signature = { enabled = true },
|
signature = { enabled = true },
|
||||||
}
|
}
|
||||||
|
end
|
||||||
|
|
||||||
-- [[ Colorscheme ]]
|
-- ============================================================
|
||||||
-- You can easily change to a different colorscheme.
|
-- SECTION 8: TREESITTER
|
||||||
-- Change the name of the colorscheme plugin below, and then
|
-- Parser installation, syntax highlighting, folds, indentation
|
||||||
-- change the command under that to load whatever the name of that colorscheme is.
|
-- ============================================================
|
||||||
--
|
do
|
||||||
-- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`.
|
|
||||||
---@diagnostic disable-next-line: missing-fields
|
|
||||||
require('tokyonight').setup {
|
|
||||||
styles = {
|
|
||||||
comments = { italic = false }, -- Disable italics in comments
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Load the colorscheme here.
|
|
||||||
-- Like many other themes, this one has different styles, and you could load
|
|
||||||
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
|
|
||||||
vim.cmd.colorscheme 'tokyonight-night'
|
|
||||||
|
|
||||||
-- Highlight todo, notes, etc in comments
|
|
||||||
require('todo-comments').setup { signs = false }
|
|
||||||
|
|
||||||
-- [[ mini.nvim ]]
|
|
||||||
-- A collection of various small independent plugins/modules
|
|
||||||
|
|
||||||
-- Better Around/Inside textobjects
|
|
||||||
--
|
|
||||||
-- Examples:
|
|
||||||
-- - va) - [V]isually select [A]round [)]paren
|
|
||||||
-- - yiiq - [Y]ank [I]nside [I]+1 [Q]uote
|
|
||||||
-- - ci' - [C]hange [I]nside [']quote
|
|
||||||
require('mini.ai').setup {
|
|
||||||
-- NOTE: Avoid conflicts with the built-in incremental selection mappings on Neovim>=0.12 (see `:help treesitter-incremental-selection`)
|
|
||||||
mappings = {
|
|
||||||
around_next = 'aa',
|
|
||||||
inside_next = 'ii',
|
|
||||||
},
|
|
||||||
n_lines = 500,
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Add/delete/replace surroundings (brackets, quotes, etc.)
|
|
||||||
--
|
|
||||||
-- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren
|
|
||||||
-- - sd' - [S]urround [D]elete [']quotes
|
|
||||||
-- - sr)' - [S]urround [R]eplace [)] [']
|
|
||||||
require('mini.surround').setup()
|
|
||||||
|
|
||||||
-- Simple and easy statusline.
|
|
||||||
-- You could remove this setup call if you don't like it,
|
|
||||||
-- and try some other statusline plugin
|
|
||||||
local statusline = require 'mini.statusline'
|
|
||||||
-- Set `use_icons` to true if you have a Nerd Font
|
|
||||||
statusline.setup { use_icons = vim.g.have_nerd_font }
|
|
||||||
|
|
||||||
-- You can configure sections in the statusline by overriding their
|
|
||||||
-- default behavior. For example, here we set the section for
|
|
||||||
-- cursor location to LINE:COLUMN
|
|
||||||
---@diagnostic disable-next-line: duplicate-set-field
|
|
||||||
statusline.section_location = function() return '%2l:%-2v' end
|
|
||||||
|
|
||||||
-- ... and there is more!
|
|
||||||
-- Check out: https://github.com/nvim-mini/mini.nvim
|
|
||||||
|
|
||||||
-- [[ Configure Treesitter ]]
|
-- [[ Configure Treesitter ]]
|
||||||
-- Used to highlight, edit, and navigate code
|
-- Used to highlight, edit, and navigate code
|
||||||
--
|
--
|
||||||
@ -862,7 +907,13 @@ vim.api.nvim_create_autocmd('FileType', {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ============================================================
|
||||||
|
-- SECTION 9: OPTIONAL EXAMPLES / NEXT STEPS
|
||||||
|
-- kickstart.plugins.* examples
|
||||||
|
-- ============================================================
|
||||||
|
do
|
||||||
-- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the
|
-- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the
|
||||||
-- init.lua. If you want these files, they are in the repository, so you can just download them and
|
-- 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.
|
-- place them in the correct locations.
|
||||||
@ -883,6 +934,7 @@ vim.api.nvim_create_autocmd('FileType', {
|
|||||||
--
|
--
|
||||||
-- 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.
|
||||||
-- require 'custom.plugins'
|
-- require 'custom.plugins'
|
||||||
|
end
|
||||||
|
|
||||||
-- The line beneath this is called `modeline`. See `:help modeline`
|
-- The line beneath this is called `modeline`. See `:help modeline`
|
||||||
-- vim: ts=2 sts=2 sw=2 et
|
-- vim: ts=2 sts=2 sw=2 et
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user