-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for the [djlinter](https://www.djlint.com/) #4909
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR in incomplete. Please ensure to:
I have complete the tasks indicated. Let me know if you want me to do something else. |
I found an obvious mistake :-| |
If you have docker installed you can run tests with |
I'm running on Windows :-| I believe I have fixed the problem (although I'm not yet able to run the tests). |
Should I do something to trigger the 5 pending checks? |
I recommend you add |
Hi, thanks for implementing this linter. I'd also like to see this in ale. This patch should fix the linting issues (save to file and apply with From 3e202bbc002b7c377743bb8a88a481b9dd6b6366 Mon Sep 17 00:00:00 2001
From: Adrian Vollmer
Date: Fri, 7 Mar 2025 13:25:47 +0100
Subject: [PATCH] Fix linting
---
ale_linters/html/djlint.vim | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/ale_linters/html/djlint.vim b/ale_linters/html/djlint.vim
index 9e12fa02..a185dfea 100644
--- a/ale_linters/html/djlint.vim
+++ b/ale_linters/html/djlint.vim
@@ -13,34 +13,35 @@ function! ale_linters#html#djlint#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'html_djlint_options')
- return ale#Escape(l:executable)
- \ . (!empty(l:options) ? ' ' . l:options : '') . ' %s'
+ return ale#Escape(l:executable) . (!empty(l:options) ? ' ' . l:options : '') . ' %s'
endfunction
-function! ale_linters#html#djlint#Handle(buffer, lines)
+function! ale_linters#html#djlint#Handle(buffer, lines) abort
let l:output = []
let l:pattern = '\v^([A-Z]\d+) (\d+):(\d+) (.*)$'
let l:i = 0
+
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:i += 1
let l:item = {
- \ 'lnum': l:match[2] + 0,
- \ 'col': l:match[3] + 0,
- \ 'vcol': 1,
- \ 'text': l:match[4],
- \ 'code': l:match[1],
- \ 'type': 'W',
- \}
+ \ 'lnum': l:match[2] + 0,
+ \ 'col': l:match[3] + 0,
+ \ 'vcol': 1,
+ \ 'text': l:match[4],
+ \ 'code': l:match[1],
+ \ 'type': 'W',
+ \}
call add(l:output, l:item)
endfor
+
return l:output
endfunction
call ale#linter#Define('html', {
- \ 'name': 'djlint',
- \ 'executable': function('ale_linters#html#djlint#GetExecutable'),
- \ 'command': function('ale_linters#html#djlint#GetCommand'),
- \ 'callback': 'ale_linters#html#djlint#Handle',
- \})
+\ 'name': 'djlint',
+\ 'executable': function('ale_linters#html#djlint#GetExecutable'),
+\ 'command': function('ale_linters#html#djlint#GetCommand'),
+\ 'callback': 'ale_linters#html#djlint#Handle',
+\})
" vim:ts=4:sw=4:et:
--
2.47.2
|
Unfortunately I'm on Windows and the custom_linting_rules seems to be a bash script :-| based on |
Thanks for your help! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the work and patience.
Thanks for your patience! And thank you for the very helpfu ALE project :-) |
Thanks for the effort! However, I have a question. Does this work for you as is? Because my vim instance recognizes Django HTML templates as I'm not entirely sure how the internals of ALE work and if we can simply link the linter to the Edit: I suppose we might as well support Edit2: |
This code aim to propose a linter for the djlinter from: djlinter