123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- if !exists("g:go_list_type")
- let g:go_list_type = ""
- endif
- if !exists("g:go_list_type_commands")
- let g:go_list_type_commands = {}
- endif
- function! go#list#Window(listtype, ...) abort
-
-
-
-
-
- if !a:0 || a:1 == 0
- call go#list#Close(a:listtype)
- return
- endif
- let height = get(g:, "go_list_height", 0)
- if height == 0
-
- if a:1 > 10
- let height = 10
- else
- let height = a:1
- endif
- endif
- if a:listtype == "locationlist"
- exe 'lopen ' . height
- else
- exe 'copen ' . height
- endif
- endfunction
- function! go#list#Get(listtype) abort
- if a:listtype == "locationlist"
- return getloclist(0)
- else
- return getqflist()
- endif
- endfunction
- function! go#list#Populate(listtype, items, title) abort
- if a:listtype == "locationlist"
- call setloclist(0, a:items, 'r')
-
-
- if has("patch-7.4.2200") | call setloclist(0, [], 'a', {'title': a:title}) | endif
- else
- call setqflist(a:items, 'r')
- if has("patch-7.4.2200") | call setqflist([], 'a', {'title': a:title}) | endif
- endif
- endfunction
- function! go#list#ParseFormat(listtype, errformat, items, title) abort
-
- let old_errorformat = &errorformat
-
- let &errorformat = a:errformat
- try
- call go#list#Parse(a:listtype, a:items, a:title)
- finally
-
- let &errorformat = old_errorformat
- endtry
- endfunction
- function! go#list#Parse(listtype, items, title) abort
- if a:listtype == "locationlist"
- lgetexpr a:items
- if has("patch-7.4.2200") | call setloclist(0, [], 'a', {'title': a:title}) | endif
- else
- cgetexpr a:items
- if has("patch-7.4.2200") | call setqflist([], 'a', {'title': a:title}) | endif
- endif
- endfunction
- function! go#list#JumpToFirst(listtype) abort
- if a:listtype == "locationlist"
- ll 1
- else
- cc 1
- endif
- endfunction
- function! go#list#Clean(listtype) abort
- if a:listtype == "locationlist"
- lex []
- else
- cex []
- endif
- call go#list#Close(a:listtype)
- endfunction
- function! go#list#Close(listtype) abort
- let autoclose_window = get(g:, 'go_list_autoclose', 1)
- if !autoclose_window
- return
- endif
- if a:listtype == "locationlist"
- lclose
- else
- cclose
- endif
- endfunction
- function! s:listtype(listtype) abort
- if g:go_list_type == "locationlist"
- return "locationlist"
- elseif g:go_list_type == "quickfix"
- return "quickfix"
- endif
- return a:listtype
- endfunction
- let s:default_list_type_commands = {
- \ "GoBuild": "quickfix",
- \ "GoErrCheck": "quickfix",
- \ "GoFmt": "locationlist",
- \ "GoGenerate": "quickfix",
- \ "GoInstall": "quickfix",
- \ "GoLint": "quickfix",
- \ "GoMetaLinter": "quickfix",
- \ "GoMetaLinterAutoSave": "locationlist",
- \ "GoModifyTags": "locationlist",
- \ "GoRename": "quickfix",
- \ "GoRun": "quickfix",
- \ "GoTest": "quickfix",
- \ "GoVet": "quickfix",
- \ "_guru": "locationlist",
- \ "_term": "locationlist",
- \ "_job": "locationlist",
- \ }
- function! go#list#Type(for) abort
- let l:listtype = s:listtype(get(s:default_list_type_commands, a:for))
- if l:listtype == "0"
- call go#util#EchoError(printf(
- \ "unknown list type command value found ('%s'). Please open a bug report in the vim-go repo.",
- \ a:for))
- let l:listtype = "quickfix"
- endif
- return get(g:go_list_type_commands, a:for, l:listtype)
- endfunction
|