From 202afc37eb5f75c2fc7b557cff668744b977e6ca Mon Sep 17 00:00:00 2001 From: maple-leaf Date: Fri, 28 Apr 2017 10:22:12 +0800 Subject: [PATCH 1/3] print doc to status bar instead of spliting a window if length < 120 --- script/tern.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/script/tern.py b/script/tern.py index f570d49..d727ac2 100644 --- a/script/tern.py +++ b/script/tern.py @@ -319,7 +319,11 @@ def tern_lookupDocumentation(browse=False): return result doc = ((doc and doc + "\n\n") or "") + "See " + url if doc: - vim.command("call tern#PreviewInfo(" + json.dumps(doc) + ")") + docstr = json.dumps(doc) + if len(docstr) > 120: + vim.command("call tern#PreviewInfo(" + docstr + ")") + else: + print(docstr) else: print("no documentation found") From 2cf971b5048868b72cf3c21dcec184a7aac2bea4 Mon Sep 17 00:00:00 2001 From: maple-leaf Date: Fri, 28 Apr 2017 11:03:14 +0800 Subject: [PATCH 2/3] fix non ascii chars not showing as it is --- script/tern.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/tern.py b/script/tern.py index d727ac2..3113e61 100644 --- a/script/tern.py +++ b/script/tern.py @@ -319,7 +319,7 @@ def tern_lookupDocumentation(browse=False): return result doc = ((doc and doc + "\n\n") or "") + "See " + url if doc: - docstr = json.dumps(doc) + docstr = json.dumps(doc, ensure_ascii=False) if len(docstr) > 120: vim.command("call tern#PreviewInfo(" + docstr + ")") else: From 4d5625578f331b0d6e5656b66c32d043af5fd7d7 Mon Sep 17 00:00:00 2001 From: maple-leaf Date: Tue, 2 May 2017 12:57:32 +0800 Subject: [PATCH 3/3] split doc window below while keeping user's window setting --- autoload/tern.vim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/autoload/tern.vim b/autoload/tern.vim index 15f8295..50f713b 100644 --- a/autoload/tern.vim +++ b/autoload/tern.vim @@ -21,10 +21,15 @@ endif function! tern#PreviewInfo(info) pclose + let s:originalSplitBelow = &splitbelow + set splitbelow new +setlocal\ previewwindow|setlocal\ buftype=nofile|setlocal\ noswapfile|setlocal\ wrap exe "normal z" . &previewheight . "\" call append(0, type(a:info)==type("") ? split(a:info, "\n") : a:info) wincmd p + if (s:originalSplitBelow != 1) + set nosplitbelow + endif endfunction function! tern#Complete(findstart, complWord)