Git Product home page Git Product logo

Comments (11)

ray-x avatar ray-x commented on September 28, 2024 1

It is very likely when you run nvim_set_hl the vim.o.ft was not detected.
You can do that in yamlls on_attach(), or more recommended
in after/ftplugin/yaml.vim

lua <<EOF
  vim.api.nvim_set_hl(0, '@string', {fg='#59E343'})
  vim.api.nvim_set_hl(0, '@field', {fg='#f93393'})
  vim.api.nvim_set_hl(0, '@number', {fg='#e933e3'})
EOF

from aurora.

ray-x avatar ray-x commented on September 28, 2024

1> Are you using neovim 0.7.x +
2> Are you using treesitter for yml?
The yaml only used for vim users.

Suppose you are using both.
Then you may need to adjust the treesitter setup for
@string @field @Number etc

So in you setup with lua

if vim.o.ft == 'yaml' then
  vim.api.nvim_set_hl(0, '@string', {fg='#59E343'})
  vim.api.nvim_set_hl(0, '@field', {fg='#f93393'})
  vim.api.nvim_set_hl(0, '@number', {fg='#e933e3'})
end

Check nvim-treesitter/queries/yaml/highlights.scm for all available color groups.

from aurora.

liketoeatcheese avatar liketoeatcheese commented on September 28, 2024

Hi Ray,

Thanks for your prompt response. I tried using your method, but I still couldn't get it to work.

In the image below:

  1. The yaml file which has the current color scheme
  2. Showed the set up script for aurora with your script
  3. That's ~/.local/share/nvim/site/pack/packer/start/nvim-treesitter/queries/yaml/highlights.scm. But I couldn't see any color group here.
  4. That's what show up when I do :version. So Neovim version is v0.8.1

Did I miss something?
image

from aurora.

ray-x avatar ray-x commented on September 28, 2024

Did you install yaml parser?
TSInstall yaml

from aurora.

liketoeatcheese avatar liketoeatcheese commented on September 28, 2024

Hi Ray,

Yes, it is installed. I use mason and also added it to my lspconfig like so:

require("lspconfig").yamlls.setup({
  on_attach = require("wpham.lsp.handlers").on_attach,
  capabilities = require("wpham.lsp.handlers").capabilities,
  settings = {
    yaml = {
      --[[ format = { ]]
      --[[   enable = true ]]
      --[[ }, ]]
      schemas = {
        --[[ ["https://raw.githubusercontent.com/quantumblacklabs/kedro/develop/static/jsonschema/kedro-catalog-0.17.json"] = "conf/**/*catalog*", ]]
        --[[ ["https://json.schemastore.org/github-workflow.json"] = "/.github/workflows/*", ]]
        kubernetes = "/*.yaml",
      },
    },
  },
})

The language server is there. I also tried TSInstall yaml like you suggested, and it also said yaml is already installed. I reinstalled it but nothing've changed.
image

from aurora.

ray-x avatar ray-x commented on September 28, 2024

How about you run
vim.api.nvim_set_hl(0, '@string', {fg='#59E343'})
after yml file loaded?

from aurora.

liketoeatcheese avatar liketoeatcheese commented on September 28, 2024

I got this error: E194: No alternate file name to substitue for '#'
image

image

from aurora.

ray-x avatar ray-x commented on September 28, 2024

should be like this:
:lua vim.api.nvim_set_hl(0, '@string', {fg='#59E343'})

from aurora.

liketoeatcheese avatar liketoeatcheese commented on September 28, 2024

That works.

How would I automatically load it up?

Not sure if this is the issue:
When I tried :lua vim.o.ft, based on your script, I would expect it to be "yaml", but I got E5107: Error loading lua [string ":lua"]:1: '=' expected near '<eof>'
image

image

from aurora.

liketoeatcheese avatar liketoeatcheese commented on September 28, 2024

Worked perfectly!!!! Thanks for your assist Ray

from aurora.

liketoeatcheese avatar liketoeatcheese commented on September 28, 2024

Oh btw, I have been curios about this, what's this sidebar package name? Or is this a custom thing.
image

from aurora.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.