wiki/notebook/editor.neovim.lua.org

38 lines
2.2 KiB
Org Mode
Raw Normal View History

:PROPERTIES:
:ID: fa34ab22-2b49-485b-a797-cbcccb8bcd04
:END:
#+title: Neovim Lua integration
#+date: "2021-07-15 07:45:50 +08:00"
#+date_modified: "2022-04-20 18:49:17 +08:00"
#+language: en
- with Lua integration, you can create [[id:bdcff35e-15e1-4539-9c4e-5fdd5b978c26][Neovim Lua modules]]
- you can start with =lua-intro= section from [[id:0a0fe63e-dcf3-4928-9e82-5513784c1244][Neovim help system]];
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;
- Neovim also extends the Lua standard library found in =vim= object;
see the =lua-stdlib= in [[id:0a0fe63e-dcf3-4928-9e82-5513784c1244][Neovim help system]]
- comprehensive examples include Neovim plugins that are already written in Lua
+ [[https://github.com/savq/paq-nvim][paq-nvim]] is a simple Neovim package manager
+ [[https://github.com/wbthomason/packer.nvim][packer.nvim]] is a more comprehensive package manager
+ [[https://github.com/L3MON4D3/LuaSnip][LuaSnip]] is a snippet engine
+ [[https://github.com/nvim-telescope/telescope.nvim][telescope.nvim]] is a fuzzy finder integrated inside Neovim
* Setting configuration with Lua
- you can still execute Vimscript with =vim.cmd=;
more information is at =:h lua-vimscript=
- to set options, it's mostly in =vim.opt= — e.g., ~set number relativenumber~ versus ~vim.opt.number, vim.opt.relativenumber = true, true~
- highlight options are mostly in =vim.highlight= — e.g., ~highlight clear SpellCap~ versus ~vim.highlight~
- to set local options, use =vim.opt_local= — e.g., ~setlocal spell~ versus ~vim.opt_local.spell = true~
- otherwise, to set global options, use =vim.opt_global=
- you can access environment variables through =vim.env= — e.g., ~vim.env.HOME~, ~vim.env.MYVIMRC~
- you can manipulate variables of various scales from =vim.{g,b,t}=;
to see more details, see =lua-vim-variables= help section
- =vim.opt= will return an Option object, it has a common API;
to learn more about it, see =vim.opt= and its subsections
- to run Vimscript, you can use =vim.cmd= — e.g., ~vim.cmd "colorscheme nord"~
- interacting with Neovim API through =vim.api=