-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathREADME.Rmd
More file actions
114 lines (79 loc) · 2.37 KB
/
README.Rmd
File metadata and controls
114 lines (79 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
---
title: Neovim Lua Script
output: amaryaml::github
---
# Introduction
Due to the hype of the excellent Lua support that Neovim provides, many people
want to move their configuration to Lua from Vim Script.
However, it is much more difficult to configure Neovim via Lua than Vim Script,
despite Lua being an easy programming language.
This does not change the fact that Lua is a better and more robust language, so
this trade-off is worth it.
What if I told you that you do not need to have a trade-off?
You can actually configure Neovim easier with Lua than with Vim Script with this
plugin.
# Installation
## Vim Plug
```vim
Plug "amarakon/nvim-lua-script"
```
## Vim
```sh
`# user` git clone https://github.com/amarakon/nvim-sensible ~/.vim/pack/vendor/start/nvim-sensible
```
## Neovim
```sh
`# user` git clone https://github.com/amarakon/nvim-sensible ~/.local/share/nvim/site/pack/default/start/nvim-sensible
```
# Setup
To set up the functions and variables provided by this plugin, simply put the
following line in your Lua configuration.
If you are configuring Neovim with Vim, add `lua` in front of the following
line.
```lua
require("lua-script")
```
# Usage
## List of functions and variables
### Keybindings
#### Basic
You have to specify the mode for these functions.
- `keymap(mode, lhs, rhs, opts)`
- `keynoremap(mode, lhs, rhs, opts)`
#### Modal
- `nmap(lhs, rhs, opts)`
- `imap(lhs, rhs, opts)`
- `vmap(lhs, rhs, opts)`
- `cmap(lhs, rhs, opts)`
- `omap(lhs, rhs, opts)`
#### Regular
These keybindings apply to normal and visual mode.
- `map(lhs, rhs, opts)`
- `noremap(lhs, rhs, opts)`
### Auto-commands
- `autocmd(type, match, opts)`
### Options
- `g` = `vim.g`
- `o` = `vim.o`
- `opt` = `vim.opt`
## Converting from Vim Script
Using the concepts provided by this plugin, I will convert the first code block
(Vim Script) into the second code block (Lua).
```vim
nmap <Space> <nop>
imap <C-c> #<Space>
noremap tn <Escape>
let g:mapleader = " "
set pumheight=5
autocmd TextYankPost * lua vim.highlight.on_yank { higroup = "Visual" }
```
```lua
nmap("<Space>", "") -- No need to use `<nop>`
imap("<C-c>", "# ") -- No trailing whitespace by using a space character
map("tn", "<Escape>")
g.mapleader = " " -- Fewer columns of code
opt.pumheight = 5
autocmd("TextYankPost", "*", function ()
vim.highlight.on_yank { higroup = "Visual" } -- No need to call Lua from Vim
end)
```