Skip to content

Commit 9627164

Browse files
authored
Merge branch 'nvim-lua:master' into master
2 parents 1a92260 + a229761 commit 9627164

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
@@ -157,14 +160,11 @@ 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
-- Diagnostic keymaps
165-
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' })
166-
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' })
167-
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' })
168168
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
169169

170170
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
@@ -207,9 +207,12 @@ vim.api.nvim_create_autocmd('TextYankPost', {
207207
-- [[ Install `lazy.nvim` plugin manager ]]
208208
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
209209
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
210-
if not vim.loop.fs_stat(lazypath) then
210+
if not (vim.uv or vim.loop).fs_stat(lazypath) then
211211
local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
212-
vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
212+
local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
213+
if vim.v.shell_error ~= 0 then
214+
error('Error cloning lazy.nvim:\n' .. out)
215+
end
213216
end ---@diagnostic disable-next-line: undefined-field
214217
vim.opt.rtp:prepend(lazypath)
215218

@@ -234,11 +237,6 @@ require('lazy').setup({
234237
--
235238
-- Use `opts = {}` to force a plugin to be loaded.
236239
--
237-
-- This is equivalent to:
238-
-- require('Comment').setup({})
239-
240-
-- "gc" to comment visual regions/lines
241-
{ 'numToStr/Comment.nvim', opts = {} },
242240

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

282315
-- Document existing key chains
283-
require('which-key').register {
284-
['<leader>c'] = { name = '[C]ode', _ = 'which_key_ignore' },
285-
['<leader>d'] = { name = '[D]ocument', _ = 'which_key_ignore' },
286-
['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' },
287-
['<leader>s'] = { name = '[S]earch', _ = 'which_key_ignore' },
288-
['<leader>w'] = { name = '[W]orkspace', _ = 'which_key_ignore' },
289-
['<leader>t'] = { name = '[T]oggle', _ = 'which_key_ignore' },
290-
['<leader>h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' },
291-
}
292-
-- visual mode
293-
require('which-key').register({
294-
['<leader>h'] = { 'Git [H]unk' },
295-
}, { mode = 'v' })
296-
end,
316+
spec = {
317+
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
318+
{ '<leader>d', group = '[D]ocument' },
319+
{ '<leader>r', group = '[R]ename' },
320+
{ '<leader>s', group = '[S]earch' },
321+
{ '<leader>w', group = '[W]orkspace' },
322+
{ '<leader>t', group = '[T]oggle' },
323+
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
324+
},
325+
},
297326
},
298327

299328
-- NOTE: Plugins can specify dependencies.
@@ -408,7 +437,22 @@ require('lazy').setup({
408437
end,
409438
},
410439

411-
{ -- LSP Configuration & Plugins
440+
-- LSP Plugins
441+
{
442+
-- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins
443+
-- used for completion, annotations and signatures of Neovim apis
444+
'folke/lazydev.nvim',
445+
ft = 'lua',
446+
opts = {
447+
library = {
448+
-- Load luvit types when the `vim.uv` word is found
449+
{ path = 'luvit-meta/library', words = { 'vim%.uv' } },
450+
},
451+
},
452+
},
453+
{ 'Bilal2453/luvit-meta', lazy = true },
454+
{
455+
-- Main LSP Configuration
412456
'neovim/nvim-lspconfig',
413457
dependencies = {
414458
-- Automatically install LSPs and related tools to stdpath for Neovim
@@ -420,9 +464,8 @@ require('lazy').setup({
420464
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
421465
{ 'j-hui/fidget.nvim', opts = {} },
422466

423-
-- `neodev` configures Lua LSP for your Neovim config, runtime and plugins
424-
-- used for completion, annotations and signatures of Neovim apis
425-
{ 'folke/neodev.nvim', opts = {} },
467+
-- Allows extra capabilities provided by nvim-cmp
468+
'hrsh7th/cmp-nvim-lsp',
426469
},
427470
config = function()
428471
-- Brief aside: **What is LSP?**
@@ -462,8 +505,9 @@ require('lazy').setup({
462505
--
463506
-- In this case, we create a function that lets us more easily define mappings specific
464507
-- for LSP related items. It sets the mode, buffer and description for us each time.
465-
local map = function(keys, func, desc)
466-
vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
508+
local map = function(keys, func, desc, mode)
509+
mode = mode or 'n'
510+
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
467511
end
468512

469513
-- Jump to the definition of the word under your cursor.
@@ -497,11 +541,7 @@ require('lazy').setup({
497541

498542
-- Execute a code action, usually your cursor needs to be on top of an error
499543
-- or a suggestion from your LSP for this to activate.
500-
map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
501-
502-
-- Opens a popup that displays documentation about the word under your cursor
503-
-- See `:help K` for why this keymap.
504-
map('K', vim.lsp.buf.hover, 'Hover Documentation')
544+
map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' })
505545

506546
-- WARN: This is not Goto Definition, this is Goto Declaration.
507547
-- For example, in C this would take you to the header.
@@ -513,7 +553,7 @@ require('lazy').setup({
513553
--
514554
-- When you move your cursor, the highlights will be cleared (the second autocommand).
515555
local client = vim.lsp.get_client_by_id(event.data.client_id)
516-
if client and client.server_capabilities.documentHighlightProvider then
556+
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then
517557
local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false })
518558
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
519559
buffer = event.buf,
@@ -536,13 +576,13 @@ require('lazy').setup({
536576
})
537577
end
538578

539-
-- The following autocommand is used to enable inlay hints in your
579+
-- The following code creates a keymap to toggle inlay hints in your
540580
-- code, if the language server you are using supports them
541581
--
542582
-- This may be unwanted, since they displace some of your code
543-
if client and client.server_capabilities.inlayHintProvider and vim.lsp.inlay_hint then
583+
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then
544584
map('<leader>th', function()
545-
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
585+
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf })
546586
end, '[T]oggle Inlay [H]ints')
547587
end
548588
end,
@@ -627,12 +667,13 @@ require('lazy').setup({
627667

628668
{ -- Autoformat
629669
'stevearc/conform.nvim',
630-
lazy = false,
670+
event = { 'BufWritePre' },
671+
cmd = { 'ConformInfo' },
631672
keys = {
632673
{
633674
'<leader>f',
634675
function()
635-
require('conform').format { async = true, lsp_fallback = true }
676+
require('conform').format { async = true, lsp_format = 'fallback' }
636677
end,
637678
mode = '',
638679
desc = '[F]ormat buffer',
@@ -645,19 +686,24 @@ require('lazy').setup({
645686
-- have a well standardized coding style. You can add additional
646687
-- languages here or re-enable it for the disabled ones.
647688
local disable_filetypes = { c = true, cpp = true }
689+
local lsp_format_opt
690+
if disable_filetypes[vim.bo[bufnr].filetype] then
691+
lsp_format_opt = 'never'
692+
else
693+
lsp_format_opt = 'fallback'
694+
end
648695
return {
649696
timeout_ms = 500,
650-
lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
697+
lsp_format = lsp_format_opt,
651698
}
652699
end,
653700
formatters_by_ft = {
654701
lua = { 'stylua' },
655702
-- Conform can also run multiple formatters sequentially
656703
-- python = { "isort", "black" },
657704
--
658-
-- You can use a sub-list to tell conform to run *until* a formatter
659-
-- is found.
660-
-- javascript = { { "prettierd", "prettier" } },
705+
-- You can use 'stop_after_first' to run the first available formatter from the list
706+
-- javascript = { "prettierd", "prettier", stop_after_first = true },
661707
},
662708
},
663709
},
@@ -765,6 +811,11 @@ require('lazy').setup({
765811
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
766812
},
767813
sources = {
814+
{
815+
name = 'lazydev',
816+
-- set group index to 0 to skip loading LuaLS completions as lazydev recommends it
817+
group_index = 0,
818+
},
768819
{ name = 'nvim_lsp' },
769820
{ name = 'luasnip' },
770821
{ name = 'path' },
@@ -801,7 +852,7 @@ require('lazy').setup({
801852
--
802853
-- Examples:
803854
-- - va) - [V]isually select [A]round [)]paren
804-
-- - yinq - [Y]ank [I]nside [N]ext [']quote
855+
-- - yinq - [Y]ank [I]nside [N]ext [Q]uote
805856
-- - ci' - [C]hange [I]nside [']quote
806857
require('mini.ai').setup { n_lines = 500 }
807858

@@ -834,8 +885,10 @@ require('lazy').setup({
834885
{ -- Highlight, edit, and navigate code
835886
'nvim-treesitter/nvim-treesitter',
836887
build = ':TSUpdate',
888+
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
889+
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
837890
opts = {
838-
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc' },
891+
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' },
839892
-- Autoinstall languages that are not installed
840893
auto_install = true,
841894
highlight = {
@@ -847,21 +900,12 @@ require('lazy').setup({
847900
},
848901
indent = { enable = true, disable = { 'ruby' } },
849902
},
850-
config = function(_, opts)
851-
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
852-
853-
-- Prefer git instead of curl in order to improve connectivity in some environments
854-
require('nvim-treesitter.install').prefer_git = true
855-
---@diagnostic disable-next-line: missing-fields
856-
require('nvim-treesitter.configs').setup(opts)
857-
858-
-- There are additional nvim-treesitter modules that you can use to interact
859-
-- with nvim-treesitter. You should go explore a few and see what interests you:
860-
--
861-
-- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
862-
-- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
863-
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
864-
end,
903+
-- There are additional nvim-treesitter modules that you can use to interact
904+
-- with nvim-treesitter. You should go explore a few and see what interests you:
905+
--
906+
-- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
907+
-- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
908+
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
865909
},
866910

867911
-- 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)