summaryrefslogtreecommitdiff
path: root/ale_linters/cs
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2021-03-01 20:11:10 +0000
committerw0rp <devw0rp@gmail.com>2021-03-01 20:11:10 +0000
commit9fe7b1fe6a23fb55e6d782293585d58193123f59 (patch)
tree0403deb70011aee7be08e586b10b5828cf69499e /ale_linters/cs
parent48fab99a0ab793e1b9607795c21659f12bd6947f (diff)
downloadale-9fe7b1fe6a23fb55e6d782293585d58193123f59.zip
Close #2281 - Separate cwd commands from commands
Working directories are now set seperately from the commands so they can later be swapped out when running linters over projects is supported, and also better support filename mapping for running linters on other machines in future.
Diffstat (limited to 'ale_linters/cs')
-rw-r--r--ale_linters/cs/csc.vim17
-rw-r--r--ale_linters/cs/mcsc.vim16
2 files changed, 12 insertions, 21 deletions
diff --git a/ale_linters/cs/csc.vim b/ale_linters/cs/csc.vim
index 308abc77..5ee3de29 100644
--- a/ale_linters/cs/csc.vim
+++ b/ale_linters/cs/csc.vim
@@ -3,14 +3,10 @@ call ale#Set('cs_csc_source', '')
call ale#Set('cs_csc_assembly_path', [])
call ale#Set('cs_csc_assemblies', [])
-function! s:GetWorkingDirectory(buffer) abort
- let l:working_directory = ale#Var(a:buffer, 'cs_csc_source')
+function! ale_linters#cs#csc#GetCwd(buffer) abort
+ let l:cwd = ale#Var(a:buffer, 'cs_csc_source')
- if !empty(l:working_directory)
- return l:working_directory
- endif
-
- return expand('#' . a:buffer . ':p:h')
+ return !empty(l:cwd) ? l:cwd : expand('#' . a:buffer . ':p:h')
endfunction
function! ale_linters#cs#csc#GetCommand(buffer) abort
@@ -34,8 +30,7 @@ function! ale_linters#cs#csc#GetCommand(buffer) abort
" The code is compiled as a module and the output is redirected to a
" temporary file.
- return ale#path#CdString(s:GetWorkingDirectory(a:buffer))
- \ . 'csc /unsafe'
+ return 'csc /unsafe'
\ . ale#Pad(ale#Var(a:buffer, 'cs_csc_options'))
\ . ale#Pad(l:lib_option)
\ . ale#Pad(l:r_option)
@@ -57,8 +52,7 @@ function! ale_linters#cs#csc#Handle(buffer, lines) abort
\ '^\v([^ ]+)\s+([Cc][sS][^ ]+):\s+(.+)$',
\]
let l:output = []
-
- let l:dir = s:GetWorkingDirectory(a:buffer)
+ let l:dir = ale_linters#cs#csc#GetCwd(a:buffer)
for l:match in ale#util#GetMatches(a:lines, l:patterns)
if len(l:match) > 6 && strlen(l:match[5]) > 2 && l:match[5][:1] is? 'CS'
@@ -89,6 +83,7 @@ call ale#linter#Define('cs',{
\ 'name': 'csc',
\ 'output_stream': 'stdout',
\ 'executable': 'csc',
+\ 'cwd': function('ale_linters#cs#csc#GetCwd'),
\ 'command': function('ale_linters#cs#csc#GetCommand'),
\ 'callback': 'ale_linters#cs#csc#Handle',
\ 'lint_file': 1
diff --git a/ale_linters/cs/mcsc.vim b/ale_linters/cs/mcsc.vim
index 0e4e5667..2dd46661 100644
--- a/ale_linters/cs/mcsc.vim
+++ b/ale_linters/cs/mcsc.vim
@@ -3,14 +3,10 @@ call ale#Set('cs_mcsc_source', '')
call ale#Set('cs_mcsc_assembly_path', [])
call ale#Set('cs_mcsc_assemblies', [])
-function! s:GetWorkingDirectory(buffer) abort
- let l:working_directory = ale#Var(a:buffer, 'cs_mcsc_source')
+function! ale_linters#cs#mcsc#GetCwd(buffer) abort
+ let l:cwd = ale#Var(a:buffer, 'cs_mcsc_source')
- if !empty(l:working_directory)
- return l:working_directory
- endif
-
- return expand('#' . a:buffer . ':p:h')
+ return !empty(l:cwd) ? l:cwd : expand('#' . a:buffer . ':p:h')
endfunction
function! ale_linters#cs#mcsc#GetCommand(buffer) abort
@@ -34,8 +30,7 @@ function! ale_linters#cs#mcsc#GetCommand(buffer) abort
" The code is compiled as a module and the output is redirected to a
" temporary file.
- return ale#path#CdString(s:GetWorkingDirectory(a:buffer))
- \ . 'mcs -unsafe'
+ return 'mcs -unsafe'
\ . ale#Pad(ale#Var(a:buffer, 'cs_mcsc_options'))
\ . ale#Pad(l:lib_option)
\ . ale#Pad(l:r_option)
@@ -58,7 +53,7 @@ function! ale_linters#cs#mcsc#Handle(buffer, lines) abort
\]
let l:output = []
- let l:dir = s:GetWorkingDirectory(a:buffer)
+ let l:dir = ale_linters#cs#mcsc#GetCwd(a:buffer)
for l:match in ale#util#GetMatches(a:lines, l:patterns)
if len(l:match) > 6 && strlen(l:match[5]) > 2 && l:match[5][:1] is? 'CS'
@@ -89,6 +84,7 @@ call ale#linter#Define('cs',{
\ 'name': 'mcsc',
\ 'output_stream': 'stderr',
\ 'executable': 'mcs',
+\ 'cwd': function('ale_linters#cs#mcsc#GetCwd'),
\ 'command': function('ale_linters#cs#mcsc#GetCommand'),
\ 'callback': 'ale_linters#cs#mcsc#Handle',
\ 'lint_file': 1