ale
ale copied to clipboard
KTLint formatting adding debug text to file
Information
NVIM v0.6.1 Build type: Release
Arch Linux x86_64
What went wrong
After setting up ktlint using kotlin = { "ktlint" },
in my neovim config and saving a file, the file formats correctly but the ktlint debug information is added on both sides of the file. Here is an example from Gradle's default hello world after removing a tab and then saving with the format on save option enabled:
`00:46:02.120 [main] DEBUG com.pinterest.ktlint.Main - Discovered reporter with "baseline" id. 00:46:02.122 [main] DEBUG com.pinterest.ktlint.Main - Discovered reporter with "checkstyle" id. 00:46:02.123 [main] DEBUG com.pinterest.ktlint.Main - Discovered reporter with "json" id. 00:46:02.123 [main] DEBUG com.pinterest.ktlint.Main - Discovered reporter with "html" id. 00:46:02.123 [main] DEBUG com.pinterest.ktlint.Main - Discovered reporter with "plain" id. 00:46:02.123 [main] DEBUG com.pinterest.ktlint.Main - Discovered reporter with "sarif" id. 00:46:02.123 [main] DEBUG com.pinterest.ktlint.Main - Initializing "plain" reporter with {verbose=false, color=false, color_name=DARK_GRAY} /*
- This Kotlin source file was generated by the Gradle 'init' task. */ package hello_world
class App {
val greeting: String
get() {
return "Hello World!"
}
}
fun main() { println(App().greeting) } 00:46:03.083 [main] DEBUG com.pinterest.ktlint.Main - 1248ms / 1 file(s) / 0 error(s)`
Reproducing the bug
- Install neovim
- Set up ale with ktlint enabled for kotlin formatting and format on save
- Generate Gradle hello world project
- Save App.kt
:ALEInfo
let g:ale_loclist_msg_format = v:null let g:ale_max_buffer_history_size = v:null let g:ale_max_signs = v:null let g:ale_maximum_file_size = v:null let g:ale_open_list = v:null let g:ale_pattern_options = v:null let g:ale_pattern_options_enabled = v:null let g:ale_root = {} let g:ale_set_balloons = 0 let g:ale_set_highlights = 1 let g:ale_set_loclist = 1 let g:ale_set_quickfix = 0 let g:ale_set_signs = 1 let g:ale_sign_column_always = v:null let g:ale_sign_error = v:null let g:ale_sign_info = v:null let g:ale_sign_offset = v:null let g:ale_sign_style_error = v:null let g:ale_sign_style_warning = v:null let g:ale_sign_warning = v:null let g:ale_sign_highlight_linenrs = v:null let g:ale_statusline_format = v:null let g:ale_type_map = v:null let g:ale_use_global_executables = v:null let g:ale_virtualtext_cursor = 0 let g:ale_warn_about_trailing_blank_lines = 1 let g:ale_warn_about_trailing_whitespace = 1
I use ktlint with ALE for work and I have never seen this behavior. I just tested on my machine and the fixer works as expected. Can you verify if you have some ktlint configuration that causes it to output debug information?
I am using latest ALE from master, neovim 0.7.0-dev, and ktlint 0.42.1.
I don't have any ktlint configuration and other ALE fixers are working properly. I tried a few different ktlint versions as well and updated ALE. Same result each time.
Seems there was a bug that caused ktlint to output debug info even if --debug flag was not used: https://github.com/pinterest/ktlint/issues/1412
If you still see this behavior and are sure the --debug flag is not being passed to ktlint then is a regression on Ktlint side. I recommend to report this problem at Ktlint repository.
Does not seem to be ALE issue. Ktlint works fine on my own projects.