Compare commits

..

2 commits

Author SHA1 Message Date
9f4b7f8e9f
feat: nvim-treesitter 2024-12-08 11:59:54 -08:00
c310916b13
fix: Set buffer on gitsigns.nvim mappings 2024-12-05 18:11:09 -08:00
4 changed files with 178 additions and 82 deletions

View file

@ -55,6 +55,39 @@ with final.pkgs.lib; let
flash-nvim flash-nvim
which-key-nvim which-key-nvim
gitsigns-nvim gitsigns-nvim
# Treesitter
(nvim-treesitter.withPlugins (
plugins:
with plugins; [
bash
diff
html
gitignore
javascript
jsdoc
json
jsonc
just
lua
luadoc
markdown
markdown_inline
nix
just
printf
python
query
regex
toml
tsx
typescript
vim
vimdoc
xml
yaml
]
))
]; ];
extraPackages = with pkgs; [ extraPackages = with pkgs; [

View file

@ -27,102 +27,105 @@ return {
local icons = require('icons') local icons = require('icons')
local mkKey = MarleyVim.wkSpec(require('colors').git) local mkKey = MarleyVim.wkSpec(require('colors').git)
require('which-key').add({ require('which-key').add({
mkKey(']h', function() {
if vim.wo.diff then buffer = buf,
vim.cmd.normal({ ']c', bang = true }) mkKey(']h', function()
else if vim.wo.diff then
gitsigns.nav_hunk('next') vim.cmd.normal({ ']c', bang = true })
end else
end, icons.next, { desc = 'next hunk' }), gitsigns.nav_hunk('next')
end
end, icons.next, { desc = 'next hunk' }),
mkKey('[h', function() mkKey('[h', function()
if vim.wo.diff then if vim.wo.diff then
vim.cmd.normal({ '[c', bang = true }) vim.cmd.normal({ '[c', bang = true })
else else
gitsigns.nav_hunk('prev') gitsigns.nav_hunk('prev')
end end
end, icons.prev, { desc = 'previous hunk' }), end, icons.prev, { desc = 'previous hunk' }),
mkKey(']H', function() mkKey(']H', function()
gitsigns.nav_hunk('last') gitsigns.nav_hunk('last')
end, icons.last, { desc = 'last hunk' }), end, icons.last, { desc = 'last hunk' }),
mkKey('[H', function() mkKey('[H', function()
gitsigns.nav_hunk('first') gitsigns.nav_hunk('first')
end, icons.first, { desc = 'first hunk' }), end, icons.first, { desc = 'first hunk' }),
mkKey( mkKey(
'<LEADER>ghs', '<LEADER>ghs',
'<CMD>Gitsigns stage_hunk<CR>', '<CMD>Gitsigns stage_hunk<CR>',
icons.git.staged, icons.git.staged,
{ mode = { 'n', 'v' }, desc = 'stage hunk' } { mode = { 'n', 'v' }, desc = 'stage hunk' }
), ),
mkKey( mkKey(
'<LEADER>ghr', '<LEADER>ghr',
'<CMD>Gitsigns reset_hunk<CR>', '<CMD>Gitsigns reset_hunk<CR>',
icons.git.unstaged, icons.git.unstaged,
{ mode = { 'n', 'v' }, desc = 'reset hunk' } { mode = { 'n', 'v' }, desc = 'reset hunk' }
), ),
mkKey( mkKey(
'<LEADER>ghS', '<LEADER>ghS',
gitsigns.stage_buffer, gitsigns.stage_buffer,
icons.git.staged, icons.git.staged,
{ desc = 'stage buffer' } { desc = 'stage buffer' }
), ),
mkKey( mkKey(
'<LEADER>ghu', '<LEADER>ghu',
gitsigns.undo_stage_hunk, gitsigns.undo_stage_hunk,
icons.undo, icons.undo,
{ desc = 'undo stage hunk' } { desc = 'undo stage hunk' }
), ),
mkKey( mkKey(
'<LEADER>ghR', '<LEADER>ghR',
gitsigns.reset_buffer, gitsigns.reset_buffer,
icons.git.unstaged, icons.git.unstaged,
{ desc = 'reset buffer' } { desc = 'reset buffer' }
), ),
mkKey( mkKey(
'<LEADER>ghp', '<LEADER>ghp',
gitsigns.preview_hunk_inline, gitsigns.preview_hunk_inline,
'', '',
{ desc = 'preview hunk inline' } { desc = 'preview hunk inline' }
), ),
mkKey('<LEADER>ghb', function() mkKey('<LEADER>ghb', function()
gitsigns.blame_line({ full = true }) gitsigns.blame_line({ full = true })
end, { cat = 'filetype', name = 'git' }, { end, { cat = 'filetype', name = 'git' }, {
desc = 'blame line', desc = 'blame line',
}), }),
mkKey( mkKey(
'<LEADER>ghB', '<LEADER>ghB',
gitsigns.blame, gitsigns.blame,
{ cat = 'filetype', name = 'git' }, { cat = 'filetype', name = 'git' },
{ desc = 'blame buffer' } { desc = 'blame buffer' }
), ),
mkKey( mkKey(
'<LEADER>ghd', '<LEADER>ghd',
gitsigns.diffthis, gitsigns.diffthis,
icons.git.diff, icons.git.diff,
{ desc = 'diff file' } { desc = 'diff file' }
), ),
mkKey('<LEADER>ghD', function() mkKey('<LEADER>ghD', function()
gitsigns.diffthis('~') gitsigns.diffthis('~')
end, icons.git.diff, { desc = 'diff file from ~' }), end, icons.git.diff, { desc = 'diff file from ~' }),
mkKey( mkKey(
'ih', 'ih',
'<CMD><C-u>Gitsigns select_hunk<CR>', '<CMD><C-u>Gitsigns select_hunk<CR>',
'󰿚', '󰿚',
{ mode = { 'o', 'x' }, desc = 'select hunk' } { mode = { 'o', 'x' }, desc = 'select hunk' }
), ),
},
}) })
end, end,
}) })

View file

@ -0,0 +1,5 @@
local req = MarleyVim.local_require('plugins.treesitter')
return {
req('nvim-treesitter'),
}

View file

@ -0,0 +1,55 @@
return {
event = { 'BufReadPost', 'BufWritePost', 'BufNewFile', 'DeferredUIEnter' },
keys = {
{ '<C-space>', desc = 'increment selection' },
{ '<BS>', desc = 'decrement selection', mode = 'x' },
},
before = function()
require('lz.n').trigger_load('which-key.nvim')
end,
after = function()
require('nvim-treesitter.configs').setup({
highlight = { enable = true },
indent = { enable = true },
incremental_selection = {
enable = true,
keymaps = {
init_selection = '<C-space>',
node_incremental = '<C-space>',
scope_incremental = false,
node_decremental = '<BS>',
},
},
textobjects = {
move = {
enable = true,
goto_next_start = {
[']f'] = '@function.outer',
[']c'] = '@class.outer',
[']a'] = '@parameter.inner',
},
goto_next_end = {
[']F'] = '@function.outer',
[']C'] = '@class.outer',
[']A'] = '@parameter.inner',
},
goto_previous_tart = {
['[f'] = '@function.outer',
['[c'] = '@class.outer',
['[a'] = '@parameter.inner',
},
goto_previous_end = {
['[F'] = '@function.outer',
['[C'] = '@class.outer',
['[A'] = '@parameter.inner',
},
},
},
})
require('which-key').add({
{ '<BS>', desc = 'decrement selection', mode = 'x' },
{ '<C-space>', desc = 'increment selection', mode = { 'x', 'n' } },
})
end,
}