Skip to content

Conversation

@Eckii24
Copy link

@Eckii24 Eckii24 commented Sep 18, 2025

Discussion

I'm not sure, if you will even consider this PR. At least I want to avoid external dependencies as much as possible.
The YAML logic is only used to parse the frontmatter, which has a rather simple yaml structure.

Changes

This pull request introduces a built-in lightweight YAML parser for frontmatter parsing, removing the dependency on external Lua YAML libraries. The main changes update documentation to reflect this, replace the YAML parsing implementation, and add the new parser.

Disclaimer

The changes itself are generated by copilot...

Copilot AI review requested due to automatic review settings September 18, 2025 20:04
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces the external lyaml dependency with a custom lightweight YAML parser specifically designed for frontmatter parsing. The change reduces external dependencies while maintaining the same functionality for parsing YAML frontmatter in markdown files.

  • Removes dependency on external Lua YAML libraries (lyaml)
  • Implements a built-in YAML parser optimized for frontmatter use cases
  • Updates documentation to reflect the removal of external dependencies

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
lua/codecompanion/filewise/yaml_parser.lua New custom YAML parser implementation with support for key-value pairs, lists, and block scalars
lua/codecompanion/filewise/frontmatter.lua Updates import and function call to use the new custom YAML parser instead of lyaml
docs/project-description.md Updates documentation to reflect the use of built-in YAML parser instead of external libraries
README.md Removes installation requirement note about the lyaml dependency

if line == '' or line:match('^#') then
i = i + 1
else
local key, value = line:match('^([%w_%-]+)%s*:%s*(.*)$')
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key pattern [%w_%-]+ allows hyphens anywhere in the key name, but YAML keys with leading/trailing hyphens or consecutive hyphens may cause parsing issues. Consider using a more restrictive pattern like [%w_]+[%w_%-]*[%w_]+ or [%w_][%w_%-]* to ensure valid key names.

Suggested change
local key, value = line:match('^([%w_%-]+)%s*:%s*(.*)$')
local key, value = line:match('^([%w_]+[%w_%-]*[%w_]+)%s*:%s*(.*)$')

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about this one...

local inline = value:match('^%[(.*)%]$')
if inline then
local items = {}
for part in inline:gmatch('[^,]+') do
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This parsing logic will incorrectly split quoted strings containing commas. For example, [\"a, b\", \"c\"] will be split into three parts instead of two. The comment on line 41 acknowledges this limitation, but it could cause issues with frontmatter that contains quoted strings with commas.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@dyamon
Copy link
Owner

dyamon commented Sep 23, 2025

Hey @Eckii24, thanks for the PR. I'm thinking about this but to be completely honest why would I maintain some custom yaml parser just to avoid installing a dependency. lyaml seems pretty standard to me.

@Eckii24
Copy link
Author

Eckii24 commented Sep 23, 2025

Hi @dyamon,

totally valid!

My reason for considering this PR is really, that I'm only using nvim without e.g. LuaRocks. Therefore there is no easy way to install this dependency (at least I'm not aware of it).

Not sure if I'm alone with this.

@dyamon
Copy link
Owner

dyamon commented Sep 24, 2025

I'm not sure because I use Nix to manage the installation, so it is rather straightforward to declare dependencies.

A possible solution would be to have a configuration field that allows to specify a custom YAML parser (so you can use yours). Smells a bit like feature creep, but still I'd be happy to add this.

@kronn
Copy link

kronn commented Nov 6, 2025

tl;dr I do not know how to install lua-dependencies for a neovim-setup.

I only use lua through NeoVim I am still in the process of figuring out how to install the dependency and where and how to point neovim there and now I am 3 yaks deep into avoiding to type "Please read AGENTS.md with @{read_file}." which could also be a custom prompt on a keybinding.

I think the plugin could make things better, but the dependency (regardless of how standard and easy it seems to you), is effectively blocking me for now.

Therefore, I vote for switching to this little parsing-addition which of course is not a complete YAML-parser and never will be. Alternatively, better instructions on how to install the dependency would also work, if the dependency is better for your project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants