Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
use plugin/zellij.lua to define commands (#2)
Browse files Browse the repository at this point in the history
this removes the need to call `require('zellij').setup({})`
to use the default config
  • Loading branch information
p00f authored Sep 2, 2023
1 parent a0eef9e commit 577fa5c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 18 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 15,12 @@ For [vim-tmux-navigator](https://github.com/zellij-org/zellij) compatibility, us
```lua
use {
'Lilja/zellij.nvim',
-- If you want to configure the plugin
--[[
config = function()
require('zellij').setup({})
end
]]
}
```

Expand Down
26 changes: 8 additions & 18 deletions lua/zellij/init.lua
Original file line number Diff line number Diff line change
@@ -1,6 1,13 @@
local keybindings = require('zellij.keybindings')

local zellij = {}
local zellij = {
opts = {
path = "zellij",
replaceVimWindowNavigationKeybinds = false,
vimTmuxNavigatorKeybinds = false,
debug = false,
}
}

local directionTranslation = {
h = "left",
Expand Down Expand Up @@ -123,21 130,4 @@ function zellij.setup(opts)
zellij.opts = opts
end

vim.api.nvim_create_user_command('ZellijNavigateLeft', function() zellij.zjNavigate('h') end,
{ desc = "Navigate left vim window or zellij pane", nargs = 0 })
vim.api.nvim_create_user_command('ZellijNavigateRight', function() zellij.zjNavigate('l') end,
{ desc = "Navigate right vim window or zellij pane", nargs = 0 })
vim.api.nvim_create_user_command('ZellijNavigateUp', function() zellij.zjNavigate('k') end,
{ desc = "Navigate up vim window or zellij pane", nargs = 0 })
vim.api.nvim_create_user_command('ZellijNavigateDown', function() zellij.zjNavigate('j') end,
{ desc = "Navigate down vim window or zellij pane", nargs = 0 })
vim.api.nvim_create_user_command('ZellijNewPane', zellij.newPane, { desc = "New Zellij pane", nargs = 0 })
vim.api.nvim_create_user_command('ZellijNewTab', zellij.newTab, { desc = "New Zellij tab", nargs = 0 })
vim.api.nvim_create_user_command('ZellijRenamePane', function(opts) zellij.renamePane(opts.args) end,
{ desc = "Rename the current Zellij pane", nargs = 1 })
vim.api.nvim_create_user_command('ZellijRenameTab', function(opts) zellij.renameTab(opts.args) end,
{ desc = "Rename the current Zellij tab", nargs = 1 })
vim.api.nvim_create_user_command('ZellijOpenDebugLog', zellij.openDebugLog,
{ desc = "Rename the current Zellij pane", nargs = 0 })

return zellij
27 changes: 27 additions & 0 deletions plugin/zellij.lua
Original file line number Diff line number Diff line change
@@ -0,0 1,27 @@
vim.api.nvim_create_user_command('ZellijNavigateLeft', function()
require("zellij").zjNavigate('h')
end, { desc = "Navigate left vim window or zellij pane", nargs = 0 })
vim.api.nvim_create_user_command('ZellijNavigateRight', function()
require("zellij").zjNavigate('l')
end, { desc = "Navigate right vim window or zellij pane", nargs = 0 })
vim.api.nvim_create_user_command('ZellijNavigateUp', function()
require("zellij").zjNavigate('k')
end, { desc = "Navigate up vim window or zellij pane", nargs = 0 })
vim.api.nvim_create_user_command('ZellijNavigateDown', function()
require("zellij").zjNavigate('j')
end, { desc = "Navigate down vim window or zellij pane", nargs = 0 })
vim.api.nvim_create_user_command('ZellijNewPane', function()
require("zellij").newPane()
end, { desc = "New Zellij pane", nargs = 0 })
vim.api.nvim_create_user_command('ZellijNewTab', function()
require("zellij").newTab()
end, { desc = "New Zellij tab", nargs = 0 })
vim.api.nvim_create_user_command('ZellijRenamePane', function(opts)
require("zellij").renamePane(opts.args)
end, { desc = "Rename the current Zellij pane", nargs = 1 })
vim.api.nvim_create_user_command('ZellijRenameTab', function(opts)
require("zellij").renameTab(opts.args)
end, { desc = "Rename the current Zellij tab", nargs = 1 })
vim.api.nvim_create_user_command('ZellijOpenDebugLog', function()
require("zellij").openDebugLog()
end, { desc = "Rename the current Zellij pane", nargs = 0 })

0 comments on commit 577fa5c

Please sign in to comment.