]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(go): add recommended indent options to ftplugin
authormarkmacode <code@mamo.aleeas.com>
Tue, 16 Jul 2024 19:20:34 +0000 (21:20 +0200)
committerChristian Brabandt <cb@256bit.org>
Tue, 16 Jul 2024 19:26:47 +0000 (21:26 +0200)
related: #15264

Signed-off-by: markmacode <code@mamo.aleeas.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/doc/filetype.txt
runtime/ftplugin/go.vim

index 1885f86882f8695c806cb3a5b884754386af950f..6c706b1775abd9042e14cde9f4a37c750db03c48 100644 (file)
@@ -1,4 +1,4 @@
-*filetype.txt* For Vim version 9.1.  Last change: 2024 Jul 15
+*filetype.txt* For Vim version 9.1.  Last change: 2024 Jul 16
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -641,6 +641,17 @@ in the preview window.  It is equivalent to calling "git diff --cached" plus
 any arguments given to the command.
 
 
+GO                                                     *ft-go-plugin*
+
+By default the following options are set, based on Golang official docs: >
+
+       setlocal noexpandtab softtabstop=0 shiftwidth=0
+
+To disable this behavior, set the following variable in your vimrc: >
+
+       let g:go_recommended_style = 0
+
+
 GPROF                                                  *ft-gprof-plugin*
 
 The gprof filetype plugin defines a mapping <C-]> to jump from a function
index 61dc1a13b79a1d926aff38edeb4516323a5b2104..75f78cfa4b90bbc2b2fd61dcf9999f9ddd120186 100644 (file)
@@ -2,6 +2,7 @@
 " Language:    Go
 " 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)
 
 if exists('b:did_ftplugin')
   finish
@@ -15,4 +16,9 @@ setlocal commentstring=//\ %s
 
 let b:undo_ftplugin = 'setl fo< com< cms<'
 
+if get(g:, 'go_recommended_style', 1)
+  setlocal noexpandtab softtabstop=0 shiftwidth=0
+  let b:undo_ftplugin ..= ' | setl et< sts< sw<'
+endif
+
 " vim: sw=2 sts=2 et