From c63915c829affced69f20d0ea0bcd32a71088d68 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 9 Jul 2018 01:41:50 +1200 Subject: Revert :setglobal changes I thought that global options were the defaults for local options for new buffers, but that does not seem to be the case. Instead, reload the filetype for the active buffer in the reload guard. I wonder what the point of :setglobal even is? --- vim/vimrc | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) (limited to 'vim/vimrc') diff --git a/vim/vimrc b/vim/vimrc index c08ec677..199dd85b 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -32,15 +32,15 @@ if has('syntax') && !exists('g:syntax_on') endif " The all-important default indent settings; filetypes to tweak -setglobal autoindent " Use indent of previous line on new lines -setglobal expandtab " Use spaces instead of tabs -setglobal shiftwidth=4 " Indent with four spaces +set autoindent " Use indent of previous line on new lines +set expandtab " Use spaces instead of tabs +set shiftwidth=4 " Indent with four spaces " Spaces to insert on Tab key insert if v:version > 703 || v:version == 703 && has('patch693') - setglobal softtabstop=-1 " Refer to 'shiftwidth' if supported + set softtabstop=-1 " Refer to 'shiftwidth' if supported else - setglobal softtabstop=4 " Otherwise just four spaces + set softtabstop=4 " Otherwise just four spaces endif " Let me backspace over pretty much anything @@ -69,14 +69,14 @@ endif " Delete comment leaders when joining lines, if supported if v:version > 703 || v:version == 703 && has('patch541') - setglobal formatoptions+=j + set formatoptions+=j endif " Keep more command and search history set history=500 " Don't assume I'm editing C; let the filetype set this -setglobal include= +set include= " Don't join lines with two spaces at the end of sentences set nojoinspaces @@ -99,13 +99,13 @@ if v:version >= 700 endif " Add angle brackets to pairs of matched characters -setglobal matchpairs+=<:> +set matchpairs+=<:> " Don't allow setting options via buffer content -setglobal nomodeline +set nomodeline " Treat numbers with a leading zero as decimal, not octal -setglobal nrformats-=octal +set nrformats-=octal " Abbreviate some more regularly displayed messages set shortmess+=I " Don't show startup splash screen @@ -115,7 +115,7 @@ set shortmess+=w " written -> [w], appended -> [a] " Clear default 'comments' value, let the filetype handle it if has('comments') - setglobal comments= + set comments= endif " Highlight settings for search @@ -127,7 +127,7 @@ endif " More sensible language-agnostic setting for gf/:find if has('file_in_path') - setglobal path=.,,** + set path=.,,** endif " Don't load GUI menus; set here before GUI starts @@ -137,10 +137,10 @@ endif " Line break behaviour settings for 'wrap' if has('linebreak') - setglobal linebreak " Break lines at word boundaries - set showbreak=... " Prefix wrapped rows with three dots + set linebreak " Break lines at word boundaries + set showbreak=... " Prefix wrapped rows with three dots if exists('+breakindent') - setglobal breakindent " Indent wrapped lines, if supported + set breakindent " Indent wrapped lines, if supported endif endif @@ -300,10 +300,14 @@ nnoremap :enew " Source any .vim files from ~/.vim/config runtime! config/*.vim -" Flag that we loaded, tell the user if we reload -if 1 - if exists('g:loaded_vimrc') - echomsg 'Reloaded vimrc: '.$MYVIMRC +" If we reloaded, reload filetype detection for the active buffer too, so that +" any local settings for it are restored +if exists('g:loaded_vimrc') + if &filetype != '' + doautocmd filetypedetect BufRead endif + echomsg 'Reloaded vimrc: '.$MYVIMRC +endif +if 1 let g:loaded_vimrc = 1 endif -- cgit v1.2.3