Skip to content

Weird syntax highlighting behavior in 'custom syntax support' #379

@serg3295

Description

@serg3295

When replacing the function name with the plugin.lua script the replacement is performed correctly, but part of the function name is highlighted in a different color.

Screenshots

luaSrvErr3.mp4

Environment (please complete the following information):

  • OS: Windows
  • Is WSL remote? no
  • Client: VSCode

plugin.lua

function OnSetText(uri, text)
  local diffs = {}
  local textAny = text:sub(1, 2)
  diffs[#diffs+1] = {
        start  = 1,
        finish = 2,
        text   = (textAny),
  }

  for displTypePos, finish in text:gmatch '[%w_]+%s*%=%s*ucg%.()[%w_]+_hw_spi()' do
    diffs[#diffs+1] = {
        start  = displTypePos,
        finish = finish - 1,
        text   = ('ucgDisplayType'),
    }
  end

  for displTypePos, finish in text:gmatch '[%w_]+%s*%=%s*u8g2%.()[%w]+_i2c_[%w_]+()' do
    diffs[#diffs+1] = {
        start  = displTypePos,
        finish = finish - 1,
        text   = ('u8g2DisplayTypeI2C'),
    }
  end

  for displTypePos, finish in text:gmatch '[%w_]+%s*%=%s*u8g2%.()[%w]+_[^i][%w_]+()' do
    diffs[#diffs+1] = {
        start  = displTypePos,
        finish = finish - 1,
        text   = ('u8g2DisplayTypeSPI'),
    }
  end

   return diffs
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions