robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
7945732ed7
master
1" Vim filetype plugin file 2" Language: Go 3" Maintainer: David Barnett (https://github.com/google/vim-ft-go is archived) 4" Last Change: 2014 Aug 16 5" 2024 Jul 16 by Vim Project (add recommended indent style) 6" 2025 Mar 07 by Vim Project (add formatprg and keywordprg option #16804) 7" 2025 Mar 18 by Vim Project (use :term for 'keywordprg' #16911) 8" 2025 Apr 16 by Vim Project (set 'cpoptions' for line continuation, #17121) 9" 2025 Jul 02 by Vim Project (add section movement mappings #17641) 10" 2025 Jul 05 by Vim Project (update b:undo_ftplugin #17664) 11" 2026 Feb 13 by Vim Project (remove formatprg #19108) 12" 2026 Jun 27 by Vim Project (normalize recommended style guard) 13 14if exists ( 'b:did_ftplugin' ) 15finish 16endif 17let b: did_ftplugin = 1 18 19let s: cpo_save = & cpo 20set cpo & vim 21 22setlocal formatoptions -= t 23 24setlocal comments = s1:/*,mb:*,ex:*/,:// 25setlocal commentstring = //\ %s 26setlocal keywordprg = :GoKeywordPrg 27 28command ! -buffer -nargs = * GoKeywordPrg call s:GoKeywordPrg() 29 30let b: undo_ftplugin = 'setl fo< com< cms< kp<' 31 \. '| delcommand -buffer GoKeywordPrg' 32 33if get ( g:, 'go_recommended_style' , 34 \get ( g:, 'filetype_recommended_style' , 1 )) 35setlocal noexpandtab softtabstop = 0 shiftwidth = 0 36let b: undo_ftplugin .= ' | setl et< sts< sw<' 37endif 38 39if ! exists ( '*' . expand ( '<SID>' ) . 'GoKeywordPrg' ) 40func ! s: GoKeywordPrg () 41let temp_isk = & l: iskeyword 42setl iskeyword += . 43try 44let cmd = 'go doc -C ' . shellescape ( expand ( '%:h' )) . ' ' . shellescape ( expand ( '<cword>' )) 45if has ( 'gui_running' ) || has ( 'nvim' ) 46exe 'hor term' cmd 47else 48exe '!' . cmd 49endif 50finally 51let & l: iskeyword = temp_isk 52endtry 53endfunc 54endif 55 56if ! exists ( "no_plugin_maps" ) && ! exists ( "no_go_maps" ) 57noremap <silent> <buffer> ]]<Cmd> call <SID> GoFindSection ( 'next_start' , v: count1 ) <CR> 58noremap <silent> <buffer> ][<Cmd> call <SID> GoFindSection ( 'next_end' , v: count1 ) <CR> 59noremap <silent> <buffer> [[<Cmd> call <SID> GoFindSection ( 'prev_start' , v: count1 ) <CR> 60noremap <silent> <buffer> []<Cmd> call <SID> GoFindSection ( 'prev_end' , v: count1 ) <CR> 61let b: undo_ftplugin .= '' 62 \. "| silent! exe 'unmap <buffer> ]]'" 63 \. "| silent! exe 'unmap <buffer> ]['" 64 \. "| silent! exe 'unmap <buffer> [['" 65 \. "| silent! exe 'unmap <buffer> []'" 66endif 67 68function ! <SID> GoFindSection ( dir , count ) 69mark ' 70let c = a: count 71while c > 0 72if a: dir == 'next_start' 73keepjumps call search('^\(type\|func\)\>','W' ) 74elseif a: dir == 'next_end' 75keepjumps call search('^}','W' ) 76elseif a: dir == 'prev_start' 77keepjumps call search('^\(type\|func\)\>','bW' ) 78elseif a: dir == 'prev_end' 79keepjumps call search('^}','bW' ) 80endif 81let c -= 1 82endwhile 83endfunction 84 85let & cpo = s: cpo_save 86unlet s: cpo_save 87 88" vim: sw=2 sts=2 et