mirror of
https://github.com/chenasraf/nvim-treesitter.git
synced 2026-05-18 01:39:00 +00:00
feat(python): add match-case indents
This commit is contained in:
committed by
Amaan Qureshi
parent
a072d923c7
commit
1ffa019856
@@ -44,6 +44,10 @@
|
||||
(#set! indent.immediate 1))
|
||||
((with_statement) @indent.begin
|
||||
(#set! indent.immediate 1))
|
||||
((match_statement) @indent.begin
|
||||
(#set! indent.immediate 1))
|
||||
((case_clause) @indent.begin
|
||||
(#set! indent.immediate 1))
|
||||
|
||||
(if_statement
|
||||
condition: (parenthesized_expression) @indent.align
|
||||
|
||||
15
tests/indent/python/match_case.py
Normal file
15
tests/indent/python/match_case.py
Normal file
@@ -0,0 +1,15 @@
|
||||
a = 0
|
||||
|
||||
def test_match_case():
|
||||
match a:
|
||||
case 1:
|
||||
return
|
||||
|
||||
|
||||
def test_match():
|
||||
match a:
|
||||
|
||||
|
||||
def test_case():
|
||||
match a:
|
||||
case b:
|
||||
@@ -84,6 +84,10 @@ describe("indent Python:", function()
|
||||
run:new_line("line_after_indent.py", { on_line = 49, text = "x", indent = 0 })
|
||||
run:new_line("line_after_indent.py", { on_line = 55, text = "x", indent = 4 })
|
||||
run:new_line("line_after_indent.py", { on_line = 63, text = "x", indent = 4 })
|
||||
run:new_line("match_case.py", { on_line = 4, text = "pass", indent = 8 })
|
||||
run:new_line("match_case.py", { on_line = 5, text = "pass", indent = 12 })
|
||||
run:new_line("match_case.py", { on_line = 10, text = "pass", indent = 8 })
|
||||
run:new_line("match_case.py", { on_line = 15, text = "pass", indent = 12 })
|
||||
|
||||
for _, line in ipairs { 2, 5, 8, 11, 16, 21, 24, 27, 34, 39 } do
|
||||
run:new_line("return_dedent.py", { on_line = line, text = "x", indent = 0 })
|
||||
|
||||
Reference in New Issue
Block a user