1
0
mirror of https://github.com/amix/vimrc synced 2025-06-16 01:25:00 +08:00

Added missing commits

This commit is contained in:
Amir Salihefendic
2019-03-11 17:39:30 -03:00
parent f50b2142bc
commit bf7b5985f1
28 changed files with 1928 additions and 0 deletions

View File

@ -0,0 +1,43 @@
" Author: w0rp <devw0rp@gmail.com>
" Description: This module implements a function for parsing arguments for
" commands.
" Given a list of valid arguments like ['foo', 'bar'] and a string to parse,
" parse the arguments from the string and return [parsed_args, remainder].
"
" Arguments must be prefixed in the string with a single minus (-), and a
" double minus (--) denotes the end of arguments.
function! ale#args#Parse(arg_list, string) abort
let l:parsed = {}
let l:end_of_args = 0
let l:word_list = split(a:string, ' ')
let l:index = 0
while l:index < len(l:word_list)
let l:word = l:word_list[l:index]
if l:word[:0] is# '-'
let l:index += 1
if l:word is# '--'
break
endif
let l:arg = l:word[1:]
if index(a:arg_list, l:arg) >= 0
let l:parsed[l:arg] = ''
else
throw 'Invalid argument: ' . l:word
endif
elseif l:word is# ''
let l:index += 1
else
break
endif
endwhile
let l:new_string = join(l:word_list[l:index :], ' ')
return [l:parsed, l:new_string]
endfunction

View File

@ -0,0 +1,18 @@
" Author: Attila Maczak <attila@maczak.hu>
" Description: Integration of cmakeformat with ALE.
call ale#Set('cmake_cmakeformat_executable', 'cmake-format')
call ale#Set('cmake_cmakeformat_options', '')
function! ale#fixers#cmakeformat#Fix(buffer) abort
let l:executable = ale#Var(a:buffer, 'cmake_cmakeformat_executable')
let l:options = ale#Var(a:buffer, 'cmake_cmakeformat_options')
return {
\ 'command': ale#Escape(l:executable)
\ . ' -i '
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ' %t',
\ 'read_temporary_file': 1,
\}
endfunction

View File

@ -0,0 +1,9 @@
" Author: Michael Phillips <michaeljoelphillips@gmail.com>
" Description: Fix Kotlin files with ktlint.
function! ale#fixers#ktlint#Fix(buffer) abort
return {
\ 'command': ale#handlers#ktlint#GetCommand(a:buffer) . ' --format',
\ 'read_temporary_file': 1,
\}
endfunction

View File

@ -0,0 +1,15 @@
" Author: TANIGUCHI Masaya <ta2gch@gmail.com>
" Description: Integration of textlint with ALE.
function! ale#fixers#textlint#Fix(buffer) abort
let l:executable = ale#handlers#textlint#GetExecutable(a:buffer)
let l:options = ale#Var(a:buffer, 'textlint_options')
return {
\ 'command': ale#Escape(l:executable)
\ . ' --fix'
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ' %t',
\ 'read_temporary_file': 1,
\}
endfunction

View File

@ -0,0 +1,45 @@
" Author: Michael Phillips <michaeljoelphillips@gmail.com>
" Description: Handler functions for ktlint.
call ale#Set('kotlin_ktlint_executable', 'ktlint')
call ale#Set('kotlin_ktlint_rulesets', [])
call ale#Set('kotlin_ktlint_options', '')
function! ale#handlers#ktlint#GetCommand(buffer) abort
let l:executable = ale#Var(a:buffer, 'kotlin_ktlint_executable')
let l:options = ale#Var(a:buffer, 'kotlin_ktlint_options')
let l:rulesets = ale#handlers#ktlint#GetRulesets(a:buffer)
return ale#Escape(l:executable)
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . (empty(l:rulesets) ? '' : ' ' . l:rulesets)
\ . ' %t'
endfunction
function! ale#handlers#ktlint#GetRulesets(buffer) abort
let l:rulesets = map(ale#Var(a:buffer, 'kotlin_ktlint_rulesets'), '''--ruleset '' . v:val')
return join(l:rulesets, ' ')
endfunction
function! ale#handlers#ktlint#Handle(buffer, lines) abort
let l:message_pattern = '^\(.*\):\([0-9]\+\):\([0-9]\+\):\s\+\(.*\)'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:message_pattern)
let l:line = l:match[2] + 0
let l:column = l:match[3] + 0
let l:text = l:match[4]
let l:type = l:text =~? 'not a valid kotlin file' ? 'E' : 'W'
call add(l:output, {
\ 'lnum': l:line,
\ 'col': l:column,
\ 'text': l:text,
\ 'type': l:type
\})
endfor
return l:output
endfunction

View File

@ -0,0 +1,8 @@
" Author: Derek Sifford <dereksifford@gmail.com>
" Description: Handlers for tsserver
function! ale#handlers#tsserver#GetProjectRoot(buffer) abort
let l:tsconfig_file = ale#path#FindNearestFile(a:buffer, 'tsconfig.json')
return !empty(l:tsconfig_file) ? fnamemodify(l:tsconfig_file, ':h') : ''
endfunction