summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2021-07-15 22:54:13 +0000
committerbrian m. carlson <sandals@crustytoothpaste.net>2021-07-16 01:01:50 +0000
commitfbd41ca7e3e2a2e5eabb8f5c6fc82ec4b479c961 (patch)
tree8abc80c8331cdabdb7426fc69f37ec40db60f9bb
parentb0da2cd48826fd033d9988e0a4318ec40450a15e (diff)
vimrc: adjusst settings for neovim-gtk
In case we're using neovim-gtk, let's set the GUI settings appropriately. Neovim does things a little differently and we won't know that we're in GUI mode until after the .vimrc has already been read, so let's set up a UIEnter autocommand to trigger when the GUI is loaded and set the proper settings. However, the UIEnter command also happens to be invoked when we're using a TTY, and we don't want to adjust the number of lines or columns when using a TTY. Detect that we're using a GUI because we're using Neovim, our standard output isn't a TTY, and we're in vi mode. The latter is required because if we're at the command line but really lack a TTY (e.g., with a dumb terminal), we'll be in ex mode and won't want to try to modify the terminal settings. Because this is all a little complex, let's move the code to a function, and move the GUI code to the bottom of the file so that the function is defined before using it. The top portion of the file must function even when we're in a tiny version of Vim with no scripting support, so we cannot define the function there. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
-rw-r--r--vim/vimrc43
1 files changed, 29 insertions, 14 deletions
diff --git a/vim/vimrc b/vim/vimrc
index 2b6643b..66e9096 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -65,20 +65,6 @@ if has("termguicolors") && exists("$COLORTERM") && $COLORTERM == "truecolor"
set tgc
end
-" GUI settings.
-if has("gui_running")
- set lines=24
- set co=133
- set gcr+=a:blinkon0
- set go-=tT " Disable tearoffs and toolbar.
-endif
-if has("gui_gtk")
- set gfn=Source\ Code\ Pro\ 12,Noto\ Mono\ Regular\ 12,Monospace\ 12
-endif
-if has("gui_macvim")
- set gfn=SourceCodePro-Regular:h8
-endif
-
"" Terminal issues.
" These terminals are capable of supporting 16 colors, but they lie and only
" claim support for 8. Fix it so things don't look ugly.
@@ -531,6 +517,25 @@ function! s:ToggleScreenSize()
endif
endfunction
+function! s:SetGUIOptions()
+ if has("gui_running") || (has("nvim") && !has("ttyout") && s:mode == 'vi')
+ set lines=24
+ set co=133
+ set gcr+=a:blinkon0
+ set go-=tT " Disable tearoffs and toolbar.
+
+ if has("gui_gtk")
+ set gfn=Source\ Code\ Pro\ 12,Noto\ Mono\ Regular\ 12,Monospace\ 12
+ endif
+ if has("gui_macvim")
+ set gfn=SourceCodePro-Regular:h8
+ endif
+ if has("nvim")
+ Guifont SourceCodePro:h12
+ endif
+ endif
+endfunction
+
function! s:SortLSPRoots(a, b)
" Sort the longest items first, since these will be more specific.
let x = len(a:b) - len(a:a)
@@ -636,4 +641,14 @@ let g:ale_rust_cargo_use_clippy = isdirectory(expand("$HOME") . '/.cargo')
"" Other language-specific setup.
call s:SetUpLanguageHooks()
+" GUI settings.
+if has("gui_running")
+ call <SID>SetGUIOptions()
+endif
+if has("nvim")
+ augroup gui
+ au UIEnter * call <SID>SetGUIOptions()
+ augroup end
+endif
+
" vim: set ts=2 sw=2 sts=2: