diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..0b7a5bf --- /dev/null +++ b/init.lua @@ -0,0 +1,18 @@ +nukevim = require('nukevim'):new() + +nukevim:enableCaching() +nukevim:initialize() +nukevim:run() + +vim.api.nvim_create_autocmd("VimResized", { + command = "lua nukevim:gui()" +}) + + +-- Should be able to do this with vim.api.nvim_add_user_command but +-- that doesn't seem to exist for some reason +vim.cmd[[ command! NukeVimInstall :lua nukevim:install() ]] + +-- Include a vimscript file so you can use all of this without having to migrate +-- literally everything day 1. +vim.cmd('source ' .. vim.env.MYVIMRC:sub(1, -9) .. 'startup.vim') diff --git a/startup.vim b/startup.vim new file mode 100644 index 0000000..1123e6a --- /dev/null +++ b/startup.vim @@ -0,0 +1,112 @@ + +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 :tabprev + noremap :tabnext +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('') + elseif (coc#rpc#ready()) + call CocActionAsync('doHover') + else + execute '!' . &keywordprg . " " . expand('') + endif +endfunction +nnoremap K :call show_documentation() + +" 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