Skip to content

Commit

Permalink
feat: capture from start of tmux pane history (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
pbnj committed Sep 2, 2023
1 parent 9847727 commit 97ec06b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -60,6 +60,12 @@ require('cmp').setup({

-- Keyword patch mattern
keyword_pattern = [[\w\+]],

-- Capture full pane history
-- `false`: show completion suggestion from text in the visible pane (default)
-- `true`: show completion suggestion from text starting from the beginning of the pane history.
-- This works by passing `-S -` flag to `tmux capture-pane` command. See `man tmux` for details.
capture_history = false,
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion doc/cmp-tmux.txt
Expand Up @@ -55,7 +55,8 @@ To configure this extension, add an options table (defaults shown):
all_panes = false,
label = '[tmux]',
trigger_characters = { '.' },
trigger_characters_ft = {} -- { filetype = { '.' } }
trigger_characters_ft = {}, -- { filetype = { '.' } },
capture_history = false,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions lua/cmp_tmux/source.lua
Expand Up @@ -16,6 +16,7 @@ local default_config = {
trigger_characters = { '.' },
trigger_characters_ft = {},
keyword_pattern = [[\w\+]],
capture_history = false,
}

local function create_config()
Expand Down
3 changes: 3 additions & 0 deletions lua/cmp_tmux/tmux.lua
Expand Up @@ -50,6 +50,9 @@ end

function Tmux.create_pane_data_job(self, pane, on_data, on_exit)
local cmd = { 'tmux', 'capture-pane', '-p', '-t', pane }
if self.config.capture_history then
table.insert(cmd, '-S-')
end

return vim.fn.jobstart(cmd, {
on_exit = on_exit,
Expand Down

0 comments on commit 97ec06b

Please sign in to comment.