codekingpro/portable-devtools
114k
1" Vim filetype plugin file2" Language: Go3" Maintainer: David Barnett (https://github.com/google/vim-ft-go is archived)4" Last Change: 2014 Aug 165" 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 13if exists('b:did_ftplugin')14 finish15endif16let b:did_ftplugin = 117 18let s:cpo_save = &cpo19set cpo&vim20 21setlocal formatoptions-=t22 23setlocal comments=s1:/*,mb:*,ex:*/,://24setlocal commentstring=//\ %s25setlocal keywordprg=:GoKeywordPrg26 27command! -buffer -nargs=* GoKeywordPrg call s:GoKeywordPrg()28 29let b:undo_ftplugin = 'setl fo< com< cms< kp<'30 \ . '| delcommand -buffer GoKeywordPrg'31 32if get(g:, 'go_recommended_style', 1)33 setlocal noexpandtab softtabstop=0 shiftwidth=034 let b:undo_ftplugin .= ' | setl et< sts< sw<'35endif36 37if !exists('*' . expand('<SID>') . 'GoKeywordPrg')38 func! s:GoKeywordPrg()39 let temp_isk = &l:iskeyword40 setl iskeyword+=.41 try42 let cmd = 'go doc -C ' . shellescape(expand('%:h')) . ' ' . shellescape(expand('<cword>'))43 if has('gui_running') || has('nvim')44 exe 'hor term' cmd45 else46 exe '!' . cmd47 endif48 finally49 let &l:iskeyword = temp_isk50 endtry51 endfunc52endif53 54if !exists("no_plugin_maps") && !exists("no_go_maps")55 noremap <silent> <buffer> ]] <Cmd>call <SID>GoFindSection('next_start', v:count1)<CR>56 noremap <silent> <buffer> ][ <Cmd>call <SID>GoFindSection('next_end', v:count1)<CR>57 noremap <silent> <buffer> [[ <Cmd>call <SID>GoFindSection('prev_start', v:count1)<CR>58 noremap <silent> <buffer> [] <Cmd>call <SID>GoFindSection('prev_end', v:count1)<CR>59 let b:undo_ftplugin .= ''60 \ . "| silent! exe 'unmap <buffer> ]]'"61 \ . "| silent! exe 'unmap <buffer> ]['"62 \ . "| silent! exe 'unmap <buffer> [['"63 \ . "| silent! exe 'unmap <buffer> []'"64endif65 66function! <SID>GoFindSection(dir, count)67 mark '68 let c = a:count69 while c > 070 if a:dir == 'next_start'71 keepjumps call search('^\(type\|func\)\>', 'W')72 elseif a:dir == 'next_end'73 keepjumps call search('^}', 'W')74 elseif a:dir == 'prev_start'75 keepjumps call search('^\(type\|func\)\>', 'bW')76 elseif a:dir == 'prev_end'77 keepjumps call search('^}', 'bW')78 endif79 let c -= 180 endwhile81endfunction82 83let &cpo = s:cpo_save84unlet s:cpo_save85 86" vim: sw=2 sts=2 et87 