3 Komitmen 64956062cf ... 9b3d712653

Pembuat SHA1 Pesan Tanggal
  Thomas Dy 9b3d712653 nixpkgs/neovim: refactor GLg off of telescope 1 bulan lalu
  Thomas Dy 19297f95af nixpkgs/neovim: add treewalker.nvim 1 bulan lalu
  Thomas Dy f2185514cc nixpkgs/neovim: restore git branch on statusline 1 bulan lalu

+ 6 - 0
.config/nixpkgs/neovim/mappings.lua

@@ -10,6 +10,12 @@ vim.keymap.set('i', 'jj', '<ESC>', opts)
 vim.keymap.set({'n', 'v'}, 'j', 'gj', opts)
 vim.keymap.set({'n', 'v'}, 'k', 'gk', opts)
 
+-- treesitter navigation
+vim.keymap.set({ 'n', 'v' }, '<C-k>', '<cmd>Treewalker Up<cr>', opts)
+vim.keymap.set({ 'n', 'v' }, '<C-j>', '<cmd>Treewalker Down<cr>', opts)
+vim.keymap.set({ 'n', 'v' }, '<C-h>', '<cmd>Treewalker Left<cr>', opts)
+vim.keymap.set({ 'n', 'v' }, '<C-l>', '<cmd>Treewalker Right<cr>', opts)
+
 -- leave insert mode with <ESC><ESC>
 vim.keymap.set('t', '<ESC><ESC>', '<C-\\><C-N>', opts)
 vim.keymap.set('t', '<C-[><C-[>', '<C-\\><C-N>', opts)

+ 11 - 0
.config/nixpkgs/neovim/overrides/after/syntax/git.vim

@@ -0,0 +1,11 @@
+syn region gitLg start=/\%(^[|\/\\_ ]*\*[|\/\\_ ]\{-\} \%(\x\{4,\}\)\)\@=/ end=/$/ contains=@NoSpell,gitLgHash,gitLgEnd
+syn match gitLgHash /\<\x\{7,\}\>/ contained nextgroup=gitLgDecorate skipwhite
+syn match gitLgDecorate /([^)]*)/ contained
+syn match gitLgEnd /([^)]*) <[^>]*>$/ contains=gitLgAuthor,gitLgDate
+syn match gitLgDate /([^)]*)/ contained
+syn match gitLgAuthor /<[^>]*>/ contained
+
+hi def link gitLgHash gitHash
+hi def link gitLgAuthor gitIdentity
+hi def link gitLgDate gitDate
+hi def link gitLgDecorate gitReference

+ 14 - 8
.config/nixpkgs/neovim/plugins.lua

@@ -144,13 +144,6 @@ local telescope_previewers = require('telescope.previewers')
 local telescope_putils = require('telescope.previewers.utils')
 local telescope_conf = require('telescope.config').values
 
--- arbitrary git log picker
-vim.api.nvim_create_user_command('GLg', function(opts)
-  local git_command = { "git", "log", "--pretty=oneline", "--abbrev-commit" }
-  vim.list_extend(git_command, opts.fargs)
-  telescope_builtin.git_commits({ git_command = git_command })
-end, { nargs = '*', complete = vim.fn['fugitive#LogComplete'] })
-
 -- custom picker to fallback to files if no git
 _G.project_files = function()
   local ok = pcall(telescope_builtin.git_files, { show_untracked = true })
@@ -232,12 +225,17 @@ MiniDiff.setup({
   }
 })
 
+local function section_git(args)
+  if MiniStatusline.is_truncated(args.trunc_width) then return '' end
+  return vim.fn.FugitiveHead()
+end
+
 require('mini.statusline').setup({
   content = {
     -- copy-pasted from default, we just want to remove the icon
     active = function()
       local mode, mode_hl = MiniStatusline.section_mode({ trunc_width = 120 })
-      local git           = MiniStatusline.section_git({ trunc_width = 75, icon = '' })
+      local git           = section_git({ trunc_width = 75 })
       local diagnostics   = MiniStatusline.section_diagnostics({ trunc_width = 75, icon = '' })
       local filename      = MiniStatusline.section_filename({ trunc_width = 140 })
       local fileinfo      = MiniStatusline.section_fileinfo({ trunc_width = 120 })
@@ -374,6 +372,9 @@ require('treesitter-context').setup({
   multiline_threshold = 5,
 })
 
+-- Treesitter navigation
+require('treewalker').setup()
+
 -- completion
 require('blink.cmp').setup({
   cmdline = {
@@ -424,3 +425,8 @@ _G.toggle_end_char = function(char)
     vim.api.nvim_buf_set_text(0, row, -1, row, -1, { char })
   end
 end
+
+-- prettier git log, relies on additional syntax highlights
+vim.api.nvim_create_user_command('GLg', function(opts)
+  vim.cmd("Git ++curwin log --abbrev-commit --graph --pretty='%h %d %s (%cr) <%an>' " .. opts.args)
+end, { nargs = '?', complete = vim.fn['fugitive#LogComplete'] })

+ 4 - 0
.config/nixpkgs/neovim/plugins/sources.json

@@ -71,5 +71,9 @@
   "mistweaverco/kulala.nvim": {
     "rev": "8d612b2a0f8be1afa2ec5e612def3707a7dff028",
     "sha256": "11g6makp0ivy7abhg4cf5ba06zj4z46rqggpzl3pvxd1favjymhy"
+  },
+  "aaronik/treewalker.nvim": {
+    "rev": "cfae49dedd041dbe867c2b3d0b081fc381a735e9",
+    "sha256": "0iglgg23halpidapj7d4fb391ivclac0i50yq3wzs2jyv1372xmp"
   }
 }