Skip to content

Commit e41fb75

Browse files
authored
Merge branch 'nvim-lua:master' into master
2 parents 14f330d + a229761 commit e41fb75

File tree

6 files changed

+148
-91
lines changed

6 files changed

+148
-91
lines changed

README.md

Lines changed: 10 additions & 6 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/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$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>

init.lua

Lines changed: 111 additions & 67 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
@@ -161,14 +164,11 @@ vim.opt.tabstop = 2
161164
-- [[ Basic Keymaps ]]
162165
-- See `:help vim.keymap.set()`
163166

164-
-- Set highlight on search, but clear on pressing <Esc> in normal mode
165-
vim.opt.hlsearch = true
167+
-- Clear highlights on search when pressing <Esc> in normal mode
168+
-- See `:help hlsearch`
166169
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
167170

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

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

@@ -238,11 +241,6 @@ require('lazy').setup({
238241
--
239242
-- Use `opts = {}` to force a plugin to be loaded.
240243
--
241-
-- This is equivalent to:
242-
-- require('Comment').setup({})
243-
244-
-- "gc" to comment visual regions/lines
245-
{ 'numToStr/Comment.nvim', opts = {} },
246244

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

286319
-- Document existing key chains
287-
require('which-key').register {
288-
['<leader>c'] = { name = '[C]ode', _ = 'which_key_ignore' },
289-
['<leader>d'] = { name = '[D]ocument', _ = 'which_key_ignore' },
290-
['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' },
291-
['<leader>s'] = { name = '[S]earch', _ = 'which_key_ignore' },
292-
['<leader>w'] = { name = '[W]orkspace', _ = 'which_key_ignore' },
293-
['<leader>t'] = { name = '[T]oggle', _ = 'which_key_ignore' },
294-
['<leader>h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' },
295-
}
296-
-- visual mode
297-
require('which-key').register({
298-
['<leader>h'] = { 'Git [H]unk' },
299-
}, { mode = 'v' })
300-
end,
320+
spec = {
321+
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
322+
{ '<leader>d', group = '[D]ocument' },
323+
{ '<leader>r', group = '[R]ename' },
324+
{ '<leader>s', group = '[S]earch' },
325+
{ '<leader>w', group = '[W]orkspace' },
326+
{ '<leader>t', group = '[T]oggle' },
327+
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
328+
},
329+
},
301330
},
302331

