class LanguageServer::Protocol::Interface::FormattingOptions

Value-object describing what options formatting should use.

Attributes

attributes[R]

Public Class Methods

new(tab_size:, insert_spaces:, trim_trailing_whitespace: nil, insert_final_newline: nil, trim_final_newlines: nil) click to toggle source
# File lib/language_server/protocol/interface/formatting_options.rb, line 8
def initialize(tab_size:, insert_spaces:, trim_trailing_whitespace: nil, insert_final_newline: nil, trim_final_newlines: nil)
  @attributes = {}

  @attributes[:tabSize] = tab_size
  @attributes[:insertSpaces] = insert_spaces
  @attributes[:trimTrailingWhitespace] = trim_trailing_whitespace if trim_trailing_whitespace
  @attributes[:insertFinalNewline] = insert_final_newline if insert_final_newline
  @attributes[:trimFinalNewlines] = trim_final_newlines if trim_final_newlines

  @attributes.freeze
end

Public Instance Methods

insert_final_newline() click to toggle source

Insert a newline character at the end of the file if one does not exist.

@return [boolean]

# File lib/language_server/protocol/interface/formatting_options.rb, line 48
def insert_final_newline
  attributes.fetch(:insertFinalNewline)
end
insert_spaces() click to toggle source

Prefer spaces over tabs.

@return [boolean]

# File lib/language_server/protocol/interface/formatting_options.rb, line 32
def insert_spaces
  attributes.fetch(:insertSpaces)
end
tab_size() click to toggle source

Size of a tab in spaces.

@return [number]

# File lib/language_server/protocol/interface/formatting_options.rb, line 24
def tab_size
  attributes.fetch(:tabSize)
end
to_hash() click to toggle source
# File lib/language_server/protocol/interface/formatting_options.rb, line 62
def to_hash
  attributes
end
to_json(*args) click to toggle source
# File lib/language_server/protocol/interface/formatting_options.rb, line 66
def to_json(*args)
  to_hash.to_json(*args)
end
trim_final_newlines() click to toggle source

Trim all newlines after the final newline at the end of the file.

@return [boolean]

# File lib/language_server/protocol/interface/formatting_options.rb, line 56
def trim_final_newlines
  attributes.fetch(:trimFinalNewlines)
end
trim_trailing_whitespace() click to toggle source

Trim trailing whitespace on a line.

@return [boolean]

# File lib/language_server/protocol/interface/formatting_options.rb, line 40
def trim_trailing_whitespace
  attributes.fetch(:trimTrailingWhitespace)
end