parent
							
								
									d5c135cfaf
								
							
						
					
					
						commit
						36314aeaf2
					
				@ -81,6 +81,7 @@ name. That seems to be the fairest way to arrange this table.
 | 
				
			|||||||
| Java | [javac](http://www.oracle.com/technetwork/java/javase/downloads/index.html) |
 | 
					| Java | [javac](http://www.oracle.com/technetwork/java/javase/downloads/index.html) |
 | 
				
			||||||
| JavaScript | [eslint](http://eslint.org/), [jscs](http://jscs.info/), [jshint](http://jshint.com/), [flow](https://flowtype.org/), [standard](http://standardjs.com/), [xo](https://github.com/sindresorhus/xo)
 | 
					| JavaScript | [eslint](http://eslint.org/), [jscs](http://jscs.info/), [jshint](http://jshint.com/), [flow](https://flowtype.org/), [standard](http://standardjs.com/), [xo](https://github.com/sindresorhus/xo)
 | 
				
			||||||
| JSON | [jsonlint](http://zaa.ch/jsonlint/) |
 | 
					| JSON | [jsonlint](http://zaa.ch/jsonlint/) |
 | 
				
			||||||
 | 
					| Kotlin | [kotlinc](https://kotlinlang.org) see `:help ale-integration-kotlin` for configuration instructions
 | 
				
			||||||
| LaTeX | [chktex](http://www.nongnu.org/chktex/), [lacheck](https://www.ctan.org/pkg/lacheck) |
 | 
					| LaTeX | [chktex](http://www.nongnu.org/chktex/), [lacheck](https://www.ctan.org/pkg/lacheck) |
 | 
				
			||||||
| Lua | [luacheck](https://github.com/mpeterv/luacheck) |
 | 
					| Lua | [luacheck](https://github.com/mpeterv/luacheck) |
 | 
				
			||||||
| Markdown | [mdl](https://github.com/mivok/markdownlint), [proselint](http://proselint.com/), [vale](https://github.com/ValeLint/vale) |
 | 
					| Markdown | [mdl](https://github.com/mivok/markdownlint), [proselint](http://proselint.com/), [vale](https://github.com/ValeLint/vale) |
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										116
									
								
								ale_linters/kotlin/kotlinc.vim
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										116
									
								
								ale_linters/kotlin/kotlinc.vim
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,116 @@
 | 
				
			|||||||
 | 
					" Author: Francis Agyapong <francisgyapong2@gmail.com>
 | 
				
			||||||
 | 
					" Description: A linter for the Kotlin programming language that uses kotlinc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					let g:ale_kotlin_kotlinc_options = get(g:, 'ale_kotlin_kotlinc_options', '')
 | 
				
			||||||
 | 
					let g:ale_kotlin_kotlinc_enable_config = get(g:, 'ale_kotlin_kotlinc_enable_config', 0)
 | 
				
			||||||
 | 
					let g:ale_kotlin_kotlinc_config_file = get(g:, 'ale_kotlin_kotlinc_config_file', '.ale_kotlinc_config')
 | 
				
			||||||
 | 
					let g:ale_kotlin_kotlinc_classpath = get(g:, 'ale_kotlin_kotlinc_classpath', '')
 | 
				
			||||||
 | 
					let g:ale_kotlin_kotlinc_sourcepath = get(g:, 'ale_kotlin_kotlinc_sourcepath', '')
 | 
				
			||||||
 | 
					let g:ale_kotlin_kotlinc_use_module_file = get(g:, 'ale_kotlin_kotlinc_use_module_file', 0)
 | 
				
			||||||
 | 
					let g:ale_kotlin_kotlinc_module_filename = get(g:, 'ale_kotlin_kotlinc_module_filename', 'module.xml')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function! ale_linters#kotlin#kotlinc#GetCommand(buffer) abort
 | 
				
			||||||
 | 
					    let l:kotlinc_opts = ale#Var(a:buffer, 'kotlin_kotlinc_options')
 | 
				
			||||||
 | 
					    let l:command = 'kotlinc '
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    " If the config file is enabled and readable, source it
 | 
				
			||||||
 | 
					    if ale#Var(a:buffer, 'kotlin_kotlinc_enable_config')
 | 
				
			||||||
 | 
					        if filereadable(expand(ale#Var(a:buffer, 'kotlin_kotlinc_config_file'), 1))
 | 
				
			||||||
 | 
					            execute 'source ' . fnameescape(expand(ale#Var(a:buffer, 'kotlin_kotlinc_config_file'), 1))
 | 
				
			||||||
 | 
					        endif
 | 
				
			||||||
 | 
					    endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    " If use module and module file is readable use that and return
 | 
				
			||||||
 | 
					    if ale#Var(a:buffer, 'kotlin_kotlinc_use_module_file')
 | 
				
			||||||
 | 
					        let l:module_filename = fnameescape(expand(ale#Var(a:buffer, 'kotlin_kotlinc_module_filename'), 1))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if filereadable(l:module_filename)
 | 
				
			||||||
 | 
					            let l:kotlinc_opts .= ' -module ' . l:module_filename
 | 
				
			||||||
 | 
					            let l:command .= 'kotlinc ' . l:kotlinc_opts
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return l:command
 | 
				
			||||||
 | 
					        endif
 | 
				
			||||||
 | 
					    endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    " We only get here if not using module or the module file not readable
 | 
				
			||||||
 | 
					    if ale#Var(a:buffer, 'kotlin_kotlinc_classpath') !=# ''
 | 
				
			||||||
 | 
					        let l:kotlinc_opts .= ' -cp ' . ale#Var(a:buffer, 'kotlin_kotlinc_classpath')
 | 
				
			||||||
 | 
					    endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let l:fname = ''
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if ale#Var(a:buffer, 'kotlin_kotlinc_sourcepath') !=# ''
 | 
				
			||||||
 | 
					        let l:fname .= expand(ale#Var(a:buffer, 'kotlin_kotlinc_sourcepath'), 1) . ' '
 | 
				
			||||||
 | 
					    endif
 | 
				
			||||||
 | 
					    let l:fname .= shellescape(expand('#' . a:buffer . ':p'))
 | 
				
			||||||
 | 
					    let l:command .= l:kotlinc_opts . ' ' . l:fname
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return l:command
 | 
				
			||||||
 | 
					endfunction
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function! ale_linters#kotlin#kotlinc#Handle(buffer, lines) abort
 | 
				
			||||||
 | 
					    let l:code_pattern = '^\(.*\):\([0-9]\+\):\([0-9]\+\):\s\+\(error\|warning\):\s\+\(.*\)'
 | 
				
			||||||
 | 
					    let l:general_pattern = '^\(warning\|error\|info\):\s*\(.*\)'
 | 
				
			||||||
 | 
					    let l:output = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for l:line in a:lines
 | 
				
			||||||
 | 
					        let l:match = matchlist(l:line, l:code_pattern)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if len(l:match) == 0
 | 
				
			||||||
 | 
					            continue
 | 
				
			||||||
 | 
					        endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let l:file = l:match[1]
 | 
				
			||||||
 | 
					        let l:line = l:match[2] + 0
 | 
				
			||||||
 | 
					        let l:column = l:match[3] + 0
 | 
				
			||||||
 | 
					        let l:type = l:match[4]
 | 
				
			||||||
 | 
					        let l:text = l:match[5]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let l:buf_abspath = fnamemodify(l:file, ':p')
 | 
				
			||||||
 | 
					        let l:curbuf_abspath = expand('#' . a:buffer . ':p')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        " Skip if file is not loaded
 | 
				
			||||||
 | 
					        if l:buf_abspath !=# l:curbuf_abspath
 | 
				
			||||||
 | 
					            continue
 | 
				
			||||||
 | 
					        endif
 | 
				
			||||||
 | 
					        let l:type_marker_str = l:type ==# 'warning' ? 'W' : 'E'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        call add(l:output, {
 | 
				
			||||||
 | 
					        \   'lnum': l:line,
 | 
				
			||||||
 | 
					        \   'col': l:column,
 | 
				
			||||||
 | 
					        \   'text': l:text,
 | 
				
			||||||
 | 
					        \   'type': l:type_marker_str,
 | 
				
			||||||
 | 
					        \})
 | 
				
			||||||
 | 
					    endfor
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    " Non-code related messages
 | 
				
			||||||
 | 
					    for l:line in a:lines
 | 
				
			||||||
 | 
					        let l:match = matchlist(l:line, l:general_pattern)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if len(l:match) == 0
 | 
				
			||||||
 | 
					            continue
 | 
				
			||||||
 | 
					        endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let l:type = l:match[1]
 | 
				
			||||||
 | 
					        let l:text = l:match[2]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let l:type_marker_str = l:type ==# 'warning' || l:type ==# 'info' ? 'W' : 'E'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        call add(l:output, {
 | 
				
			||||||
 | 
					        \   'lnum': -1,
 | 
				
			||||||
 | 
					        \   'text': l:text,
 | 
				
			||||||
 | 
					        \   'type': l:type_marker_str,
 | 
				
			||||||
 | 
					        \})
 | 
				
			||||||
 | 
					    endfor
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return l:output
 | 
				
			||||||
 | 
					endfunction
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					call ale#linter#Define('kotlin', {
 | 
				
			||||||
 | 
					\   'name': 'kotlinc',
 | 
				
			||||||
 | 
					\   'output_stream': 'stderr',
 | 
				
			||||||
 | 
					\   'executable': 'kotlinc',
 | 
				
			||||||
 | 
					\   'command_callback': 'ale_linters#kotlin#kotlinc#GetCommand',
 | 
				
			||||||
 | 
					\   'callback': 'ale_linters#kotlin#kotlinc#Handle',
 | 
				
			||||||
 | 
					\   'lint_file': 1,
 | 
				
			||||||
 | 
					\})
 | 
				
			||||||
							
								
								
									
										65
									
								
								doc/ale-kotlin.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								doc/ale-kotlin.txt
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,65 @@
 | 
				
			|||||||
 | 
					===============================================================================
 | 
				
			||||||
 | 
					ALE Kotlin Integration                                     *ale-kotlin-options*
 | 
				
			||||||
 | 
					                                                       *ale-integration-kotlin*
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Integration Information
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Make sure your setup has support for the kotlin file type. A filetype plugin
 | 
				
			||||||
 | 
					  can be found here: https://github.com/udalov/kotlin-vim
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Note: Make sure you have a working kotlin compiler
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					kotlinc                                                    *ale-kotlin-kotlinc*
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					g:ale_kotlin_kotlinc_options                     *g:ale_kotlin_kotlinc_options*
 | 
				
			||||||
 | 
					  Type: |String|
 | 
				
			||||||
 | 
					  Default: `''`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Additional options to pass to the kotlin compiler
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					g:ale_kotlin_kotlinc_enable_config         *g:ale_kotlin_kotlinc_enable_config*
 | 
				
			||||||
 | 
					  Type: |Number|
 | 
				
			||||||
 | 
					  Default: `0`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Setting this variable to `1` tells the linter to load a configuration file.
 | 
				
			||||||
 | 
					  This should be set in your vimrc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					g:ale_kotlin_kotlinc_config_file             *g:ale_kotlin_kotlinc_config_file*
 | 
				
			||||||
 | 
					  Type: |String|
 | 
				
			||||||
 | 
					  Default: `'.ale_kotlin_kotlinc_config'`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Filename of the configuration file. This should be set in your vimrc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					g:ale_kotlin_kotlinc_classpath                 *g:ale_kotlin_kotlinc_classpath*
 | 
				
			||||||
 | 
					  Type: |String|
 | 
				
			||||||
 | 
					  Default: `''`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  A string containing the paths (separated by the appropriate path separator)
 | 
				
			||||||
 | 
					  of the source directories.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					g:ale_kotlin_kotlinc_sourcepath               *g:ale_kotlin_kotlinc_sourcepath*
 | 
				
			||||||
 | 
					  Type: |String|
 | 
				
			||||||
 | 
					  Default: `''`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  A string containing the paths (separated by space) of the source
 | 
				
			||||||
 | 
					  directories.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					g:ale_kotlin_kotlinc_use_module_file     *g:ale_kotlin_kotlinc_use_module_file*
 | 
				
			||||||
 | 
					  Type: |Number|
 | 
				
			||||||
 | 
					  Default: `0`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  This option indicates whether the linter should use a module file. It is off
 | 
				
			||||||
 | 
					  by default.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					g:ale_kotlin_kotlinc_module_filename     *g:ale_kotlin_kotlinc_module_filename*
 | 
				
			||||||
 | 
					  Type: |String|
 | 
				
			||||||
 | 
					  Default: `'module.xml'`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  The filename of the module file that the linter should pass to the kotlin
 | 
				
			||||||
 | 
					  compiler.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
 | 
				
			||||||
@ -46,6 +46,8 @@ CONTENTS                                                         *ale-contents*
 | 
				
			|||||||
      jshint..............................|ale-javascript-jshint|
 | 
					      jshint..............................|ale-javascript-jshint|
 | 
				
			||||||
      standard............................|ale-javascript-standard|
 | 
					      standard............................|ale-javascript-standard|
 | 
				
			||||||
      xo..................................|ale-javascript-xo|
 | 
					      xo..................................|ale-javascript-xo|
 | 
				
			||||||
 | 
					    kotlin................................|ale-kotlin-options|
 | 
				
			||||||
 | 
					      kotlinc.............................|ale-kotlin-kotlinc|
 | 
				
			||||||
    lua...................................|ale-lua-options|
 | 
					    lua...................................|ale-lua-options|
 | 
				
			||||||
      luacheck............................|ale-lua-luacheck|
 | 
					      luacheck............................|ale-lua-luacheck|
 | 
				
			||||||
    ocaml.................................|ale-ocaml-options|
 | 
					    ocaml.................................|ale-ocaml-options|
 | 
				
			||||||
@ -139,6 +141,7 @@ The following languages and tools are supported.
 | 
				
			|||||||
* Java: 'javac'
 | 
					* Java: 'javac'
 | 
				
			||||||
* JavaScript: 'eslint', 'jscs', 'jshint', 'flow', 'xo'
 | 
					* JavaScript: 'eslint', 'jscs', 'jshint', 'flow', 'xo'
 | 
				
			||||||
* JSON: 'jsonlint'
 | 
					* JSON: 'jsonlint'
 | 
				
			||||||
 | 
					* Kotlin: 'kotlinc'
 | 
				
			||||||
* LaTeX: 'chktex', 'lacheck'
 | 
					* LaTeX: 'chktex', 'lacheck'
 | 
				
			||||||
* Lua: 'luacheck'
 | 
					* Lua: 'luacheck'
 | 
				
			||||||
* Markdown: 'mdl', 'proselint', 'vale'
 | 
					* Markdown: 'mdl', 'proselint', 'vale'
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user