Skip to content

Commit b97232e

Browse files
committed
Merge branch 'master' of https://github.com/nvim-lua/kickstart.nvim into sync_from_upstream
2 parents 3419c4b + 4b065ad commit b97232e

9 files changed

Lines changed: 96 additions & 39 deletions

File tree

.gitignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ nvim
55

66
spell/
77

8-
# You likely want to comment this, since it's recommended to track lazy-lock.json in version
9-
# control, see https://lazy.folke.io/usage/lockfile
10-
# For kickstart, it makes sense to leave it ignored.
8+
# In your personal fork, you likely want to comment this, since it's recommended to track
9+
# lazy-lock.json in version control - see https://lazy.folke.io/usage/lockfile
10+
# For the official `nvim-lua/kickstart.nvim` git repository, we leave it ignored to avoid unneeded
11+
# merge conflicts.
1112
lazy-lock.json
1213

1314
.DS_Store

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ available methods being discussed
262262
<details><summary>Bob</summary>
263263

264264
[Bob](https://github.com/MordechaiHadad/bob) is a Neovim version manager for
265-
all plattforms. Simply install
265+
all platforms. Simply install
266266
[rustup](https://rust-lang.github.io/rustup/installation/other.html),
267267
and run the following commands:
268268

after/lsp/lua_ls.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
return {
22
on_init = function(client)
3+
client.server_capabilities.documentFormattingProvider = false -- Disable formatting (formatting is done by stylua)
4+
35
if client.workspace_folders then
46
local path = client.workspace_folders[1].name
57
if
@@ -32,7 +34,10 @@ return {
3234
},
3335
})
3436
end,
37+
---@type lspconfig.settings.lua_ls
3538
settings = {
36-
Lua = {},
39+
Lua = {
40+
format = { enable = false }, -- Disable formatting (formatting is done by stylua)
41+
},
3742
},
3843
}

lua/core/globals.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Langs = {
6363
},
6464

