lukas-reineke / indent-blankline.nvim

Indent guides for Neovim
MIT License
4.2k stars 104 forks source link

C typedef and public key can't sorghum indentation #128

Closed denstiny closed 3 years ago

denstiny commented 3 years ago

image

vim.g.indent_blankline_show_current_context = true
vim.g.indent_blankline_context_patterns = {
    'class',
    'function',
    'method',
    '^if',
    '^while',
    '^typedef',
    '^for',
    '^object',
    '^table',
    'block',
    'arguments',
    'typedef',
    'while',
    '^public',
    'return',
    'if_statement',
    'else_clause',
    'jsx_element',
    'jsx_self_closing_element',
    'try_statement',
    'catch_clause',
    'import_statement'
}
vim.g.indent_blankline_char = '│'

vim.g.indent_blankline_filetype_exclude = {'help','startify','nerdtree'}
lukas-reineke commented 3 years ago

I think you want labeled_statement

denstiny commented 3 years ago

labeled_statement

Yes, what should I do

lukas-reineke commented 3 years ago

add it to vim.g.indent_blankline_context_patterns

denstiny commented 3 years ago

indent_blankline_context_patterns

I this is to join in, but he is invalid

denstiny commented 3 years ago

My configuration

vim.g.indent_blankline_show_current_context = true
vim.g.indent_blankline_context_patterns = {
    'class',
    'function',
    'method',
    '^if',
    '^while',
    '^typedef',
    '^for',
    '^object',
    '^table',
    'block',
    'arguments',
    'typedef',
    'while',
    '^public',
    'return',
    'if_statement',
    'else_clause',
    'jsx_element',
    'jsx_self_closing_element',
    'try_statement',
    'catch_clause',
    'import_statement'
}
vim.g.indent_blankline_char = '│'
-- 设置特定缓冲区不起用
vim.g.indent_blankline_filetype_exclude = {'help','startify','nerdtree'}
lukas-reineke commented 3 years ago

like this

vim.g.indent_blankline_context_patterns = {
    'class',
    'function',
    'method',
    '^if',
    '^while',
    '^typedef',
    '^for',
    '^object',
    '^table',
    'block',
    'arguments',
    'typedef',
    'while',
    '^public',
    'return',
    'if_statement',
    'else_clause',
    'jsx_element',
    'jsx_self_closing_element',
    'try_statement',
    'catch_clause',
    'import_statement',
    'labeled_statement'
}
denstiny commented 3 years ago

I'm sorry it didn't what effect

lukas-reineke commented 3 years ago

Then I don't understand your problem. Can you try to explain it again

denstiny commented 3 years ago

那我不明白你的问题。 你能不能再解释一遍 image

My rules don't work for the public

vim.g.indent_blankline_context_patterns = {
    '^public',

}
lukas-reineke commented 3 years ago

indent_blankline_context_patterns does not match your code. It matches against the treesitter node type. The type of that public statement in C is labeled_statement

It works for me to just add it to the list.

Screen Capture_select-area_20210621160118

denstiny commented 3 years ago

thank you