Merge remote-tracking branch 'origin' into feature/tune

This commit is contained in:
Thomas Alcala Schneider 2023-10-09 10:30:53 +02:00
commit 774a93db88
3 changed files with 95 additions and 67 deletions

1
.gitignore vendored
View File

@ -2,4 +2,3 @@ tags
test.sh test.sh
.luarc.json .luarc.json
nvim nvim
lazy-lock.json

View File

@ -41,6 +41,10 @@ Clone kickstart.nvim:
```sh ```sh
# on Linux and Mac # on Linux and Mac
git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim
```
```
# on Windows # on Windows
git clone https://github.com/nvim-lua/kickstart.nvim.git %userprofile%\AppData\Local\nvim\ git clone https://github.com/nvim-lua/kickstart.nvim.git %userprofile%\AppData\Local\nvim\
``` ```

157
init.lua
View File

@ -81,7 +81,7 @@ require('lazy').setup({
'neovim/nvim-lspconfig', 'neovim/nvim-lspconfig',
dependencies = { dependencies = {
-- Automatically install LSPs to stdpath for neovim -- Automatically install LSPs to stdpath for neovim
{ 'williamboman/mason.nvim', config = true }, 'williamboman/mason.nvim',
'williamboman/mason-lspconfig.nvim', 'williamboman/mason-lspconfig.nvim',
-- Useful status updates for LSP -- Useful status updates for LSP
@ -128,16 +128,24 @@ require('lazy').setup({
-- don't override the built-in and fugitive keymaps -- don't override the built-in and fugitive keymaps
local gs = package.loaded.gitsigns local gs = package.loaded.gitsigns
vim.keymap.set({'n', 'v'}, ']c', function() vim.keymap.set({ 'n', 'v' }, ']c', function()
if vim.wo.diff then return ']c' end if vim.wo.diff then
vim.schedule(function() gs.next_hunk() end) return ']c'
end
vim.schedule(function()
gs.next_hunk()
end)
return '<Ignore>' return '<Ignore>'
end, {expr=true, buffer = bufnr, desc = "Jump to next hunk"}) end, { expr = true, buffer = bufnr, desc = 'Jump to next hunk' })
vim.keymap.set({'n', 'v'}, '[c', function() vim.keymap.set({ 'n', 'v' }, '[c', function()
if vim.wo.diff then return '[c' end if vim.wo.diff then
vim.schedule(function() gs.prev_hunk() end) return '[c'
end
vim.schedule(function()
gs.prev_hunk()
end)
return '<Ignore>' return '<Ignore>'
end, {expr=true, buffer = bufnr, desc = "Jump to previous hunk"}) end, { expr = true, buffer = bufnr, desc = 'Jump to previous hunk' })
end, end,
}, },
}, },
@ -170,10 +178,8 @@ require('lazy').setup({
'lukas-reineke/indent-blankline.nvim', 'lukas-reineke/indent-blankline.nvim',
-- Enable `lukas-reineke/indent-blankline.nvim` -- Enable `lukas-reineke/indent-blankline.nvim`
-- See `:help indent_blankline.txt` -- See `:help indent_blankline.txt`
opts = { main = 'ibl',
char = '', opts = {},
show_trailing_blankline_indent = false,
},
}, },
-- "gc" to comment visual regions/lines -- "gc" to comment visual regions/lines
@ -328,69 +334,72 @@ vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc =
-- [[ Configure Treesitter ]] -- [[ Configure Treesitter ]]
-- See `:help nvim-treesitter` -- See `:help nvim-treesitter`
require('nvim-treesitter.configs').setup { -- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}'
-- Add languages to be installed here that you want installed for treesitter vim.defer_fn(function()
ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim' }, require('nvim-treesitter.configs').setup {
-- Add languages to be installed here that you want installed for treesitter
ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim' },
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
auto_install = false, auto_install = false,
highlight = { enable = true }, highlight = { enable = true },
indent = { enable = true }, indent = { enable = true },
incremental_selection = { incremental_selection = {
enable = true,
keymaps = {
init_selection = '<c-space>',
node_incremental = '<c-space>',
scope_incremental = '<c-s>',
node_decremental = '<M-space>',
},
},
textobjects = {
select = {
enable = true, enable = true,
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
keymaps = { keymaps = {
-- You can use the capture groups defined in textobjects.scm init_selection = '<c-space>',
['aa'] = '@parameter.outer', node_incremental = '<c-space>',
['ia'] = '@parameter.inner', scope_incremental = '<c-s>',
['af'] = '@function.outer', node_decremental = '<M-space>',
['if'] = '@function.inner',
['ac'] = '@class.outer',
['ic'] = '@class.inner',
}, },
}, },
move = { textobjects = {
enable = true, select = {
set_jumps = true, -- whether to set jumps in the jumplist enable = true,
goto_next_start = { lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
[']m'] = '@function.outer', keymaps = {
[']]'] = '@class.outer', -- You can use the capture groups defined in textobjects.scm
['aa'] = '@parameter.outer',
['ia'] = '@parameter.inner',
['af'] = '@function.outer',
['if'] = '@function.inner',
['ac'] = '@class.outer',
['ic'] = '@class.inner',
},
}, },
goto_next_end = { move = {
[']M'] = '@function.outer', enable = true,
[']['] = '@class.outer', set_jumps = true, -- whether to set jumps in the jumplist
goto_next_start = {
[']m'] = '@function.outer',
[']]'] = '@class.outer',
},
goto_next_end = {
[']M'] = '@function.outer',
[']['] = '@class.outer',
},
goto_previous_start = {
['[m'] = '@function.outer',
['[['] = '@class.outer',
},
goto_previous_end = {
['[M'] = '@function.outer',
['[]'] = '@class.outer',
},
}, },
goto_previous_start = { swap = {
['[m'] = '@function.outer', enable = true,
['[['] = '@class.outer', swap_next = {
}, ['<leader>a'] = '@parameter.inner',
goto_previous_end = { },
['[M'] = '@function.outer', swap_previous = {
['[]'] = '@class.outer', ['<leader>A'] = '@parameter.inner',
},
}, },
}, },
swap = { }
enable = true, end, 0)
swap_next = {
['<leader>a'] = '@parameter.inner',
},
swap_previous = {
['<leader>A'] = '@parameter.inner',
},
},
},
}
-- Diagnostic keymaps -- Diagnostic keymaps
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
@ -443,6 +452,22 @@ local on_attach = function(_, bufnr)
end, { desc = 'Format current buffer with LSP' }) end, { desc = 'Format current buffer with LSP' })
end end
-- document existing key chains
require('which-key').register {
['<leader>c'] = { name = '[C]ode', _ = 'which_key_ignore' },
['<leader>d'] = { name = '[D]ocument', _ = 'which_key_ignore' },
['<leader>g'] = { name = '[G]it', _ = 'which_key_ignore' },
['<leader>h'] = { name = 'More git', _ = 'which_key_ignore' },
['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' },
['<leader>s'] = { name = '[S]earch', _ = 'which_key_ignore' },
['<leader>w'] = { name = '[W]orkspace', _ = 'which_key_ignore' },
}
-- mason-lspconfig requires that these setup functions are called in this order
-- before setting up the servers.
require('mason').setup()
require('mason-lspconfig').setup()
-- Enable the following language servers -- Enable the following language servers
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed. -- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
-- --