Bug 265502 - editors/vim: provided vimrc duplicates config from "source $VIMRUNTIME/defaults.vim"
Summary: editors/vim: provided vimrc duplicates config from "source $VIMRUNTIME/defaul...
Status: Closed Works As Intended
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Adam Weinberger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-07-29 14:40 UTC by Michael Osipov
Modified: 2022-08-01 16:27 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (adamw)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Osipov 2022-07-29 14:40:50 UTC
$VIMRUNTIME/defaults.vim already contains

============
if &compatible
  set nocompatible
endif
set backspace=indent,eol,start
set display=truncate
set ruler
set wildmenu
if &t_Co > 2 || has("gui_running")
  " Revert with ":syntax off".
  syntax on
endif
============

Please review and trim down as necessary.
Comment 1 Michael Osipov 2022-08-01 08:03:46 UTC
I believe that this patch should do it:
root@deblndw013x3j:/usr/local/etc/vim
# diff vimrc.sample vimrc | pcdiff
--- vimrc.sample    2022-07-06 14:46:54.191216000 +0200
+++ vimrc   2022-08-01 09:53:53.585717000 +0200
@@ -3,25 +3,13 @@
 source $VIMRUNTIME/defaults.vim
 let skip_defaults_vim = 1

-set nocompatible      " Enable Vim mode (instead of vi emulation)
-
 let g:is_posix = 1    " Our /bin/sh is POSIX, not bash
 set autoindent        " Intelligent indentation matching
 set autoread          " Update the file if it's changed externally
-set backspace=indent,eol,start  " Allow backspacing over anything
 set belloff=all       " Turn off bells
-set display=truncate  " Show '@@@' when the last screen line overflows
 set formatoptions+=j  " Delete comment char when joining lines
-set history=100       " Undo up to this many commands
 set hlsearch          " Highlight search results
-set incsearch         " Highlight search matches as you type them
-set ruler             " Show cursor position
 set ttyfast           " Redraw faster for smoother scrolling
-set wildmenu          " Show menu for tab completion in command mode
-
-try
-    syntax on         " Enable syntax highlighting
-catch | endtry        " vim-tiny is installed without the syntax files

 if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
     set fileencodings=ucs-bom,utf-8,latin1
Comment 2 Adam Weinberger freebsd_committer freebsd_triage 2022-08-01 13:37:35 UTC
Hi Michael,

Unfortunately, this won't work for vim-tiny. The vim-tiny package installs an empty $VIMRUNTIME/defaults.vim and relies entirely on the settings in our vimrc.

If we install vim's defaults.vim for vim-tiny, then it errors on a missing syntax.vim. If we install the syntax.vim, it errors for missing syntax files. The only way to keep vim-tiny with no runtime is to skip vim's defaults.vim entirely.

So, if anything, perhaps //more// settings should be considered for duplication into our provided vimrc.

I'm glad you brought this up, though. I'm going to put a comment into our vimrc explaining why the unusual duplication takes place.
Comment 3 commit-hook freebsd_committer freebsd_triage 2022-08-01 13:48:36 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=8380febbf30620bc0833a9eac823b54f4799ad49

commit 8380febbf30620bc0833a9eac823b54f4799ad49
Author:     Adam Weinberger <adamw@FreeBSD.org>
AuthorDate: 2022-08-01 13:44:44 +0000
Commit:     Adam Weinberger <adamw@FreeBSD.org>
CommitDate: 2022-08-01 13:47:55 +0000

    editors/vim: Add some explanatory comments to the vimrc

    Our vimrc duplicates settings from $VIMRUNTIME/defaults.vim, which
    appears odd.

    However, it's actually required because of vim-tiny. vim-tiny installs
    an empty defaults.vim stub, meaning that it only gets the settings that
    appear in our vimrc.

    PR:             265502

 editors/vim/files/vimrc | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
Comment 4 Michael Osipov 2022-08-01 16:27:21 UTC
(In reply to Adam Weinberger from comment #2)

Adam, this explanation is good enough for me. Thank you!