Use lua to create commands

This commit is contained in:
hedy
2023-11-01 14:29:56 +08:00
parent 7a7b45f477
commit e98041c75f
3 changed files with 15 additions and 3 deletions

View File

@@ -301,6 +301,14 @@ local opts = {
| `:SymbolsOutlineOpen` | Open symbols outline | | `:SymbolsOutlineOpen` | Open symbols outline |
| `:SymbolsOutlineClose` | Close symbols outline | | `:SymbolsOutlineClose` | Close symbols outline |
### Lua
```
require'symbols-outline'.toggle_outline()
require'symbols-outline'.open_outline()
require'symbols-outline'.close_outline()
```
## Default keymaps ## Default keymaps
| Key | Action | | Key | Action |

View File

@@ -53,6 +53,12 @@ local function setup_buffer_autocmd()
end end
end end
local function setup_commands()
vim.api.nvim_create_user_command('SymbolsOutline', M.toggle_outline, { nargs = 0 })
vim.api.nvim_create_user_command('SymbolsOutlineOpen', M.open_outline, { nargs = 0 })
vim.api.nvim_create_user_command('SymbolsOutlineClose', M.close_outline, { nargs = 0 })
end
------------------------- -------------------------
-- STATE -- STATE
------------------------- -------------------------
@@ -357,6 +363,7 @@ function M.setup(opts)
M.view = View:new() M.view = View:new()
setup_global_autocmd() setup_global_autocmd()
setup_commands()
end end
return M return M

View File

@@ -1,3 +0,0 @@
command! SymbolsOutline :lua require'symbols-outline'.toggle_outline()
command! SymbolsOutlineOpen :lua require'symbols-outline'.open_outline()
command! SymbolsOutlineClose :lua require'symbols-outline'.close_outline()