mirror of
https://github.com/amix/vimrc
synced 2025-06-16 01:25:00 +08:00
Updated plugins, also experimenting with a new font
The font is IBM Plex Mono: https://ibm.github.io/type/
This commit is contained in:
@ -5,11 +5,7 @@
|
||||
let s:buf_nr = -1
|
||||
|
||||
if !exists("g:go_doc_command")
|
||||
let g:go_doc_command = "godoc"
|
||||
endif
|
||||
|
||||
if !exists("g:go_doc_options")
|
||||
let g:go_doc_options = ""
|
||||
let g:go_doc_command = ["godoc"]
|
||||
endif
|
||||
|
||||
function! go#doc#OpenBrowser(...) abort
|
||||
@ -60,12 +56,11 @@ endfunction
|
||||
function! go#doc#Open(newmode, mode, ...) abort
|
||||
" With argument: run "godoc [arg]".
|
||||
if len(a:000)
|
||||
let bin_path = go#path#CheckBinPath('godoc')
|
||||
if empty(bin_path)
|
||||
if empty(go#path#CheckBinPath(g:go_doc_command[0]))
|
||||
return
|
||||
endif
|
||||
|
||||
let command = printf("%s %s", go#util#Shellescape(bin_path), join(a:000, ' '))
|
||||
let command = printf("%s %s", go#util#Shelljoin(g:go_doc_command), join(a:000, ' '))
|
||||
let out = go#util#System(command)
|
||||
" Without argument: run gogetdoc on cursor position.
|
||||
else
|
||||
@ -85,6 +80,7 @@ endfunction
|
||||
|
||||
function! s:GodocView(newposition, position, content) abort
|
||||
" reuse existing buffer window if it exists otherwise create a new one
|
||||
let is_visible = bufexists(s:buf_nr) && bufwinnr(s:buf_nr) != -1
|
||||
if !bufexists(s:buf_nr)
|
||||
execute a:newposition
|
||||
sil file `="[Godoc]"`
|
||||
@ -96,20 +92,23 @@ function! s:GodocView(newposition, position, content) abort
|
||||
execute bufwinnr(s:buf_nr) . 'wincmd w'
|
||||
endif
|
||||
|
||||
if a:position == "split"
|
||||
" cap window height to 20, but resize it for smaller contents
|
||||
let max_height = get(g:, "go_doc_max_height", 20)
|
||||
let content_height = len(split(a:content, "\n"))
|
||||
if content_height > max_height
|
||||
exe 'resize ' . max_height
|
||||
" if window was not visible then resize it
|
||||
if !is_visible
|
||||
if a:position == "split"
|
||||
" cap window height to 20, but resize it for smaller contents
|
||||
let max_height = get(g:, "go_doc_max_height", 20)
|
||||
let content_height = len(split(a:content, "\n"))
|
||||
if content_height > max_height
|
||||
exe 'resize ' . max_height
|
||||
else
|
||||
exe 'resize ' . content_height
|
||||
endif
|
||||
else
|
||||
exe 'resize ' . content_height
|
||||
" set a sane maximum width for vertical splits. In this case the minimum
|
||||
" that fits the godoc for package http without extra linebreaks and line
|
||||
" numbers on
|
||||
exe 'vertical resize 84'
|
||||
endif
|
||||
else
|
||||
" set a sane maximum width for vertical splits. In this case the minimum
|
||||
" that fits the godoc for package http without extra linebreaks and line
|
||||
" numbers on
|
||||
exe 'vertical resize 84'
|
||||
endif
|
||||
|
||||
setlocal filetype=godoc
|
||||
@ -155,18 +154,8 @@ function! s:gogetdoc(json) abort
|
||||
let command = join(cmd, " ")
|
||||
|
||||
if &modified
|
||||
" gogetdoc supports the same archive format as guru for dealing with
|
||||
" modified buffers.
|
||||
" use the -modified flag
|
||||
" write each archive entry on stdin as:
|
||||
" filename followed by newline
|
||||
" file size followed by newline
|
||||
" file contents
|
||||
let in = ""
|
||||
let content = join(go#util#GetLines(), "\n")
|
||||
let in = fname . "\n" . strlen(content) . "\n" . content
|
||||
let command .= " -modified"
|
||||
let out = go#util#System(command, in)
|
||||
let out = go#util#System(command, go#util#archive())
|
||||
else
|
||||
let out = go#util#System(command)
|
||||
endif
|
||||
|
Reference in New Issue
Block a user