aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Clason <c.clason@uni-graz.at>2025-03-08 11:56:36 +0100
committerChristian Clason <ch.clason+github@icloud.com>2025-03-08 12:43:53 +0100
commitd5ff0aff27438829b0810cc70dec9e63cb53c1db (patch)
treeded1a0ceb16a1b246b8bf38566c6a93ee71174cc
parentb2fa51bf15252cced8032f5a995ba5252840d7d0 (diff)
downloadrneovim-d5ff0aff27438829b0810cc70dec9e63cb53c1db.tar.gz
rneovim-d5ff0aff27438829b0810cc70dec9e63cb53c1db.tar.bz2
rneovim-d5ff0aff27438829b0810cc70dec9e63cb53c1db.zip
vim-patch:62e8228: runtime(go): add 'keywordprg' and 'formatprg' to ftplugin
closes: vim/vim#16804 https://github.com/vim/vim/commit/62e822808e364c84e8abfbc4827bf6012e5b32e0 Co-authored-by: Phạm Bình An <phambinhanctb2004@gmail.com>
-rw-r--r--runtime/ftplugin/go.vim27
1 files changed, 26 insertions, 1 deletions
diff --git a/runtime/ftplugin/go.vim b/runtime/ftplugin/go.vim
index 75f78cfa4b..b83db424bd 100644
--- a/runtime/ftplugin/go.vim
+++ b/runtime/ftplugin/go.vim
@@ -3,6 +3,7 @@
" Maintainer: David Barnett (https://github.com/google/vim-ft-go)
" Last Change: 2014 Aug 16
" 2024 Jul 16 by Vim Project (add recommended indent style)
+" 2025 Mar 07 by Vim Project (add formatprg and keywordprg option #16804)
if exists('b:did_ftplugin')
finish
@@ -10,15 +11,39 @@ endif
let b:did_ftplugin = 1
setlocal formatoptions-=t
+setlocal formatprg=gofmt
setlocal comments=s1:/*,mb:*,ex:*/,://
setlocal commentstring=//\ %s
+setlocal keywordprg=:GoKeywordPrg
-let b:undo_ftplugin = 'setl fo< com< cms<'
+command! -buffer -nargs=* GoKeywordPrg call s:GoKeywordPrg()
+
+let b:undo_ftplugin = 'setl fo< com< cms< fp< kp<'
+ \ . '| delcommand -buffer GoKeywordPrg'
if get(g:, 'go_recommended_style', 1)
setlocal noexpandtab softtabstop=0 shiftwidth=0
let b:undo_ftplugin ..= ' | setl et< sts< sw<'
endif
+if !exists('*' .. expand('<SID>') .. 'GoKeywordPrg')
+ func! s:GoKeywordPrg()
+ let temp_isk = &l:iskeyword
+ setl iskeyword+=.
+ try
+ let cmd = 'go doc -C ' . shellescape(expand('%:h')) . ' ' . shellescape(expand('<cword>'))
+ if has('nvim')
+ exe "term" cmd
+ startinsert
+ tmap <buffer> <Esc> <Cmd>call jobstop(&channel) <Bar> bdelete<CR>
+ else
+ exe '!' . cmd
+ endif
+ finally
+ let &l:iskeyword = temp_isk
+ endtry
+ endfunc
+endif
+
" vim: sw=2 sts=2 et