Skip to content

Commit 4aab6e1

Browse files
committed
Remove a:module arguments
Remove the 'a:module' arguments from the calls to `ghcmod#build_command` in the sig, split, info, and type functions. No version check because they've actually been optional since v5.0, but now they have been removed completely. Also replace them with `...` in the function's argument list, so that calls with or without them are accepted, In case there are any other plugins based on ghcmod-vim. For the same reason, `ghcmod#detect_module` is still there.
1 parent a7c76b9 commit 4aab6e1

File tree

5 files changed

+18
-20
lines changed

5 files changed

+18
-20
lines changed

autoload/ghcmod.vim

+8-8
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ function! ghcmod#getHaskellIdentifier() "{{{
1414
return ll1.ll2
1515
endfunction "}}}
1616

17-
function! ghcmod#info(fexp, path, module) "{{{
18-
let l:cmd = ghcmod#build_command(["-b \n", 'info', a:path, a:module, a:fexp])
17+
function! ghcmod#info(fexp, path, ...) "{{{
18+
let l:cmd = ghcmod#build_command(["-b \n", 'info', a:path, a:fexp])
1919
let l:output = ghcmod#system(l:cmd)
2020
" Remove trailing newlines to prevent empty lines
2121
let l:output = substitute(l:output, '\n*$', '', '')
2222
return s:remove_dummy_prefix(l:output)
2323
endfunction "}}}
2424

25-
function! ghcmod#split(line, col, path, module) "{{{
25+
function! ghcmod#split(line, col, path, ...) "{{{
2626
" `ghc-mod split` is available since v5.0.0.
27-
let l:cmd = ghcmod#build_command(['split', a:path, a:module, a:line, a:col])
27+
let l:cmd = ghcmod#build_command(['split', a:path, a:line, a:col])
2828
let l:lines = s:system('split', l:cmd)
2929
if empty(l:lines)
3030
return []
@@ -36,18 +36,18 @@ function! ghcmod#split(line, col, path, module) "{{{
3636
return split(l:parsed[5], '\n')
3737
endfunction "}}}
3838

39-
function! ghcmod#sig(line, col, path, module) "{{{
39+
function! ghcmod#sig(line, col, path, ...) "{{{
4040
" `ghc-mod sig` is available since v5.0.0.
41-
let l:cmd = ghcmod#build_command(['sig', a:path, a:module, a:line, a:col])
41+
let l:cmd = ghcmod#build_command(['sig', a:path, a:line, a:col])
4242
let l:lines = s:system('sig', l:cmd)
4343
if len(l:lines) < 3
4444
return []
4545
endif
4646
return [l:lines[0], l:lines[2 :]]
4747
endfunction "}}}
4848

49-
function! ghcmod#type(line, col, path, module) "{{{
50-
let l:cmd = ghcmod#build_command(['type', a:path, a:module, a:line, a:col])
49+
function! ghcmod#type(line, col, path, ...) "{{{
50+
let l:cmd = ghcmod#build_command(['type', a:path, a:line, a:col])
5151
let l:output = ghcmod#system(l:cmd)
5252
let l:types = []
5353
for l:line in split(l:output, '\n')

autoload/ghcmod/command.vim

+6-8
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function! ghcmod#command#type(force) "{{{
3737
return
3838
endif
3939

40-
let l:types = ghcmod#type(l:line, l:col, l:path, ghcmod#detect_module())
40+
let l:types = ghcmod#type(l:line, l:col, l:path)
4141
if empty(l:types)
4242
call ghcmod#util#print_error('ghcmod#command#type: Cannot guess type')
4343
return
@@ -62,8 +62,7 @@ function! ghcmod#command#split_function_case(force) "{{{
6262
return
6363
endif
6464

