Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,15 @@ Key mappings can either be a string, or a table of strings if you want multiple
}
```

## Commands
```viml
" Toggle Triptych
:Triptych

" Open Triptych at specific directory
:Triptych ~/Documents
```

## LSP Integration

If you have [antosha417/nvim-lsp-file-operations](https://github.com/antosha417/nvim-lsp-file-operations) installed, performing
Expand Down
18 changes: 14 additions & 4 deletions lua/triptych/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ end
---@param dir? string Path of directory to open. If omitted will be the directory containing the current buffer
---@return fun()|nil
local function toggle_triptych(dir)
if dir and not vim.fn.isdirectory(dir) then
if dir and vim.fn.isdirectory(dir) == 0 then
return warn(tostring(dir) .. ' is not a directory')
end

Expand Down Expand Up @@ -157,9 +157,19 @@ local function setup(user_config)

vim.g.triptych_is_open = false

vim.api.nvim_create_user_command('Triptych', function()
toggle_triptych()
end, {})
vim.api.nvim_create_user_command('Triptych', function(opts)
if opts.args == "" then
toggle_triptych()
else
local path = vim.fn.expand(opts.args)

toggle_triptych(path)
end
end,
{
nargs = '?',
complete = 'dir',
})

vim.g.triptych_config = require('triptych.config').create_merged_config(user_config or {})
end
Expand Down
3 changes: 3 additions & 0 deletions lua/triptych/view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ end
---@param maybe_cursor_target_path string?
---@return nil
function M.set_primary_and_parent_window_targets(State, target_dir, maybe_cursor_target_path)
if target_dir:len() > 1 and string.sub(target_dir, -1) == '/' then
target_dir = string.sub(target_dir, 1, target_dir:len() - 1)
end
local config_options = vim.g.triptych_config.options
local icons_enabled = config_options.file_icons.enabled

Expand Down
Loading