File tree 3 files changed +35
-18
lines changed
3 files changed +35
-18
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -52,12 +52,16 @@ Filetypes can also be listed as regex, such as `neo%-tree*`.
52
52
:StopInsertPlug enable
53
53
:StopInsertPlug disable
54
54
:StopInsertPlug toggle
55
+ :StopInsertPlug status
55
56
```
56
57
57
58
Each of them does exactly what it says on the tin.
58
59
59
- <!-- panvimdoc-ignore-start -->
60
60
## Contribution
61
61
62
- See [ CONTRIBUTING.md] ( ./CONTRIBUTING.md ) .
63
- <!-- panvimdoc-ignore-end -->
62
+ All contributions are most welcome! Please open a PR or create an [ issue] ( https://github.com/csessh/stopinsert.nvim/issues ) .
63
+
64
+ ### Coding Style
65
+
66
+ - Follow the coding style of [ LuaRocks] ( https://github.com/luarocks/lua-style-guide ) .
67
+ - Make sure you format the code with [ StyLua] ( https://github.com/JohnnyMorganz/StyLua ) before PR.
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ local M = {}
2
2
local util = require (" stopinsert.util" )
3
3
M .enable = true
4
4
5
- local commands = {
5
+ local user_cmds = {
6
6
enable = function ()
7
7
M .enable = true
8
8
end ,
@@ -12,6 +12,13 @@ local commands = {
12
12
toggle = function ()
13
13
M .enable = not M .enable
14
14
end ,
15
+ status = function ()
16
+ if M .enable then
17
+ print (" StopInsert is active" )
18
+ else
19
+ print (" StopInsert is inactive" )
20
+ end
21
+ end ,
15
22
}
16
23
17
24
--- @param opts table
@@ -23,33 +30,47 @@ function M.setup(opts)
23
30
vim .api .nvim_create_autocmd (" InsertEnter" , {
24
31
group = vim .api .nvim_create_augroup (" InsertEnterListener" , { clear = true }),
25
32
callback = function ()
26
- if not M .enable and not util .is_filetype_disabled (vim .bo .ft ) then
33
+ if not M .enable then
34
+ return
35
+ end
36
+
37
+ if util .is_filetype_disabled (vim .bo .ft ) then
27
38
return
28
39
end
40
+
29
41
util .reset_timer ()
30
42
end ,
31
43
})
32
44
33
45
vim .on_key (function (_ , _ )
34
- if not M . enable and not util . is_filetype_disabled ( vim .bo . ft ) then
46
+ if vim .fn . mode () ~= " i " then
35
47
return
36
48
end
37
49
38
- if vim .fn .mode () ~= " i" then
50
+ if not M .enable then
51
+ return
52
+ end
53
+
54
+ if util .is_filetype_disabled (vim .bo .ft ) then
39
55
return
40
56
end
41
57
42
58
util .reset_timer ()
43
59
end )
44
60
45
61
vim .api .nvim_create_user_command (" StopInsertPlug" , function (cmd )
46
- if commands [cmd .args ] then
47
- commands [cmd .args ]()
62
+ if user_cmds [cmd .args ] then
63
+ user_cmds [cmd .args ]()
48
64
end
49
65
end , {
50
66
nargs = 1 ,
51
67
complete = function ()
52
- return { " enable" , " disable" , " toggle" }
68
+ return {
69
+ " enable" ,
70
+ " disable" ,
71
+ " toggle" ,
72
+ " status" ,
73
+ }
53
74
end ,
54
75
})
55
76
end
You can’t perform that action at this time.
0 commit comments