Skip to content

Commit 52e2d80

Browse files
authored
Merge pull request #3 from millerjason/cleanups
Improve opt
2 parents 25c5dda + 19ff586 commit 52e2d80

File tree

5 files changed

+32
-25
lines changed

5 files changed

+32
-25
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### 0.97
44

55
* Undefine unwanted overlapping key bindings
6+
* Do not set Meta keys by default (improve compatibilty)
67
* Update documentation
78

89
### 0.96-nvim1.0

README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,18 @@ To install the plugin with custom options (lazy example provided):
3131
```lua
3232
{
3333
"millerjason/neovimacs.nvim",
34-
config = function()
35-
require("neovimacs").setup({
36-
VM_Enabled = 1,
37-
VM_StartInsert = 0,
38-
})
39-
end,
34+
opts = {
35+
VM_Enabled = true,
36+
VM_StartInsert = false, -- Start in normal (not insert) mode
37+
},
4038
}
4139
```
4240

4341
## ✨ Options
4442

45-
- **VM_Enabled** (default 1): enabled vimacs (if not set, no modules will be loaded)
46-
- **VM_StartInsert** (default 1): if set start in emacs insert mode instead of vim normal mode
43+
- **VM_Enabled** (default true): enabled vimacs (if not set, no modules will be loaded)
44+
- **VM_StartInsert** (default true): if set start in emacs insert mode instead of vim normal mode
45+
**VM_UnixConsoleMetaSendsEsc** (default false): also set Meta key (required in certain terminals, requires nvim >= 0.10)
4746
- **TabIndentStyle**: (default "emacs"): options for "emacs", "whitespace", and "startofline" tab indent behavior
4847

4948
## Debugging
@@ -69,8 +68,8 @@ nvim commands to help you track down key bindings and conflicts:
6968
## 🚀 Usage
7069

7170
Many of the emacs control and meta keys (movement, kill buffers, file operations, marking) will work while
72-
your running viamcs in neovim. Neovim does not allow all bindings to work in all modes, although this module
71+
you're running vimacs in neovim. Neovim does not allow all bindings to work in all modes, although this module
7372
supports most of what is possible.
7473

7574
Plus you still get the full power of vim moded editing as well, so vimacs can be used as a module to transition
76-
you from emacs to vim until you've master the vim bindings.
75+
you from emacs to vim until you have mastered the vim bindings.

lua/neovimacs/init.lua

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@ local M = {}
22

33
-- Default options
44
M.options = {
5-
-- Enable vimacs
6-
VM_Enabled = 1,
5+
-- Enable Vimacs
6+
VM_Enabled = true,
77

88
-- If set, we start in emacs edit mode
99
-- (otherwise we start in vim normal mode)
10-
VM_StartInsert = 1,
10+
VM_StartInsert = true,
1111

12-
-- Tab Style: emacs, whitespace, startofline
13-
TabIndentStyle = "emacs"
12+
-- Should meta send escape
13+
-- (required for some terminals, incompatible with others)
14+
VM_UnixConsoleMetaSendsEsc = false,
15+
16+
-- Tab Indent Style: none, emacs, whitespace, startofline
17+
TabIndentStyle = "none",
1418
}
1519

1620
-- Find plugin root
@@ -23,8 +27,9 @@ M.plugin_root = find_plugin_root()
2327

2428
-- Set vimscript globals from configuration
2529
function M.set_vim_globals()
26-
vim.g.VM_Enabled = M.options.VM_Enabled
27-
vim.g.VM_StartInsert = M.options.VM_StartInsert
30+
vim.g.VM_Enabled = M.options.VM_Enabled and 1 or 0
31+
vim.g.VM_StartInsert = M.options.VM_StartInsert and 1 or 0
32+
vim.g.VM_UnixConsoleMetaSendsEsc = M.options.VM_UnixConsoleMetaSendsEsc and 1 or 0
2833
vim.g.TabIndentStyle = M.options.TabIndentStyle
2934
end
3035

@@ -37,9 +42,9 @@ function M.setup(opts)
3742
vim.cmd("source " .. vimscript_path .. "vimacs.vim")
3843
vim.cmd("source " .. vimscript_path .. "tab-indent.vim")
3944
--- Undefine unwanted overlaps
40-
vim.api.nvim_set_keymap('i', '<Esc>', '<Esc>', { noremap = true })
41-
vim.api.nvim_set_keymap('n', '<C-a>', '<Nop>', { noremap = true })
42-
vim.api.nvim_set_keymap('n', '<C-x>', '<Nop>', { noremap = true })
45+
vim.api.nvim_set_keymap("i", "<Esc>", "<Esc>", { noremap = true })
46+
vim.api.nvim_set_keymap("n", "<C-a>", "<Nop>", { noremap = true })
47+
vim.api.nvim_set_keymap("n", "<C-x>", "<Nop>", { noremap = true })
4348
end
4449

4550
return M

lua/neovimacs/vimscript/insertmode.vim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ endif
77

88
" insertmode equivalent (see :h insertmode) in neovim
99
"
10-
autocmd BufWinEnter * startinsert
10+
if !exists("g:VM_StartInsert") || g:VM_StartInsert == 1
11+
autocmd BufWinEnter * startinsert
12+
endif
1113
inoremap <Esc> <C-X><C-Z><C-]>
1214
inoremap <C-C> <C-X><C-Z>
1315
inoremap <C-L> <C-X><C-Z><C-]><Esc>

lua/neovimacs/vimscript/tab-indent.vim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if exists("loaded_TabIndent")
1818
finish
1919
endif
2020

21-
if !exists("g:TabIndentStyle") || g:TabIndentStyle == 0
21+
if !exists("g:TabIndentStyle") || g:TabIndentStyle == 0 || g:TabIndentStyle == "none"
2222
" A user should explicitly enable tab-indent style
2323
finish
2424
endif
@@ -48,18 +48,18 @@ function! <SID>TabOrIndent()
4848

4949
elseif g:TabIndentStyle == 2 || g:TabIndentStyle == "whitespace"
5050
if virtcol('.') <= indent(line('.'))
51-
return indent
51+
return indent
5252
else
5353
return real_tab
5454
endif
5555

5656
elseif g:TabIndentStyle == 3 || g:TabIndentStyle == "startofline"
5757
if virtcol('.') <= indent(line('.')) || virtcol('.') == 1
58-
return indent
58+
return indent
5959
else
6060
return real_tab
6161
endif
62-
62+
6363
endif
6464

6565
else

0 commit comments

Comments
 (0)