nixpkgs/home/programs/neovim/config/functions.vim
Daniel Siepmann 082ad58af1
Migrate neovim setup
I managed my setup manually.
This commit ports the existing setup to home-manager.

The program module is used to install neovim together with plugins.
Custom plugins are now maintained at Gitea / GitHub and loaded via nix as well.
2022-03-12 11:26:32 +01:00

117 lines
3.1 KiB
VimL
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

" Function to test a specific URL.
" Will output the response + response headers for the given URL.
function! TestUrl(url)
execute ":!wget -q -O - --no-check-certificate --server-response '" . a:url . "'"
endfunction
" Copy the current file name to clipboard
function! CopyFileName()
execute ':let @+ = expand("%:t")'
endfunction
" Copy the current relative file path to clipboard
function! CopyRelativeFilePath()
execute ':let @+ = expand("%")'
endfunction
" Copy the current full file path to clipboard
function! CopyFullFilePath()
execute ':let @+ = expand("%:p")'
endfunction
" Remove trailing whitespace
function! StripTrailingWhitespace()
execute ':%s/\s\+$//e'
endfunction
function! RemoveEmptyLines()
execute ':g/^\s*$/d'
endfunction
function! ReplaceLineBreaks()
execute ':%s/
/\r/g'
endfunction
function! SynStack()
if !exists("*synstack")
return
endif
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunc
function! <SID>SynStack()
if !exists("*synstack")
return
endif
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunc
function! StartDebugging()
call DebuggingConfiguration()
VdebugStart
endfunc
function! HiColors()
let num = 255
while num >= 0
exec 'hi col_'.num.' ctermbg='.num.' ctermfg=white'
exec 'syn match col_'.num.' "ctermbg='.num.':...." containedIn=ALL'
call append(0, 'ctermbg='.num.':....')
let num = num - 1
endwhile
endfunction
" Author: http://vimrcfu.com/snippet/116
function! Reg()
reg
echo "Register: "
let char = nr2char(getchar())
if char != "\<Esc>"
execute "normal! \"".char."p"
endif
redraw
endfunction
function! SortParagraph()
execute ":normal! vip:'<,'>sort\<esc>"
endfunction
" Generate .. _: anchor for headline. Cursor have to be on line with headline.
function! SphinxAnchor()
normal yyOPI.. _lguuA:V:s/ /-/g
llr jj
endfunction
function! OpenUrl()
if !exists('b:url')
let b:commandToOpen = exists('b:commandToOpen') ? b:commandToOpen : 'open'
let b:domain = exists('b:domain') ? b:domain : 'http://phptraining.local'
let b:documentRoot = exists('b:documentRoot') ? b:documentRoot : getcwd()
let b:path = exists('b:path') ? b:path : expand("%:p")
let b:url = substitute(b:path, b:documentRoot, b:domain, "")
endif
silent! execute "!" . b:commandToOpen . " " . b:url
endfunction
nnoremap <leader>t :call OpenUrl()<cr>
function! ConvertToTestFilename()
let l:string = @r
let l:testName = system('php /home/daniels/Projects/company/emoto2/reuterTypo3/htdocs/test.php "' . l:string . '"')
execute(':normal i' . l:testName)
endfunction
function! OpenPHPUnitTestFilename()
let l:fileExtension = expand('%:e')
let l:filePath = expand('%:r:s?Classes?Tests/Unit?')
execute(':vsplit ' . l:filePath . 'Test.' . l:fileExtension)
execute(':normal ]]')
endfunction
function! StartProfiling()
execute(':profile start profile.log')
execute(':profile func *')
execute(':profile file *')
endfunc
command! -nargs=0 Reg call Reg()