mirror of
https://github.com/foo-dogsquared/wiki.git
synced 2025-02-07 09:18:59 +00:00
33 lines
20 KiB
HTML
33 lines
20 KiB
HTML
|
<!DOCTYPE html><html><head><meta name="viewport" content="width=device-width"/><meta charSet="utf-8"/><title>Neovim Lua integration</title><script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script><script id="MathJax-script" async="" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script><script type="text/x-mathjax-config">
|
||
|
MathJax = {
|
||
|
tex: {
|
||
|
inlineMath: [ ['$','$'], ['\(','\)'] ],
|
||
|
displayMath: [ ['$$','$$'], ['[',']'] ]
|
||
|
},
|
||
|
options = {
|
||
|
processHtmlClass = "math"
|
||
|
}
|
||
|
}
|
||
|
</script><meta name="next-head-count" content="6"/><link rel="preload" href="/wiki/_next/static/css/52fc2ba29703df73922c.css" as="style"/><link rel="stylesheet" href="/wiki/_next/static/css/52fc2ba29703df73922c.css" data-n-g=""/><noscript data-n-css=""></noscript><link rel="preload" href="/wiki/_next/static/chunks/main-ae4733327bd95c4ac325.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/webpack-50bee04d1dc61f8adf5b.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/framework.9d524150d48315f49e80.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/commons.0e1c3f9aa780c2dfe9f0.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/pages/_app-8e3d0c58a60ec788aa69.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/940643274e605e7596ecea1f2ff8d83317a3fb76.4841a16762f602a59f00.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/pages/%5B%5B...slug%5D%5D-1aa198f87ede1cd0e1dc.js" as="script"/></head><body><div id="__next"><main><h1>Neovim Lua integration</h1><section class="post-metadata"><span>Date: <!-- -->2021-07-15 07:45:50 +08:00</span><span>Date modified: <!-- -->2022-04-20 21:19:43 +08:00</span></section><nav class="toc"><ol class="toc-level toc-level-1"><li class="toc-item toc-item-h1"><a href="/wiki/editor.neovim.lua#setting-configuration-with-lua" class="toc-link toc-link-h1">Setting configuration with Lua</a></li><li class="toc-item toc-item-h1"><a href="/wiki/editor.neovim.lua#real-life-examples-making-use-of-neovim-lua-api" class="toc-link toc-link-h1">Real-life examples making use of Neovim Lua API</a></li></ol></nav><ul><li><p>with Lua integration, you can create <a href="/wiki/editor.neovim.lua-modules">Neovim Lua modules</a></p></li><li><p>you can start with <code class="inline-verbatim">lua-intro</code> section from <a href="/wiki/editor.neovim.help-system">Neovim help system</a>;
|
||
|
it gives all of the information on the things you need to get started with configuring Neovim with Lua as well as pointers for more things to do with Lua;
|
||
|
</p></li><li><p>Neovim also extends the Lua standard library found in <code class="inline-verbatim">vim</code> object;
|
||
|
see the <code class="inline-verbatim">lua-stdlib</code> in <a href="/wiki/editor.neovim.help-system">Neovim help system</a></p></li></ul><h1 id="setting-configuration-with-lua">Setting configuration with Lua</h1><p>There are some equivalent setting values in Lua versus Vimscript.
|
||
|
For more information, see the <code class="inline-verbatim">lua-vimscript</code> help section.
|
||
|
</p><table><thead><tr><th>Description</th><th>Vimscript statement</th><th>Lua equivalent</th></tr></thead><tbody><tr><td>Setting options</td><td><code class="inline-code">set number relativenumber</code></td><td><code class="inline-code">vim.opt.number, vim.opt.relativenumber = true, true</code></td></tr><tr><td>Setting local options</td><td><code class="inline-code">setlocal spell</code></td><td><code class="inline-code">vim.opt_local.spell = true</code></td></tr><tr><td>Running Vimscript commands</td><td><code class="inline-code">colorscheme nord</code></td><td><code class="inline-code">vim.cmd "colorscheme nord"</code></td></tr><tr><td>Setting buffer-specific options</td><td><code class="inline-code">b:ale-enabled=1</code></td><td><code class="inline-code">vim.b["ale-enabled"] = 1</code></td></tr></tbody></table><p>Some more general things you generally want to know:
|
||
|
</p><ul><li><p>You can still execute Vimscript with <code class="inline-verbatim">vim.cmd</code>.
|
||
|
For more information, see <code class="inline-verbatim">:h lua-vimscript</code> from the help system.
|
||
|
</p></li><li><p>You can access environment variables through <code class="inline-verbatim">vim.env</code> — e.g., <code class="inline-code">vim.env.HOME</code>, <code class="inline-code">vim.env.MYVIMRC</code>.
|
||
|
</p></li><li><p>Highlight options are mostly in <code class="inline-verbatim">vim.highlight</code> — e.g., <code class="inline-code">highlight clear SpellCap</code> versus <code class="inline-code">vim.highlight</code>.
|
||
|
</p></li><li><p>You can manipulate variables of various scopes from <code class="inline-verbatim">vim.{g,b,..,t}</code>.
|
||
|
To see more details, see <code class="inline-verbatim">lua-vim-variables</code> help section.
|
||
|
</p></li><li><p><code class="inline-verbatim">vim.opt</code> will return an Option object, it has a common API.
|
||
|
to learn more about it, see <code class="inline-verbatim">vim.opt</code> and its subsections.
|
||
|
</p></li></ul><h1 id="real-life-examples-making-use-of-neovim-lua-api">Real-life examples making use of Neovim Lua API</h1><p>This is a list of <a href="/wiki/editor.neovim.lua-modules">Neovim Lua modules</a> that can serve as a basis for learning to interact Neovim with Lua.
|
||
|
</p><ul><li><p><a href="https://github.com/savq/paq-nvim">paq-nvim</a> is a simple Neovim package manager
|
||
|
</p></li><li><p><a href="https://github.com/wbthomason/packer.nvim">packer.nvim</a> is a more comprehensive package manager
|
||
|
</p></li><li><p><a href="https://github.com/L3MON4D3/LuaSnip">LuaSnip</a> is a snippet engine
|
||
|
</p></li><li><p><a href="https://github.com/nvim-telescope/telescope.nvim">telescope.nvim</a> is a fuzzy finder integrated inside Neovim
|
||
|
</p></li></ul><p>Several people have already replaced their already existing Vim configurations with Neovim.
|
||
|
</p><ul><li><p>TJ DeVries' <a href="https://github.com/tjdevries/config_manager/">Neovim config</a> is fully written in Lua complete with his own plugins.
|
||
|
</p></li><li><p>ThePrimeagen's <a href="https://github.com/ThePrimeagen/.dotfiles/">public dotfiles</a> contains Neovim config written in Lua.
|
||
|
</p></li></ul></main></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"metadata":{"date":"\"2021-07-15 07:45:50 +08:00\"","date_modified":"\"2022-04-20 21:19:43 +08:00\"","language":"en","source":""},"title":"Neovim Lua integration","hast":{"type":"root","children":[{"type":"element","tagName":"nav","properties":{"className":"toc"},"children":[{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-1"},"children":[{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"setting-configuration-with-lua"},"children":[{"type":"text","value":"Setting configuration with Lua"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/editor.neovim.lua#setting-configuration-with-lua"},"children":[{"type":"text","value":"Setting configuration with Lua"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"real-life-examples-making-use-of-neovim-lua-api"},"children":[{"type":"text","value":"Real-life examples making use of Neovim Lua API"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/editor.neovim.lua#real-life-examples-making-use-of-neovim-lua-api"},"children":[{"type":"text","value":"Real-life examples making use of Neovim Lua API"}]}]}]}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"with Lua integration, you can create "},{"type":"element","tagName":"a","properties":{"href":"/editor.neovim.lua-modules"},"children":[{"type":"text","value":"Neovim Lua modules"}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"you can start with "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"lua-intro"}]},{"type":"text","value":" section from "},{"type":"element","tagName":"a","properties":{"href":"/editor.neovim.help-system"},"children":[{"type":"text","value":"Neovim help system"}]},{"type":"text","value":";\n it gives all of the information on the things you need to get started with configuring Neovim with Lua as well as pointers for more things to do with Lua;\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Neovim also extends the Lua standard library found in "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"vim"}]},{"type":"text","value":" object;\n see the "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"lua-stdlib"}]},{"type":"text","value":" in "},{"type":"element","tagName":"a","properties":{"href":"/editor.neovim.help-system"},"children":[{"type":"text","value":"Neovim help system"}]}]}]}]},{"type":"element","tagName":"h1","properties":{"id":"setting-configuration-with-lua"},"children":[{"type":"text","value":"Setting configuration with Lua"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"There are some equivalent setting values in Lua versus Vimscript.\nFor more information, see the "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"lua-vimscript"}]},{"type":"text","value":" help section.\n"}]},{"type":"element","tagName":"table","properties":{},"children":[{"type":"element","tagName":"thead","properties":{},"children":[{"type":"element","tagName":"tr","properties":{},"children":[{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Description"}]},{"type":"
|