Add indent expr support - #23
Conversation
- Although it may not work perfectly in some situations, it is better than nothing - Added end semicolon highlighting for name definition to assist indentation
| let indent = 0 | ||
|
|
||
| if pline =~# '\v^\s*%(\|\s*)?%(def|try|then|if|elif|else)>|[:{([]$' | ||
| \|| pline =~# '\v<%(try|then|if|elif|else)$' |
There was a problem hiding this comment.
" Define a list of command names
let s:jq_commands = '\v(def|try|then|if|elif|else)'
" Updated condition using the variable
if previous_line =~# '^\s*%(\|\s*)?' . s:jq_commands . '>|[:{([]$'
\ || previous_line =~# '<' . s:jq_commands . '$'
let indent_adjustment += 1
endif
we should add a jq_commands actually could you reuse the jqKeywords here?
Line 17 in e5c2f21
then you could do something like this:
" Function to check if a line starts with a jqKeyword
function! IsJqKeyword(line) abort
let col = match(a:line, '\S') + 1
let syntax_id = synID(a:lnum, col, 1)
let syntax_name = synIDattr(syntax_id, 'name')
return syntax_name ==# 'jqKeywords'
endfunction
|
Thanks for your contribution!
Can you give me some more details about what situations won't work perfectly and what works well. Then we could try and correct the issues. Right now this repo eventually gets merged into the vim codebase so I would rather have it working and validated. Potential Issues I saw:
The closing
The script might fail to calculate the correct indentation level for the second if block, especially if the previous lines are stripped incorrectly. |
|
Also since you added some highlighting could you add a screenshot with and without the highlighting. I think we would probably have to add a flag for that. |
|
The indentation of parentheses at the end and beginning of unpaired lines may be incorrect Perhaps we can match |
Add `reduce` and `foreach` matching
|
Reducing multi-level indentation in the same line is troublesome, and how much indentation should be added to multiple parentheses in the same line is a more complex issue. Perhaps the current one is good enough # some code
end)In the following two codes # some code
(@text | if . then
.
end)
# yes # some code
(
@text
| if . then
.
end)
# noIf we want to distinguish these situations, the complexity and performance may not be acceptable |


Close #21