Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
switch between ruby and haml formatters
  • Loading branch information
Petercopter committed Aug 5, 2022
commit 9063741b3ddb020915a35ff41c79770c48ac03c1
7 changes: 4 additions & 3 deletions lib/syntax_tree/language_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def run
store.delete(uri)
in { method: "textDocument/formatting", id:, params: { textDocument: { uri: } } }
contents = store[uri]
write(id: id, result: contents ? [format(store[uri])] : nil)
write(id: id, result: contents ? [format(store[uri], uri.split(".").last)] : nil)
in { method: "textDocument/inlayHint", id:, params: { textDocument: { uri: } } }
contents = store[uri]
write(id: id, result: contents ? inlay_hints(store[uri]) : nil)
Expand Down Expand Up @@ -86,7 +86,7 @@ def capabilities
}
end

def format(source)
def format(source, file_extension)
{
range: {
start: {
Expand All @@ -98,7 +98,7 @@ def format(source)
character: 0
}
},
newText: SyntaxTree.format(source, print_width)
newText: file_extension == "haml" ? SyntaxTree::Haml.format(source, print_width) : SyntaxTree.format(source, print_width)
}
end

Expand All @@ -119,3 +119,4 @@ def write(value)
end
end
end