harpoon module provides setup, configuration management, and utility functions for Harpoon.
setup
Initialize Harpoon with your configuration.Behavior
- Merges user config, cache config, and default settings
- Sets up autocommands for cursor position tracking
- Initializes tabline if enabled
- Must be called before using other Harpoon functions (can be called with no arguments for defaults)
Parameters
Configuration table with optional fields:
global_settings: Global configuration optionsprojects: Project-specific configurationmenu: Menu appearance configuration
Example
save
Manually save Harpoon configuration to disk.Behavior
- Refreshes other projects from disk before saving to avoid overwriting changes
- Writes the current configuration to the cache file
- Automatically called when
save_on_changeis enabled
Example
You typically don’t need to call this directly as Harpoon auto-saves when
save_on_change is true (default).get_global_settings
Get the current global settings table.Returns
Table containing all global settings (save_on_toggle, save_on_change, etc.)
Example
get_mark_config
Get the mark configuration for the current project.Behavior
- Returns marks for the current project
- Respects
mark_branchsetting (returns branch-specific marks if enabled) - Ensures proper config structure exists
Returns
Table containing:
marks: Array of mark objects withfilename,row, andcol
Example
get_term_config
Get the terminal configuration for the current project.Returns
Table containing:
cmds: Array of saved terminal commands
Example
get_menu_config
Get the menu configuration.Returns
Table containing menu options (width, height, borderchars, etc.)
Example
print_config
Print the entire Harpoon configuration for debugging.Behavior
- Uses
vim.inspectto pretty-print the configuration - Useful for troubleshooting configuration issues
Example
refresh_projects_b4update
Refresh all projects from disk except the current one.Behavior
- Saves current project config temporarily
- Reloads all other projects from the cache file
- Merges current project config back in
- Used internally before saving to prevent overwriting other project changes
Example
This is called automatically by
save(). You typically don’t need to call it directly.Configuration Files
Harpoon uses two configuration files:Cache Config
- Location:
vim.fn.stdpath("data") .. "/harpoon.json" - Purpose: Stores marks, terminal commands, and runtime state
- Persistence: Automatically saved and loaded
User Config
- Location:
vim.fn.stdpath("config") .. "/harpoon.json" - Purpose: Optional static configuration that overrides defaults
- Usage: Create this file if you want persistent configuration
Example: Check config paths
Complete Setup Example
Here’s a comprehensive setup example:Related
Configuration Setup
Learn more about configuring Harpoon
Global Settings
All available global settings
Project Settings
Project-specific configuration
Mark API
Mark management functions