Class: Mui::Lsp::Highlighters::DiagnosticHighlighter
- Inherits:
-
Highlighters::Base
- Object
- Highlighters::Base
- Mui::Lsp::Highlighters::DiagnosticHighlighter
- Defined in:
- lib/mui/lsp/highlighters/diagnostic_highlighter.rb
Overview
Highlighter for LSP diagnostics (errors, warnings, etc.)
Constant Summary collapse
- PRIORITY_DIAGNOSTICS =
Between selection and search
250
Instance Method Summary collapse
- #highlights_for(row, line, _options = {}) ⇒ Object
-
#initialize(color_scheme, diagnostics) ⇒ DiagnosticHighlighter
constructor
A new instance of DiagnosticHighlighter.
- #priority ⇒ Object
-
#update(diagnostics) ⇒ Object
Update diagnostics (called when new diagnostics arrive).
Constructor Details
#initialize(color_scheme, diagnostics) ⇒ DiagnosticHighlighter
Returns a new instance of DiagnosticHighlighter.
10 11 12 13 |
# File 'lib/mui/lsp/highlighters/diagnostic_highlighter.rb', line 10 def initialize(color_scheme, diagnostics) super(color_scheme) @diagnostics = diagnostics end |
Instance Method Details
#highlights_for(row, line, _options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mui/lsp/highlighters/diagnostic_highlighter.rb', line 15 def highlights_for(row, line, = {}) highlights = [] @diagnostics.each do |d| next unless row.between?(d.range.start.line, d.range.end.line) start_col = d.range.start.line == row ? d.range.start.character : 0 end_col = if d.range.end.line == row d.range.end.character else line.length end # Ensure end_col is at least start_col + 1 end_col = [end_col, start_col + 1].max style = severity_style(d.severity) highlights << Mui::Highlight.new( start_col: start_col, end_col: end_col, style: style, priority: priority ) end highlights end |
#priority ⇒ Object
43 44 45 |
# File 'lib/mui/lsp/highlighters/diagnostic_highlighter.rb', line 43 def priority PRIORITY_DIAGNOSTICS end |
#update(diagnostics) ⇒ Object
Update diagnostics (called when new diagnostics arrive)
48 49 50 |
# File 'lib/mui/lsp/highlighters/diagnostic_highlighter.rb', line 48 def update(diagnostics) @diagnostics = diagnostics end |