65-
let l:module = ghcmod#detect_module()
66-
let l:decls = ghcmod#split(line('.'), col('.'), l:path, l:module)
65+
let l:decls = ghcmod#split(line('.'), col('.'), l:path)
6766
if empty(l:decls)
6867
call ghcmod#util#print_warning('No splittable constructor')
6968
return
@@ -79,7 +78,7 @@ function! ghcmod#command#initial_code_from_signature(force) "{{{
7978
return
8079
endif
8180

82-
let l:initial_code = ghcmod#sig(line('.'), col('.'), l:path, ghcmod#detect_module())
81+
let l:initial_code = ghcmod#sig(line('.'), col('.'), l:path)
8382
if empty(l:initial_code)
8483
call ghcmod#util#print_warning('Cannot generate initial code')
8584
return
@@ -106,8 +105,7 @@ function! ghcmod#command#type_insert(force) "{{{
106105
return
107106
endif
108107

109-
let l:module = ghcmod#detect_module()
110-
let l:types = ghcmod#type(line('.'), ghcmod#util#getcol(), l:path, l:module)
108+
let l:types = ghcmod#type(line('.'), ghcmod#util#getcol(), l:path)
111109
if empty(l:types) " Everything failed so let's just abort
112110
call ghcmod#util#print_error('ghcmod#command#type_insert: Cannot guess type')
113111
return
@@ -117,7 +115,7 @@ function! ghcmod#command#type_insert(force) "{{{
117115
let [_, l:offset, _, _] = l:locsym
118116

119117
if l:offset == 1 " We're doing top-level, let's try to use :info instead
120-
let l:info = ghcmod#info(l:fexp, l:path, l:module)
118+
let l:info = ghcmod#info(l:fexp, l:path)
121119
if !empty(l:info) " Continue only if we don't find errors
122120
let l:info = substitute(l:info, '\n\|\t.*', "", "g") " Remove extra lines
123121
let l:info = substitute(l:info, '\s\+', " ", "g") " Compress whitespace
@@ -137,7 +135,7 @@ function! s:info(fexp, force) "{{{
137135
if empty(l:fexp)
138136
let l:fexp = ghcmod#getHaskellIdentifier()
139137
end
140-
return ghcmod#info(l:fexp, l:path, ghcmod#detect_module())
138+
return ghcmod#info(l:fexp, l:path)
141139
endfunction "}}}
142140

143141
function! ghcmod#command#info(fexp, force) "{{{

test/test_info.vim

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function! s:info(fexp)
2-
return ghcmod#info(a:fexp, expand('%:p'), ghcmod#detect_module())
2+
return ghcmod#info(a:fexp, expand('%:p'))
33
endfunction
44

55
let s:unit = tinytest#new()

test/test_split.vim

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ let s:unit = tinytest#new()
22

33
function! s:unit.test_split()
44
edit test/data/split/Split.hs
5-
let l:decls = ghcmod#split(4, 3, expand('%:p'), 'Split')
5+
let l:decls = ghcmod#split(4, 3, expand('%:p'))
66
call self.assert.equal(['f [] = undefined', 'f (x:xs) = undefined'], l:decls)
77
endfunction
88

test/test_type.vim

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ endfunction
66

77
function! s:unit.test_type()
88
edit test/data/with-cabal/src/Foo.hs
9-
let l:types = ghcmod#type(4, 7, expand('%:p'), ghcmod#detect_module())
9+
let l:types = ghcmod#type(4, 7, expand('%:p'))
1010
call self.assert.equal([
1111
\ [[4, 7, 4, 10], '[Char]'],
1212
\ [[4, 7, 4, 16], '[Char]'],
@@ -16,7 +16,7 @@ endfunction
1616

1717
function! s:unit.test_type_compilation_failure()
1818
edit test/data/failure/Main.hs
19-
let l:types = ghcmod#type(4, 7, expand('%:p'), ghcmod#detect_module())
19+
let l:types = ghcmod#type(4, 7, expand('%:p'))
2020
call self.assert.empty(l:types)
2121
endfunction
2222

0 commit comments

Comments
 (0)