Skip to content

Conversation

@rmuir
Copy link
Contributor

@rmuir rmuir commented Sep 2, 2025

Previously, these elements were not listed as symbols. redhat's yaml-language-server lists these as numbered elements such as 0, 1, 2, but treesitter strategy didn't match them at all.

There's a de-facto standard for many yaml formats, to use the "name" key to solve this problem. It is a best practice for commonly used yaml files such as github workflows and ansible.

Note: I can tune the query if there are concerns: I'm aware this looks a bit strange, but it really makes these files possible to navigate, and doesn't hurt anything else (only introduces symbol where one didn't exist before). Try it out on some actions/ansible files.

Screen_Shot_2025-09-02_at_02 14 57

Previously, these elements were not listed as symbols. redhat's yaml-language-server lists these as
numbered elements such as 0, 1, 2, but treesitter strategy didn't match them at all.

There's a de-facto standard for many yaml formats, to use the "name" key to solve this problem. It
is a best practice for commonly used yaml files such as github workflows and ansible.

Signed-off-by: Robert Muir <rmuir@apache.org>
@github-actions github-actions bot requested a review from stevearc September 2, 2025 06:16
@stevearc
Copy link
Owner

Yeah this seems like a good improvement, and is in line with some of the other specific cases made for other languages (e.g. rspec tests). Thanks!

@stevearc stevearc merged commit 5e687b5 into stevearc:master Sep 27, 2025
9 checks passed
@ZachVec
Copy link

ZachVec commented Oct 31, 2025

Great job! Is it possible to work with lsp?

@rmuir
Copy link
Contributor Author

rmuir commented Oct 31, 2025

@ZachVec personally I use treesitter, falling back to LSP (which I believe is the default with this plugin).

There are a few exceptions where I prefer LSP. Hope this helps:

  backends = {
    -- jdtls does a fantastic job
    java = { 'lsp', 'treesitter' },
    -- gopls does better for now
    go = { 'lsp', 'treesitter' },
    -- lua: don't fall back to lsp, no symbols is better than crazy symbols (emmylua_ls)
    lua = { 'treesitter' },
  },

@ZachVec
Copy link

ZachVec commented Nov 3, 2025

@rmuir Many thanks for the setup! That’s really helpful!

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