Skip to content

feat: use path relative to server's cwd for Context.format filepaths #272

@nickjvandyke

Description

@nickjvandyke

Prerequisites

  • I searched the docs
  • I searched existing issues

Is your feature request related to a problem? Please describe.

Absolute paths are reliable, but kinda long and noisy.

Not urgent but if opencode ever fixes interpreting file references in appended prompts, I think this is a prerequisite to leverage that again. It doesn't seem to support @<absolute_path> even typing directly in the TUI.

Context.server would likely benefit future needs too.

Describe the solution you'd like

Format the path relative to the target server's CWD.

  1. Context.lua needs to be aware of the server it's formatting for. Probably add a server field and receive it in Context.new. May require some reordering of server retrieval + context creation to have it available, but I think it's viable given the current code paths.
  2. In Context.format: manually modify absolute_path to be relative to server.cwd. vim.fn.fnamemodify only supports formatting relative to Neovim's CWD, so we need to DIY. Hopefully a simple regex?

Describe alternatives you've considered

No alternative afaik

Additional context

#270

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions