1616< link rel ="stylesheet " href ="/book.min.0379377fb17315c9a560efd4d406aea4535c095a461b220fd9e3d2e9c05550e6.css " integrity ="sha256-A3k3f7FzFcmlYO/U1AaupFNcCVpGGyIP2ePS6cBVUOY= ">
1717
1818
19- < script defer src ="/en.search.min.b0eae01fffe660cbcd1b9d6a59c1a158fac818c2554422bf73f2eba170e38f2a .js " integrity ="sha256-sOrgH//mYMvNG51qWcGhWPrIGMJVRCK/c/LroXDjjyo = "> </ script >
19+ < script defer src ="/en.search.min.6fd424a94e58b4ed84c154c9bf99d72f047db2bac5993f39795d63ab194e211b .js " integrity ="sha256-b9QkqU5YtO2EwVTJv5nXLwR9srrFmT85eV1jqxlOIRs = "> </ script >
2020
2121< link rel ="alternate " type ="application/rss+xml " href ="http://jacobsimpson.github.io/docs/interacting/index.xml " title ="Scripting Neovim with Lua " />
2222<!--
@@ -253,8 +253,7 @@ <h2 id="echo">Echo</h2>
253253
254254< p > To put a message at the bottom of the screen, and in the < code > :messages</ code > buffer:</ p >
255255
256- < pre > < code class ="language-lua "> print("Something really important.")
257- </ code > </ pre >
256+ < div class ="highlight "> < pre style ="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4 "> < code class ="language-lua " data-lang ="lua "> print(< span style ="color:#e6db74 "> "Something really important."</ span > )</ code > </ pre > </ div >
258257
259258< p > This is analogous to the < code > echo</ code > command in VimScript.</ p >
260259
@@ -270,14 +269,23 @@ <h4 id="a-floating-window-with-borders">A Floating Window with Borders</h4>
270269
271270< h4 id ="for-a-tool-tip "> For a tool tip</ h4 >
272271
273- < pre > < code class ="language-lua "> let buf = nvim_create_buf(v:false, v:true)
274- call nvim_buf_set_lines(buf, 0, -1, v:true, ["test", "text"])
275- let opts = {'relative': 'cursor', 'width': 10, 'height': 2, 'col': 0,
276- \ 'row': 1, 'anchor': 'NW', 'style': 'minimal'}
277- let win = nvim_open_win(buf, 0, opts)
278- " optional: change highlight, otherwise Pmenu is used
279- call nvim_win_set_option(win, 'winhl', 'Normal:MyHighlight')
280- </ code > </ pre >
272+ < p > This uses Neovim’s new floating window capability to overlay a window. The
273+ window is backed by a buffer containing the two lines, “test” and “text”.</ p >
274+
275+ < div class ="highlight "> < pre style ="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4 "> < code class ="language-lua " data-lang ="lua "> < span style ="color:#66d9ef "> local</ span > buf < span style ="color:#f92672 "> =</ span > vim.api.nvim_create_buf(< span style ="color:#66d9ef "> false</ span > , < span style ="color:#66d9ef "> true</ span > )
276+ vim.api.nvim_buf_set_lines(buf, < span style ="color:#ae81ff "> 0</ span > , < span style ="color:#f92672 "> -</ span > < span style ="color:#ae81ff "> 1</ span > , < span style ="color:#66d9ef "> true</ span > , {< span style ="color:#e6db74 "> "test"</ span > , < span style ="color:#e6db74 "> "text"</ span > })
277+ < span style ="color:#66d9ef "> local</ span > opts < span style ="color:#f92672 "> =</ span > {
278+ relative < span style ="color:#f92672 "> =</ span > < span style ="color:#e6db74 "> 'cursor'</ span > ,
279+ width < span style ="color:#f92672 "> =</ span > < span style ="color:#ae81ff "> 10</ span > ,
280+ height < span style ="color:#f92672 "> =</ span > < span style ="color:#ae81ff "> 2</ span > ,
281+ col < span style ="color:#f92672 "> =</ span > < span style ="color:#ae81ff "> 0</ span > ,
282+ row < span style ="color:#f92672 "> =</ span > < span style ="color:#ae81ff "> 1</ span > ,
283+ anchor < span style ="color:#f92672 "> =</ span > < span style ="color:#e6db74 "> 'NW'</ span > ,
284+ style < span style ="color:#f92672 "> =</ span > < span style ="color:#e6db74 "> 'minimal'</ span >
285+ }
286+ < span style ="color:#66d9ef "> local</ span > win < span style ="color:#f92672 "> =</ span > vim.api.nvim_open_win(buf, < span style ="color:#ae81ff "> 0</ span > , opts)
287+ < span style ="color:#75715e "> -- optional: change highlight, otherwise Pmenu is used</ span >
288+ vim.api.nvim_win_set_option(win, < span style ="color:#e6db74 "> 'winhl'</ span > , < span style ="color:#e6db74 "> 'Normal:MyHighlight'</ span > )</ code > </ pre > </ div >
281289</ article >
282290
283291 < div class ="book-footer justify-between ">
0 commit comments