Skip to content

Commit d14a02d

Browse files
Merge remote-tracking branch 'upstream/master'
2 parents e8af01f + 8d1ef97 commit d14a02d

File tree

6 files changed

+203
-64
lines changed

6 files changed

+203
-64
lines changed

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ External Requirements:
2828
- A [Nerd Font](https://www.nerdfonts.com/): optional, provides various icons
2929
- if you have it set `vim.g.have_nerd_font` in `init.lua` to true
3030
- Language Setup:
31-
- If want to write Typescript, you need `npm`
32-
- If want to write Golang, you will need `go`
31+
- If you want to write Typescript, you need `npm`
32+
- If you want to write Golang, you will need `go`
3333
- etc.
3434

3535
> **NOTE**
@@ -46,8 +46,8 @@ Neovim's configurations are located under the following paths, depending on your
4646
| OS | PATH |
4747
| :- | :--- |
4848
| Linux, MacOS | `$XDG_CONFIG_HOME/nvim`, `~/.config/nvim` |
49-
| Windows (cmd)| `%userprofile%\AppData\Local\nvim\` |
50-
| Windows (powershell)| `$env:USERPROFILE\AppData\Local\nvim\` |
49+
| Windows (cmd)| `%localappdata%\nvim\` |
50+
| Windows (powershell)| `$env:LOCALAPPDATA\nvim\` |
5151

5252
#### Recommended Step
5353

@@ -59,6 +59,10 @@ fork to your machine using one of the commands below, depending on your OS.
5959
> Your fork's url will be something like this:
6060
> `https://github.com/<your_github_username>/kickstart.nvim.git`
6161
62+
You likely want to remove `lazy-lock.json` from your fork's `.gitignore` file
63+
too - it's ignored in the kickstart repo to make maintenance easier, but it's
64+
[recommmended to track it in version control](https://lazy.folke.io/usage/lockfile).
65+
6266
#### Clone kickstart.nvim
6367
> **NOTE**
6468
> If following the recommended step above (i.e., forking the repo), replace
@@ -77,13 +81,13 @@ git clone https://github.com/Paul-0x5061756c/kickstart.nvim.git "${XDG_CONFIG_HO
7781
If you're using `cmd.exe`:
7882

7983
```
80-
git clone https://github.com/nvim-lua/kickstart.nvim.git %userprofile%\AppData\Local\nvim\
84+
git clone https://github.com/nvim-lua/kickstart.nvim.git "%localappdata%\nvim"
8185
```
8286

8387
If you're using `powershell.exe`
8488

8589
```
86-
git clone https://github.com/nvim-lua/kickstart.nvim.git $env:USERPROFILE\AppData\Local\nvim\
90+
git clone https://github.com/nvim-lua/kickstart.nvim.git "${env:LOCALAPPDATA}\nvim"
8791
```
8892

8993
</details>
@@ -126,7 +130,7 @@ examples of adding popularly requested plugins.
126130
`~/.local/share/nvim-kickstart`. You can apply this approach to any Neovim
127131
distribution that you would like to try out.
128132
* What if I want to "uninstall" this configuration:
129-
* See [lazy.nvim uninstall](https://github.com/folke/lazy.nvim#-uninstalling) information
133+
* See [lazy.nvim uninstall](https://lazy.folke.io/usage#-uninstalling) information
130134
* Why is the kickstart `init.lua` a single file? Wouldn't it make sense to split it into multiple files?
131135
* The main purpose of kickstart is to serve as a teaching tool and a reference
132136
configuration that someone can easily use to `git clone` as a basis for their own.

init.lua

Lines changed: 118 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,12 @@ vim.opt.mouse = 'a'
111111
vim.opt.showmode = false
112112

113113
-- Sync clipboard between OS and Neovim.
114+
-- Schedule the setting after `UiEnter` because it can increase startup-time.
114115
-- Remove this option if you want your OS clipboard to remain independent.
115116
-- See `:help 'clipboard'`
116-
vim.opt.clipboard = 'unnamedplus'
117+
vim.schedule(function()
118+
vim.opt.clipboard = 'unnamedplus'
119+
end)
117120

118121
-- Enable break indent
119122
vim.opt.breakindent = true
@@ -157,17 +160,14 @@ vim.opt.scrolloff = 10
157160
-- [[ Basic Keymaps ]]
158161
-- See `:help vim.keymap.set()`
159162

160-
-- Set highlight on search, but clear on pressing <Esc> in normal mode
161-
vim.opt.hlsearch = true
163+
-- Clear highlights on search when pressing <Esc> in normal mode
164+
-- See `:help hlsearch`
162165
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
163166

164167
-- use <C-n> to open and close the file tree
165168
vim.keymap.set('n', '<C-n>', '<cmd>Ex<CR>')
166169

167170
-- Diagnostic keymaps
168-
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' })
169-
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' })
170-
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' })
171171
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
172172

173173
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
@@ -213,9 +213,12 @@ vim.g.disable_auto_format = true
213213
-- [[ Install `lazy.nvim` plugin manager ]]
214214
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
215215
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
216-
if not vim.loop.fs_stat(lazypath) then
216+
if not (vim.uv or vim.loop).fs_stat(lazypath) then
217217
local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
218-
vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
218+
local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
219+
if vim.v.shell_error ~= 0 then
220+
error('Error cloning lazy.nvim:\n' .. out)
221+
end
219222
end ---@diagnostic disable-next-line: undefined-field
220223
vim.opt.rtp:prepend(lazypath)
221224

@@ -240,11 +243,6 @@ require('lazy').setup({
240243
--
241244
-- Use `opts = {}` to force a plugin to be loaded.
242245
--
243-
-- This is equivalent to:
244-
-- require('Comment').setup({})
245-
246-
-- "gc" to comment visual regions/lines
247-
{ 'numToStr/Comment.nvim', opts = {} },
248246

249247
-- Here is a more advanced example where we pass configuration
250248
-- options to `gitsigns.nvim`. This is equivalent to the following Lua:
@@ -282,8 +280,43 @@ require('lazy').setup({
282280
{ -- Useful plugin to show you pending keybinds.
283281
'folke/which-key.nvim',
284282
event = 'VimEnter', -- Sets the loading event to 'VimEnter'
285-
config = function() -- This is the function that runs, AFTER loading
286-
require('which-key').setup()
283+
opts = {
284+
icons = {
285+
-- set icon mappings to true if you have a Nerd Font
286+
mappings = vim.g.have_nerd_font,
287+
-- If you are using a Nerd Font: set icons.keys to an empty table which will use the
288+
-- default which-key.nvim defined Nerd Font icons, otherwise define a string table
289+
keys = vim.g.have_nerd_font and {} or {
290+
Up = '<Up> ',
291+
Down = '<Down> ',
292+
Left = '<Left> ',
293+
Right = '<Right> ',
294+
C = '<C-…> ',
295+
M = '<M-…> ',
296+
D = '<D-…> ',
297+
S = '<S-…> ',
298+
CR = '<CR> ',
299+
Esc = '<Esc> ',
300+
ScrollWheelDown = '<ScrollWheelDown> ',
301+
ScrollWheelUp = '<ScrollWheelUp> ',
302+
NL = '<NL> ',
303+
BS = '<BS> ',
304+
Space = '<Space> ',
305+
Tab = '<Tab> ',
306+
F1 = '<F1>',
307+
F2 = '<F2>',
308+
F3 = '<F3>',
309+
F4 = '<F4>',
310+
F5 = '<F5>',
311+
F6 = '<F6>',
312+
F7 = '<F7>',
313+
F8 = '<F8>',
314+
F9 = '<F9>',
315+
F10 = '<F10>',
316+
F11 = '<F11>',
317+
F12 = '<F12>',
318+
},
319+
},
287320

288321
-- Document existing key chains
289322
require('which-key').register {
@@ -395,7 +428,22 @@ require('lazy').setup({
395428
end,
396429
},
397430

398-
{ -- LSP Configuration & Plugins
431+
-- LSP Plugins
432+
{
433+
-- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins
434+
-- used for completion, annotations and signatures of Neovim apis
435+
'folke/lazydev.nvim',
436+
ft = 'lua',
437+
opts = {
438+
library = {
439+
-- Load luvit types when the `vim.uv` word is found
440+
{ path = 'luvit-meta/library', words = { 'vim%.uv' } },
441+
},
442+
},
443+
},
444+
{ 'Bilal2453/luvit-meta', lazy = true },
445+
{
446+
-- Main LSP Configuration
399447
'neovim/nvim-lspconfig',
400448
dependencies = {
401449
-- Automatically install LSPs and related tools to stdpath for Neovim
@@ -407,9 +455,8 @@ require('lazy').setup({
407455
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
408456
{ 'j-hui/fidget.nvim', opts = {} },
409457

410-
-- `neodev` configures Lua LSP for your Neovim config, runtime and plugins
411-
-- used for completion, annotations and signatures of Neovim apis
412-
{ 'folke/neodev.nvim', opts = {} },
458+
-- Allows extra capabilities provided by nvim-cmp
459+
'hrsh7th/cmp-nvim-lsp',
413460
},
414461
config = function()
415462
-- Brief aside: **What is LSP?**
@@ -449,8 +496,9 @@ require('lazy').setup({
449496
--
450497
-- In this case, we create a function that lets us more easily define mappings specific
451498
-- for LSP related items. It sets the mode, buffer and description for us each time.
452-
local map = function(keys, func, desc)
453-
vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
499+
local map = function(keys, func, desc, mode)
500+
mode = mode or 'n'
501+
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
454502
end
455503

456504
-- Jump to the definition of the word under your cursor.
@@ -484,11 +532,7 @@ require('lazy').setup({
484532

485533
-- Execute a code action, usually your cursor needs to be on top of an error
486534
-- or a suggestion from your LSP for this to activate.
487-
map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
488-
489-
-- Opens a popup that displays documentation about the word under your cursor
490-
-- See `:help K` for why this keymap.
491-
map('K', vim.lsp.buf.hover, 'Hover Documentation')
535+
map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' })
492536

493537
-- WARN: This is not Goto Definition, this is Goto Declaration.
494538
-- For example, in C this would take you to the header.
@@ -503,7 +547,8 @@ require('lazy').setup({
503547
--
504548
-- When you move your cursor, the highlights will be cleared (the second autocommand).
505549
local client = vim.lsp.get_client_by_id(event.data.client_id)
506-
if client and client.server_capabilities.documentHighlightProvider then
550+
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then
551+
local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false })
507552
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
508553
buffer = event.buf,
509554
callback = vim.lsp.buf.document_highlight,
@@ -523,18 +568,28 @@ require('lazy').setup({
523568
})
524569
end
525570

526-
-- The following autocommand is used to enable inlay hints in your
571+
-- The following code creates a keymap to toggle inlay hints in your
527572
-- code, if the language server you are using supports them
528573
--
529574
-- This may be unwanted, since they displace some of your code
530-
if client and client.server_capabilities.inlayHintProvider and vim.lsp.inlay_hint then
575+
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then
531576
map('<leader>th', function()
532-
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
577+
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf })
533578
end, '[T]oggle Inlay [H]ints')
534579
end
535580
end,
536581
})
537582

583+
-- Change diagnostic symbols in the sign column (gutter)
584+
-- if vim.g.have_nerd_font then
585+
-- local signs = { ERROR = '', WARN = '', INFO = '', HINT = '' }
586+
-- local diagnostic_signs = {}
587+
-- for type, icon in pairs(signs) do
588+
-- diagnostic_signs[vim.diagnostic.severity[type]] = icon
589+
-- end
590+
-- vim.diagnostic.config { signs = { text = diagnostic_signs } }
591+
-- end
592+
538593
-- LSP servers and clients are able to communicate to each other what features they support.
539594
-- By default, Neovim doesn't support everything that is in the LSP specification.
540595
-- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities.
@@ -573,6 +628,9 @@ require('lazy').setup({
573628
}
574629
}
575630
},
631+
-- But for many setups, the LSP (`ts_ls`) will work just fine
632+
-- ts_ls = {},
633+
--
576634

577635
lua_ls = {
578636
-- cmd = {...},
@@ -625,7 +683,7 @@ require('lazy').setup({
625683
local server = servers[server_name] or {}
626684
-- This handles overriding only values explicitly passed
627685
-- by the server configuration above. Useful when disabling
628-
-- certain features of an LSP (for example, turning off formatting for tsserver)
686+
-- certain features of an LSP (for example, turning off formatting for ts_ls)
629687
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
630688
require('lspconfig')[server_name].setup(server)
631689

@@ -702,12 +760,13 @@ require('lazy').setup({
702760
},
703761
{ -- Autoformat
704762
'stevearc/conform.nvim',
705-
lazy = false,
763+
event = { 'BufWritePre' },
764+
cmd = { 'ConformInfo' },
706765
keys = {
707766
{
708767
'<leader>f',
709768
function()
710-
require('conform').format { async = true, lsp_fallback = true }
769+
require('conform').format { async = true, lsp_format = 'fallback' }
711770
end,
712771
mode = '',
713772
desc = '[F]ormat buffer',
@@ -728,16 +787,24 @@ require('lazy').setup({
728787
return {
729788
timeout_ms = 500,
730789
lsp_fallback = true,
790+
local lsp_format_opt
791+
if disable_filetypes[vim.bo[bufnr].filetype] then
792+
lsp_format_opt = 'never'
793+
else
794+
lsp_format_opt = 'fallback'
795+
end
796+
return {
797+
timeout_ms = 500,
798+
lsp_format = lsp_format_opt,
731799
}
732800
end,
733801
formatters_by_ft = {
734802
lua = { 'stylua' },
735803
-- Conform can also run multiple formatters sequentially
736804
-- pyt,on = { "isort", "black" },
737805
--
738-
-- You can use a sub-list to tell conform to run *until* a formatter
739-
-- is found.
740-
-- javascript = { { "prettierd", "prettier" } },
806+
-- You can use 'stop_after_first' to run the first available formatter from the list
807+
-- javascript = { "prettierd", "prettier", stop_after_first = true },
741808
},
742809
},
743810
},
@@ -836,6 +903,11 @@ require('lazy').setup({
836903
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
837904
},
838905
sources = {
906+
{
907+
name = 'lazydev',
908+
-- set group index to 0 to skip loading LuaLS completions as lazydev recommends it
909+
group_index = 0,
910+
},
839911
{ name = 'nvim_lsp' },
840912
{ name = 'luasnip' },
841913
{ name = 'path' },
@@ -871,7 +943,7 @@ require('lazy').setup({
871943
--
872944
-- Examples:
873945
-- - va) - [V]isually select [A]round [)]paren
874-
-- - yinq - [Y]ank [I]nside [N]ext [']quote
946+
-- - yinq - [Y]ank [I]nside [N]ext [Q]uote
875947
-- - ci' - [C]hange [I]nside [']quote
876948
require('mini.ai').setup { n_lines = 500 }
877949

@@ -904,8 +976,10 @@ require('lazy').setup({
904976
{ -- Highlight, edit, and navigate code
905977
'nvim-treesitter/nvim-treesitter',
906978
build = ':TSUpdate',
979+
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
980+
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
907981
opts = {
908-
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc' },
982+
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' },
909983
-- Autoinstall languages that are not installed
910984
auto_install = true,
911985
highlight = {
@@ -932,7 +1006,7 @@ require('lazy').setup({
9321006
end,
9331007
},
9341008

935-
-- The following two comments only work if you have downloaded the kickstart repo, not just copy pasted the
1009+
-- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the
9361010
-- init.lua. If you want these files, they are in the repository, so you can just download them and
9371011
-- place them in the correct locations.
9381012

@@ -947,8 +1021,12 @@ require('lazy').setup({
9471021
-- This is the easiest way to modularize your config.
9481022
--
9491023
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
950-
-- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins`
9511024
-- { import = 'custom.plugins' },
1025+
--
1026+
-- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec`
1027+
-- Or use telescope!
1028+
-- In normal mode type `<space>sh` then write `lazy.nvim-plugin`
1029+
-- you can continue same window with `<space>sr` which resumes last telescope search
9521030
}, {
9531031
ui = {
9541032
-- If you are using a Nerd Font: set icons to an empty table which will use the

0 commit comments

Comments
 (0)