303332
-- NOTE: Plugins can specify dependencies.
@@ -416,7 +445,22 @@ require('lazy').setup({
416445
end,
417446
},
418447

419-
{ -- LSP Configuration & Plugins
448+
-- LSP Plugins
449+
{
450+
-- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins
451+
-- used for completion, annotations and signatures of Neovim apis
452+
'folke/lazydev.nvim',
453+
ft = 'lua',
454+
opts = {
455+
library = {
456+
-- Load luvit types when the `vim.uv` word is found
457+
{ path = 'luvit-meta/library', words = { 'vim%.uv' } },
458+
},
459+
},
460+
},
461+
{ 'Bilal2453/luvit-meta', lazy = true },
462+
{
463+
-- Main LSP Configuration
420464
'neovim/nvim-lspconfig',
421465
dependencies = {
422466
-- Automatically install LSPs and related tools to stdpath for Neovim
@@ -428,9 +472,8 @@ require('lazy').setup({
428472
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
429473
{ 'j-hui/fidget.nvim', opts = {} },
430474

431-
-- `neodev` configures Lua LSP for your Neovim config, runtime and plugins
432-
-- used for completion, annotations and signatures of Neovim apis
433-
{ 'folke/neodev.nvim', opts = {} },
475+
-- Allows extra capabilities provided by nvim-cmp
476+
'hrsh7th/cmp-nvim-lsp',
434477
},
435478
config = function()
436479
-- Brief aside: **What is LSP?**
@@ -470,8 +513,9 @@ require('lazy').setup({
470513
--
471514
-- In this case, we create a function that lets us more easily define mappings specific
472515
-- for LSP related items. It sets the mode, buffer and description for us each time.
473-
local map = function(keys, func, desc)
474-
vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
516+
local map = function(keys, func, desc, mode)
517+
mode = mode or 'n'
518+
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
475519
end
476520

477521
-- Jump to the definition of the word under your cursor.
@@ -505,11 +549,7 @@ require('lazy').setup({
505549

506550
-- Execute a code action, usually your cursor needs to be on top of an error
507551
-- or a suggestion from your LSP for this to activate.
508-
map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
509-
510-
-- Opens a popup that displays documentation about the word under your cursor
511-
-- See `:help K` for why this keymap.
512-
map('K', vim.lsp.buf.hover, 'Hover Documentation')
552+
map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' })
513553

514554
-- WARN: This is not Goto Definition, this is Goto Declaration.
515555
-- For example, in C this would take you to the header.
@@ -521,7 +561,7 @@ require('lazy').setup({
521561
--
522562
-- When you move your cursor, the highlights will be cleared (the second autocommand).
523563
local client = vim.lsp.get_client_by_id(event.data.client_id)
524-
if client and client.server_capabilities.documentHighlightProvider then
564+
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then
525565
local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false })
526566
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
527567
buffer = event.buf,
@@ -544,13 +584,13 @@ require('lazy').setup({
544584
})
545585
end
546586

547-
-- The following autocommand is used to enable inlay hints in your
587+
-- The following code creates a keymap to toggle inlay hints in your
548588
-- code, if the language server you are using supports them
549589
--
550590
-- This may be unwanted, since they displace some of your code
551-
if client and client.server_capabilities.inlayHintProvider and vim.lsp.inlay_hint then
591+
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then
552592
map('<leader>th', function()
553-
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
593+
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf })
554594
end, '[T]oggle Inlay [H]ints')
555595
end
556596
end,
@@ -637,12 +677,13 @@ require('lazy').setup({
637677

638678
{ -- Autoformat
639679
'stevearc/conform.nvim',
640-
lazy = false,
680+
event = { 'BufWritePre' },
681+
cmd = { 'ConformInfo' },
641682
keys = {
642683
{
643684
'<leader>f',
644685
function()
645-
require('conform').format { async = true, lsp_fallback = true }
686+
require('conform').format { async = true, lsp_format = 'fallback' }
646687
end,
647688
mode = '',
648689
desc = '[F]ormat buffer',
@@ -655,19 +696,24 @@ require('lazy').setup({
655696
-- have a well standardized coding style. You can add additional
656697
-- languages here or re-enable it for the disabled ones.
657698
local disable_filetypes = { c = true, cpp = true }
699+
local lsp_format_opt
700+
if disable_filetypes[vim.bo[bufnr].filetype] then
701+
lsp_format_opt = 'never'
702+
else
703+
lsp_format_opt = 'fallback'
704+
end
658705
return {
659706
timeout_ms = 500,
660-
lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
707+
lsp_format = lsp_format_opt,
661708
}
662709
end,
663710
formatters_by_ft = {
664711
lua = { 'stylua' },
665712
-- Conform can also run multiple formatters sequentially
666713
python = { 'isort', 'black' },
667714
--
668-
-- You can use a sub-list to tell conform to run *until* a formatter
669-
-- is found.
670-
-- javascript = { { "prettierd", "prettier" } },
715+
-- You can use 'stop_after_first' to run the first available formatter from the list
716+
-- javascript = { "prettierd", "prettier", stop_after_first = true },
671717
},
672718
},
673719
},
@@ -775,6 +821,11 @@ require('lazy').setup({
775821
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
776822
},
777823
sources = {
824+
{
825+
name = 'lazydev',
826+
-- set group index to 0 to skip loading LuaLS completions as lazydev recommends it
827+
group_index = 0,
828+
},
778829
{ name = 'nvim_lsp' },
779830
{ name = 'luasnip' },
780831
{ name = 'path' },
@@ -811,7 +862,7 @@ require('lazy').setup({
811862
--
812863
-- Examples:
813864
-- - va) - [V]isually select [A]round [)]paren
814-
-- - yinq - [Y]ank [I]nside [N]ext [']quote
865+
-- - yinq - [Y]ank [I]nside [N]ext [Q]uote
815866
-- - ci' - [C]hange [I]nside [']quote
816867
require('mini.ai').setup { n_lines = 500 }
817868

@@ -844,8 +895,10 @@ require('lazy').setup({
844895
{ -- Highlight, edit, and navigate code
845896
'nvim-treesitter/nvim-treesitter',
846897
build = ':TSUpdate',
898+
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
899+
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
847900
opts = {
848-
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc' },
901+
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' },
849902
-- Autoinstall languages that are not installed
850903
auto_install = true,
851904
highlight = {
@@ -857,21 +910,12 @@ require('lazy').setup({
857910
},
858911
indent = { enable = true, disable = { 'ruby' } },
859912
},
860-
config = function(_, opts)
861-
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
862-
863-
-- Prefer git instead of curl in order to improve connectivity in some environments
864-
require('nvim-treesitter.install').prefer_git = true
865-
---@diagnostic disable-next-line: missing-fields
866-
require('nvim-treesitter.configs').setup(opts)
867-
868-
-- There are additional nvim-treesitter modules that you can use to interact
869-
-- with nvim-treesitter. You should go explore a few and see what interests you:
870-
--
871-
-- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
872-
-- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
873-
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
874-
end,
913+
-- There are additional nvim-treesitter modules that you can use to interact
914+
-- with nvim-treesitter. You should go explore a few and see what interests you:
915+
--
916+
-- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
917+
-- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
918+
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
875919
},
876920

877921
-- The following two comments only work if you have downloaded the kickstart repo, not just copy pasted the

lua/kickstart/health.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
--]]
77

88
local check_version = function()
9-
local verstr = string.format('%s.%s.%s', vim.version().major, vim.version().minor, vim.version().patch)
10-
if not vim.version.cmp then
9+
local verstr = tostring(vim.version())
10+
if not vim.version.ge then
1111
vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr))
1212
return
1313
end
1414

15-
if vim.version.cmp(vim.version(), { 0, 9, 4 }) >= 0 then
15+
if vim.version.ge(vim.version(), '0.10-dev') then
1616
vim.health.ok(string.format("Neovim version is: '%s'", verstr))
1717
else
1818
vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr))

0 commit comments

Comments
 (0)