6565
fmt = {
66-
lua = { 'stylua' },
66+
-- lua = { 'stylua' }, -- see [Use stylua as an lsp formatter instead of an external formatter · nvim-lua/kickstart.nvim@459b868](https://github.com/nvim-lua/kickstart.nvim/commit/459b86865e9e81235c9db3be553d107adac5f72f)
6767
sh = { 'shfmt' },
6868
bash = { 'shfmt' },
6969
python = { 'ruff_format' },

lua/plugins/conform.lua

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ return {
77
{
88
'<leader>F',
99
function()
10-
require('conform').format { async = true, lsp_format = 'fallback' }
10+
require('conform').format { async = true }
1111
end,
1212
mode = '',
1313
desc = '[F]ormat buffer',
@@ -18,20 +18,28 @@ return {
1818
opts = {
1919
notify_on_error = true,
2020
format_on_save = function(bufnr)
21-
-- Disable "format_on_save lsp_fallback" for languages that don't
22-
-- have a well standardized coding style. You can add additional
23-
-- languages here or re-enable it for the disabled ones.
24-
local disable_filetypes = { c = true, cpp = true }
25-
if disable_filetypes[vim.bo[bufnr].filetype] then
26-
return nil
27-
else
28-
return {
29-
timeout_ms = 500,
30-
lsp_format = 'fallback',
31-
}
21+
-- NOTE:
22+
-- See:
23+
-- - [Change format_on_save to a whitelist instead of a blacklist · nvim-lua/kickstart.nvim@ce353a9](https://github.com/nvim-lua/kickstart.nvim/commit/ce353a9b0e3c47d27784509217200818f522329e)
24+
-- - [please disable autoformat on save in default configuration · Issue #1819 · nvim-lua/kickstart.nvim](https://github.com/nvim-lua/kickstart.nvim/issues/1819)
25+
26+
-- You can specify filetypes to autoformat on save here:
27+
local enabled_filetypes = {
28+
lua = true,
29+
-- python = true,
30+
}
31+
if enabled_filetypes[vim.bo[bufnr].filetype] then
32+
return { timeout_ms = 500 }
3233
end
34+
return nil
3335
end,
36+
default_format_opts = {
37+
lsp_format = 'fallback', -- Use external formatters if configured below, otherwise use LSP formatting. Set to `false` to disable LSP formatting entirely.
38+
},
39+
-- You can also specify external formatters in here.
3440
formatters_by_ft = Langs.fmt,
41+
-- Example
42+
-- rust = { 'rustfmt' },
3543
-- Conform can also run multiple formatters sequentially
3644
-- python = { "isort", "black" },
3745
--

lua/plugins/gitsigns.lua

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
-- Adds git related signs to the gutter, as well as utilities for managing changes
2+
3+
---@module 'lazy'
4+
---@type LazySpec
25
return {
36
'lewis6991/gitsigns.nvim',
47
---@module 'gitsigns'
@@ -50,17 +53,26 @@ return {
5053
map('n', '<leader>hs', gitsigns.stage_hunk, { desc = 'git [s]tage hunk' })
5154
map('n', '<leader>hr', gitsigns.reset_hunk, { desc = 'git [r]eset hunk' })
5255
map('n', '<leader>hS', gitsigns.stage_buffer, { desc = 'git [S]tage buffer' })
53-
map('n', '<leader>hu', gitsigns.stage_hunk, { desc = 'git [u]ndo stage hunk' })
5456
map('n', '<leader>hR', gitsigns.reset_buffer, { desc = 'git [R]eset buffer' })
5557
map('n', '<leader>hp', gitsigns.preview_hunk, { desc = 'git [p]review hunk' })
56-
map('n', '<leader>hb', gitsigns.blame_line, { desc = 'git [b]lame line' })
58+
map('n', '<leader>hi', gitsigns.preview_hunk_inline, { desc = 'git preview hunk [i]nline' })
59+
map('n', '<leader>hb', function()
60+
gitsigns.blame_line { full = true }
61+
end, { desc = 'git [b]lame line' })
5762
map('n', '<leader>hd', gitsigns.diffthis, { desc = 'git [d]iff against index' })
5863
map('n', '<leader>hD', function()
5964
gitsigns.diffthis '@'
6065
end, { desc = 'git [D]iff against last commit' })
66+
map('n', '<leader>hQ', function()
67+
gitsigns.setqflist 'all'
68+
end, { desc = 'git hunk [Q]uickfix list (all files in repo)' })
69+
map('n', '<leader>hq', gitsigns.setqflist, { desc = 'git hunk [q]uickfix list (all changes in this file)' })
6170
-- Toggles
6271
map('n', '<leader>tb', gitsigns.toggle_current_line_blame, { desc = '[T]oggle git show [b]lame line' })
63-
map('n', '<leader>tD', gitsigns.preview_hunk_inline, { desc = '[T]oggle git show [D]eleted' })
72+
map('n', '<leader>tW', gitsigns.toggle_word_diff, { desc = '[T]oggle git intra-line [w]ord diff' })
73+
74+
-- Text object
75+
map({ 'o', 'x' }, 'ih', gitsigns.select_hunk)
6476
end,
6577
},
6678
}

lua/plugins/mini.lua

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@ return {
66
--
77
-- Examples:
88
-- - va) - [V]isually select [A]round [)]paren
9-
-- - yinq - [Y]ank [I]nside [N]ext [Q]uote
9+
-- - yiiq - [Y]ank [I]nside [I]next [Q]uote
1010
-- - ci' - [C]hange [I]nside [']quote
11-
require('mini.ai').setup { n_lines = 500 }
11+
require('mini.ai').setup {
12+
-- NOTE: Avoid conflicts with the built-in incremental selection mappings on Neovim>=0.12 (see `:help treesitter-incremental-selection`)
13+
mappings = {
14+
around_next = 'aa',
15+
inside_next = 'ii',
16+
},
17+
n_lines = 500,
18+
}
1219

1320
-- Add/delete/replace surroundings (brackets, quotes, etc.)
1421
--

lua/plugins/nvim-lspconfig.lua

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ return {
2424

2525
-- Useful status updates for LSP.
2626
{ 'j-hui/fidget.nvim', opts = {} },
27-
28-
-- Allows extra capabilities provided by blink.cmp
29-
'saghen/blink.cmp',
3027
},
3128
config = function()
3229
-- Brief aside: **What is LSP?**

lua/plugins/nvim-treesitter.lua

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,33 @@ return {
77
-- [[ Configure Treesitter ]] See `:help nvim-treesitter-intro`
88
config = function()
99
require('nvim-treesitter').install(Langs.treesitter)
10+
11+
---@param buf integer
12+
---@param language string
13+
local function treesitter_try_attach(buf, language)
14+
-- check if parser exists and load it
15+
if not vim.treesitter.language.add(language) then
16+
return
17+
end
18+
-- enables syntax highlighting and other treesitter features
19+
vim.treesitter.start(buf, language)
20+
21+
-- enables treesitter based folds
22+
-- for more info on folds see `:help folds`
23+
-- vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
24+
-- vim.wo.foldmethod = 'expr'
25+
26+
-- check if treesitter indentation is available for this language, and if so enable it
27+
-- in case there is no indent query, the indentexpr will fallback to the vim's built in one
28+
local has_indent_query = vim.treesitter.query.get(language, 'indents') ~= nil
29+
30+
-- enables treesitter based indentation
31+
if has_indent_query then
32+
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
33+
end
34+
end
35+
36+
local available_parsers = require('nvim-treesitter').get_available()
1037
vim.api.nvim_create_autocmd('FileType', {
1138
callback = function(args)
1239
local buf, filetype = args.buf, args.match
@@ -16,20 +43,20 @@ return {
1643
return
1744
end
1845

19-
-- check if parser exists and load it
20-
if not vim.treesitter.language.add(language) then
21-
return
22-
end
23-
-- enables syntax highlighting and other treesitter features
24-
vim.treesitter.start(buf, language)
25-
26-
-- enables treesitter based folds
27-
-- for more info on folds see `:help folds`
28-
-- vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
29-
-- vim.wo.foldmethod = 'expr'
46+
local installed_parsers = require('nvim-treesitter').get_installed 'parsers'
3047

31-
-- enables treesitter based indentation
32-
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
48+
if vim.tbl_contains(installed_parsers, language) then
49+
-- enable the parser if it is installed
50+
treesitter_try_attach(buf, language)
51+
elseif vim.tbl_contains(available_parsers, language) then
52+
-- if a parser is available in `nvim-treesitter` auto install it, and enable it after the installation is done
53+
require('nvim-treesitter').install(language):await(function()
54+
treesitter_try_attach(buf, language)
55+
end)
56+
else
57+
-- try to enable treesitter features in case the parser exists but is not available from `nvim-treesitter`
58+
treesitter_try_attach(buf, language)
59+
end
3360
end,
3461
})
3562
end,

0 commit comments

Comments
 (0)