You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

112 lines
3.4 KiB

function! SynGroup()
let l:s = synID(line('.'), col('.'), 1)
echo synIDattr(l:s, 'name') . ' -> ' . synIDattr(synIDtrans(l:s), 'name')
endfun
function! SynStack ()
for i1 in synstack(line("."), col("."))
let i2 = synIDtrans(i1)
let n1 = synIDattr(i1, "name")
let n2 = synIDattr(i2, "name")
echo n1 "->" n2
endfor
endfunction
" autocmd BufNewFile,BufRead *.php,*.blade.php set filetype=php
" autocmd BufEnter * nested :call tagbar#autoopen(0)
autocmd FileType * :lua nukevim.modules:get('keymap'):registerBufferLocal()
" Disable whitespace highlighting in startup screen
autocmd FileType startup setlocal nolist
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Netrw key mappings
" Special case for mapping ctrl l/r in netrw since it already has those bound
" to stuff I don't use.
augroup netrw_mapping
autocmd!
autocmd filetype netrw call NetrwMapping()
augroup END
function! NetrwMapping()
noremap <buffer> <C-H> :tabprev<CR>
noremap <buffer> <C-L> :tabnext<CR>
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Terminals
" Some junk to make the terminal buffers exist when the underlying app exits.
" Get the exit status from a terminal buffer by looking for a line near the end
" of the buffer with the format, '[Process exited ?]'.
func! s:getExitStatus() abort
let ln = line('$')
" The terminal buffer includes several empty lines after the 'Process exited'
" line that need to be skipped over.
while ln >= 1
let l = getline(ln)
let ln -= 1
let exitCode = substitute(l, '^\[Process exited \([0-9]\+\)\]$', '\1', '')
if l != '' && l == exitCode
" The pattern did not match, and the line was not empty. It looks like
" there is no process exit message in this buffer.
break
elseif exitCode != ''
return str2nr(exitCode)
endif
endwhile
return 255
" throw 'Could not determine exit status for buffer, ' . expand('%')
endfunc
func! s:afterTermClose() abort
if s:getExitStatus() == 0
bdelete!
endif
endfunc
augroup terminal
autocmd!
" The line '[Process exited ?]' is appended to the terminal buffer after the
" `TermClose` event. So we use a timer to wait a few milliseconds to read the
" exit status. Setting the timer to 0 or 1 ms is not sufficient; 20 ms seems
" to work for me.
autocmd TermClose * call timer_start(20, { -> s:afterTermClose() })
augroup END
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" vim-commentary
" Map Ctrl+/ in visual mode to toggle block comments with vim-commentary
:vmap  gc
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" coc
" `K` shows method signature/documentation
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
elseif (coc#rpc#ready())
call CocActionAsync('doHover')
else
execute '!' . &keywordprg . " " . expand('<cword>')
endif
endfunction
nnoremap <silent> K :call <SID>show_documentation()<CR>
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" Merge the signal column (your shit broke, yo') into the number column,
" or if not supported at least show it all the time so the whole text
" isn't constantly shifting as errors appear/disappear.
if has("patch-8.1.1564")
set signcolumn=number
else
set signcolumn=yes
endif