Add commands SynStack and Hi for easier colorscheme edits
dblume

dblume commited on 2024-04-16 09:08:04
Showing 2 changed files, with 26 additions and 4 deletions.


Since I'm apparently going to be tweaking color themes, may as well
add a "Hi" (highlight) command to display the current syntax/highlight
info.
... ...
@@ -328,10 +328,16 @@ set omnifunc=syntaxcomplete#Complete
328 328
 " Omni completion via ctrl-space (in addition to ctrl-x ctrl-o)
329 329
 inoremap <C-Space> <C-x><C-o>
330 330
 
331
-" See https://wiki.dlma.com/neovim#cscope
332
-"lua << EOF
333
-"require("cscope_maps").setup()
334
-"EOF
331
+" These two commands display syntax/highlight info for what's under the cursor.
332
+if exists(":SynStack") != 2
333
+    command SynStack :echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
334
+endif
335
+
336
+function! SynGroup()
337
+    let l:s = synID(line('.'), col('.'), 1)
338
+    echo synIDattr(l:s, 'name') . ' -> ' . synIDattr(synIDtrans(l:s), 'name')
339
+endfun
340
+command Hi :call SynGroup()
335 341
 
336 342
 " From https://stackoverflow.com/questions/15393301/how-to-automatically-sort-quickfix-entries-by-line-text-in-vim
337 343
 " :grep term %
... ...
@@ -392,6 +398,11 @@ let g:rooter_patterns = ['.git', 'Makefile', 'builds/']
392 398
 let g:rooter_cd_cmd = 'lcd'
393 399
 let g:rooter_manual_only = 1
394 400
 
401
+" See https://wiki.dlma.com/neovim#cscope
402
+lua << EOF
403
+  require('cscope_maps').setup()
404
+EOF
405
+
395 406
 " In some environments, Vim starts in replace mode:
396 407
 " https://superuser.com/questions/1284561/why-is-vim-starting-in-replace-mode
397 408
 " set t_u7=
... ...
@@ -349,6 +349,17 @@ set omnifunc=syntaxcomplete#Complete
349 349
 " Omni completion via ctrl-space (in addition to ctrl-x ctrl-o)
350 350
 inoremap <Nul> <C-x><C-o>
351 351
 
352
+" These two commands display syntax/highlight info for what's under the cursor.
353
+if exists(":SynStack") != 2
354
+    command SynStack :echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
355
+endif
356
+
357
+function! SynGroup()
358
+    let l:s = synID(line('.'), col('.'), 1)
359
+    echo synIDattr(l:s, 'name') . ' -> ' . synIDattr(synIDtrans(l:s), 'name')
360
+endfun
361
+command Hi :call SynGroup()
362
+
352 363
 " cscope
353 364
 if has("cscope")
354 365
     set cscopetag  " Use both cscope and ctag for 'ctrl-]'
355 366