From d16e82d468eb0d5bb1e662ac4812c0ca6fc0fc64 Mon Sep 17 00:00:00 2001 From: Yaroslav Date: Tue, 25 Feb 2020 14:47:03 +0300 Subject: reorganized repo to be easier to use with GNU stow; added script to stow --- dotfiles/.vim/autoload/neomake/action_queue.vim | 307 ++++++ dotfiles/.vim/autoload/neomake/cmd.vim | 192 ++++ dotfiles/.vim/autoload/neomake/compat.vim | 322 ++++++ dotfiles/.vim/autoload/neomake/config.vim | 192 ++++ dotfiles/.vim/autoload/neomake/configure.vim | 785 +++++++++++++++ dotfiles/.vim/autoload/neomake/core.vim | 120 +++ dotfiles/.vim/autoload/neomake/debug.vim | 273 ++++++ dotfiles/.vim/autoload/neomake/highlights.vim | 155 +++ dotfiles/.vim/autoload/neomake/jobinfo.vim | 87 ++ dotfiles/.vim/autoload/neomake/list.vim | 1020 ++++++++++++++++++++ dotfiles/.vim/autoload/neomake/log.vim | 171 ++++ dotfiles/.vim/autoload/neomake/makers/cabal.vim | 15 + dotfiles/.vim/autoload/neomake/makers/clippy.vim | 39 + dotfiles/.vim/autoload/neomake/makers/ft/ada.vim | 14 + .../.vim/autoload/neomake/makers/ft/angular.vim | 9 + .../.vim/autoload/neomake/makers/ft/ansible.vim | 17 + .../autoload/neomake/makers/ft/apiblueprint.vim | 16 + .../autoload/neomake/makers/ft/applescript.vim | 11 + .../.vim/autoload/neomake/makers/ft/asciidoc.vim | 28 + .../.vim/autoload/neomake/makers/ft/beancount.vim | 12 + dotfiles/.vim/autoload/neomake/makers/ft/bib.vim | 16 + dotfiles/.vim/autoload/neomake/makers/ft/c.vim | 110 +++ dotfiles/.vim/autoload/neomake/makers/ft/cf3.vim | 14 + dotfiles/.vim/autoload/neomake/makers/ft/chef.vim | 23 + .../.vim/autoload/neomake/makers/ft/coffee.vim | 15 + dotfiles/.vim/autoload/neomake/makers/ft/cpp.vim | 50 + .../.vim/autoload/neomake/makers/ft/crystal.vim | 25 + dotfiles/.vim/autoload/neomake/makers/ft/cs.vim | 22 + dotfiles/.vim/autoload/neomake/makers/ft/css.vim | 35 + dotfiles/.vim/autoload/neomake/makers/ft/cuda.vim | 15 + dotfiles/.vim/autoload/neomake/makers/ft/d.vim | 92 ++ dotfiles/.vim/autoload/neomake/makers/ft/docbk.vim | 8 + .../.vim/autoload/neomake/makers/ft/dockerfile.vim | 13 + .../.vim/autoload/neomake/makers/ft/elixir.vim | 72 ++ dotfiles/.vim/autoload/neomake/makers/ft/elm.vim | 53 + .../.vim/autoload/neomake/makers/ft/erlang.vim | 72 ++ dotfiles/.vim/autoload/neomake/makers/ft/fish.vim | 16 + .../.vim/autoload/neomake/makers/ft/fortran.vim | 32 + dotfiles/.vim/autoload/neomake/makers/ft/go.vim | 84 ++ dotfiles/.vim/autoload/neomake/makers/ft/haml.vim | 13 + .../.vim/autoload/neomake/makers/ft/haskell.vim | 169 ++++ dotfiles/.vim/autoload/neomake/makers/ft/haxe.vim | 11 + dotfiles/.vim/autoload/neomake/makers/ft/help.vim | 40 + dotfiles/.vim/autoload/neomake/makers/ft/html.vim | 20 + dotfiles/.vim/autoload/neomake/makers/ft/idris.vim | 25 + dotfiles/.vim/autoload/neomake/makers/ft/jade.vim | 13 + .../.vim/autoload/neomake/makers/ft/jasmine.vim | 9 + dotfiles/.vim/autoload/neomake/makers/ft/java.vim | 396 ++++++++ .../neomake/makers/ft/java/classpath.gradle | 46 + .../autoload/neomake/makers/ft/java/classpath.py | 15 + .../.vim/autoload/neomake/makers/ft/javascript.vim | 119 +++ dotfiles/.vim/autoload/neomake/makers/ft/json.vim | 38 + dotfiles/.vim/autoload/neomake/makers/ft/jsx.vim | 17 + dotfiles/.vim/autoload/neomake/makers/ft/julia.vim | 24 + .../.vim/autoload/neomake/makers/ft/kotlin.vim | 12 + dotfiles/.vim/autoload/neomake/makers/ft/less.vim | 19 + dotfiles/.vim/autoload/neomake/makers/ft/lex.vim | 11 + dotfiles/.vim/autoload/neomake/makers/ft/lua.vim | 33 + dotfiles/.vim/autoload/neomake/makers/ft/mail.vim | 8 + .../.vim/autoload/neomake/makers/ft/markdown.vim | 97 ++ .../.vim/autoload/neomake/makers/ft/matlab.vim | 15 + dotfiles/.vim/autoload/neomake/makers/ft/moon.vim | 15 + .../autoload/neomake/makers/ft/neomake_tests.vim | 58 ++ dotfiles/.vim/autoload/neomake/makers/ft/nim.vim | 16 + dotfiles/.vim/autoload/neomake/makers/ft/nix.vim | 14 + dotfiles/.vim/autoload/neomake/makers/ft/node.vim | 9 + dotfiles/.vim/autoload/neomake/makers/ft/objc.vim | 55 ++ .../.vim/autoload/neomake/makers/ft/pandoc.vim | 8 + dotfiles/.vim/autoload/neomake/makers/ft/perl.vim | 34 + dotfiles/.vim/autoload/neomake/makers/ft/php.vim | 72 ++ dotfiles/.vim/autoload/neomake/makers/ft/proto.vim | 12 + dotfiles/.vim/autoload/neomake/makers/ft/pug.vim | 13 + .../.vim/autoload/neomake/makers/ft/puppet.vim | 29 + .../.vim/autoload/neomake/makers/ft/purescript.vim | 63 ++ .../.vim/autoload/neomake/makers/ft/python.vim | 419 ++++++++ .../autoload/neomake/makers/ft/python/compile.py | 14 + dotfiles/.vim/autoload/neomake/makers/ft/r.vim | 17 + .../.vim/autoload/neomake/makers/ft/racket.vim | 32 + dotfiles/.vim/autoload/neomake/makers/ft/rst.vim | 89 ++ dotfiles/.vim/autoload/neomake/makers/ft/ruby.vim | 90 ++ dotfiles/.vim/autoload/neomake/makers/ft/rust.vim | 233 +++++ dotfiles/.vim/autoload/neomake/makers/ft/scala.vim | 40 + dotfiles/.vim/autoload/neomake/makers/ft/scss.vim | 25 + .../.vim/autoload/neomake/makers/ft/serpent.vim | 13 + dotfiles/.vim/autoload/neomake/makers/ft/sh.vim | 86 ++ dotfiles/.vim/autoload/neomake/makers/ft/slim.vim | 13 + dotfiles/.vim/autoload/neomake/makers/ft/sml.vim | 19 + .../.vim/autoload/neomake/makers/ft/solidity.vim | 16 + dotfiles/.vim/autoload/neomake/makers/ft/spar.vim | 13 + dotfiles/.vim/autoload/neomake/makers/ft/spec.vim | 16 + dotfiles/.vim/autoload/neomake/makers/ft/sql.vim | 13 + .../.vim/autoload/neomake/makers/ft/stylus.vim | 16 + dotfiles/.vim/autoload/neomake/makers/ft/swift.vim | 54 ++ dotfiles/.vim/autoload/neomake/makers/ft/tcl.vim | 15 + dotfiles/.vim/autoload/neomake/makers/ft/tex.vim | 69 ++ dotfiles/.vim/autoload/neomake/makers/ft/text.vim | 30 + dotfiles/.vim/autoload/neomake/makers/ft/toml.vim | 15 + dotfiles/.vim/autoload/neomake/makers/ft/tsx.vim | 15 + .../.vim/autoload/neomake/makers/ft/typescript.vim | 45 + .../.vim/autoload/neomake/makers/ft/verilog.vim | 16 + dotfiles/.vim/autoload/neomake/makers/ft/vhdl.vim | 12 + dotfiles/.vim/autoload/neomake/makers/ft/vim.vim | 87 ++ dotfiles/.vim/autoload/neomake/makers/ft/vue.vim | 28 + dotfiles/.vim/autoload/neomake/makers/ft/xml.vim | 25 + dotfiles/.vim/autoload/neomake/makers/ft/xslt.vim | 8 + dotfiles/.vim/autoload/neomake/makers/ft/yacc.vim | 17 + dotfiles/.vim/autoload/neomake/makers/ft/yaml.vim | 12 + dotfiles/.vim/autoload/neomake/makers/ft/zsh.vim | 19 + dotfiles/.vim/autoload/neomake/makers/gradle.vim | 28 + dotfiles/.vim/autoload/neomake/makers/mvn.vim | 9 + dotfiles/.vim/autoload/neomake/makers/sbt.vim | 13 + dotfiles/.vim/autoload/neomake/postprocess.vim | 77 ++ dotfiles/.vim/autoload/neomake/quickfix.vim | 363 +++++++ dotfiles/.vim/autoload/neomake/setup.vim | 37 + dotfiles/.vim/autoload/neomake/signs.vim | 289 ++++++ dotfiles/.vim/autoload/neomake/statusline.vim | 423 ++++++++ dotfiles/.vim/autoload/neomake/utils.vim | 795 +++++++++++++++ dotfiles/.vim/autoload/neomake/virtualtext.vim | 113 +++ 118 files changed, 9878 insertions(+) create mode 100644 dotfiles/.vim/autoload/neomake/action_queue.vim create mode 100644 dotfiles/.vim/autoload/neomake/cmd.vim create mode 100644 dotfiles/.vim/autoload/neomake/compat.vim create mode 100644 dotfiles/.vim/autoload/neomake/config.vim create mode 100644 dotfiles/.vim/autoload/neomake/configure.vim create mode 100644 dotfiles/.vim/autoload/neomake/core.vim create mode 100644 dotfiles/.vim/autoload/neomake/debug.vim create mode 100644 dotfiles/.vim/autoload/neomake/highlights.vim create mode 100644 dotfiles/.vim/autoload/neomake/jobinfo.vim create mode 100644 dotfiles/.vim/autoload/neomake/list.vim create mode 100644 dotfiles/.vim/autoload/neomake/log.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/cabal.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/clippy.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/ada.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/angular.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/ansible.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/apiblueprint.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/applescript.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/asciidoc.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/beancount.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/bib.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/c.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/cf3.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/chef.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/coffee.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/cpp.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/crystal.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/cs.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/css.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/cuda.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/d.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/docbk.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/dockerfile.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/elixir.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/elm.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/erlang.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/fish.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/fortran.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/go.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/haml.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/haskell.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/haxe.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/help.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/html.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/idris.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/jade.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/jasmine.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/java.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/java/classpath.gradle create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/java/classpath.py create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/javascript.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/json.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/jsx.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/julia.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/kotlin.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/less.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/lex.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/lua.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/mail.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/markdown.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/matlab.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/moon.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/neomake_tests.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/nim.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/nix.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/node.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/objc.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/pandoc.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/perl.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/php.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/proto.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/pug.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/puppet.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/purescript.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/python.vim create mode 100755 dotfiles/.vim/autoload/neomake/makers/ft/python/compile.py create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/r.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/racket.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/rst.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/ruby.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/rust.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/scala.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/scss.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/serpent.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/sh.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/slim.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/sml.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/solidity.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/spar.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/spec.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/sql.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/stylus.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/swift.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/tcl.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/tex.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/text.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/toml.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/tsx.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/typescript.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/verilog.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/vhdl.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/vim.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/vue.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/xml.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/xslt.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/yacc.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/yaml.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/ft/zsh.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/gradle.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/mvn.vim create mode 100644 dotfiles/.vim/autoload/neomake/makers/sbt.vim create mode 100644 dotfiles/.vim/autoload/neomake/postprocess.vim create mode 100644 dotfiles/.vim/autoload/neomake/quickfix.vim create mode 100644 dotfiles/.vim/autoload/neomake/setup.vim create mode 100644 dotfiles/.vim/autoload/neomake/signs.vim create mode 100644 dotfiles/.vim/autoload/neomake/statusline.vim create mode 100644 dotfiles/.vim/autoload/neomake/utils.vim create mode 100644 dotfiles/.vim/autoload/neomake/virtualtext.vim (limited to 'dotfiles/.vim/autoload/neomake') diff --git a/dotfiles/.vim/autoload/neomake/action_queue.vim b/dotfiles/.vim/autoload/neomake/action_queue.vim new file mode 100644 index 0000000..4fc3fc1 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/action_queue.vim @@ -0,0 +1,307 @@ +if !exists('s:action_queue') + let s:action_queue = [] +endif +if !exists('s:action_queue_registered_events') + let s:action_queue_registered_events = [] +endif +let s:action_queue_timer_timeouts = get(g:, 'neomake_action_queue_timeouts', {1: 100, 2: 200, 3: 500}) + +let g:neomake#action_queue#processed = {} +let g:neomake#action_queue#not_processed = {} +let g:neomake#action_queue#any_event = [] + +let g:neomake#action_queue#_s = s: + +function! s:actionname(funcref) abort + let s = string(a:funcref) + let r = matchstr(s, '\v^^function\(''\zs.*\ze''\)$') + if empty(r) + return s + endif + return substitute(r, '\v^(\\d+_|s:)', '', '') +endfunction + +" Queue an action to be processed later for autocmd a:event or through a timer +" for a:event=Timer. +" It will call a:data[0], with a:data[1] as args (where the first should be +" a jobinfo object). The callback should return 1 if it was successful, +" with 0 it will be re-queued. +" When called recursively (queuing the same event/data again, it will be +" re-queued also). +function! neomake#action_queue#add(events, data) abort + let job_or_make_info = a:data[1][0] + if a:events is# g:neomake#action_queue#any_event + call neomake#log#debug(printf('Queuing action %s for any event.', + \ s:actionname(a:data[0])), job_or_make_info) + else + call neomake#log#debug(printf('Queuing action %s for %s.', + \ s:actionname(a:data[0]), join(a:events, ', ')), job_or_make_info) + endif + + for event in a:events + if event ==# 'Timer' + if !has_key(job_or_make_info, 'action_queue_timer_tries') + let job_or_make_info.action_queue_timer_tries = {'count': 1, 'data': a:data[0]} + else + let job_or_make_info.action_queue_timer_tries.count += 1 + endif + if has_key(s:action_queue_timer_timeouts, job_or_make_info.action_queue_timer_tries.count) + let timeout = s:action_queue_timer_timeouts[job_or_make_info.action_queue_timer_tries.count] + else + throw printf('Neomake: Giving up handling Timer callbacks after %d attempts. Please report this. See :messages for more information.', len(s:action_queue_timer_timeouts)) + endif + if has('timers') + if exists('s:action_queue_timer') + call timer_stop(s:action_queue_timer) + endif + let s:action_queue_timer = timer_start(timeout, function('s:process_action_queue_timer_cb')) + call neomake#log#debug(printf( + \ 'Retrying Timer event in %dms (timer %d).', + \ timeout, s:action_queue_timer), job_or_make_info) + else + call neomake#log#debug('Retrying Timer event on CursorHold(I).', job_or_make_info) + if !exists('#neomake_event_queue#CursorHold') + let s:action_queue_registered_events += ['CursorHold', 'CursorHoldI'] + augroup neomake_event_queue + exe 'autocmd CursorHold,CursorHoldI * call s:process_action_queue('''.event.''')' + augroup END + endif + endif + else + if !exists('#neomake_event_queue#'.event) + let s:action_queue_registered_events += [event] + augroup neomake_event_queue + exe 'autocmd '.event.' * call s:process_action_queue('''.event.''')' + augroup END + endif + endif + endfor + call add(s:action_queue, [a:events, a:data]) + return g:neomake#action_queue#not_processed +endfunction + +" Remove any queued actions for a jobinfo or make_info object. +function! neomake#action_queue#clean(job_or_make_info) abort + let len_before = len(s:action_queue) + call filter(s:action_queue, 'v:val[1][1][0] != a:job_or_make_info') + let removed = len_before - len(s:action_queue) + if removed + call s:clean_action_queue_events() + call neomake#log#debug(printf( + \ 'Removed %d action queue entries.', + \ removed), a:job_or_make_info) + endif +endfunction + +" Remove given action for a jobinfo or make_info object. +function! neomake#action_queue#remove(job_or_make_info, action) abort + let len_before = len(s:action_queue) + call filter(s:action_queue, 'v:val[1][1][0] != a:job_or_make_info || v:val[1][0] != a:action') + let removed = len_before - len(s:action_queue) + if removed + call s:clean_action_queue_events() + call neomake#log#debug(printf( + \ 'Removed %d action queue entries for %s.', + \ removed, s:actionname(a:action)), a:job_or_make_info) + endif +endfunction + +function! s:process_action_queue_timer_cb(...) abort + call neomake#log#debug(printf( + \ 'action queue: callback for Timer queue (%d).', s:action_queue_timer)) + unlet s:action_queue_timer + call s:process_action_queue('Timer') +endfunction + +function! s:process_action_queue(event) abort + let queue = s:action_queue + let q_for_this_event = [] + let i = 0 + if g:neomake#core#_ignore_autocommands + call neomake#log#debug(printf('action queue: skip processing for %s (ignore_autocommands=%d).', + \ a:event, g:neomake#core#_ignore_autocommands), + \ {'bufnr': bufnr('%'), 'winnr': winnr()}) + return + endif + for [events, v] in queue + if index(events, a:event) != -1 || events is# g:neomake#action_queue#any_event + call add(q_for_this_event, [i, v]) + endif + let i += 1 + endfor + call neomake#log#debug(printf('action queue: processing for %s (%d items).', + \ a:event, len(q_for_this_event)), {'bufnr': bufnr('%'), 'winnr': winnr()}) + + let processed = [] + let removed = 0 + let stop_processing = {'make_id': [], 'job_id': []} + for [idx_q_for_this_event, data] in q_for_this_event + let job_or_make_info = data[1][0] + let current_event = remove(queue, idx_q_for_this_event - removed) + let removed += 1 + + let make_id_job_id = {} " make_id/job_id relevant to re-queue following. + if has_key(job_or_make_info, 'make_id') + if has_key(job_or_make_info, 'options') + let make_id_job_id = { + \ 'make_id': job_or_make_info.make_id, + \ } + else + let make_id_job_id = { + \ 'make_id': job_or_make_info.make_id, + \ 'job_id': job_or_make_info.id, + \ } + endif + endif + + " Skip/re-queue entries for same make/job. + let skip = 0 + for [prop_name, prop_value] in items(make_id_job_id) + if index(stop_processing[prop_name], prop_value) != -1 + call neomake#log#debug(printf('action queue: skipping %s for not processed %s.', + \ s:actionname(data[0]), prop_name), job_or_make_info) + call add(queue, current_event) + let skip = 1 + break + endif + endfor + if skip + continue + endif + + call neomake#log#debug(printf('action queue: calling %s.', + \ s:actionname(data[0])), job_or_make_info) + let queue_before_call = copy(queue) + try + " Call the queued action. On failure they should have requeued + " themselves already. + let rv = call(data[0], data[1]) + catch + if v:exception =~# '^Neomake: ' + let error = substitute(v:exception, '^Neomake: ', '', '') + else + let error = printf('Error during action queue processing: %s.', + \ v:exception) + endif + call neomake#log#exception(error, job_or_make_info) + + " Cancel job in case its action failed to get re-queued after X + " attempts. + if has_key(job_or_make_info, 'id') + call neomake#CancelJob(job_or_make_info.id) + endif + continue + endtry + if rv is# g:neomake#action_queue#processed + let processed += [data] + continue + endif + + if rv is# g:neomake#action_queue#not_processed + if a:event !=# 'Timer' && has_key(job_or_make_info, 'action_queue_timer_tries') + call neomake#log#debug('s:process_action_queue: decrementing timer tries for non-Timer event.', job_or_make_info) + let job_or_make_info.action_queue_timer_tries.count -= 1 + endif + + " Requeue any entries for the same job. + let i = 0 + for q in queue_before_call + for [prop_name, prop_value] in items(make_id_job_id) + " Assert current_event != q + if get(q[1][1][0], prop_name) == prop_value + call neomake#log#debug(printf('action queue: re-queuing %s for not processed %s.', + \ s:actionname(q[1][0]), prop_name), job_or_make_info) + call add(queue, remove(queue, i)) + let i -= 1 + break + endif + endfor + let i += 1 + endfor + for [prop_name, prop_value] in items(make_id_job_id) + call add(stop_processing[prop_name], prop_value) + endfor + else + let args_str = neomake#utils#Stringify(data[1]) + throw printf('Internal Neomake error: hook function %s(%s) returned unexpected value (%s)', data[0], args_str, rv) + endif + endfor + call neomake#log#debug(printf('action queue: processed %d items.', + \ len(processed)), {'bufnr': bufnr('%')}) + + call s:clean_action_queue_events() +endfunction + +if has('timers') + function! s:get_left_events() abort + let r = {} + for [events, _] in s:action_queue + for event in events + let r[event] = 1 + endfor + endfor + return keys(r) + endfunction +else + function! s:get_left_events() abort + let r = {} + for [events, _] in s:action_queue + for event in events + if event ==# 'Timer' + let r['CursorHold'] = 1 + let r['CursorHoldI'] = 1 + else + let r[event] = 1 + endif + endfor + endfor + return keys(r) + endfunction +endif + +function! neomake#action_queue#get_queued_actions(jobinfo) abort + " Check if there are any queued actions for this job. + let queued_actions = [] + for [events, v] in s:action_queue + if v[1][0] == a:jobinfo + let queued_actions += [[s:actionname(v[0]), events]] + endif + endfor + return queued_actions +endfunction + +function! s:clean_action_queue_events() abort + let left_events = s:get_left_events() + + if empty(left_events) + if exists('#neomake_event_queue') + autocmd! neomake_event_queue + augroup! neomake_event_queue + endif + else + let clean_events = [] + for event in s:action_queue_registered_events + if index(left_events, event) == -1 + let clean_events += [event] + endif + endfor + if !empty(clean_events) + augroup neomake_event_queue + for event in clean_events + if exists('#neomake_event_queue#'.event) + exe 'au! '.event + endif + endfor + augroup END + endif + endif + let s:action_queue_registered_events = left_events + + if index(left_events, 'Timer') == -1 + if exists('s:action_queue_timer') + call timer_stop(s:action_queue_timer) + unlet s:action_queue_timer + endif + endif +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/cmd.vim b/dotfiles/.vim/autoload/neomake/cmd.vim new file mode 100644 index 0000000..35806dc --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/cmd.vim @@ -0,0 +1,192 @@ +scriptencoding utf8 + +let s:last_completion = [] +function! neomake#cmd#complete_makers(ArgLead, CmdLine, ...) abort + if a:CmdLine !~# '\s' + " Just 'Neomake!' without following space. + return [' '] + endif + + " Filter only by name before non-breaking space. + let filter_name = split(a:ArgLead, ' ', 1)[0] + + let file_mode = a:CmdLine =~# '\v^(Neomake|NeomakeFile)\s' + + let compl_info = [bufnr('%'), &filetype, a:CmdLine] + if empty(&filetype) + let maker_names = neomake#GetProjectMakers() + else + let maker_names = neomake#GetMakers(&filetype) + + " Prefer (only) makers for the current filetype. + if file_mode + if !empty(filter_name) + call filter(maker_names, 'v:val[:len(filter_name)-1] ==# filter_name') + endif + if empty(maker_names) || s:last_completion == compl_info + call extend(maker_names, neomake#GetProjectMakers()) + endif + else + call extend(maker_names, neomake#GetProjectMakers()) + endif + endif + + " Only display executable makers. + let makers = [] + for maker_name in maker_names + try + let maker = neomake#GetMaker(maker_name) + catch /^Neomake: / + let error = substitute(v:exception, '^Neomake: ', '', '').'.' + call neomake#log#debug(printf('Could not get maker %s: %s', + \ maker_name, error)) + continue + endtry + if type(get(maker, 'exe', 0)) != type('') || executable(maker.exe) + let makers += [[maker_name, maker]] + endif + endfor + + " Append maker.name if it differs, uses non-breaking-space. + let r = [] + for [maker_name, maker] in makers + if maker.name !=# maker_name + \ && (empty(a:ArgLead) || stridx(maker_name, a:ArgLead) != 0) + let r += [printf('%s (%s)', maker_name, maker.name)] + else + let r += [maker_name] + endif + endfor + + let s:last_completion = compl_info + if !empty(filter_name) + call filter(r, 'v:val[:len(filter_name)-1] ==# filter_name') + endif + return r +endfunction + +function! neomake#cmd#complete_jobs(...) abort + return join(map(neomake#GetJobs(), "v:val.id.': '.v:val.maker.name"), "\n") +endfunction + +function! s:is_neomake_list(list) abort + if empty(a:list) + return 0 + endif + return a:list[0].text =~# ' nmcfg:{.\{-}}$' +endfunction + +function! neomake#cmd#clean(file_mode) abort + let buf = bufnr('%') + call neomake#_clean_errors({ + \ 'file_mode': a:file_mode, + \ 'bufnr': buf, + \ }) + if a:file_mode + if s:is_neomake_list(getloclist(0)) + call setloclist(0, [], 'r') + lclose + endif + call neomake#signs#ResetFile(buf) + call neomake#statusline#ResetCountsForBuf(buf) + else + if s:is_neomake_list(getqflist()) + call setqflist([], 'r') + cclose + endif + call neomake#signs#ResetProject() + call neomake#statusline#ResetCountsForProject() + endif + call neomake#EchoCurrentError(1) +endfunction + +" Enable/disable/toggle commands. {{{ +function! s:handle_disabled_status(scope, disabled) abort + if a:scope is# g: + if a:disabled + if exists('#neomake') + autocmd! neomake + augroup! neomake + endif + call neomake#configure#disable_automake() + else + call neomake#setup#setup_autocmds() + endif + elseif a:scope is# t: + let buffers = neomake#compat#uniq(sort(tabpagebuflist())) + if a:disabled + for b in buffers + call neomake#configure#disable_automake_for_buffer(b) + endfor + else + for b in buffers + call neomake#configure#enable_automake_for_buffer(b) + endfor + endif + elseif a:scope is# b: + let bufnr = bufnr('%') + if a:disabled + call neomake#configure#disable_automake_for_buffer(bufnr) + else + call neomake#configure#enable_automake_for_buffer(bufnr) + endif + endif + call neomake#cmd#display_status() + call neomake#configure#automake() + call neomake#statusline#clear_cache() +endfunction + +function! neomake#cmd#disable(scope) abort + let old = get(get(a:scope, 'neomake', {}), 'disabled', -1) + if old ==# 1 + return + endif + call neomake#config#set_dict(a:scope, 'neomake.disabled', 1) + call s:handle_disabled_status(a:scope, 1) +endfunction + +function! neomake#cmd#enable(scope) abort + let old = get(get(a:scope, 'neomake', {}), 'disabled', -1) + if old != 1 + return + endif + call neomake#config#set_dict(a:scope, 'neomake.disabled', 0) + call s:handle_disabled_status(a:scope, 0) +endfunction + +function! neomake#cmd#toggle(scope) abort + let new = !get(get(a:scope, 'neomake', {}), 'disabled', 0) + if new + call neomake#config#set_dict(a:scope, 'neomake.disabled', 1) + call s:handle_disabled_status(a:scope, 1) + else + call neomake#config#unset_dict(a:scope, 'neomake.disabled') + call s:handle_disabled_status(a:scope, 0) + endif +endfunction + +function! neomake#cmd#display_status() abort + let [disabled, source] = neomake#config#get_with_source('disabled', 0) + let msg = 'Neomake is ' . (disabled ? 'disabled' : 'enabled') + if source !=# 'default' + let msg .= ' ('.source.')' + endif + + " Add information from different scopes (if explicitly configured there). + for [scope_name, scope] in [['buffer', b:], ['tab', t:], ['global', g:]] + if scope_name ==# source + continue + endif + let disabled = get(get(scope, 'neomake', {}), 'disabled', -1) + if disabled != -1 + let msg .= printf(' [%s: %s]', scope_name, disabled ? 'disabled' : 'enabled') + endif + endfor + let msg .= '.' + + echom msg + call neomake#log#debug(msg) +endfunction +" }}} + +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/compat.vim b/dotfiles/.vim/autoload/neomake/compat.vim new file mode 100644 index 0000000..d558bf7 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/compat.vim @@ -0,0 +1,322 @@ +" Compatibility wrappers for different (Neo)Vim versions and platforms. + +if neomake#utils#IsRunningWindows() + let g:neomake#compat#dev_null = 'NUL' +else + let g:neomake#compat#dev_null = '/dev/null' +endif + +if v:version >= 704 + function! neomake#compat#getbufvar(buf, key, def) abort + return getbufvar(a:buf, a:key, a:def) + endfunction + function! neomake#compat#getwinvar(win, key, def) abort + return getwinvar(a:win, a:key, a:def) + endfunction +else + function! neomake#compat#getbufvar(buf, key, def) abort + return get(getbufvar(a:buf, ''), a:key, a:def) + endfunction + function! neomake#compat#getwinvar(win, key, def) abort + return get(getwinvar(a:win, ''), a:key, a:def) + endfunction +endif + +unlockvar neomake#compat#json_true +unlockvar neomake#compat#json_false +unlockvar neomake#compat#json_null +unlockvar neomake#compat#json_none + +if exists('v:none') + let neomake#compat#json_none = v:none +else + let neomake#compat#json_none = [] +endif + +if exists('*json_decode') + let neomake#compat#json_true = v:true + let neomake#compat#json_false = v:false + let neomake#compat#json_null = v:null + + if has('nvim') + function! neomake#compat#json_decode(json) abort + if a:json is# '' + " Prevent Neovim from throwing E474: Attempt to decode a blank string. + return g:neomake#compat#json_none + endif + return json_decode(a:json) + endfunction + else + function! neomake#compat#json_decode(json) abort + return json_decode(a:json) + endfunction + endif +else + let neomake#compat#json_true = 1 + let neomake#compat#json_false = 0 + function! s:json_null() abort + endfunction + let neomake#compat#json_null = [function('s:json_null')] + + " Via Syntastic (https://github.com/vim-syntastic/syntastic/blob/6fb14d624b6081459360fdbba743f82cf84c8f92/autoload/syntastic/preprocess.vim#L576-L607), + " based on https://github.com/MarcWeber/vim-addon-json-encoding/blob/master/autoload/json_encoding.vim. + " @vimlint(EVL102, 1, l:true) + " @vimlint(EVL102, 1, l:false) + " @vimlint(EVL102, 1, l:null) + function! neomake#compat#json_decode(json) abort " {{{2 + if a:json ==# '' + return g:neomake#compat#json_none + endif + + " The following is inspired by https://github.com/MarcWeber/vim-addon-manager and + " http://stackoverflow.com/questions/17751186/iterating-over-a-string-in-vimscript-or-parse-a-json-file/19105763#19105763 + " A hat tip to Marc Weber for this trick + " Replace newlines, which eval() does not like. + let json = substitute(a:json, "\n", '', 'g') + if substitute(json, '\v\"%(\\.|[^"\\])*\"|true|false|null|[+-]?\d+%(\.\d+%([Ee][+-]?\d+)?)?', '', 'g') !~# "[^,:{}[\\] \t]" + " JSON artifacts + let true = g:neomake#compat#json_true + let false = g:neomake#compat#json_false + let null = g:neomake#compat#json_null + + try + let object = eval(json) + catch + throw 'Neomake: Failed to parse JSON input: '.v:exception + endtry + else + throw 'Neomake: Failed to parse JSON input: invalid input' + endif + + return object + endfunction " }}}2 + " @vimlint(EVL102, 0, l:true) + " @vimlint(EVL102, 0, l:false) + " @vimlint(EVL102, 0, l:null) +endif + +lockvar neomake#compat#json_true +lockvar neomake#compat#json_false +lockvar neomake#compat#json_null + +if exists('*uniq') + function! neomake#compat#uniq(l) abort + return uniq(a:l) + endfunction +else + function! neomake#compat#uniq(l) abort + let n = len(a:l) + if n < 2 + return a:l + endif + let prev = a:l[0] + let idx = 1 + while idx < n + if a:l[idx] ==# prev && type(a:l[idx]) == type(prev) + call remove(a:l, idx) + let n -= 1 + else + let prev = a:l[idx] + let idx += 1 + endif + endwhile + return a:l + endfunction +endif + +if exists('*reltimefloat') + function! neomake#compat#reltimefloat() abort + return reltimefloat(reltime()) + endfunction +else + function! neomake#compat#reltimefloat() abort + let t = split(reltimestr(reltime()), '\V.') + return str2float(t[0] . '.' . t[1]) + endfunction +endif + +" Wrapper around systemlist() that supports a list for a:cmd. +" It returns an empty string on error. +" NOTE: Neovim before 0.2.0 would throw an error (which is caught), but it +" does not set v:shell_error! +function! neomake#compat#systemlist(cmd) abort + if empty(a:cmd) + return [] + endif + if has('nvim') && exists('*systemlist') + " @vimlint(EVL108, 1) + if !has('nvim-0.2.0') + try + return systemlist(a:cmd) + catch /^Vim\%((\a\+)\)\=:E902/ + return '' + endtry + endif + " @vimlint(EVL108, 0) + return systemlist(a:cmd) + endif + + if type(a:cmd) == type([]) + let cmd = join(map(a:cmd, 'neomake#utils#shellescape(v:val)')) + else + let cmd = a:cmd + endif + if exists('*systemlist') + return systemlist(cmd) + endif + return split(system(cmd), '\n') +endfunction + +function! neomake#compat#globpath_list(path, pattern, suf) abort + if v:version >= 705 || (v:version == 704 && has('patch279')) + return globpath(a:path, a:pattern, a:suf, 1) + endif + return split(globpath(a:path, a:pattern, a:suf), '\n') +endfunction + +function! neomake#compat#glob_list(pattern) abort + if v:version <= 703 + return split(glob(a:pattern, 1), '\n') + endif + return glob(a:pattern, 1, 1) +endfunction + +if neomake#utils#IsRunningWindows() + " Windows needs a shell to handle PATH/%PATHEXT% etc. + function! neomake#compat#get_argv(exe, args, args_is_list) abort + let prefix = &shell.' '.&shellcmdflag.' ' + if a:args_is_list + if a:exe ==# &shell && get(a:args, 0) ==# &shellcmdflag + " Remove already existing &shell/&shellcmdflag from e.g. NeomakeSh. + let argv = join(a:args[1:]) + else + let argv = join(map(copy([a:exe] + a:args), 'neomake#utils#shellescape(v:val)')) + endif + else + let argv = a:exe . (empty(a:args) ? '' : ' '.a:args) + if argv[0:len(prefix)-1] ==# prefix + return argv + endif + endif + return prefix.argv + endfunction +elseif has('nvim') + function! neomake#compat#get_argv(exe, args, args_is_list) abort + if a:args_is_list + return [a:exe] + a:args + endif + return a:exe . (empty(a:args) ? '' : ' '.a:args) + endfunction +elseif neomake#has_async_support() " Vim-async. + function! neomake#compat#get_argv(exe, args, args_is_list) abort + if a:args_is_list + return [a:exe] + a:args + endif + " Use a shell to handle argv properly (Vim splits at spaces). + let argv = a:exe . (empty(a:args) ? '' : ' '.a:args) + return [&shell, &shellcmdflag, argv] + endfunction +else + " Vim (synchronously), via system(). + function! neomake#compat#get_argv(exe, args, args_is_list) abort + if a:args_is_list + return join(map(copy([a:exe] + a:args), 'neomake#utils#shellescape(v:val)')) + endif + return a:exe . (empty(a:args) ? '' : ' '.a:args) + endfunction +endif + +if v:version >= 704 || (v:version == 703 && has('patch831')) + function! neomake#compat#gettabwinvar(t, w, v, d) abort + return gettabwinvar(a:t, a:w, a:v, a:d) + endfunction +else + " Wrapper around gettabwinvar that has no default (older Vims). + function! neomake#compat#gettabwinvar(t, w, v, d) abort + let r = gettabwinvar(a:t, a:w, a:v) + if r is# '' + unlet r + let r = a:d + endif + return r + endfunction +endif + +" Not really necessary for now, but allows to overwriting and extending. +if exists('*nvim_get_mode') + function! neomake#compat#get_mode() abort + let mode = nvim_get_mode() + return mode.mode + endfunction +else + function! neomake#compat#get_mode() abort + return mode(1) + endfunction +endif + +function! neomake#compat#in_completion() abort + if pumvisible() + return 1 + endif + if has('patch-8.0.0283') + let mode = mode(1) + if mode[1] ==# 'c' || mode[1] ==# 'x' + return 1 + endif + endif + return 0 +endfunction + +let s:prev_windows = [] +if exists('*win_getid') + function! neomake#compat#save_prev_windows() abort + call add(s:prev_windows, [win_getid(winnr('#')), win_getid(winnr())]) + endfunction + + function! neomake#compat#restore_prev_windows() abort + " Go back, maintaining the '#' window (CTRL-W_p). + let [aw_id, pw_id] = remove(s:prev_windows, 0) + let pw = win_id2win(pw_id) + if !pw + call neomake#log#debug(printf( + \ 'Cannot restore previous windows (previous window with ID %d not found).', + \ pw_id)) + elseif winnr() != pw + let aw = win_id2win(aw_id) + if aw + exec aw . 'wincmd w' + endif + exec pw . 'wincmd w' + endif + endfunction +else + function! neomake#compat#save_prev_windows() abort + call add(s:prev_windows, [winnr('#'), winnr()]) + endfunction + + function! neomake#compat#restore_prev_windows() abort + " Go back, maintaining the '#' window (CTRL-W_p). + let [aw, pw] = remove(s:prev_windows, 0) + if pw > winnr('$') + call neomake#log#debug(printf( + \ 'Cannot restore previous windows (%d > %d).', + \ pw, winnr('$'))) + elseif winnr() != pw + if aw + exec aw . 'wincmd w' + endif + exec pw . 'wincmd w' + endif + endfunction +endif + +if v:version >= 704 || (v:version == 703 && has('patch442')) + function! neomake#compat#doautocmd(event) abort + exec 'doautocmd ' . a:event + endfunction +else + function! neomake#compat#doautocmd(event) abort + exec 'doautocmd ' . a:event + endfunction +endif +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/config.vim b/dotfiles/.vim/autoload/neomake/config.vim new file mode 100644 index 0000000..5f03cd1 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/config.vim @@ -0,0 +1,192 @@ +" Config API. + +let g:neomake#config#_defaults = { + \ 'maker_defaults': { + \ 'buffer_output': 1, + \ 'output_stream': 'both', + \ 'remove_invalid_entries': 0, + \ }} +lockvar g:neomake#config#_defaults + +let g:neomake#config#undefined = {} +lockvar! g:neomake#config#undefined + +" Resolve a:name (split on dots) and (optionally) init a:dict accordingly. +function! s:resolve_name(dict, name, init) abort + let parts = type(a:name) == type([]) ? a:name : split(a:name, '\.') + let c = a:dict + for p in parts[0:-2] + if !has_key(c, p) + if !a:init + return [g:neomake#config#undefined, ''] + endif + let c[p] = {} + endif + if type(c[p]) != type({}) + return [g:neomake#config#undefined, ''] + endif + let c = c[p] + endfor + return [c, parts[-1]] +endfunction + +" Get a:name (list of keys) from a:dict, using a:prefixes. +function! s:get(dict, parts, prefixes) abort + for prefix in a:prefixes + let [c, k] = s:resolve_name(a:dict, prefix + a:parts[0:-1], 0) + if has_key(c, k) + return [prefix, get(c, k)] + endif + endfor + return [[], g:neomake#config#undefined] +endfunction + +" Get a:name (string (split on dots), or list of keys) from config. +" See neomake#config#get_with_source for args. +function! neomake#config#get(name, ...) abort + return call('neomake#config#get_with_source', [a:name] + a:000)[0] +endfunction + +" Get a:name (string (split on dots), or list of keys) from config, with +" information about the setting's source ('buffer', 'tab', 'global', 'maker', +" 'default'). +" Optional args: +" - a:1: default value +" - a:2: context: defaults to {'ft': &filetype} +" - maker: a maker dict (where maker.name is used from for prefixes, and +" as a lookup itself) +" - ft: filetype string (use an empty string to ignore it) +" - bufnr: buffer number (use an empty string to ignore it) +" - maker_only: should settings get looked up only in the maker context? +" (i.e. with maker.name prefix in general and in context.maker) +" - log_source: additional information to log. +function! neomake#config#get_with_source(name, ...) abort + let context = a:0 > 1 ? a:2 : {'ft': &filetype, 'bufnr': bufnr('%')} + let parts = type(a:name) == type([]) ? a:name : split(a:name, '\.') + + let prefixes = [[]] + if has_key(context, 'ft') && !empty(context.ft) + for ft in neomake#utils#get_config_fts(context.ft, '.') + call insert(prefixes, ['ft', ft], 0) + endfor + endif + + let maker_name = get(get(context, 'maker', {}), 'name', '') + let maker_only = get(context, 'maker_only', 0) + if parts[0][0:1] ==# 'b:' + if !has_key(context, 'bufnr') + let context.bufnr = bufnr('%') + endif + let parts[0] = parts[0][2:-1] + if context.bufnr is# '' + let lookups = [] + else + let lookups = [['buffer', getbufvar(context.bufnr, 'neomake')]] + endif + call add(lookups, ['maker', get(context, 'maker', {})]) + elseif empty(maker_name) && maker_only + let lookups = [['maker', get(context, 'maker', {})]] + else + let lookups = (has_key(context, 'bufnr') && context.bufnr isnot# '' + \ ? [['buffer', getbufvar(context.bufnr, 'neomake')]] + \ : []) + [ + \ ['tab', get(t:, 'neomake', {})], + \ ['global', get(g:, 'neomake', {})], + \ ['maker', get(context, 'maker', {})]] + if !empty(maker_name) + if maker_only + if parts[0] !=# maker_name + call map(prefixes, 'add(v:val, maker_name)') + endif + else + for prefix in reverse(copy(prefixes)) + call insert(prefixes, prefix + [maker_name], 0) + endfor + endif + endif + endif + + for [source, lookup] in lookups + if !empty(lookup) + if source ==# 'maker' + let maker_prefixes = map(copy(prefixes), '!empty(v:val) && v:val[-1] ==# maker_name ? v:val[:-2] : v:val') + let maker_setting_parts = parts[0] == maker_name ? parts[1:] : parts + let [prefix, l:R] = s:get(lookup, maker_setting_parts, maker_prefixes) + else + let [prefix, l:R] = s:get(lookup, parts, prefixes) + endif + if R isnot# g:neomake#config#undefined + let log_name = join(map(copy(parts), "substitute(v:val, '\\.', '|', '')"), '.') + let log_source = get(context, 'log_source', '') + call neomake#log#debug(printf( + \ "Using setting %s=%s from '%s'%s%s.", + \ log_name, string(R), source, + \ empty(prefix) ? '' : ' (prefix: '.string(prefix).')', + \ empty(log_source) ? '' : ' ('.log_source.')'), + \ context) + return [R, source] + endif + unlet R " for Vim without patch-7.4.1546 + endif + unlet lookup " for Vim without patch-7.4.1546 + endfor + + " Return default. + if a:0 + return [a:1, 'default'] + elseif has_key(g:neomake#config#_defaults, a:name) + return [copy(g:neomake#config#_defaults[a:name]), 'default'] + endif + return [g:neomake#config#undefined, 'default'] +endfunction + + +" Set a:name in a:dict to a:value, after resolving it (split on dots). +function! s:set(dict, name, value) abort + let [c, k] = s:resolve_name(a:dict, a:name, 1) + let c[k] = a:value + return c +endfunction + +" Set a:name (resolved on dots) to a:value in the config. +function! neomake#config#set(name, value) abort + let parts = type(a:name) == type([]) ? a:name : split(a:name, '\.') + if parts[0] =~# '^b:' + let parts[0] = parts[0][2:-1] + return neomake#config#set_buffer(bufnr('%'), parts, a:value) + endif + if !has_key(g:, 'neomake') + let g:neomake = {} + endif + return s:set(g:neomake, parts, a:value) +endfunction + +" Set a:name (resolved on dots) to a:value for buffer a:bufnr. +function! neomake#config#set_buffer(bufnr, name, value) abort + let bufnr = +a:bufnr + let bneomake = getbufvar(bufnr, 'neomake') + if bneomake is# '' + unlet bneomake " for Vim without patch-7.4.1546 + let bneomake = {} + call setbufvar(bufnr, 'neomake', bneomake) + endif + return s:set(bneomake, a:name, a:value) +endfunction + +" Set a:name (resolved on dots) to a:value in a:scope. +" This is meant for advanced usage, e.g.: +" set_scope(t:, 'neomake.disabled', 1) +function! neomake#config#set_dict(dict, name, value) abort + return s:set(a:dict, a:name, a:value) +endfunction + +" Unset a:name (resolved on dots). +" This is meant for advanced usage, e.g.: +" unset_dict(t:, 'neomake.disabled', 1) +function! neomake#config#unset_dict(dict, name) abort + let [c, k] = s:resolve_name(a:dict, a:name, 0) + if has_key(c, k) + unlet c[k] + endif +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/configure.vim b/dotfiles/.vim/autoload/neomake/configure.vim new file mode 100644 index 0000000..f802d7f --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/configure.vim @@ -0,0 +1,785 @@ +" Default settings, setup in global config dict. +let s:default_settings = { + \ 'ignore_filetypes': ['startify'], + \ } +let g:neomake = get(g:, 'neomake', {}) +let g:neomake.automake = get(g:neomake, 'automake', {}) +call extend(g:neomake.automake, s:default_settings, 'keep') + +if !exists('s:timer_info') + let s:timer_info = {} + let s:timer_by_bufnr = {} +endif + +let s:default_delay = has('timers') ? 500 : 0 + +" A mapping of configured buffers with cached settings (maker_jobs). +let s:configured_buffers = {} +" A list of configured/used autocommands. +let s:registered_events = [] + +" TextChanged gets triggered in this case when loading a buffer (Vim +" issue #2742). +let s:need_to_skip_first_textchanged = !has('nvim-0.3.2') && has('patch-8.0.1494') && !has('patch-8.0.1633') + + +" TODO: allow for namespaces, and prefer 'automake' here. +" TODO: handle bufnr! (getbufvar) +function! s:get_setting(name, default) abort + return get(get(b:, 'neomake', {}), a:name, + \ get(get(t:, 'neomake', {}), a:name, + \ get(get(g:, 'neomake', {}), a:name, a:default))) +endfunction + + +function! s:debug_log(msg, ...) abort + let context = {'bufnr': bufnr('%')} + if a:0 + call extend(context, a:1) + endif + call neomake#log#debug(printf('automake: %s.', a:msg), context) +endfunction + +" Check if buffer's tick (or ft) changed. +function! s:tick_changed(context) abort + let bufnr = +a:context.bufnr + let ft = get(a:context, 'ft', getbufvar(bufnr, '&filetype')) + let prev_tick = getbufvar(bufnr, '_neomake_automake_tick') + let r = 1 + if empty(prev_tick) + call s:debug_log('tick changed (new)') + else + let cur_tick = [getbufvar(bufnr, 'changedtick'), ft] + if cur_tick == prev_tick + call s:debug_log('tick is unchanged') + return 0 + endif + + " NOTE: every write (BufWritePost) increments b:changedtick. + if a:context.event ==# 'BufWritePost' + let adjusted_prev_tick = [prev_tick[0]+1, prev_tick[1]] + if adjusted_prev_tick == cur_tick + let r = 0 + call setbufvar(bufnr, '_neomake_automake_tick', adjusted_prev_tick) + call s:debug_log('tick is unchanged with BufWritePost adjustment') + endif + endif + endif + return r +endfunction + +function! neomake#configure#_update_automake_tick(bufnr, ft) abort + if has_key(s:configured_buffers, a:bufnr) + let tick = getbufvar(a:bufnr, 'changedtick') + call s:debug_log('updating tick: '.tick) + call setbufvar(a:bufnr, '_neomake_automake_tick', [tick, a:ft]) + endif +endfunction + +function! neomake#configure#_reset_automake_cancelations(bufnr) abort + if has_key(s:configured_buffers, a:bufnr) + call setbufvar(a:bufnr, '_neomake_cancelations', [0, 0]) + endif +endfunction + +function! s:update_cancel_rate(bufnr, via_timer) abort + let canceled = getbufvar(a:bufnr, '_neomake_cancelations', [0, 0]) + if a:via_timer + let canceled[0] += 1 + else + let canceled[1] += 1 + endif + call setbufvar(a:bufnr, '_neomake_cancelations', canceled) + return canceled +endfunction + +function! s:handle_changed_buffer(make_id, event) abort + " Cleanup always. + if exists('b:_neomake_automake_changed_context') + let [make_id, prev_tick, changedtick, context] = b:_neomake_automake_changed_context + + if s:need_to_skip_first_textchanged && a:event ==# 'TextChanged' + if !get(b:, '_neomake_seen_TextChanged', 0) + call s:debug_log('ignoring first TextChanged') + let b:_neomake_seen_TextChanged = 1 + return + endif + endif + + if changedtick == b:changedtick + call s:debug_log(printf('handle_changed_buffer: %s: tick was not changed', a:event)) + return + endif + + unlet b:_neomake_automake_changed_context + augroup neomake_automake_abort + au! * + augroup END + else + return + endif + + if make_id != a:make_id + call neomake#log#warning(printf('automake: handle_changed_buffer: mismatched make_id: %d != %d.', make_id, a:make_id)) + return + endif + + let window_make_ids = get(w:, 'neomake_make_ids', []) + if index(window_make_ids, a:make_id) == -1 + return + endif + + call setbufvar(context.bufnr, '_neomake_automake_tick', prev_tick) + call filter(b:_neomake_automake_make_ids, 'v:val != '.a:make_id) + call s:update_cancel_rate(context.bufnr, 0) + + call s:debug_log(printf('buffer was changed (%s), canceling make', a:event), {'make_id': a:make_id}) + call neomake#CancelMake(a:make_id) + + if a:event ==# 'TextChangedI' + call s:debug_log('queueing make restart for InsertLeave', {'make_id': a:make_id}) + let b:_neomake_postponed_automake_context = [1, context] + augroup neomake_automake_retry + au! * + autocmd InsertLeave call s:do_postponed_automake(2) + augroup END + elseif context.delay + call s:debug_log(printf('restarting timer for original event %s', context.event), {'make_id': a:make_id}) + if has_key(context, '_via_timer_cb') + unlet context._via_timer_cb + endif + if has_key(context, 'pos') + unlet context.pos + endif + call s:neomake_do_automake(context) + else + call s:debug_log(printf('restarting for original event (%s) without delay', context.event)) + call s:neomake_do_automake(context) + endif +endfunction + +function! s:neomake_do_automake(context) abort + let bufnr = +a:context.bufnr + + if !get(a:context, '_via_timer_cb') && a:context.delay + if exists('s:timer_by_bufnr[bufnr]') + let timer = s:timer_by_bufnr[bufnr] + call s:stop_timer(timer) + call s:debug_log(printf('stopped existing timer: %d', timer), {'bufnr': bufnr}) + call s:update_cancel_rate(bufnr, 1) + endif + if !s:tick_changed(a:context) + call s:debug_log('buffer was not changed', {'bufnr': bufnr}) + return + endif + + " Cancel any already running automake runs. + let prev_make_ids = getbufvar(bufnr, '_neomake_automake_make_ids') + if !empty(prev_make_ids) + call s:debug_log(printf('stopping previous make runs: %s', join(prev_make_ids, ', '))) + for prev_make_id in prev_make_ids + call neomake#CancelMake(prev_make_id) + endfor + let canceled = s:update_cancel_rate(bufnr, 0) + else + let canceled = getbufvar(bufnr, '_neomake_cancelations', [0, 0]) + endif + + let delay = a:context.delay + + " Increase delay for canceled/restarted timers, and canceled makes. + " IDEA: take into account the mean duration of this make run. + if canceled[0] || canceled[1] + let [mult_timers, mult_makes, max_delay] = neomake#config#get('automake.cancelation_delay', [0.2, 0.5, 3000], {'bufnr': bufnr}) + let cancel_rate = 1 + (canceled[0]*mult_timers + canceled[1]*mult_makes) + let delay = min([max_delay, float2nr(ceil(delay * cancel_rate))]) + call s:debug_log(printf('increasing delay (%d/%d canceled timers/makes, rate=%.2f): %d => %d/%d', canceled[0], canceled[1], cancel_rate, a:context.delay, delay, max_delay)) + endif + + let timer = timer_start(delay, function('s:automake_delayed_cb')) + let s:timer_info[timer] = a:context + if !has_key(a:context, 'pos') + let s:timer_info[timer].pos = s:get_position_context() + endif + let s:timer_by_bufnr[bufnr] = timer + call s:debug_log(printf('started timer (%dms): %d', delay, timer), + \ {'bufnr': a:context.bufnr}) + return + endif + + let ft = getbufvar(bufnr, '&filetype') + let event = a:context.event + + call s:debug_log('neomake_do_automake: '.event, {'bufnr': bufnr}) + if !s:tick_changed({'event': event, 'bufnr': bufnr, 'ft': ft}) + call s:debug_log('buffer was not changed', {'bufnr': bufnr}) + return + endif + let prev_tick = getbufvar(bufnr, '_neomake_automake_tick') + + call s:debug_log(printf('enabled makers: %s', join(map(copy(a:context.maker_jobs), 'v:val.maker.name'), ', '))) + let make_options = { + \ 'file_mode': 1, + \ 'jobs': deepcopy(a:context.maker_jobs), + \ 'ft': ft, + \ 'automake': 1} + let jobinfos = neomake#Make(make_options) + + let started_jobs = filter(copy(jobinfos), "!get(v:val, 'finished', 0)") + call s:debug_log(printf('started jobs: %s', string(map(copy(started_jobs), 'v:val.id')))) + if !empty(started_jobs) + let make_id = jobinfos[0].make_id + call setbufvar(bufnr, '_neomake_automake_make_ids', + \ neomake#compat#getbufvar(bufnr, '_neomake_automake_make_ids', []) + [make_id]) + + " Setup buffer autocmd to cancel/restart make for changed buffer. + let events = [] + for event in ['TextChangedI', 'TextChanged'] + if a:context.event !=# event + call add(events, event) + endif + endfor + call setbufvar(bufnr, '_neomake_automake_changed_context', [make_id, prev_tick, getbufvar(bufnr, 'changedtick'), a:context]) + augroup neomake_automake_abort + exe printf('au! * ', bufnr) + for event in events + exe printf('autocmd %s call s:handle_changed_buffer(%s, %s)', + \ event, bufnr, string(make_id), string(event)) + endfor + augroup END + endif +endfunction + +function! s:get_position_context() abort + let w = exists('*win_getid') ? win_getid() : winnr() + return [w, getpos('.'), neomake#compat#get_mode()] +endfunction + +function! s:automake_delayed_cb(timer) abort + let timer_info = s:timer_info[a:timer] + unlet s:timer_info[a:timer] + unlet s:timer_by_bufnr[timer_info.bufnr] + + if !bufexists(timer_info.bufnr) + call s:debug_log(printf('buffer does not exist anymore for timer %d', a:timer), + \ {'bufnr': timer_info.bufnr}) + return + endif + + call s:debug_log(printf('callback for timer %d (via %s)', string(a:timer), timer_info.event), + \ {'bufnr': timer_info.bufnr}) + + let bufnr = bufnr('%') + if timer_info.bufnr != bufnr + call s:debug_log(printf('buffer changed: %d => %d, queueing make restart for BufEnter,WinEnter', + \ timer_info.bufnr, bufnr)) + let restart_context = copy(timer_info) + call setbufvar(restart_context.bufnr, '_neomake_postponed_automake_context', [1, restart_context]) + let b:_neomake_postponed_automake_context = [1, restart_context] + augroup neomake_automake_retry + exe 'au! * ' + exe 'autocmd BufEnter,WinEnter call s:do_postponed_automake(2)' + augroup END + return + endif + + if neomake#compat#in_completion() + call s:debug_log('postponing automake during completion') + if has_key(timer_info, 'pos') + unlet timer_info.pos + endif + let b:_neomake_postponed_automake_context = [0, timer_info] + + augroup neomake_automake_retry + au! * + autocmd CompleteDone call s:do_postponed_automake(1) + autocmd InsertLeave call s:do_postponed_automake(2) + augroup END + return + endif + + " Verify context/position is the same. + " This is meant to give an additional delay after e.g. TextChanged. + " Only events with delay are coming here, so this does not affect + " BufWritePost etc typically. + if !empty(timer_info.pos) + let current_context = s:get_position_context() + if current_context != timer_info.pos + if current_context[2] != timer_info.pos[2] + " Mode was changed. + if current_context[2][0] ==# 'i' && timer_info.event !=# 'TextChangedI' + " Changed to insert mode, trigger on InsertLeave. + call s:debug_log(printf('context/position changed: %s => %s, restarting on InsertLeave', + \ string(timer_info.pos), string(current_context))) + let context = copy(timer_info) + let context.delay = 0 + unlet context.pos + call s:update_cancel_rate(bufnr, 1) + let b:_neomake_postponed_automake_context = [1, context] + augroup neomake_automake_retry + au! * + autocmd InsertLeave call s:do_postponed_automake(2) + augroup END + return + endif + endif + call s:debug_log(printf('context/position changed: %s => %s, restarting', + \ string(timer_info.pos), string(current_context))) + unlet timer_info.pos + call s:update_cancel_rate(bufnr, 1) + call s:neomake_do_automake(timer_info) + return + endif + endif + " endif + + let context = copy(timer_info) + let context._via_timer_cb = 1 + call s:neomake_do_automake(context) +endfunction + +function! s:do_postponed_automake(step) abort + if exists('b:_neomake_postponed_automake_context') + let context = b:_neomake_postponed_automake_context + + if context[0] == a:step - 1 + if a:step == 2 + call s:debug_log('re-starting postponed automake') + let context[1].pos = s:get_position_context() + call s:neomake_do_automake(context[1]) + else + let context[0] = a:step + return + endif + else + call s:debug_log('postponed automake: unexpected step '.a:step.', cleaning up') + endif + unlet b:_neomake_postponed_automake_context + else + call s:debug_log('missing context information for postponed automake') + endif + " Cleanup. + augroup neomake_automake_retry + autocmd! * + augroup END +endfunction + +" Parse/get events dict from args. +" a:config: config dict to write into. +" a:string_or_dict_config: a string or dict describing the config. +" a:1: default delay. +function! s:parse_events_from_args(config, string_or_dict_config, ...) abort + " Get default delay from a:1. + if a:0 + if has('timers') + let delay = a:1 + else + if a:1 != 0 + call neomake#log#warning('automake: timer support is required for delayed events.') + endif + let delay = 0 + endif + else + let delay = s:default_delay + endif + + if type(a:string_or_dict_config) == type({}) + let events = copy(a:string_or_dict_config) + + " Validate events. + for [event, config] in items(events) + if !exists('##'.event) + call neomake#log#error(printf( + \ 'automake: event %s does not exist.', event)) + unlet events[event] + continue + endif + + if get(config, 'delay', 0) && !has('timers') + call neomake#log#error(printf( + \ 'automake: timer support is required for automaking, removing event %s.', + \ event)) + unlet events[event] + endif + endfor + call neomake#config#set_dict(a:config, 'automake.events', events) + if a:0 + let a:config.automake_delay = a:1 + endif + else + " Map string config to events dict. + let modes = a:string_or_dict_config + let events = {} + let default_with_delay = {} + + " Insert mode. + if modes =~# 'i' + if exists('##TextChangedI') && has('timers') + let events['TextChangedI'] = default_with_delay + else + call s:debug_log('using CursorHoldI instead of TextChangedI') + let events['CursorHoldI'] = (delay != 0 ? {'delay': 0} : {}) + endif + endif + " Normal mode. + if modes =~# 'n' + if exists('##TextChanged') && has('timers') + let events['TextChanged'] = default_with_delay + if !has_key(events, 'TextChangedI') + " Run when leaving insert mode, since only TextChangedI would be triggered + " for `ciw` etc. + let events['InsertLeave'] = default_with_delay + endif + else + call s:debug_log('using CursorHold instead of TextChanged') + let events['CursorHold'] = (delay != 0 ? {'delay': 0} : {}) + let events['InsertLeave'] = (delay != 0 ? {'delay': 0} : {}) + endif + endif + " On writes. + if modes =~# 'w' + let events['BufWritePost'] = (delay != 0 ? {'delay': 0} : {}) + endif + " On reads. + if modes =~# 'r' + let events['BufWinEnter'] = {} + let events['FileType'] = {} + + " When a file was changed outside of Vim. + " TODO: test + let events['FileChangedShellPost'] = {} + " XXX: FileType might work better, at least when wanting to skip filetypes. + " let events['FileType'] = {'delay': a:0 > 1 ? delay : 0} + endif + endif + + call neomake#config#set_dict(a:config, 'automake.events', events) + if a:0 + let a:config.automake_delay = delay + endif +endfunction + +" Setup automake for buffer (current, or options.bufnr). +" a:1: delay +" a:2: options ('bufnr', 'makers') / or list of makers TODO +function! neomake#configure#automake_for_buffer(string_or_dict_config, ...) abort + let options = {} + if a:0 + let options.delay = a:1 + endif + let bufnr = bufnr('%') + if a:0 > 1 + if type(a:2) == type([]) + let options.makers = a:2 + else + call extend(options, a:2) + if has_key(options, 'bufnr') + let bufnr = options.bufnr + unlet options.bufnr + endif + endif + endif + return call('s:configure_buffer', [bufnr, a:string_or_dict_config, options]) +endfunction + +" Workaround for getbufvar not having support for defaults. +function! s:getbufvar(bufnr, name, default) abort + let b_dict = getbufvar(+a:bufnr, '') + if empty(b_dict) + " NOTE: it is an empty string for non-existing buffers. + return a:default + endif + return get(b_dict, a:name, a:default) +endfunction + +function! s:is_buffer_ignored(bufnr) abort + " TODO: blacklist/whitelist. + let bufnr = +a:bufnr + let buftype = getbufvar(bufnr, '&buftype') + if !empty(buftype) + call s:debug_log(printf('ignoring buffer with buftype=%s', buftype), {'bufnr': bufnr}) + return 1 + endif + + let ft = getbufvar(bufnr, '&filetype') + if index(neomake#config#get('automake.ignore_filetypes', []), ft) != -1 + call s:debug_log(printf('ignoring buffer with filetype=%s', ft), {'bufnr': bufnr}) + return 1 + endif +endfunction + +if exists('##OptionSet') + function! s:update_buffer_options() abort + let bufnr = bufnr('%') + call s:maybe_reconfigure_buffer(bufnr) + endfunction + augroup neomake_automake_update + au! + au OptionSet buftype call s:update_buffer_options() + augroup END +endif + +" a:1: string or dict describing the events +" a:2: options ('delay', 'makers') +function! s:configure_buffer(bufnr, ...) abort + let bufnr = +a:bufnr + let ft = getbufvar(bufnr, '&filetype') + let config = s:getbufvar(bufnr, 'neomake', {}) + let old_config = deepcopy(config) + if a:0 + let args = [config, a:1] + if a:0 > 1 && has_key(a:2, 'delay') + let args += [a:2.delay] + endif + call call('s:parse_events_from_args', args) + call setbufvar(bufnr, 'neomake', config) + + let implicit_config = {'custom': 1, 'ignore': 0} + else + let implicit_config = {'custom': 0, 'ignore': s:is_buffer_ignored(bufnr)} + endif + + " Register the buffer, and remember if it is custom. + if has_key(s:configured_buffers, bufnr) + let old_registration = copy(get(s:configured_buffers, bufnr, {})) + call extend(s:configured_buffers[bufnr], implicit_config, 'force') + else + let s:configured_buffers[bufnr] = implicit_config + + augroup neomake_automake_clean + autocmd BufWipeout call s:neomake_automake_clean(expand('')) + augroup END + endif + + if implicit_config.ignore + return s:configured_buffers[bufnr] + endif + + let s:configured_buffers[bufnr].events_config = neomake#config#get('automake.events', {}) + + " Create jobs. + let options = a:0 > 1 ? a:2 : {} + if has_key(options, 'makers') + let makers = neomake#map_makers(options.makers, ft, 0) + let source = 'options' + else + let [makers, source] = neomake#config#get_with_source('automake.enabled_makers') + if makers is g:neomake#config#undefined + unlet makers + let makers = neomake#GetEnabledMakers(ft) + else + let makers = neomake#map_makers(makers, ft, 0) + endif + endif + let options = {'file_mode': 1, 'ft': ft, 'bufnr': bufnr, 'automake': 1} + let jobs = neomake#core#create_jobs(options, makers) + let s:configured_buffers[bufnr].maker_jobs = jobs + call s:debug_log(printf('configured buffer for ft=%s (%s)', + \ ft, empty(jobs) ? 'no enabled makers' : join(map(copy(jobs), 'v:val.maker.name'), ', ').' ('.source.')'), {'bufnr': bufnr}) + if old_config != config + call s:debug_log('resetting tick because of config changes') + call setbufvar(bufnr, '_neomake_automake_tick', []) + elseif exists('old_registration') + if old_registration != s:configured_buffers[bufnr] + call s:debug_log('resetting tick because of registration changes') + call setbufvar(bufnr, '_neomake_automake_tick', []) + endif + else + call s:debug_log('setting tick for new buffer') + call setbufvar(bufnr, '_neomake_automake_tick', []) + endif + + if a:0 + " Setup autocommands etc (when called manually)?! + call neomake#configure#automake() + endif + return config +endfunction + +function! s:maybe_reconfigure_buffer(bufnr) abort + if has_key(s:configured_buffers, a:bufnr) && !s:configured_buffers[a:bufnr].custom + call s:configure_buffer(a:bufnr) + endif +endfunction + +" Called from autocommands. +function! s:neomake_automake(event, bufnr) abort + let disabled = neomake#config#get_with_source('disabled', 0) + if disabled[0] + call s:debug_log(printf('disabled (%s)', disabled[1])) + return + endif + let bufnr = +a:bufnr + + if has_key(s:configured_buffers, bufnr) + let buffer_config = s:configured_buffers[bufnr] + else + " Register the buffer, and remember that it's automatic. + let buffer_config = s:configure_buffer(bufnr) + endif + if get(buffer_config, 'ignore', 0) + " NOTE: might be too verbose. + call s:debug_log('buffer is ignored') + return + endif + + if s:need_to_skip_first_textchanged && a:event ==# 'TextChanged' + if !getbufvar(bufnr, '_neomake_seen_TextChanged', 0) + call s:debug_log('ignoring first TextChanged') + call setbufvar(bufnr, '_neomake_seen_TextChanged', 1) + return + endif + endif + + call s:debug_log(printf('handling event %s', a:event), {'bufnr': bufnr}) + + if empty(s:configured_buffers[bufnr].maker_jobs) + call s:debug_log('no enabled makers', {'bufnr': bufnr}) + return + endif + + call s:debug_log(printf('automake for event %s', a:event), {'bufnr': bufnr}) + let config = s:configured_buffers[bufnr].events_config + if !has_key(config, a:event) + call s:debug_log('event is not registered', {'bufnr': bufnr}) + return + endif + let config = config[a:event] + + let event = a:event + let bufnr = +a:bufnr + " TODO: rename to neomake.automake.delay + let delay = get(config, 'delay', s:get_setting('automake_delay', s:default_delay)) + let context = { + \ 'delay': delay, + \ 'bufnr': bufnr, + \ 'event': a:event, + \ 'maker_jobs': s:configured_buffers[bufnr].maker_jobs, + \ } + if event ==# 'BufWinEnter' + " Ignore context, so that e.g. with vim-stay restoring the view + " (cursor position), it will still be triggered. + let context.pos = [] + endif + call s:neomake_do_automake(context) +endfunction + +function! s:stop_timer(timer) abort + let timer_info = s:timer_info[a:timer] + unlet s:timer_info[a:timer] + unlet s:timer_by_bufnr[timer_info.bufnr] + call timer_stop(+a:timer) +endfunction + +function! s:stop_timers() abort + let timers = keys(s:timer_info) + if !empty(timers) + call s:debug_log(printf('stopping timers: %s', join(timers, ', '))) + for timer in timers + call s:stop_timer(timer) + endfor + endif +endfunction + +function! neomake#configure#reset_automake() abort + for bufnr in keys(s:configured_buffers) + call s:neomake_automake_clean(bufnr) + endfor + let s:registered_events = [] + call s:stop_timers() + call neomake#configure#automake() +endfunction + +function! s:neomake_automake_clean(bufnr) abort + if has_key(s:timer_by_bufnr, a:bufnr) + let timer = s:timer_by_bufnr[a:bufnr] + call s:stop_timer(timer) + call s:debug_log('stopped timer for cleaned buffer: '.timer) + endif + if has_key(s:configured_buffers, a:bufnr) + unlet s:configured_buffers[a:bufnr] + augroup neomake_automake_clean + exe printf('au! * ', a:bufnr) + augroup END + endif +endfunction + +function! neomake#configure#disable_automake() abort + call s:debug_log('disabling globally') + call s:stop_timers() +endfunction + +function! neomake#configure#disable_automake_for_buffer(bufnr) abort + call s:debug_log(printf('disabling buffer %d', a:bufnr)) + if has_key(s:timer_by_bufnr, a:bufnr) + let timer = s:timer_by_bufnr[a:bufnr] + call s:stop_timer(timer) + call s:debug_log('stopped timer for buffer: '.timer) + endif + if has_key(s:configured_buffers, a:bufnr) + let s:configured_buffers[a:bufnr].disabled = 1 + endif +endfunction + +function! neomake#configure#enable_automake_for_buffer(bufnr) abort + if exists('s:configured_buffers[a:bufnr].disabled') + call s:debug_log(printf('Re-enabled buffer %d', a:bufnr)) + unlet s:configured_buffers[a:bufnr].disabled + endif +endfunction + +function! neomake#configure#reset_automake_for_buffer(...) abort + let bufnr = a:0 ? +a:1 : bufnr('%') + call s:neomake_automake_clean(bufnr) +endfunction + +function! neomake#configure#automake(...) abort + call s:debug_log(printf('configuring automake: %s', string(a:000))) + if !exists('g:neomake') + let g:neomake = {} + endif + if a:0 + call call('s:parse_events_from_args', [g:neomake] + a:000) + endif + + let disabled_globally = get(get(g:, 'neomake', {}), 'disabled', 0) + if disabled_globally + let s:registered_events = [] + else + let s:registered_events = keys(get(get(g:neomake, 'automake', {}), 'events', {})) + endif + " Keep custom configured buffers. + call filter(s:configured_buffers, 'v:val.custom') + for b in keys(s:configured_buffers) + if empty(s:configured_buffers[b].maker_jobs) + continue + endif + if get(s:configured_buffers[b], 'disabled', 0) + continue + endif + let b_cfg = neomake#config#get('b:automake.events', {}) + for event_config in items(b_cfg) + let event = event_config[0] + if index(s:registered_events, event) == -1 + call add(s:registered_events, event) + endif + endfor + endfor + call s:debug_log('registered events: '.join(s:registered_events, ', ')) + + augroup neomake_automake + au! + for event in s:registered_events + exe 'autocmd '.event." * call s:neomake_automake('".event."', expand(''))" + endfor + augroup END + if empty(s:registered_events) + augroup! neomake_automake + endif +endfunction + +augroup neomake_automake_base + au! + autocmd FileType * call s:maybe_reconfigure_buffer(expand('')) +augroup END +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/core.vim b/dotfiles/.vim/autoload/neomake/core.vim new file mode 100644 index 0000000..b61a351 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/core.vim @@ -0,0 +1,120 @@ +let g:neomake#core#valid_maker_name_pattern = '\v^\w+$' + +let g:neomake#core#_ignore_autocommands = 0 + +function! neomake#core#create_jobs(options, makers) abort + let args = [a:options, a:makers] + let jobs = call('s:bind_makers_for_job', args) + return jobs +endfunction + +" Map/bind a:makers to a list of job options, using a:options. +function! s:bind_makers_for_job(options, makers) abort + let r = [] + for maker in a:makers + let options = copy(a:options) + try + let maker = neomake#core#instantiate_maker(maker, options, 1) + catch /^Neomake: skip_job: / + let msg = substitute(v:exception, '^Neomake: skip_job: ', '', '') + call neomake#log#debug(printf('%s: skipping job: %s.', + \ maker.name, msg), options) + continue + catch /^Neomake: / + let error = substitute(v:exception, '^Neomake: ', '', '').'.' + call neomake#log#error(error, options) + continue + endtry + if !empty(maker) + let options.maker = maker + let r += [options] + endif + endfor + return r +endfunction + +function! neomake#core#instantiate_maker(maker, options, check_exe) abort + let maker = a:maker + let options = a:options + let ft = get(options, 'ft', '') + let bufnr = get(options, 'bufnr', '') + + " Call InitForJob function in maker object, if any. + let l:Init = neomake#utils#GetSetting('InitForJob', maker, g:neomake#config#undefined, ft, bufnr) + if empty(Init) + " Deprecated: should use InitForJob instead. + if has_key(maker, 'fn') + unlet Init " vim73 + let l:Init = maker.fn + call neomake#log#warn_once(printf("Please use 'InitForJob' instead of 'fn' for maker %s.", maker.name), + \ printf('deprecated-fn-%s', maker.name)) + endif + endif + if !empty(Init) + let returned_maker = call(Init, [options], maker) + if returned_maker isnot# 0 + " This conditional assignment allows to both return a copy + " (factory), while also can be used as a init method. + let maker = returned_maker + endif + endif + + if has_key(maker, '_bind_args') + call maker._bind_args() + if type(maker.exe) != type('') + let error = printf('Non-string given for executable of maker %s: type %s', + \ maker.name, type(maker.exe)) + if !get(maker, 'auto_enabled', 0) + throw 'Neomake: '.error + endif + call neomake#log#debug(error.'.', options) + return {} + endif + if a:check_exe && !executable(maker.exe) + if get(maker, 'auto_enabled', 0) + call neomake#log#debug(printf( + \ 'Exe (%s) of auto-configured maker %s is not executable, skipping.', maker.exe, maker.name), options) + else + let error = printf('Exe (%s) of maker %s is not executable', maker.exe, maker.name) + throw 'Neomake: '.error + endif + return {} + endif + endif + return maker +endfunction + +" Base class for command makers. +let g:neomake#core#command_maker_base = {} + +function! g:neomake#core#command_maker_base._get_fname_for_args(jobinfo) abort dict + " Append file? (defaults to jobinfo.file_mode, project/global makers should set it to 0) + let append_file = neomake#utils#GetSetting('append_file', self, a:jobinfo.file_mode, a:jobinfo.ft, a:jobinfo.bufnr) + " Use/generate a filename? (defaults to 1 if tempfile_name is set) + let uses_filename = append_file || neomake#utils#GetSetting('uses_filename', self, has_key(self, 'tempfile_name'), a:jobinfo.ft, a:jobinfo.bufnr) + if append_file || uses_filename + let filename = self._get_fname_for_buffer(a:jobinfo) + if append_file + return filename + endif + endif + return '' +endfunction + +function! g:neomake#core#command_maker_base._get_argv(_jobinfo) abort dict + return neomake#compat#get_argv(self.exe, self.args, type(self.args) == type([])) +endfunction + +" Get tabnr and winnr for a given make ID. +function! neomake#core#get_tabwin_for_makeid(make_id) abort + let curtab = tabpagenr() + for t in [curtab] + range(1, curtab-1) + range(curtab+1, tabpagenr('$')) + for w in range(1, tabpagewinnr(t, '$')) + if index(neomake#compat#gettabwinvar(t, w, 'neomake_make_ids', []), a:make_id) != -1 + return [t, w] + endif + endfor + endfor + return [-1, -1] +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/debug.vim b/dotfiles/.vim/autoload/neomake/debug.vim new file mode 100644 index 0000000..66abcaf --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/debug.vim @@ -0,0 +1,273 @@ +" Debug/feedback helpers. + +function! neomake#debug#pprint(d, ...) abort + return call('s:pprint', [a:d] + a:000) +endfunction + +function! s:pprint(v, ...) abort + let indent = a:0 ? a:1 : '' + if type(a:v) ==# type({}) + if empty(a:v) + return '{}' + endif + let r = "{\n" + for [k, l:V] in items(a:v) + let r .= printf("%s %s: %s,\n", + \ indent, + \ string(k), + \ s:pprint(neomake#utils#fix_self_ref(V), indent . ' ')) + unlet V " old-vim + endfor + let r .= indent.'}' + return r + elseif type(a:v) ==# type([]) + if empty(a:v) + return '[]' + endif + let r = '['."\n".join(map(copy(a:v), 'indent." ".s:pprint(v:val, indent." ")'), ",\n").",\n".indent.']' + return r + endif + return string(a:v) +endfunction + +function! neomake#debug#validate_maker(maker) abort + let issues = {'errors': [], 'warnings': []} + + if has_key(a:maker, 'process_json') && has_key(a:maker, 'process_output') + let issues.warnings += ['maker has process_json and process_output, but only process_json will be used.'] + let check_process = ['process_json'] + else + let check_process = ['process_json', 'process_output'] + endif + + for f in check_process + if has_key(a:maker, f) + if has_key(a:maker, 'mapexpr') + let issues.warnings += [printf( + \ 'maker has mapexpr, but only %s will be used.', + \ f)] + endif + if has_key(a:maker, 'postprocess') + let issues.warnings += [printf( + \ 'maker has postprocess, but only %s will be used.', + \ f)] + endif + if has_key(a:maker, 'errorformat') + let issues.warnings += [printf( + \ 'maker has errorformat, but only %s will be used.', + \ f)] + endif + endif + endfor + + try + let maker = neomake#core#instantiate_maker(a:maker, {}, 0) + if !executable(maker.exe) + let t = get(maker, 'auto_enabled', 0) ? 'warnings' : 'errors' + let issues[t] += [printf("maker's exe (%s) is not executable.", maker.exe)] + endif + catch /^Neomake: / + let issues.errors += [substitute(v:exception, '^Neomake: ', '', '').'.'] + endtry + + if has_key(a:maker, 'name') + if a:maker.name !~# g:neomake#core#valid_maker_name_pattern + call add(issues['errors'], printf( + \ 'Invalid maker name: %s (should match %s)', + \ string(a:maker.name), + \ string(g:neomake#core#valid_maker_name_pattern))) + endif + endif + + return issues +endfunction + +" Optional arg: ft +function! s:get_makers_info(...) abort + let maker_names = call('neomake#GetEnabledMakers', a:000) + if empty(maker_names) + return ['None.'] + endif + let maker_defaults = g:neomake#config#_defaults['maker_defaults'] + let r = [] + for maker_name in maker_names + let maker = call('neomake#GetMaker', [maker_name] + a:000) + let r += [' - '.maker.name] + let r += map(s:get_maker_info(maker, maker_defaults), "' '.v:val") + endfor + return r +endfunction + +function! s:get_maker_info(maker, ...) abort + let maker_defaults = a:0 ? a:1 : {} + let maker = a:maker + let r = [] + for [k, l:V] in sort(copy(items(maker))) + if k !=# 'name' && k !=# 'ft' && k !~# '^_' + if !has_key(maker_defaults, k) + \ || type(V) != type(maker_defaults[k]) + \ || V !=# maker_defaults[k] + let r += [' - '.k.': '.string(V)] + endif + endif + unlet V " vim73 + endfor + + let issues = neomake#debug#validate_maker(maker) + if !empty(issues) + for type in sort(copy(keys(issues))) + let items = issues[type] + if !empty(items) + let r += [' - '.toupper(type) . ':'] + for issue in items + let r += [' - ' . issue] + endfor + endif + endfor + endif + + if type(maker.exe) == type('') && executable(maker.exe) + let version_arg = get(maker, 'version_arg', '--version') + let exe = exists('*exepath') ? exepath(maker.exe) : maker.exe + let version_output = neomake#compat#systemlist([exe, version_arg]) + if empty(version_output) + let version_output = [printf( + \ 'failed to get version information (%s)', + \ v:shell_error)] + endif + let r += [printf(' - version information (%s %s): %s', + \ exe, + \ version_arg, + \ join(version_output, "\n "))] + endif + return r +endfunction + +function! s:get_fts_with_makers() abort + return neomake#compat#uniq(sort(map(split(globpath(escape(&runtimepath, ' '), + \ 'autoload/neomake/makers/ft/*.vim'), "\n"), + \ 'fnamemodify(v:val, ":t:r")'))) +endfunction + +function! neomake#debug#get_maker_info(maker_name) abort + let source = '' + let maker = neomake#get_maker_by_name(a:maker_name, &filetype) + if empty(maker) + let maker = neomake#get_maker_by_name(a:maker_name) + if empty(maker) + let fts = filter(s:get_fts_with_makers(), 'v:val != &filetype') + for ft in fts + let maker = neomake#get_maker_by_name(a:maker_name, ft) + if !empty(maker) + let source = 'filetype '.ft + break + endif + endfor + else + let source = 'project maker' + endif + endif + if empty(maker) + call neomake#log#error(printf('Maker not found: %s.', a:maker_name)) + return [] + endif + let maker = neomake#create_maker_object(maker, &filetype) + return [maker.name . (empty(source) ? '' : ' ('.source.')')] + \ + s:get_maker_info(maker) +endfunction + +function! neomake#debug#display_info(...) abort + let bang = a:0 ? a:1 : 0 + if a:0 > 1 + let maker_name = a:2 + let lines = neomake#debug#get_maker_info(maker_name) + else + let lines = neomake#debug#_get_info_lines() + endif + if bang + try + call setreg('+', join(lines, "\n"), 'l') + catch + call neomake#log#error(printf( + \ 'Could not set clipboard: %s.', v:exception)) + return + endtry + echom 'Copied Neomake info to clipboard ("+).' + else + echon join(lines, "\n") + endif +endfunction + +function! s:trim(s) abort + return substitute(a:s, '\v^[ \t\r\n]+|[ \t\r\n]+$', '', 'g') +endfunction + +function! neomake#debug#_get_info_lines() abort + let r = [] + let ft = &filetype + + let r += ['#### Neomake debug information'] + let r += [''] + let r += ['Async support: '.neomake#has_async_support()] + let r += ['Current filetype: '.ft] + let r += ['Windows: '.neomake#utils#IsRunningWindows()] + let r += ['[shell, shellcmdflag, shellslash]: '.string([&shell, &shellcmdflag, &shellslash])] + let r += [join(map(split(neomake#utils#redir('verb set makeprg?'), '\n'), 's:trim(v:val)'), ', ')] + + let r += [''] + let r += ['##### Enabled makers'] + let r += [''] + let r += ['For the current filetype ("'.ft.'", used with :Neomake):'] + let r += s:get_makers_info(ft) + if empty(ft) + let r += ['NOTE: the current buffer does not have a filetype.'] + else + let conf_ft = neomake#utils#get_ft_confname(ft) + let r += ['NOTE: you can define g:neomake_'.conf_ft.'_enabled_makers' + \ .' to configure it (or b:neomake_'.conf_ft.'_enabled_makers).'] + endif + let r += [''] + let r += ['For the project (used with :Neomake!):'] + let r += s:get_makers_info() + let r += ['NOTE: you can define g:neomake_enabled_makers to configure it.'] + let r += [''] + let r += ['Default maker settings:'] + for [k, v] in items(neomake#config#get('maker_defaults')) + let r += [' - '.k.': '.string(v)] + unlet! v " Fix variable type mismatch with Vim 7.3. + endfor + let r += [''] + let r += ['##### Settings'] + let r += [''] + let r += ['###### New-style (dict, overrides old-style)'] + let r += [''] + let r += ['```'] + + let r += ['g:neomake: '.(exists('g:neomake') ? s:pprint(g:neomake) : 'unset')] + let r += ['b:neomake: '.(exists('b:neomake') ? s:pprint(b:neomake) : 'unset')] + let r += ['```'] + let r += [''] + let r += ['###### Old-style'] + let r += [''] + let r += ['```'] + for [k, V] in sort(items(filter(copy(g:), "v:key =~# '^neomake_'"))) + let r += ['g:'.k.' = '.string(V)] + unlet! V " Fix variable type mismatch with Vim 7.3. + endfor + let r += [''] + let r += ['```'] + let r += ["\n"] + let r += ['#### :version'] + let r += [''] + let r += ['```'] + let r += split(neomake#utils#redir('version'), '\n') + let r += ['```'] + let r += [''] + let r += ['#### :messages'] + let r += [''] + let r += ['```'] + let r += split(neomake#utils#redir('messages'), '\n') + let r += ['```'] + return r +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/highlights.vim b/dotfiles/.vim/autoload/neomake/highlights.vim new file mode 100644 index 0000000..cdc416a --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/highlights.vim @@ -0,0 +1,155 @@ +" vim: ts=4 sw=4 et + +let s:highlights = {'file': {}, 'project': {}} +let s:highlight_types = { + \ 'E': 'NeomakeError', + \ 'W': 'NeomakeWarning', + \ 'I': 'NeomakeInfo', + \ 'M': 'NeomakeMessage' + \ } + +let s:nvim_api = exists('*nvim_buf_add_highlight') + +" Used in tests. +function! neomake#highlights#_get() abort + return s:highlights +endfunction + +if s:nvim_api + function! s:InitBufHighlights(type, buf) abort + if !bufexists(a:buf) + " The buffer might be wiped by now: prevent 'Invalid buffer id'. + return + endif + if has_key(s:highlights[a:type], a:buf) + call nvim_buf_clear_highlight(a:buf, s:highlights[a:type][a:buf], 0, -1) + else + let s:highlights[a:type][a:buf] = nvim_buf_add_highlight(a:buf, 0, '', 0, 0, -1) + endif + endfunction + + function! s:reset(type, buf) abort + if has_key(s:highlights[a:type], a:buf) + call nvim_buf_clear_highlight(a:buf, s:highlights[a:type][a:buf], 0, -1) + unlet s:highlights[a:type][a:buf] + endif + endfunction +else + function! s:InitBufHighlights(type, buf) abort + let s:highlights[a:type][a:buf] = { + \ 'NeomakeError': [], + \ 'NeomakeWarning': [], + \ 'NeomakeInfo': [], + \ 'NeomakeMessage': [] + \ } + endfunction + + function! s:reset(type, buf) abort + if has_key(s:highlights[a:type], a:buf) + unlet s:highlights[a:type][a:buf] + call neomake#highlights#ShowHighlights() + endif + endfunction +endif + +function! neomake#highlights#ResetFile(buf) abort + call s:reset('file', a:buf) +endfunction +function! neomake#highlights#ResetProject(...) abort + if a:0 " deprecated a:buf + call neomake#log#warn_once('neomake#highlights#ResetProject does not use a:buf anymore.', + \ 'deprecated-highlight-resetproject') + endif + for buf in keys(s:highlights['project']) + call s:reset('project', +buf) + endfor +endfunction + +function! neomake#highlights#AddHighlight(entry, type) abort + " Some makers use line 0 for file warnings (which cannot be highlighted, + " e.g. cpplint with "no copyright" warnings). + if a:entry.lnum == 0 + return + endif + + if !has_key(s:highlights[a:type], a:entry.bufnr) + call s:InitBufHighlights(a:type, a:entry.bufnr) + endif + let hi = get(s:highlight_types, toupper(a:entry.type), 'NeomakeError') + + if a:entry.col > 0 && get(g:, 'neomake_highlight_columns', 1) + let length = get(a:entry, 'length', 1) + if s:nvim_api + call nvim_buf_add_highlight(a:entry.bufnr, s:highlights[a:type][a:entry.bufnr], hi, a:entry.lnum - 1, a:entry.col - 1, a:entry.col + length - 1) + else + call add(s:highlights[a:type][a:entry.bufnr][hi], [a:entry.lnum, a:entry.col, length]) + endif + elseif get(g:, 'neomake_highlight_lines', 0) + if s:nvim_api + call nvim_buf_add_highlight(a:entry.bufnr, s:highlights[a:type][a:entry.bufnr], hi, a:entry.lnum - 1, 0, -1) + else + call add(s:highlights[a:type][a:entry.bufnr][hi], a:entry.lnum) + endif + endif +endfunction + +if s:nvim_api + function! neomake#highlights#ShowHighlights() abort + endfunction +else + function! neomake#highlights#ShowHighlights() abort + if exists('w:neomake_highlights') + for highlight in w:neomake_highlights + try + call matchdelete(highlight) + catch /^Vim\%((\a\+)\)\=:E803/ + endtry + endfor + endif + let w:neomake_highlights = [] + + let buf = bufnr('%') + for type in ['file', 'project'] + for [hi, locs] in items(filter(copy(get(s:highlights[type], buf, {})), '!empty(v:val)')) + if exists('*matchaddpos') + call add(w:neomake_highlights, matchaddpos(hi, locs)) + else + for loc in locs + if len(loc) == 1 + call add(w:neomake_highlights, matchadd(hi, '\%' . loc[0] . 'l')) + else + call add(w:neomake_highlights, matchadd(hi, '\%' . loc[0] . 'l\%' . loc[1] . 'c.\{' . loc[2] . '}')) + endif + endfor + endif + endfor + endfor + endfunction +endif + +function! neomake#highlights#DefineHighlights() abort + for [group, link] in items({ + \ 'NeomakeError': 'SpellBad', + \ 'NeomakeWarning': 'SpellCap', + \ 'NeomakeInfo': 'NeomakeWarning', + \ 'NeomakeMessage': 'NeomakeWarning' + \ }) + if !neomake#utils#highlight_is_defined(group) + exe 'highlight link '.group.' '.link + endif + endfor +endfunction + +function! s:wipe_highlights(bufnr) abort + for type in ['file', 'project'] + if has_key(s:highlights[type], a:bufnr) + unlet s:highlights[type][a:bufnr] + endif + endfor +endfunction +augroup neomake_highlights + au! + autocmd BufWipeout * call s:wipe_highlights(expand('')) +augroup END + +call neomake#highlights#DefineHighlights() diff --git a/dotfiles/.vim/autoload/neomake/jobinfo.vim b/dotfiles/.vim/autoload/neomake/jobinfo.vim new file mode 100644 index 0000000..278a3f5 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/jobinfo.vim @@ -0,0 +1,87 @@ +let s:jobinfo_base = { + \ 'cd_back_cmd': '', + \ 'pending_output': [], + \ } +function! s:jobinfo_base.get_pid() abort + if has_key(self, 'vim_job') + let info = job_info(self.vim_job) + if info.status ==# 'run' + return info.process + endif + return -1 + endif + try + return jobpid(self.nvim_job) + catch /^Vim(return):E900:/ + return -1 + endtry +endfunction + +function! s:jobinfo_base.as_string() abort + let extra = [] + for k in ['canceled', 'finished'] + if get(self, k, 0) + let extra += [k] + endif + endfor + return printf('Job %d: %s%s', self.id, self.name, + \ empty(extra) ? '' : ' ['.join(extra, ', ').']') +endfunction + +function! s:jobinfo_base.cd_back() abort + if !empty(self.cd_back_cmd) + exe self.cd_back_cmd + let self.cd_back_cmd = '' + endif +endfunction + +function! s:jobinfo_base.cd(...) abort + if a:0 + if has_key(self, 'cd_from_setting') + call neomake#log#debug(printf( + \ 'jobinfo.cd(): keeping cwd from setting: %s.', + \ string(self.cd_from_setting)), self) + return '' + endif + let dir = a:1 + else + let maker = self.maker + let dir = neomake#utils#GetSetting('cwd', maker, '', self.ft, self.bufnr, 1) + if !empty(dir) + let self.cd_from_setting = dir + endif + endif + + if dir !=# '' + if dir[0:1] ==# '%:' + let dir = neomake#utils#fnamemodify(self.bufnr, dir[1:]) + else + let dir = expand(dir, 1) + endif + let dir = fnamemodify(dir, ':p') + " NOTE: need to keep trailing backslash with "/" and "X:\" on Windows. + if dir !=# '/' && dir[-1:] ==# neomake#utils#Slash() && dir[-2] !=# ':' + let dir = dir[:-2] + endif + else + let dir = get(self, 'cwd', $HOME) + endif + + let cur_wd = getcwd() + if dir !=# cur_wd + let [cd_error, cd_back_cmd] = neomake#utils#temp_cd(dir, cur_wd) + if !empty(cd_error) + call neomake#log#debug(printf('jobinfo.cd(): error when trying to change cwd to %s: %s.', + \ dir, cd_error)) + return cd_error + endif + let self.cwd = dir + let self.cd_back_cmd = cd_back_cmd + else + let self.cwd = cur_wd + endif + return '' +endfunction + +let g:neomake#jobinfo#base = s:jobinfo_base +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/list.vim b/dotfiles/.vim/autoload/neomake/list.vim new file mode 100644 index 0000000..120b665 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/list.vim @@ -0,0 +1,1020 @@ +scriptencoding utf-8 +" Create a List object from a quickfix/location list. +" TODO: (optionally?) add entries sorted? (errors first, grouped by makers (?) etc) + +let s:can_set_qf_title = has('patch-7.4.2200') +let s:can_set_qf_context = has('patch-8.0.0590') +let s:can_set_qf_items = has('patch-8.0.0657') +let s:has_support_for_qfid = has('patch-8.0.1023') +let s:use_efm_parsing = has('patch-8.0.1040') " 'efm' in setqflist/getqflist + +" Do we need to replace (instead of append) the location/quickfix list, for +" :lwindow to not open it with only invalid entries?! +" Without patch-7.4.379 this does not work though, and a new list needs to +" be created (which is not done). +" @vimlint(EVL108, 1) +let s:needs_to_replace_qf_for_lwindow = has('patch-7.4.379') + \ && (!has('patch-7.4.1752') || (has('nvim') && !has('nvim-0.2.0'))) +" @vimlint(EVL108, 0) +let s:needs_to_init_qf_for_lwindow = !has('patch-8.1.0622') + +function! neomake#list#ListForMake(make_info) abort + let type = a:make_info.options.file_mode ? 'loclist' : 'quickfix' + let list = neomake#list#List(type) + let list.make_info = a:make_info + if type ==# 'loclist' + let info = get(w:, '_neomake_info', {}) + let info['loclist'] = list + let w:_neomake_info = info + else + let info = get(g:, '_neomake_info', {}) + let info['qflist'] = list + let g:_neomake_info = info + endif + return list +endfunction + +" a:type: "loclist" or "quickfix" +function! neomake#list#List(type) abort + let list = deepcopy(s:base_list) + let list.type = a:type + " Display debug messages about changed entries. + let list.debug = get(g:, 'neomake_debug_list', + \ exists('g:neomake_test_messages') + \ || !empty(get(g:, 'neomake_logfile')) + \ || neomake#utils#get_verbosity() >= 3) + return list +endfunction + +" Internal base list implementation. +let s:base_list = { + \ 'need_init': 1, + \ 'entries': [], + \ } +" Info about contained jobs. +let s:base_list.job_entries = {} +let s:base_list.maker_info_by_jobid = {} + +function! s:base_list.sort_by_location() dict abort + let entries = get(self, '_sorted_entries_by_location', copy(self.entries)) + let self._sorted_entries_by_location = sort(entries, 's:cmp_listitem_loc') + return self._sorted_entries_by_location +endfunction + +" a:1: optional jobinfo +function! s:base_list.add_entries(entries, ...) dict abort + let idx = len(self.entries) + if a:0 && !has_key(self.job_entries, a:1.id) + let self.job_entries[a:1.id] = [] + let self.maker_info_by_jobid[a:1.id] = a:1.maker + endif + for entry in a:entries + let idx += 1 + let e = extend(copy(entry), {'nmqfidx': idx}) + if a:0 + call add(self.job_entries[a:1.id], e) + let e.job_id = a:1.id + endif + call add(self.entries, e) + endfor + if self.debug + let indexes = map(copy(self.entries), 'v:val.nmqfidx') + if len(neomake#compat#uniq(sort(copy(indexes)))) != len(indexes) + call neomake#log#error(printf('Duplicate qf indexes in list entries: %s.', + \ string(indexes))) + endif + endif + " Sort if it was sorted before. + if has_key(self, '_sorted_entries_by_location') + call extend(self._sorted_entries_by_location, a:entries) + call self.sort_by_location() + endif +endfunction + +" Add entries for a job (non-efm method). +function! s:base_list.add_entries_for_job(entries, jobinfo) dict abort + let tempfiles = get(self.make_info, 'tempfiles', []) + if !empty(tempfiles) + let mapped = 0 + for e in a:entries + if has_key(e, 'filename') && get(e, 'bufnr', 0) == 0 + if index(tempfiles, e.filename) != -1 + unlet e.filename + let e.bufnr = a:jobinfo.bufnr + let mapped += 1 + endif + endif + endfor + if mapped + call neomake#log#debug(printf('Mapped %d bufnrs from temporary files.', mapped), a:jobinfo) + endif + endif + return self._appendlist(a:entries, a:jobinfo) +endfunction + +function! neomake#list#get_title(prefix, bufnr, maker_info) abort + let prefix = 'Neomake' + if !empty(a:prefix) + let prefix .= '['.a:prefix.']' + endif + if a:bufnr + let bufname = bufname(a:bufnr) + if empty(bufname) + let bufname = 'buf:'.a:bufnr + else + let bufname = pathshorten(bufname) + endif + let maker_info = bufname + if empty(a:maker_info) + let maker_info = bufname + else + let maker_info = bufname.' ('.a:maker_info.')' + endif + else + let maker_info = a:maker_info + endif + let title = prefix + if !empty(maker_info) + let title = prefix.': '.maker_info + endif + return title +endfunction + +function! s:base_list._get_title() abort + let maker_info = [] + for job in self.make_info.finished_jobs + let info = job.maker.name + let ok = 1 + if get(job, 'aborted', 0) + let info .= '!' + let ok = 0 + endif + if has_key(self.job_entries, job.id) + let c = len(self.job_entries[job.id]) + let info .= '('.c.')' + let ok = 0 + endif + if ok + let info .= '✓' + endif + call add(maker_info, info) + endfor + for job in self.make_info.active_jobs + let info = job.maker.name + let info .= '...' + if has_key(self.job_entries, job.id) + let c = len(self.job_entries[job.id]) + let info .= '('.c.')' + endif + call add(maker_info, info) + endfor + for job in self.make_info.jobs_queue + let info = job.maker.name + let info .= '?' + call add(maker_info, info) + endfor + for job in get(self.make_info, 'aborted_jobs', []) + let info = job.maker.name + let info .= '-' + call add(maker_info, info) + endfor + let maker_info_str = join(maker_info, ', ') + if self.type ==# 'loclist' + let bufnr = self.make_info.options.bufnr + else + let bufnr = 0 + endif + if get(self.make_info.options, 'automake') + let prefix = 'auto' + elseif self.make_info.options.file_mode + let prefix = 'file' + else + let prefix = 'project' + endif + return neomake#list#get_title(prefix, bufnr, maker_info_str) +endfunction + +function! s:base_list.finish_for_make() abort + if self.need_init + if self.type ==# 'loclist' + call neomake#log#debug('Cleaning location list.', self.make_info) + else + call neomake#log#debug('Cleaning quickfix list.', self.make_info) + endif + call self._call_qf_fn('set', [], ' ') + else + " Set title, but only if list window is still valid. + if s:has_support_for_qfid + let valid = self._has_valid_qf() + elseif self.type ==# 'loclist' + let valid = self._get_loclist_win(1) != -1 + else + let valid = 1 + endif + if !valid + call neomake#log#debug('list: finish: list is not valid anymore.', self.make_info) + return + endif + call self.set_title() + endif +endfunction + +function! s:base_list._call_qf_fn(action, ...) abort + let fns_args = call(self._get_fn_args, [a:action] + a:000, self) + + if a:action ==# 'get' + let [fn, args] = fns_args[0] + if s:has_support_for_qfid + let args[-1].items = 1 + if self.debug + call neomake#log#debug(printf('list: call: "get", returning items: %s.', string(fns_args))) + endif + return call(fn, args).items + endif + if self.debug + call neomake#log#debug(printf('list: call: "get": %s.', string(fns_args))) + endif + return call(fn, args) + endif + + for fns in fns_args + let [fn, args] = fns + + if self.debug + if a:action ==# 'set' + let log_args = deepcopy(args) + " Only display 5 items. + if self.type ==# 'loclist' + let log_args[1] = neomake#utils#shorten_list_for_log(log_args[1], 5) + else + let log_args[0] = neomake#utils#shorten_list_for_log(log_args[0], 5) + endif + " Massage options dict. + if type(log_args[-1]) == type({}) + let neomake_context = get(get(log_args[-1], 'context', {}), 'neomake', {}) + if !empty(neomake_context) + for [k, v] in items(neomake_context) + if k ==# 'make_info' + " Fixes self-ref, and makes it much shorter. + let neomake_context[k] = 'make_id='.v.make_id + endif + endfor + endif + " Only display 5 items. + if has_key(log_args[-1], 'items') + let log_args[-1].items = neomake#utils#shorten_list_for_log(log_args[-1].items, 5) + endif + endif + call neomake#log#debug(printf('list: call: set: %s.', string(log_args))) + else + call neomake#log#debug(printf('list: call: "%s": %s.', a:action, string(args))) + endif + endif + + call call(fn, args, self) + endfor + + " Get qfid. + if self.need_init + if a:action ==# 'set' && s:has_support_for_qfid + if self.type ==# 'loclist' + let loclist_win = self._get_loclist_win() + let self.qfid = getloclist(loclist_win, {'id': 0}).id + else + let self.qfid = getqflist({'id': 0}).id + endif + if self.debug + call neomake#log#debug(printf('list: got qfid (action=%s): %s.', a:action, self.qfid)) + endif + endif + let self.need_init = 0 + endif +endfunction + +function! s:base_list.set_title() abort + if s:can_set_qf_title + call self._call_qf_fn('title', self._get_title()) + endif +endfunction + +" Check if quickfix list is still valid, which might not be the case anymore +" if more than 10 new lists have been opened etc. +" Returns -1 without suffort for quickfix ids. +function! s:base_list._has_valid_qf() abort + if !s:has_support_for_qfid + return -1 + endif + + if self.type ==# 'loclist' + let loclist_win = self._get_loclist_win(1) + if loclist_win is -1 + return 0 + endif + if !get(getloclist(loclist_win, {'id': self.qfid}), 'id') + return 0 + endif + else + if !get(getqflist({'id': self.qfid}), 'id') + return 0 + endif + endif + return 1 +endfunction + +" Get winnr/winid to be used with loclist functions. +" a:1: return -1 instead of throwing when no window could be found? +function! s:base_list._get_loclist_win(...) abort + if !has_key(self, 'make_info') + throw 'cannot handle type=loclist without make_info' + endif + let loclist_win = 0 + let make_id = self.make_info.make_id + " NOTE: prefers using 0 for when winid is not supported with + " setloclist() yet (vim74-xenial). + if index(get(w:, 'neomake_make_ids', []), make_id) == -1 + if has_key(self.make_info.options, 'winid') + let loclist_win = self.make_info.options.winid + else + let [t, w] = neomake#core#get_tabwin_for_makeid(make_id) + if [t, w] == [-1, -1] + if a:0 && a:1 + return -1 + endif + throw printf('Neomake: could not find location list for make_id %d.', make_id) + endif + if t != tabpagenr() + if a:0 && a:1 + return -1 + endif + throw printf('Neomake: trying to use location list from another tab (current=%d != target=%d).', tabpagenr(), t) + endif + let loclist_win = w + endif + endif + return loclist_win +endfunction + +" Return a list of commands to be called. +" action: "get", "set", "init", "title" +" a:000: optional args (for set/init/title) +function! s:base_list._get_fn_args(action, ...) abort + if self.type ==# 'loclist' + if a:action ==# 'get' + let fn = 'getloclist' + else + let fn = 'setloclist' + endif + else + if a:action ==# 'get' + let fn = 'getqflist' + else + let fn = 'setqflist' + endif + endif + + if self.type ==# 'loclist' + let args = [self._get_loclist_win()] + else + let args = [] + endif + + let options = {} + if !self.need_init + let valid = self._has_valid_qf() + if valid == 1 + let options.id = self.qfid + elseif valid == 0 + if self.type ==# 'loclist' + let loclist_win = args[0] + throw printf('Neomake: qfid %d for location list (%d) has become invalid.', self.qfid, loclist_win) + else + throw printf('Neomake: qfid %d for quickfix list has become invalid.', self.qfid) + endif + endif + endif + + if a:action ==# 'title' + call extend(args, [[], 'a']) + if exists('*vader#assert#true') + call vader#assert#true(s:can_set_qf_title) + endif + let options.title = a:1 + else + call extend(args, a:000) + if a:action ==# 'set' + if exists('*vader#assert#equal') + call vader#assert#equal(len(a:000), 2) + endif + if s:can_set_qf_items + let options.items = a:1 + let args[-2] = [] + endif + endif + endif + if !empty(options) + call add(args, options) + endif + + let r = [] + if a:action ==# 'set' + if self.need_init && get(self, 'reset_existing_qflist') + if self.type ==# 'loclist' + let args[2] = 'r' " action + else + let args[1] = 'r' " action + endif + if self.type ==# 'loclist' + let msg = 'Reusing location list for entries.' + else + let msg = 'Reusing quickfix list for entries.' + endif + call neomake#log#debug(msg, self.make_info) + endif + + " Experimental: set make_info into context. + " This is used to access make info from the qf window itself. + if self.need_init && s:can_set_qf_context + let options.context = {'neomake': {'make_info': self.make_info}} + endif + + " Handle setting title, which gets done initially and when maker + " names are updated. This has to be done in a separate call + " without patch-8.0.0657. + if s:can_set_qf_title + let title = self._get_title() + if s:can_set_qf_items + if type(args[-1]) != type({}) + call add(args, {'title': title, 'items': args[1]}) + else + let args[-1].title = title + endif + else + " Update title after actual call. + call add(r, [fn, args]) + + if self.type ==# 'loclist' + let args = [args[0], [], 'a', {'title': title}] + else + let args = [[], 'a', {'title': title}] + endif + endif + endif + endif + call add(r, [fn, args]) + return r +endfunction + +function! s:mark_entry_with_nmcfg(entry, maker_info) abort + let maker_name = a:maker_info.name + let config = { + \ 'name': maker_name, + \ 'short': get(a:maker_info, 'short_name', maker_name[:3]), + \ } + let marker_entry = copy(a:entry) + let marker_entry.text .= printf(' nmcfg:%s', string(config)) + return marker_entry +endfunction + +function! s:base_list._replace_qflist_entries(entries) abort + let set_entries = a:entries + + " Handle nmcfg markers when setting all entries without jobinfo. + if neomake#quickfix#is_enabled() + let set_entries = copy(set_entries) + let prev_job_id = 0 + + " Handle re-setting all entries. This is meant to be used later + " for replacing the whole list. + let i = 0 + for e in set_entries + if e.job_id != prev_job_id + let maker_info = self.maker_info_by_jobid[e.job_id] + let set_entries[i] = s:mark_entry_with_nmcfg(e, maker_info) + let prev_job_id = e.job_id + endif + let i += 1 + endfor + endif + + call self._set_qflist_entries(set_entries, 'r') +endfunction + +function! s:base_list._set_qflist_entries(entries, action) abort + let action = a:action + if self.need_init && !get(self, 'reset_existing_qflist') + if self.type ==# 'loclist' + let msg = 'Creating location list for entries.' + else + let msg = 'Creating quickfix list for entries.' + endif + call neomake#log#debug(msg, self.make_info) + + if s:needs_to_init_qf_for_lwindow + " Clean list without autocommands (customqf etc) to avoid + " flicker. This is only to work around a Vim bug anyway. + noautocmd call self._call_qf_fn('set', [], ' ') + else + let action = ' ' + endif + endif + call self._call_qf_fn('set', a:entries, action) +endfunction + +function! s:base_list._get_qflist_entries() abort + return self._call_qf_fn('get') +endfunction + +" Append entries to location/quickfix list. +function! s:base_list._appendlist(entries, jobinfo) abort + call neomake#log#debug(printf('Adding %d list entries.', len(a:entries)), self.make_info) + + let set_entries = a:entries + let action = 'a' + if !self.need_init + let action = 'a' + if s:needs_to_replace_qf_for_lwindow || neomake#quickfix#is_enabled() + " Need to replace whole list with customqf to trigger FileType + " autocmd (which is not done for action='a'). + " This should be enhanced to only format new entries instead + " later, but needs support for changing non-current buffer lines. + let action = 'r' + if self.type ==# 'loclist' + let set_entries = self._get_qflist_entries() + set_entries + else + let set_entries = getqflist() + set_entries + endif + endif + endif + + " Add marker for custom quickfix to the first (new) entry. + let needs_custom_qf_marker = neomake#quickfix#is_enabled() + if needs_custom_qf_marker + if action ==# 'a' + let prev_idx = 0 + else + let prev_idx = len(self.entries) + endif + let set_entries = copy(set_entries) + let set_entries[prev_idx] = s:mark_entry_with_nmcfg(set_entries[prev_idx], a:jobinfo.maker) + endif + + " NOTE: need to fetch (or pre-parse with new patch) to get updated bufnr etc. + call self._set_qflist_entries(set_entries, action) + let added = self._get_qflist_entries()[len(self.entries) :] + + if needs_custom_qf_marker + " Remove marker that should only be in the quickfix list. + let added[0].text = substitute(added[0].text, ' nmcfg:{.\{-}}$', '', '') + endif + + if self.debug && added != a:entries + let diff = neomake#list#_diff_new_entries(a:entries, added) + if !empty(diff) + for [k, v] in items(diff) + " TODO: handle valid=1 being added? + call neomake#log#debug(printf( + \ 'Entry %d differs after adding: %s.', + \ k+1, + \ string(v)), + \ a:jobinfo) + endfor + endif + endif + + let parsed_entries = copy(a:entries) + let idx = 0 + for e in added + if parsed_entries[idx].bufnr != e.bufnr + call neomake#log#debug(printf( + \ 'Updating entry bufnr: %s => %s.', + \ a:entries[idx].bufnr, e.bufnr)) + let parsed_entries[idx].bufnr = e.bufnr + endif + let idx += 1 + endfor + + call self.add_entries(parsed_entries, a:jobinfo) + return parsed_entries +endfunction + +function! neomake#list#_diff_new_entries(orig, new) abort + if a:orig == a:new + return {} + endif + let i = 0 + let r = {} + for new in a:new + let orig = copy(get(a:orig, i, {})) + for [k, v] in items({'pattern': '', 'module': '', 'valid': 1}) + if has_key(new, k) + let orig[k] = v + endif + endfor + if new != orig + " 'removed': {'length': 4, 'filename': 'from.rs', + " 'maker_name': 'cargo'}} + let new = copy(new) + for k in ['length', 'maker_name'] + if has_key(orig, k) + let new[k] = orig[k] + endif + endfor + let diff = neomake#utils#diff_dict(orig, new) + if !empty(diff) + let r[i] = diff + endif + endif + let i += 1 + endfor + return r +endfunction + +" Add raw lines using errorformat. +" This either pre-parses them with newer versions, or uses +" :laddexpr/:caddexpr. +function! s:base_list.add_lines_with_efm(lines, jobinfo) dict abort + let maker = a:jobinfo.maker + let file_mode = self.type ==# 'loclist' + + if s:use_efm_parsing + let efm = a:jobinfo.maker.errorformat + let parsed_entries = get(getqflist({'lines': a:lines, 'efm': efm}), 'items', -1) + if parsed_entries is -1 + call neomake#log#error(printf('Failed to get items via efm-parsing. Invalid errorformat? (%s)', efm), a:jobinfo) + let parsed_entries = getqflist({'lines': a:lines, 'efm': &errorformat}).items + endif + if empty(parsed_entries) + return [] + endif + else + if self.need_init + if self.type ==# 'loclist' + let msg = 'Creating location list.' + else + let msg = 'Creating quickfix list.' + endif + call neomake#log#debug(msg, self.make_info) + call self._call_qf_fn('set', [], ' ') + endif + let olderrformat = &errorformat + try + let &errorformat = maker.errorformat + catch + call neomake#log#error(printf('Failed to set errorformat (%s): %s.', string(maker.errorformat), v:exception), a:jobinfo) + endtry + try + if file_mode + let cmd = 'laddexpr' + else + let cmd = 'caddexpr' + endif + let a:jobinfo._delayed_qf_autocmd = 'QuickfixCmdPost '.cmd + let cmd = 'noautocmd '.cmd.' a:lines' + if self.debug + call neomake#log#debug(printf('list: exe: %s (with %d lines).', cmd, len(a:lines)), a:jobinfo) + endif + exe cmd + finally + let &errorformat = olderrformat + call a:jobinfo.cd_back() + endtry + + let new_list = self._get_qflist_entries() + let parsed_entries = new_list[len(self.entries) :] + if empty(parsed_entries) + return [] + endif + endif + + let l:Postprocess = neomake#utils#GetSetting('postprocess', maker, [], a:jobinfo.ft, a:jobinfo.bufnr) + if type(Postprocess) != type([]) + let postprocessors = [Postprocess] + else + let postprocessors = Postprocess + endif + + let default_type = 'unset' + + let entries = [] + let changed_entries = {} + let removed_entries = [] + let different_bufnrs = {} + let bufnr_from_temp = {} + let bufnr_from_stdin = {} + let tempfile_bufnrs = has_key(self.make_info, 'tempfiles') ? map(copy(self.make_info.tempfiles), 'bufnr(v:val)') : [] + let uses_stdin = get(a:jobinfo, 'uses_stdin', 0) + + let entry_idx = -1 + for entry in parsed_entries + let entry_idx += 1 + let before = copy(entry) + " Handle unlisted buffers via tempfiles and uses_stdin. + if entry.bufnr && entry.bufnr != a:jobinfo.bufnr + \ && (!empty(tempfile_bufnrs) || uses_stdin) + let map_bufnr = index(tempfile_bufnrs, entry.bufnr) + if map_bufnr != -1 + let entry.bufnr = a:jobinfo.bufnr + let map_bufnr = tempfile_bufnrs[map_bufnr] + if !has_key(bufnr_from_temp, map_bufnr) + let bufnr_from_temp[map_bufnr] = [] + endif + let bufnr_from_temp[map_bufnr] += [entry_idx+1] + elseif uses_stdin + if !buflisted(entry.bufnr) && bufexists(entry.bufnr) + if !has_key(bufnr_from_stdin, entry.bufnr) + let bufnr_from_stdin[entry.bufnr] = [] + endif + let bufnr_from_stdin[entry.bufnr] += [entry_idx+1] + let entry.bufnr = a:jobinfo.bufnr + endif + endif + endif + if self.debug && entry.bufnr && entry.bufnr != a:jobinfo.bufnr + if !has_key(different_bufnrs, entry.bufnr) + let different_bufnrs[entry.bufnr] = 1 + else + let different_bufnrs[entry.bufnr] += 1 + endif + endif + if !empty(postprocessors) + let g:neomake_postprocess_context = {'jobinfo': a:jobinfo} + try + for l:F in postprocessors + if type(F) == type({}) + call call(F.fn, [entry], F) + else + call call(F, [entry], maker) + endif + unlet! F " vim73 + endfor + finally + unlet! g:neomake_postprocess_context " Might be unset already with sleep in postprocess. + endtry + endif + if entry != before + let changed_entries[entry_idx] = entry + if self.debug + " Ignore bufnr changes for tempfiles/stdin (logged together + " later). + let diff = neomake#utils#diff_dict(before, entry) + let changed_bufnr = get(get(diff, 'changed', {}), 'bufnr', []) + if !empty(changed_bufnr) && ( + \ has_key(bufnr_from_temp, changed_bufnr[0]) + \ || has_key(bufnr_from_stdin, changed_bufnr[0])) + unlet diff.changed.bufnr + if empty(diff.changed) + unlet diff.changed + endif + endif + if !empty(diff) + call neomake#log#debug(printf( + \ 'Modified list entry %d (postprocess): %s.', + \ entry_idx + 1, + \ substitute(string(diff), '\n', '\\n', 'g')), + \ a:jobinfo) + endif + endif + endif + + if entry.valid <= 0 + if entry.valid < 0 || maker.remove_invalid_entries + call insert(removed_entries, entry_idx) + let entry_copy = copy(entry) + call neomake#log#debug(printf( + \ 'Removing invalid entry: %s (%s).', + \ remove(entry_copy, 'text'), + \ string(entry_copy)), a:jobinfo) + continue + endif + endif + + if empty(entry.type) && entry.valid + if default_type ==# 'unset' + let default_type = neomake#utils#GetSetting('default_entry_type', maker, 'W', a:jobinfo.ft, a:jobinfo.bufnr) + endif + if !empty(default_type) + let entry.type = default_type + let changed_entries[entry_idx] = entry + endif + endif + call add(entries, entry) + endfor + + if !s:use_efm_parsing + let new_index = len(self.entries) + " Add marker for custom quickfix to the first (new) entry. + if neomake#quickfix#is_enabled() + let changed_entries[0] = s:mark_entry_with_nmcfg(entries[0], maker) + endif + + if !empty(changed_entries) || !empty(removed_entries) + " Need to update/replace current list. + let list = self._get_qflist_entries() + if !empty(changed_entries) + for k in keys(changed_entries) + let list[new_index + k] = changed_entries[k] + endfor + endif + if !empty(removed_entries) + for k in removed_entries + call remove(list, new_index + k) + endfor + endif + call self._set_qflist_entries(list, 'r') + endif + endif + + if !empty(bufnr_from_temp) || !empty(bufnr_from_stdin) + if !has_key(self.make_info, '_wipe_unlisted_buffers') + let self.make_info._wipe_unlisted_buffers = [] + endif + let self.make_info._wipe_unlisted_buffers += keys(bufnr_from_stdin) + keys(bufnr_from_stdin) + if !empty(bufnr_from_temp) + for [tempbuf, entries_idx] in items(bufnr_from_temp) + let log_entries_idx = join(neomake#utils#shorten_list_for_log(entries_idx, 50), ', ') + call neomake#log#debug(printf( + \ 'Used bufnr from temporary buffer %d (%s) for %d entries: %s.', + \ tempbuf, + \ bufname(+tempbuf), + \ len(entries_idx), + \ log_entries_idx), a:jobinfo) + endfor + endif + if !empty(bufnr_from_stdin) + for [tempbuf, entries_idx] in items(bufnr_from_stdin) + let log_entries_idx = join(neomake#utils#shorten_list_for_log(entries_idx, 50), ', ') + call neomake#log#debug(printf( + \ 'Used bufnr from stdin buffer %d (%s) for %d entries: %s.', + \ tempbuf, + \ bufname(+tempbuf), + \ len(entries_idx), + \ log_entries_idx), a:jobinfo) + endfor + endif + endif + if !empty(different_bufnrs) + call neomake#log#debug(printf('WARN: seen entries with bufnr different from jobinfo.bufnr (%d): %s, current bufnr: %d.', a:jobinfo.bufnr, string(different_bufnrs), bufnr('%'))) + endif + + if empty(entries) + return [] + endif + + if s:use_efm_parsing + call self._appendlist(entries, a:jobinfo) + else + call self.add_entries(entries, a:jobinfo) + endif + return entries +endfunction + +" Get the current location or quickfix list. +function! neomake#list#get() abort + let winnr = winnr() + let win_info = neomake#compat#getwinvar(winnr, '_neomake_info', {}) + if has_key(win_info, 'loclist') + return win_info['loclist'] + endif + let info = get(g:, '_neomake_info', {}) + if has_key(info, 'qflist') + return info['qflist'] + endif + return {} +endfunction + +function! neomake#list#get_loclist(...) abort + let winnr = a:0 ? a:1 : winnr() + let info = neomake#compat#getwinvar(winnr, '_neomake_info', {}) + if !has_key(info, 'loclist') + " Create a new list, not bound to a job. + call neomake#log#debug('Creating new List object.') + let list = neomake#list#List('loclist') + call list.add_entries(getloclist(winnr)) + let info['loclist'] = list + call setwinvar(winnr, '_neomake_info', info) + endif + return info['loclist'] +endfunction + +" TODO: save project-maker quickfix list. +function! neomake#list#get_qflist() abort + let info = get(g:, '_neomake_info', {}) + if !has_key(info, 'qflist') + " Create a new list, not bound to a job. + call neomake#log#debug('Creating new List object.') + let list = neomake#list#List('quickfix') + call list.add_entries(getqflist()) + let info['qflist'] = list + let g:_neomake_info = info + endif + return info['qflist'] +endfunction + +function! s:get_list(file_mode) abort + if a:file_mode + let list = neomake#list#get_loclist() + let g:unimpaired_prevnext = ['NeomakePrevLoclist', 'NeomakeNextLoclist'] + else + let list = neomake#list#get_qflist() + let g:unimpaired_prevnext = ['NeomakePrevQuickfix', 'NeomakeNextQuickfix'] + endif + return list +endfunction + +function! neomake#list#next(c, ...) abort + let file_mode = a:0 ? a:1 : 1 + let list = s:get_list(file_mode) + call s:goto_nearest(list, a:c == 0 ? 1 : a:c) +endfunction + +function! neomake#list#prev(c, ...) abort + let file_mode = a:0 ? a:1 : 1 + let list = s:get_list(file_mode) + call s:goto_nearest(list, a:c == 0 ? -1 : -a:c) +endfunction + +" TODO: global / already used somewhere else? / config +let g:neomake#list#type_prio = { + \ 'E': 0, + \ 'W': 1, + \ 'I': 2, + \ } + +" TODO: allow to customize via own callback(s)? +function! s:cmp_listitem_loc(a, b) abort + let buf_diff = a:a.bufnr - a:b.bufnr + if buf_diff + return buf_diff + endif + + if exists('*vader#assert#not_equal') + call vader#assert#not_equal(a:a.bufnr, -1) + call vader#assert#not_equal(a:b.bufnr, -1) + endif + + let lnum_diff = a:a.lnum - a:b.lnum + if lnum_diff + return lnum_diff + endif + + let col_diff = a:a.col - a:b.col + if col_diff + return col_diff + endif + + let prio = g:neomake#list#type_prio + return get(prio, a:a.type, 99) - get(prio, a:b.type, 99) +endfunction + +function! s:goto_nearest(list, offset) abort + let [lnum, col] = getpos('.')[1:2] + if a:offset == 0 + throw 'a:offset must not be 0' + endif + + if !has_key(a:list, '_sorted_entries_by_location') + call a:list.sort_by_location() + endif + let entries = a:list._sorted_entries_by_location + if a:offset < 0 + call reverse(entries) + endif + + let c = a:offset + let step = a:offset > 0 ? 1 : -1 + let found = 0 + for item in entries + if (a:offset > 0 && (item.lnum > lnum || (item.lnum == lnum && item.col > col))) + \ || (a:offset < 0 && (item.lnum < lnum || (item.lnum == lnum && item.col < col))) + let c -= step + let found = item.nmqfidx + if c == 0 + break + endif + endif + endfor + + if found + if a:list.type ==# 'loclist' + if exists('*vader#assert#equal') + " @vimlint(EVL102, 1, l:ll_item) + let ll_item = getloclist(0)[found-1] + call vader#assert#equal([ll_item.bufnr, ll_item.lnum], [item.bufnr, item.lnum]) + endif + execute 'll '.found + else + if exists('*vader#assert#equal') + " @vimlint(EVL102, 1, l:cc_item) + let cc_item = getqflist()[found-1] + call vader#assert#equal([cc_item.bufnr, cc_item.lnum], [item.bufnr, item.lnum]) + endif + execute 'cc '.found + endif + elseif c > 0 + call neomake#log#error('No more next items.') + elseif c < 0 + call neomake#log#error('No more previous items.') + endif +endfunction + +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/log.vim b/dotfiles/.vim/autoload/neomake/log.vim new file mode 100644 index 0000000..4e8e6bf --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/log.vim @@ -0,0 +1,171 @@ +let s:level_to_name = {0: 'error ', 1: 'warning', 2: 'verbose', 3: 'debug '} +let s:name_to_level = {'error': 0, 'warning': 1, 'verbose': 2, 'debug': 3} +let s:short_level_to_name = {0: 'E', 1: 'W', 2: 'V', 3: 'D'} +let s:is_testing = exists('g:neomake_test_messages') +let s:pid = getpid() + +let s:last_msg_ts = neomake#compat#reltimefloat() + +function! s:reltime_lastmsg() abort + let cur = neomake#compat#reltimefloat() + let diff = (cur - s:last_msg_ts) + let s:last_msg_ts = neomake#compat#reltimefloat() + + if diff < 0.01 + return ' ' + elseif diff < 10 + let format = '+%.2f' + elseif diff < 100 + let format = '+%.1f' + elseif diff < 100 + let format = ' +%.0f' + elseif diff < 1000 + let format = ' +%.0f' + else + let format = '+%.0f' + endif + return printf(format, diff) +endfunction + +function! s:log(level, msg, ...) abort + let context = a:0 ? a:1 : {} + let verbosity = neomake#utils#get_verbosity(context) + let logfile = get(g:, 'neomake_logfile', '') + + if !s:is_testing && verbosity < a:level && empty(logfile) + return + endif + + if a:0 + if has_key(a:1, 'options') + let context = copy(a:1.options) + let context.make_id = a:1.make_id + else + let context = copy(a:1) + endif + let msg = printf('[%s.%s:%s:%d] %s', + \ get(context, 'make_id', '-'), + \ get(context, 'id', '-'), + \ get(context, 'bufnr', get(context, 'file_mode', 0) ? '?' : '-'), + \ get(context, 'winnr', winnr()), + \ a:msg) + else + let msg = a:msg + endif + + " Use Vader's log for messages during tests. + " @vimlint(EVL104, 1, l:timediff) + if s:is_testing && (verbosity >= a:level || get(g:, 'neomake_test_log_all_messages', 0)) + let timediff = s:reltime_lastmsg() + if timediff !=# ' ' + let test_msg = '['.s:short_level_to_name[a:level].' '.timediff.']: '.msg + else + let test_msg = '['.s:level_to_name[a:level].']: '.msg + endif + + if exists('*vader#log') + " Might not exist with rpcrequest-based nvim test, or throw errors + " if called too early. + call vader#log(test_msg) + endif + " Only keep context entries that are relevant for / used in the message. + let context = a:0 + \ ? extend(filter(copy(context), "index(['id', 'make_id', 'bufnr', 'winnr'], v:key) != -1"), {'winnr': winnr()}, 'keep') + \ : {} + call add(g:neomake_test_messages, [a:level, a:msg, context]) + if index(['.', '!', ')', ']'], a:msg[-1:-1]) == -1 + let g:neomake_test_errors += ['Log msg does not end with punctuation: "'.a:msg.'".'] + endif + elseif verbosity >= a:level + redraw + if verbosity > 2 + echom 'Neomake: '.msg + else + if a:level ==# 0 + echohl ErrorMsg + else + echohl WarningMsg + endif + " Use message without context for non-debug msgs. + echom 'Neomake: '.a:msg + echohl None + endif + endif + if !empty(logfile) + if !exists('s:logfile_writefile_opts') + " Use 'append' with writefile, but only if it is available. Otherwise, just + " overwrite the file. 'S' is used to disable fsync in Neovim + " (https://github.com/neovim/neovim/pull/6427). + if has('patch-7.4.503') + let s:logfile_writefile_opts = 'aS' + else + let s:logfile_writefile_opts = '' + redraw + echohl WarningMsg + echom 'Neomake: appending to the logfile is not supported in your Vim version.' + echohl NONE + endif + endif + + let time = strftime('%H:%M:%S') + if !exists('timediff') + let timediff = s:reltime_lastmsg() + endif + try + call writefile([printf('%s %s [%s %s] %s', + \ time, s:pid, s:short_level_to_name[a:level], timediff, msg)], + \ logfile, s:logfile_writefile_opts) + catch + unlet g:neomake_logfile + call neomake#log#error(printf('Error when trying to write to logfile %s: %s. Unsetting g:neomake_logfile.', logfile, v:exception)) + endtry + endif + " @vimlint(EVL104, 0, l:timediff) +endfunction + +function! neomake#log#error(...) abort + call call('s:log', [0] + a:000) +endfunction + +function! neomake#log#warning(...) abort + call call('s:log', [1] + a:000) +endfunction + +function! neomake#log#info(...) abort + call call('s:log', [2] + a:000) +endfunction + +function! neomake#log#debug(...) abort + call call('s:log', [3] + a:000) +endfunction + +function! neomake#log#debug_obj(msg, obj) abort + if s:is_testing || neomake#utils#get_verbosity() >= 3 || !empty(get(g:, 'neomake_logfile', '')) + call neomake#log#debug(a:msg.': '.neomake#utils#Stringify(a:obj).'.') + endif +endfunction + +function! neomake#log#exception(error, ...) abort + let log_context = a:0 ? a:1 : {'bufnr': bufnr('%')} + redraw + echom printf('Neomake error in: %s', v:throwpoint) + call neomake#log#error(a:error, log_context) + call neomake#log#debug(printf('(in %s)', v:throwpoint), log_context) +endfunction + +let s:warned = {} +function! neomake#log#warn_once(msg, key) abort + if !has_key(s:warned, a:key) + let s:warned[a:key] = 1 + echohl WarningMsg + redraw | echom 'Neomake: ' . a:msg + echohl None + let v:warningmsg = 'Neomake: '.a:msg + call neomake#log#debug('Neomake warning: '.a:msg) + endif +endfunction + +function! neomake#log#reset_warnings() abort + let s:warned = {} +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/cabal.vim b/dotfiles/.vim/autoload/neomake/makers/cabal.vim new file mode 100644 index 0000000..070b2a5 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/cabal.vim @@ -0,0 +1,15 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#cabal#cabal() abort + let errorformat = join([ + \ '%A%f:%l:%c:', + \ '%A%f:%l:%c: %m', + \ '%+C %m', + \ '%-Z%[%^ ]', + \ ], ',') + return { + \ 'exe': 'cabal', + \ 'args': ['build'], + \ 'errorformat': errorformat + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/clippy.vim b/dotfiles/.vim/autoload/neomake/makers/clippy.vim new file mode 100644 index 0000000..6f2a8a3 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/clippy.vim @@ -0,0 +1,39 @@ +" vim: ts=4 sw=4 et + +" Yet to be determined +let s:rustup_has_nightly = get(g:, 'neomake_clippy_rustup_has_nightly', -1) + +function! neomake#makers#clippy#clippy() abort + " When rustup and a nightly toolchain is installed, that is used. + " Otherwise, the default cargo exectuable is used. If this is not part + " of a nightly rust, this will fail. + if s:rustup_has_nightly == -1 + if !executable('rustup') + let s:rustup_has_nightly = 0 + call system('rustc --version | grep -q "\-nightly"') + if v:shell_error + call neomake#log#warning('Clippy requires a nightly rust installation.') + endif + else + call system('rustup show | grep -q "^nightly-"') + let s:rustup_has_nightly = !v:shell_error + endif + endif + + let cargo_maker = neomake#makers#ft#rust#cargo() + let json_args = ['--message-format=json', '--quiet'] + + if s:rustup_has_nightly + return { + \ 'exe': 'rustup', + \ 'args': ['run', 'nightly', 'cargo', 'clippy'] + json_args, + \ 'process_output': cargo_maker.process_output, + \ } + else + return { + \ 'exe': 'cargo', + \ 'args': ['clippy'] + json_args, + \ 'process_output': cargo_maker.process_output, + \ } + endif +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/ada.vim b/dotfiles/.vim/autoload/neomake/makers/ft/ada.vim new file mode 100644 index 0000000..822da3c --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/ada.vim @@ -0,0 +1,14 @@ +function! neomake#makers#ft#ada#EnabledMakers() abort + return ['gcc'] +endfunction + +function! neomake#makers#ft#ada#gcc() abort + return { + \ 'args': ['-c', '-x', 'ada', '-gnatc'], + \ 'errorformat': + \ '%-G%f:%s:,' . + \ '%f:%l:%c: %m,' . + \ '%f:%l: %m' + \ } +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/angular.vim b/dotfiles/.vim/autoload/neomake/makers/ft/angular.vim new file mode 100644 index 0000000..8c2f2d9 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/angular.vim @@ -0,0 +1,9 @@ +function! neomake#makers#ft#angular#SupersetOf() abort + return 'javascript' +endfunction + +function! neomake#makers#ft#angular#EnabledMakers() abort + return ['jshint', 'eslint', 'jscs'] +endfunction + +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/ansible.vim b/dotfiles/.vim/autoload/neomake/makers/ft/ansible.vim new file mode 100644 index 0000000..a1a001f --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/ansible.vim @@ -0,0 +1,17 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#ansible#EnabledMakers() abort + return ['ansiblelint', 'yamllint'] +endfunction + +function! neomake#makers#ft#ansible#yamllint() abort + return neomake#makers#ft#yaml#yamllint() +endfunction + +function! neomake#makers#ft#ansible#ansiblelint() abort + return { + \ 'exe': 'ansible-lint', + \ 'args': ['-p', '--nocolor'], + \ 'errorformat': '%f:%l: [%tANSIBLE%n] %m', + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/apiblueprint.vim b/dotfiles/.vim/autoload/neomake/makers/ft/apiblueprint.vim new file mode 100644 index 0000000..2e91b42 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/apiblueprint.vim @@ -0,0 +1,16 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#apiblueprint#EnabledMakers() abort + return executable('drafter') ? ['drafter'] : [] +endfunction + +function! neomake#makers#ft#apiblueprint#drafter() abort + " Drafter only operates on a single file at a time, and therefore doesn't + " bother to print out a file name with each error. We need to attach this + " so that the quickfix list can function properly. + return { + \ 'args': ['-l', '-u'], + \ 'errorformat': '%f: %t%[%^:]\\+: (%n) %m; line %l\, column %c%.%#', + \ 'mapexpr': 'neomake_bufname . ": " . v:val' + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/applescript.vim b/dotfiles/.vim/autoload/neomake/makers/ft/applescript.vim new file mode 100644 index 0000000..71a00f1 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/applescript.vim @@ -0,0 +1,11 @@ +function! neomake#makers#ft#applescript#EnabledMakers() abort + return ['osacompile'] +endfunction + +function! neomake#makers#ft#applescript#osacompile() abort + return { + \ 'args': ['-o', g:neomake#compat#dev_null], + \ 'errorformat': '%f:%l: %trror: %m', + \ } +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/asciidoc.vim b/dotfiles/.vim/autoload/neomake/makers/ft/asciidoc.vim new file mode 100644 index 0000000..4d53751 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/asciidoc.vim @@ -0,0 +1,28 @@ +function! neomake#makers#ft#asciidoc#SupersetOf() abort + return 'text' +endfunction + +function! neomake#makers#ft#asciidoc#EnabledMakers() abort + let makers = executable('asciidoctor') ? ['asciidoctor'] : ['asciidoc'] + return makers + neomake#makers#ft#text#EnabledMakers() +endfunction + +function! neomake#makers#ft#asciidoc#asciidoc() abort + return { + \ 'errorformat': + \ '%E%\w%\+: %tRROR: %f: line %l: %m,' . + \ '%E%\w%\+: %tRROR: %f: %m,' . + \ '%E%\w%\+: FAILED: %f: line %l: %m,' . + \ '%E%\w%\+: FAILED: %f: %m,' . + \ '%W%\w%\+: %tARNING: %f: line %l: %m,' . + \ '%W%\w%\+: %tARNING: %f: %m,' . + \ '%W%\w%\+: DEPRECATED: %f: line %l: %m,' . + \ '%W%\w%\+: DEPRECATED: %f: %m', + \ 'args': ['-o', g:neomake#compat#dev_null], + \ } +endfunction + +function! neomake#makers#ft#asciidoc#asciidoctor() abort + return neomake#makers#ft#asciidoc#asciidoc() +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/beancount.vim b/dotfiles/.vim/autoload/neomake/makers/ft/beancount.vim new file mode 100644 index 0000000..95eb31a --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/beancount.vim @@ -0,0 +1,12 @@ +function! neomake#makers#ft#beancount#EnabledMakers() abort + return ['bean_check'] +endfunction + +function! neomake#makers#ft#beancount#bean_check() abort + return { + \ 'exe': 'bean-check', + \ 'errorformat': '%E%f:%l:%m', + \ 'postprocess': function('neomake#postprocess#compress_whitespace'), + \ } +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/bib.vim b/dotfiles/.vim/autoload/neomake/makers/ft/bib.vim new file mode 100644 index 0000000..e3a9602 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/bib.vim @@ -0,0 +1,16 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#bib#EnabledMakers() abort + return [] +endfunction + +function! neomake#makers#ft#bib#bibtex() abort + return { + \ 'exe': 'bibtex', + \ 'args': ['-terse', '%:r'], + \ 'append_file': 0, + \ 'uses_filename': 0, + \ 'errorformat': '%E%m---line %l of file %f', + \ 'cwd': '%:p:h' + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/c.vim b/dotfiles/.vim/autoload/neomake/makers/ft/c.vim new file mode 100644 index 0000000..1d0cda8 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/c.vim @@ -0,0 +1,110 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#c#EnabledMakers() abort + let makers = executable('clang') ? ['clang', 'clangtidy', 'clangcheck'] : ['gcc'] + call add(makers, 'checkpatch') + call add(makers, 'cppcheck') + return makers +endfunction + +let g:neomake#makers#ft#c#project_root_files = ['configure', 'CMakeLists.txt'] + +function! neomake#makers#ft#c#clang() abort + " as a single-file maker, include the current directory in the default + " search path + return { + \ 'args': ['-fsyntax-only', '-Wall', '-Wextra', '-I./'], + \ 'errorformat': + \ '%-G%f:%s:,' . + \ '%f:%l:%c: %trror: %m,' . + \ '%f:%l:%c: %tarning: %m,' . + \ '%I%f:%l:%c: note: %m,' . + \ '%f:%l:%c: %m,'. + \ '%f:%l: %trror: %m,'. + \ '%f:%l: %tarning: %m,'. + \ '%I%f:%l: note: %m,'. + \ '%f:%l: %m' + \ } +endfunction + +function! neomake#makers#ft#c#clangcheck() abort + return { + \ 'exe': 'clang-check', + \ 'errorformat': + \ '%-G%f:%s:,' . + \ '%f:%l:%c: %trror: %m,' . + \ '%f:%l:%c: %tarning: %m,' . + \ '%I%f:%l:%c: note: %m,' . + \ '%f:%l:%c: %m,'. + \ '%f:%l: %trror: %m,'. + \ '%f:%l: %tarning: %m,'. + \ '%I%f:%l: note: %m,'. + \ '%f:%l: %m', + \ } +endfunction + +function! neomake#makers#ft#c#gcc() abort + " as a single-file maker, include the current directory in the default + " search path + return { + \ 'args': ['-fsyntax-only', '-Wall', '-Wextra', '-I./'], + \ 'errorformat': + \ '%-G%f:%s:,' . + \ '%-G%f:%l: %#error: %#(Each undeclared identifier is reported only%.%#,' . + \ '%-G%f:%l: %#error: %#for each function it appears%.%#,' . + \ '%-GIn file included%.%#,' . + \ '%-G %#from %f:%l\,,' . + \ '%f:%l:%c: %trror: %m,' . + \ '%f:%l:%c: %tarning: %m,' . + \ '%I%f:%l:%c: note: %m,' . + \ '%f:%l:%c: %m,' . + \ '%f:%l: %trror: %m,' . + \ '%f:%l: %tarning: %m,'. + \ '%I%f:%l: note: %m,'. + \ '%f:%l: %m', + \ } +endfunction + +" The -p option followed by the path to the build directory should be set in +" the maker's arguments. That directory should contain the compile command +" database (compile_commands.json). +function! neomake#makers#ft#c#clangtidy() abort + return { + \ 'exe': 'clang-tidy', + \ 'errorformat': + \ '%E%f:%l:%c: fatal error: %m,' . + \ '%E%f:%l:%c: error: %m,' . + \ '%W%f:%l:%c: warning: %m,' . + \ '%-G%\m%\%%(LLVM ERROR:%\|No compilation database found%\)%\@!%.%#,' . + \ '%E%m', + \ 'short_name': 'ctdy', + \ } +endfunction + +function! neomake#makers#ft#c#checkpatch() abort + return { + \ 'exe': 'checkpatch.pl', + \ 'args': ['--no-summary', '--no-tree', '--terse', '--file'], + \ 'errorformat': + \ '%f:%l: %tARNING: %m,' . + \ '%f:%l: %tRROR: %m', + \ } +endfunction + +function! neomake#makers#ft#c#cppcheck() abort + " Uses --force to avoid: + " nofile:0:0:information:Too many #ifdef configurations - cppcheck only checks 12 configurations. + " NOTE: '--language=c' should be the first args, it gets replaced in + " neomake#makers#ft#cpp#cppcheck. + return { + \ 'args': ['--language=c', '--quiet', '--enable=warning', '--force', + \ '--template="{file}:{line}:{column}:{severity}:{message}"'], + \ 'errorformat': + \ 'nofile:0:0:%trror:%m,' . + \ '%f:%l:%c:%trror:%m,' . + \ 'nofile:0:0:%tarning:%m,'. + \ '%f:%l:%c:%tarning:%m,'. + \ 'nofile:0:0:%tnformation:%m,'. + \ '%f:%l:%c:%tnformation:%m', + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/cf3.vim b/dotfiles/.vim/autoload/neomake/makers/ft/cf3.vim new file mode 100644 index 0000000..7826fc6 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/cf3.vim @@ -0,0 +1,14 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#cf3#EnabledMakers() abort + return ['cfpromises'] +endfunction + +function! neomake#makers#ft#cf3#cfpromises() abort + return { + \ 'exe': 'cf-promises', + \ 'args': ['-cf'], + \ 'errorformat': + \ '%E%f:%l:%c: error: %m', + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/chef.vim b/dotfiles/.vim/autoload/neomake/makers/ft/chef.vim new file mode 100644 index 0000000..805a070 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/chef.vim @@ -0,0 +1,23 @@ +function! neomake#makers#ft#chef#SupersetOf() abort + return 'ruby' +endfunction + +function! neomake#makers#ft#chef#EnabledMakers() abort + let ruby_makers = neomake#makers#ft#ruby#EnabledMakers() + return ruby_makers + ['foodcritic', 'cookstyle'] +endfunction + +function! neomake#makers#ft#chef#foodcritic() abort + return { + \ 'errorformat': '%WFC%n: %m: %f:%l', + \ } +endfunction + +function! neomake#makers#ft#chef#cookstyle() abort + return { + \ 'args': ['-f', 'emacs'], + \ 'errorformat': '%f:%l:%c: %t: %m', + \ 'postprocess': function('neomake#makers#ft#ruby#RubocopEntryProcess'), + \ } +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/coffee.vim b/dotfiles/.vim/autoload/neomake/makers/ft/coffee.vim new file mode 100644 index 0000000..67c6cc3 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/coffee.vim @@ -0,0 +1,15 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#coffee#EnabledMakers() abort + return ['coffeelint'] +endfunction + +function! neomake#makers#ft#coffee#coffeelint() abort + return { + \ 'args': ['--reporter=csv'], + \ 'errorformat': '%f\,%l\,%\d%#\,%trror\,%m,' . + \ '%f\,%l\,%trror\,%m,' . + \ '%f\,%l\,%\d%#\,%tarn\,%m,' . + \ '%f\,%l\,%tarn\,%m' + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/cpp.vim b/dotfiles/.vim/autoload/neomake/makers/ft/cpp.vim new file mode 100644 index 0000000..0cfa877 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/cpp.vim @@ -0,0 +1,50 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#cpp#EnabledMakers() abort + let makers = executable('clang++') ? ['clang', 'clangtidy', 'clangcheck'] : ['gcc'] + call add(makers, 'cppcheck') + return makers +endfunction + +function! neomake#makers#ft#cpp#clang() abort + let maker = neomake#makers#ft#c#clang() + let maker.exe = 'clang++' + let maker.args += ['-std=c++1z'] + return maker +endfunction + +function! neomake#makers#ft#cpp#gcc() abort + let maker = neomake#makers#ft#c#gcc() + let maker.exe = 'g++' + let maker.args += ['-std=c++1z'] + return maker +endfunction + +function! neomake#makers#ft#cpp#clangtidy() abort + return neomake#makers#ft#c#clangtidy() +endfunction + +function! neomake#makers#ft#cpp#clangcheck() abort + return neomake#makers#ft#c#clangcheck() +endfunction + +function! neomake#makers#ft#cpp#cppcheck() abort + let maker = neomake#makers#ft#c#cppcheck() + let maker.args[0] = '--language=c++' + return maker +endfunction + +function! neomake#makers#ft#cpp#cpplint() abort + return { + \ 'exe': executable('cpplint') ? 'cpplint' : 'cpplint.py', + \ 'args': ['--verbose=3'], + \ 'errorformat': + \ '%A%f:%l: %m [%t],' . + \ '%-G%.%#', + \ 'postprocess': function('neomake#makers#ft#cpp#CpplintEntryProcess') + \ } +endfunction + +function! neomake#makers#ft#cpp#CpplintEntryProcess(entry) abort + let a:entry.type = str2nr(a:entry.type) < 5 ? 'W' : 'E' +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/crystal.vim b/dotfiles/.vim/autoload/neomake/makers/ft/crystal.vim new file mode 100644 index 0000000..b570c74 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/crystal.vim @@ -0,0 +1,25 @@ +function! neomake#makers#ft#crystal#EnabledMakers() abort + return ['crystal', 'ameba'] +endfunction + +function! neomake#makers#ft#crystal#crystal() abort + " from vim-crystal + return { + \ 'args': ['run', '--no-color', '--no-codegen'], + \ 'errorformat': + \ '%ESyntax error in line %l: %m,'. + \ '%ESyntax error in %f:%l: %m,'. + \ '%EError in %f:%l: %m,'. + \ '%C%p^,'. + \ '%-C%.%#' + \ } +endfunction + +function! neomake#makers#ft#crystal#ameba() abort + " from vim-crystal + return { + \ 'args': ['--format', 'flycheck'], + \ 'errorformat': '%f:%l:%c: %t: %m' + \ } +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/cs.vim b/dotfiles/.vim/autoload/neomake/makers/ft/cs.vim new file mode 100644 index 0000000..6457cff --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/cs.vim @@ -0,0 +1,22 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#cs#EnabledMakers() abort + return ['mcs'] +endfunction + +function! neomake#makers#ft#cs#mcs() abort + return { + \ 'args': ['--parse', '--unsafe'], + \ 'errorformat': '%f(%l\,%c): %trror %m', + \ } +endfunction + +function! neomake#makers#ft#cs#msbuild() abort + return { + \ 'exe': 'msbuild', + \ 'args': ['-nologo', '-v:q', '-property:GenerateFullPaths=true', neomake#utils#FindGlobFile('*.sln')], + \ 'errorformat': '%E%f(%l\,%c): error CS%n: %m [%.%#],'. + \ '%W%f(%l\,%c): warning CS%n: %m [%.%#]', + \ 'append_file' : 0, + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/css.vim b/dotfiles/.vim/autoload/neomake/makers/ft/css.vim new file mode 100644 index 0000000..3afbccd --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/css.vim @@ -0,0 +1,35 @@ +scriptencoding utf8 + +function! neomake#makers#ft#css#EnabledMakers() abort + return ['csslint', 'stylelint'] +endfunction + +function! neomake#makers#ft#css#csslint() abort + return { + \ 'args': ['--format=compact'], + \ 'errorformat': + \ '%-G,'. + \ '%-G%f: lint free!,'. + \ '%f: line %l\, col %c\, %trror - %m,'. + \ '%f: line %l\, col %c\, %tarning - %m,'. + \ '%f: line %l\, col %c\, %m,'. + \ '%f: %tarning - %m' + \ } +endfunction + +function! neomake#makers#ft#css#stylelint() abort + let maker = { + \ 'errorformat': + \ '%-P%f,'. + \ '%W%*\s%l:%c%*\s✖ %m,'. + \ '%-Q,'. + \ '%+EError: No configuration provided for %f,%-C %.%#' + \ } + + function! maker.postprocess(entry) abort + let a:entry.text = substitute(a:entry.text, '\v\s\s+(.{-})\s*$', ' [\1]', 'g') + endfunction + + return maker +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/cuda.vim b/dotfiles/.vim/autoload/neomake/makers/ft/cuda.vim new file mode 100644 index 0000000..0fbf6c9 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/cuda.vim @@ -0,0 +1,15 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#cuda#EnabledMakers() abort + return ['nvcc'] +endfunction + +function! neomake#makers#ft#cuda#nvcc() abort + return { + \ 'exe': 'nvcc', + \ 'errorformat': + \ '%f\(%l\): %trror: %m,'. + \ '%f\(%l\): %tarning: %m,'. + \ '%f\(%l\): %m', + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/d.vim b/dotfiles/.vim/autoload/neomake/makers/ft/d.vim new file mode 100644 index 0000000..5206a8d --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/d.vim @@ -0,0 +1,92 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#d#EnabledMakers() abort + " dmd, ldmd, and gdmd all share a common CLI. + " Ordered in efficiency of compiler + for m in ['dmd', 'ldmd', 'gdmd'] + if executable(m) + return [m] + endif + endfor + return [] +endfunction + +function! s:findDubRoot() abort + "Look upwards for a dub.json or dub.sdl to find the root + "I did it like this because it's the only cross platform way I know of + let tmp_file = findfile('dub.json', '.;') + if empty(tmp_file) + let tmp_file = findfile('dub.sdl', '.;') + endif + return tmp_file +endfunction + +function! s:UpdateDub() abort + "Add dub directories + let s:dubImports = [] + let tmp_file = s:findDubRoot() + if executable('dub') && !empty(tmp_file) + let tmp_dir = fnamemodify(tmp_file,':p:h') + let dubCmd = 'dub describe --data=import-paths --annotate ' + \ .'--skip-registry=all --vquiet --data-list --root=' + let output = system(dubCmd . tmp_dir) + if(v:shell_error == 0 && !empty(output)) + " Is \n portable? + let s:dubImports = split(output, '\n') + call map(s:dubImports, "'-I' . v:val") + endif + endif +endfunction + +"GDMD does not adhere to dmd's flags or output, but to GCC's. +"This is for LDMD and dmd only. +function! s:DmdStyleMaker(args) abort + "Updating dub paths each make might be slow? + call s:UpdateDub() + let args = ['-w', '-wi', '-c', '-o-', '-vcolumns'] + a:args + s:dubImports + return { + \ 'args': args, + \ 'errorformat': + \ '%f(%l\,%c): %trror: %m,' . + \ '%f(%l): %trror: %m,' . + \ '%f(%l\,%c): %tarning: %m,' . + \ '%f(%l): %tarning: %m,' . + \ '%f(%l\,%c): Deprecation: %m,' . + \ '%f(%l): Deprecation: %m,', + \ } +endfunction + +function! neomake#makers#ft#d#dmd() abort + let args = [] + if exists('g:neomake_d_dmd_args_conf') + call add(args, '-conf=' . expand(g:neomake_d_dmd_args_conf)) + endif + return s:DmdStyleMaker(args) +endfunction + +function! neomake#makers#ft#d#ldmd() abort + let args = [] + if exists('g:neomake_d_ldmd_args_conf') + call add(args, '-conf=' . expand(g:neomake_d_ldmd_args_conf)) + endif + return s:DmdStyleMaker(args) +endfunction + +function! neomake#makers#ft#d#gdmd() abort + let args = ['-c', '-o-', '-fsyntax-only', s:UpdateDub()] + return { + \ 'args': args, + \ 'errorformat': + \ '%-G%f:%s:,' . + \ '%-G%f:%l: %#error: %#(Each undeclared identifier is reported only%.%#,' . + \ '%-G%f:%l: %#error: %#for each function it appears%.%#,' . + \ '%-GIn file included%.%#,' . + \ '%-G %#from %f:%l\,,' . + \ '%f:%l:%c: %trror: %m,' . + \ '%f:%l:%c: %tarning: %m,' . + \ '%f:%l:%c: %m,' . + \ '%f:%l: %trror: %m,' . + \ '%f:%l: %tarning: %m,'. + \ '%f:%l: %m', + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/docbk.vim b/dotfiles/.vim/autoload/neomake/makers/ft/docbk.vim new file mode 100644 index 0000000..dceffac --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/docbk.vim @@ -0,0 +1,8 @@ +function! neomake#makers#ft#docbk#EnabledMakers() abort + return ['xmllint'] +endfunction + +function! neomake#makers#ft#docbk#xmllint() abort + return neomake#makers#ft#xml#xmllint() +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/dockerfile.vim b/dotfiles/.vim/autoload/neomake/makers/ft/dockerfile.vim new file mode 100644 index 0000000..a6d767f --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/dockerfile.vim @@ -0,0 +1,13 @@ +function! neomake#makers#ft#dockerfile#EnabledMakers() abort + return ['hadolint'] +endfunction + +function! neomake#makers#ft#dockerfile#hadolint() abort + return { + \ 'output_stream': 'stdout', + \ 'uses_stdin': 1, + \ 'args': ['--format', 'tty'], + \ 'errorformat': '%f:%l %m', + \ } +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/elixir.vim b/dotfiles/.vim/autoload/neomake/makers/ft/elixir.vim new file mode 100644 index 0000000..4de652e --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/elixir.vim @@ -0,0 +1,72 @@ +" vim: ts=4 sw=4 et + +" Credo error types. +" F -> Refactoring opportunities +" W -> Warnings +" C -> Convention violation +" D -> Software design suggestions +" R -> Readability suggestions +" Map structure {CredoError: NeomakeType, ...} +let s:neomake_elixir_credo_config_typemap = { + \ 'F': 'W', + \ 'C': 'W', + \ 'D': 'I', + \ 'R': 'I'} + +function! neomake#makers#ft#elixir#PostprocessEnforceMaxBufferLine(entry) abort + let buffer_lines = str2nr(line('$')) + if (buffer_lines < a:entry.lnum) + let a:entry.lnum = buffer_lines + endif +endfunction + +function! neomake#makers#ft#elixir#PostprocessCredo(entry) abort + let type = toupper(a:entry.type) + let type_map = extend(s:neomake_elixir_credo_config_typemap, + \ get(g:, 'neomake_elixir_credo_config_typemap', {})) + if has_key(type_map, type) + let a:entry.type = type_map[type] + endif +endfunction + +function! neomake#makers#ft#elixir#EnabledMakers() abort + return ['mix'] +endfunction + +function! neomake#makers#ft#elixir#elixir() abort + return { + \ 'errorformat': + \ '%E** %s %f:%l: %m,'. + \ '%W%f:%l: warning: %m' + \ } +endfunction + +function! neomake#makers#ft#elixir#credo() abort + return { + \ 'exe': 'mix', + \ 'args': ['credo', 'list', '--format=oneline'], + \ 'postprocess': function('neomake#makers#ft#elixir#PostprocessCredo'), + \ 'errorformat': + \'[%t] %. %f:%l:%c %m,' . + \'[%t] %. %f:%l %m' + \ } +endfunction + +function! neomake#makers#ft#elixir#mix() abort + return { + \ 'exe' : 'mix', + \ 'args': ['compile', '--warnings-as-errors'], + \ 'postprocess': function('neomake#makers#ft#elixir#PostprocessEnforceMaxBufferLine'), + \ 'errorformat': + \ '** %s %f:%l: %m,'. + \ '%Ewarning: %m,%C %f:%l,%Z' + \ } +endfunction + +function! neomake#makers#ft#elixir#dogma() abort + return { + \ 'exe': 'mix', + \ 'args': ['dogma', '--format=flycheck'], + \ 'errorformat': '%E%f:%l:%c: %.: %m' + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/elm.vim b/dotfiles/.vim/autoload/neomake/makers/ft/elm.vim new file mode 100644 index 0000000..fe1d2f6 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/elm.vim @@ -0,0 +1,53 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#elm#EnabledMakers() abort + return ['elmMake'] +endfunction + +function! neomake#makers#ft#elm#elmMake() abort + return { + \ 'exe': 'elm-make', + \ 'args': ['--report=json', '--output=' . g:neomake#compat#dev_null], + \ 'process_output': function('neomake#makers#ft#elm#ElmMakeProcessOutput') + \ } +endfunction + +function! neomake#makers#ft#elm#ElmMakeProcessOutput(context) abort + let errors = [] + " output will be a List, containing either: + " 1) A success message + " 2) A string holding a JSON array for both warnings and errors + + for line in a:context.output + if line[0] ==# '[' + let decoded = neomake#compat#json_decode(line) + for item in decoded + if get(item, 'type', '') ==# 'warning' + let code = 'W' + else + let code = 'E' + endif + + let compiler_error = item['tag'] + let message = item['overview'] + let filename = item['file'] + let region_start = item['region']['start'] + let region_end = item['region']['end'] + let row = region_start['line'] + let col = region_start['column'] + let length = region_end['column'] - region_start['column'] + + let error = { + \ 'text': compiler_error . ' : ' . message, + \ 'type': code, + \ 'lnum': row, + \ 'col': col, + \ 'length': length, + \ 'filename': filename, + \ } + call add(errors, error) + endfor + endif + endfor + return errors +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/erlang.vim b/dotfiles/.vim/autoload/neomake/makers/ft/erlang.vim new file mode 100644 index 0000000..a554098 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/erlang.vim @@ -0,0 +1,72 @@ + +function! neomake#makers#ft#erlang#EnabledMakers() abort + return ['erlc'] +endfunction + +function! neomake#makers#ft#erlang#erlc() abort + let maker = { + \ 'errorformat': + \ '%W%f:%l: Warning: %m,' . + \ '%E%f:%l: %m' + \ } + function! maker.InitForJob(_jobinfo) abort + let self.args = neomake#makers#ft#erlang#GlobPaths() + endfunction + return maker +endfunction + +if !exists('g:neomake_erlang_erlc_target_dir') + let g:neomake_erlang_erlc_target_dir = tempname() +endif + +function! neomake#makers#ft#erlang#GlobPaths() abort + " Find project root directory. + let rebar_config = neomake#utils#FindGlobFile('rebar.config') + if !empty(rebar_config) + let root = fnamemodify(rebar_config, ':h') + else + " At least try with CWD + let root = getcwd() + endif + let root = fnamemodify(root, ':p') + let build_dir = root . '_build' + let ebins = [] + if isdirectory(build_dir) + " Pick the rebar3 profile to use + let default_profile = expand('%') =~# '_SUITE.erl$' ? 'test' : 'default' + let profile = get(b:, 'neomake_erlang_erlc_rebar3_profile', default_profile) + let ebins += neomake#compat#glob_list(build_dir . '/' . profile . '/lib/*/ebin') + let target_dir = build_dir . '/neomake' + else + let target_dir = get(b:, 'neomake_erlang_erlc_target_dir', + \ get(g:, 'neomake_erlang_erlc_target_dir')) + endif + " If /_build doesn't exist it might be a rebar2/erlang.mk project + if isdirectory(root . 'deps') + let ebins += neomake#compat#glob_list(root . 'deps/*/ebin') + endif + " Set g:neomake_erlang_erlc_extra_deps in a project-local .vimrc, e.g.: + " let g:neomake_erlang_erlc_extra_deps = ['deps.local'] + " Or just b:neomake_erlang_erlc_extra_deps in a specific buffer. + let extra_deps_dirs = get(b:, 'neomake_erlang_erlc_extra_deps', + \ get(g:, 'neomake_erlang_erlc_extra_deps')) + if !empty(extra_deps_dirs) + for extra_deps in extra_deps_dirs + if extra_deps[-1] !=# '/' + let extra_deps .= '/' + endif + let ebins += neomake#compat#glob_list(extra_deps . '*/ebin') + endfor + endif + let args = ['-pa', 'ebin', '-I', 'include', '-I', 'src'] + for ebin in ebins + let args += [ '-pa', ebin, + \ '-I', substitute(ebin, 'ebin$', 'include', '') ] + endfor + if !isdirectory(target_dir) + call mkdir(target_dir, 'p') + endif + let args += ['-o', target_dir] + return args +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/fish.vim b/dotfiles/.vim/autoload/neomake/makers/ft/fish.vim new file mode 100644 index 0000000..429afcc --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/fish.vim @@ -0,0 +1,16 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#fish#EnabledMakers() abort + return ['fish'] +endfunction + +function! neomake#makers#ft#fish#fish() abort + return { + \ 'args': ['-n'], + \ 'errorformat': + \ '%C%f (line %l): %s,'. + \ '%-Gfish: %.%#,'. + \ '%Z%p^,'. + \ '%E%m' + \} +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/fortran.vim b/dotfiles/.vim/autoload/neomake/makers/ft/fortran.vim new file mode 100644 index 0000000..828bba9 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/fortran.vim @@ -0,0 +1,32 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#fortran#EnabledMakers() abort + return ['gfortran'] +endfunction + +" Using the errorformat from syntastic +function! neomake#makers#ft#fortran#ifort() abort + return { + \ 'args': ['-syntax-only', '-warn'], + \ 'errorformat': + \ '%E%f(%l): error #%n: %m,'. + \ '%W%f(%l): warning #%n: %m,'. + \ '%W%f(%l): remark #%n: %m,'. + \ '%-Z%p^,'. + \ '%-G%.%#', + \ } +endfunction + +" Using the errorformat from syntastic +function! neomake#makers#ft#fortran#gfortran() abort + return { + \ 'args': ['-fsyntax-only', '-Wall', '-Wextra'], + \ 'errorformat': + \ '%-C %#,'. + \ '%-C %#%.%#,'. + \ '%A%f:%l%[.:]%c:,'. + \ '%Z%\m%\%%(Fatal %\)%\?%trror: %m,'. + \ '%Z%tarning: %m,'. + \ '%-G%.%#', + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/go.vim b/dotfiles/.vim/autoload/neomake/makers/ft/go.vim new file mode 100644 index 0000000..ac53730 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/go.vim @@ -0,0 +1,84 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#go#EnabledMakers() abort + let makers = ['go'] + if executable('golangci-lint') + call add(makers, 'golangci_lint') + elseif executable('gometalinter') + call add(makers, 'gometalinter') + else + call extend(makers, ['golint', 'govet']) + endif + return makers +endfunction + +function! neomake#makers#ft#go#go() abort + return { + \ 'args': [ + \ 'test', '-c', + \ '-o', g:neomake#compat#dev_null, + \ ], + \ 'append_file': 0, + \ 'cwd': '%:h', + \ 'serialize': 1, + \ 'serialize_abort_on_error': 1, + \ 'errorformat': + \ '%W%f:%l: warning: %m,' . + \ '%E%f:%l:%c:%m,' . + \ '%E%f:%l:%m,' . + \ '%C%\s%\+%m,' . + \ '%-G%.%#\\\[no test files],' . + \ '%-G#%.%#', + \ 'postprocess': function('neomake#postprocess#compress_whitespace'), + \ 'version_arg': 'version', + \ } +endfunction + +function! neomake#makers#ft#go#golint() abort + " golint's issues are informational, as they're stylistic (not bugs) + return { + \ 'errorformat': + \ '%I%f:%l:%c: %m,' . + \ '%-G%.%#' + \ } +endfunction + +function! neomake#makers#ft#go#govet() abort + return { + \ 'exe': 'go', + \ 'args': ['vet'], + \ 'append_file': 0, + \ 'cwd': '%:h', + \ 'errorformat': + \ '%Evet: %.%\+: %f:%l:%c: %m,' . + \ '%W%f:%l: %m,' . + \ '%-G%.%#' + \ } +endfunction + +function! neomake#makers#ft#go#gometalinter() abort + " Only run a subset of gometalinter for speed, users can override with: + " let g:neomake_go_gometalinter_args = ['--disable-all', '--enable=X', ...] + " + " All linters are only warnings, the go compiler will report errors + return { + \ 'args': ['--disable-all', '--enable=errcheck', '--enable=megacheck', '--vendor'], + \ 'append_file': 0, + \ 'cwd': '%:h', + \ 'errorformat': + \ '%f:%l:%c:%t%*[^:]: %m,' . + \ '%f:%l::%t%*[^:]: %m' + \ } +endfunction + +function! neomake#makers#ft#go#golangci_lint() abort + return { + \ 'exe': 'golangci-lint', + \ 'args': ['run', '--out-format=line-number', '--print-issued-lines=false'], + \ 'output_stream': 'stdout', + \ 'append_file': 0, + \ 'cwd': '%:h', + \ 'errorformat': + \ '%f:%l:%c: %m' + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/haml.vim b/dotfiles/.vim/autoload/neomake/makers/ft/haml.vim new file mode 100644 index 0000000..df79b38 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/haml.vim @@ -0,0 +1,13 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#haml#EnabledMakers() abort + return ['hamllint'] +endfunction + +function! neomake#makers#ft#haml#hamllint() abort + return { + \ 'exe': 'haml-lint', + \ 'args': ['--no-color'], + \ 'errorformat': '%f:%l [%t] %m' + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/haskell.vim b/dotfiles/.vim/autoload/neomake/makers/ft/haskell.vim new file mode 100644 index 0000000..64a5227 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/haskell.vim @@ -0,0 +1,169 @@ +unlet! s:makers +unlet! s:uses_cabal + +function! neomake#makers#ft#haskell#EnabledMakers() abort + if !exists('s:makers') + " cache whether each maker is available, to avoid lots of (UI blocking) + " system calls + " TODO: figure out how to do all this configuration async instead of + " caching it--that would allow the user to change directories from + " within vim and recalculate maker availability without restarting vim + let commands = ['ghc-mod', 'hdevtools', 'hlint', 'liquid'] + let s:makers = [] + let s:jobs = [] + for command in commands + " stack may be able to find a maker binary that's not on the normal + " path so check for that first + if executable('stack') + " run the maker command using stack to see whether stack can + " find it use the help flag to run the maker command without + " doing anything + let stack_command = [ + \ 'stack' + \ , 'exec' + \ , '--' + \ , command + \ , '--help' + \ ] + if has('nvim') + let job_id = jobstart( + \ stack_command, + \ { 'command': command + \ , 'on_exit': function('s:CheckStackMakerAsync') + \ }) + if job_id > 0 + call add(s:jobs, job_id) + endif + else + call extend(stack_command, ['> /dev/null 2>&1;', 'echo $?']) + if system(join(stack_command, ' ')) == 0 + call add(s:makers, substitute(command, '-', '', 'g')) + endif + endif + elseif executable(command) " no stack bin so check for maker bin + call add(s:makers, substitute(command, '-', '', 'g')) + endif + endfor + if has('nvim') + call jobwait(s:jobs) + endif + endif + return s:makers +endfunction + +function! neomake#makers#ft#haskell#hdevtools() abort + let params = { + \ 'exe': 'hdevtools', + \ 'args': ['check', '-g-Wall'], + \ 'mapexpr': s:CleanUpSpaceAndBackticks(), + \ 'errorformat': + \ '%-Z %#,'. + \ '%W%f:%l:%v: Warning: %m,'. + \ '%W%f:%l:%v: Warning:,'. + \ '%E%f:%l:%v: %m,'. + \ '%E%>%f:%l:%v:,'. + \ '%+C %#%m,'. + \ '%W%>%f:%l:%v:,'. + \ '%+C %#%tarning: %m,' + \ } + " hdevtools needs the GHC-PACKAGE-PATH environment variable to exist + " when running on a project WITHOUT a cabal file, but it needs the + " GHC-PACKAGE-PATH to NOT exist when running on a with a project WITH + " a cabal file + if !exists('s:uses_cabal') + let s:uses_cabal = 0 + if executable('stack') + let output = neomake#compat#systemlist(['stack', '--verbosity', 'silent', 'path', '--project-root']) + if !empty(output) + let rootdir = output[0] + if !empty(glob(rootdir . '/*.cabal')) + let s:uses_cabal = 1 + endif + endif + endif + endif + if s:uses_cabal + let params['stackexecargs'] = ['--no-ghc-package-path'] + endif + return s:TryStack(params) +endfunction + +function! neomake#makers#ft#haskell#ghcmod() abort + " This filters out newlines, which is what neovim gives us instead of the + " null bytes that ghc-mod sometimes spits out. + let mapexpr = 'substitute(v:val, "\n", "", "g")' + return s:TryStack({ + \ 'exe': 'ghc-mod', + \ 'args': ['check'], + \ 'mapexpr': mapexpr, + \ 'errorformat': + \ '%-G%\s%#,' . + \ '%f:%l:%c:%trror: %m,' . + \ '%f:%l:%c:%tarning: %m,'. + \ '%f:%l:%c: %trror: %m,' . + \ '%f:%l:%c: %tarning: %m,' . + \ '%E%f:%l:%c:%m,' . + \ '%E%f:%l:%c:,' . + \ '%Z%m' + \ }) +endfunction + +function! neomake#makers#ft#haskell#HlintEntryProcess(entry) abort + " Postprocess hlint output to make it more readable as a single line + let a:entry.text = substitute(a:entry.text, '\v(Found:)\s*\n', ' | \1', 'g') + let a:entry.text = substitute(a:entry.text, '\v(Why not:)\s*\n', ' | \1', 'g') + let a:entry.text = substitute(a:entry.text, '^No hints$', '', 'g') + call neomake#postprocess#compress_whitespace(a:entry) +endfunction + +function! neomake#makers#ft#haskell#hlint() abort + return s:TryStack({ + \ 'exe': 'hlint', + \ 'postprocess': function('neomake#makers#ft#haskell#HlintEntryProcess'), + \ 'args': [], + \ 'errorformat': + \ '%E%f:%l:%v: Error: %m,' . + \ '%W%f:%l:%v: Warning: %m,' . + \ '%I%f:%l:%v: Suggestion: %m,' . + \ '%C%m' + \ }) +endfunction + +function! neomake#makers#ft#haskell#liquid() abort + return s:TryStack({ + \ 'exe': 'liquid', + \ 'args': [], + \ 'mapexpr': s:CleanUpSpaceAndBackticks(), + \ 'errorformat': + \ '%E %f:%l:%c-%.%#Error: %m,' . + \ '%C%.%#|%.%#,' . + \ '%C %#^%#,' . + \ '%C%m,' + \ }) +endfunction + +function! s:CheckStackMakerAsync(_job_id, data, _event) dict abort + if a:data == 0 + call add(s:makers, substitute(self.command, '-', '', 'g')) + endif +endfunction + +function! s:TryStack(maker) abort + if executable('stack') + if !has_key(a:maker, 'stackexecargs') + let a:maker['stackexecargs'] = [] + endif + let a:maker['args'] = + \ ['--verbosity', 'silent', 'exec'] + \ + a:maker['stackexecargs'] + \ + ['--', a:maker['exe']] + \ + a:maker['args'] + let a:maker['exe'] = 'stack' + endif + return a:maker +endfunction + +function! s:CleanUpSpaceAndBackticks() abort + return 'substitute(substitute(v:val, " \\{2,\\}", " ", "g"), "`", "''", "g")' +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/haxe.vim b/dotfiles/.vim/autoload/neomake/makers/ft/haxe.vim new file mode 100644 index 0000000..9fd07ec --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/haxe.vim @@ -0,0 +1,11 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#haxe#EnabledMakers() abort + return ['haxe'] +endfunction + +function! neomake#makers#ft#haxe#haxe() abort + return { + \ 'errorformat': '%E%f:%l: characters %c-%n : %m' + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/help.vim b/dotfiles/.vim/autoload/neomake/makers/ft/help.vim new file mode 100644 index 0000000..c573cef --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/help.vim @@ -0,0 +1,40 @@ +let s:makers = ['writegood'] + +let s:slash = neomake#utils#Slash() +let s:vimhelplint_exe = '' +if executable('vimhelplint') + let s:vimhelplint_exe = 'vimhelplint' +else + let s:neomake_root = expand(':p:h:h:h:h:h', 1) + if !empty(glob(join([s:neomake_root, 'build', 'vimhelplint'], s:slash))) + let s:vimhelplint_exe = join([s:neomake_root, 'contrib', 'vimhelplint'], s:slash) + endif +endif +if !empty(s:vimhelplint_exe) + let s:makers += ['vimhelplint'] +endif + +function! neomake#makers#ft#help#EnabledMakers() abort + return s:makers +endfunction + +function! neomake#makers#ft#help#vimhelplint() abort + " NOTE: does not support/uses arg from wrapper script (i.e. no support for + " tempfiles). It will use the arg only to expand/glob `*.txt` + " (which does not include the hidden tempfile). + return { + \ 'exe': s:vimhelplint_exe, + \ 'errorformat': '%f:%l:%c:%trror:%n:%m,%f:%l:%c:%tarning:%n:%m', + \ 'postprocess': function('neomake#postprocess#generic_length'), + \ 'output_stream': 'stdout', + \ } +endfunction + +function! neomake#makers#ft#help#proselint() abort + return neomake#makers#ft#text#proselint() +endfunction + +function! neomake#makers#ft#help#writegood() abort + return neomake#makers#ft#text#writegood() +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/html.vim b/dotfiles/.vim/autoload/neomake/makers/ft/html.vim new file mode 100644 index 0000000..6100175 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/html.vim @@ -0,0 +1,20 @@ +function! neomake#makers#ft#html#tidy() abort + " NOTE: could also have info items, but those are skipped with -e/-q, e.g. + " 'line 7 column 1 - Info: value for attribute "id" missing quote marks'. + return { + \ 'args': ['-e', '-q', '--gnu-emacs', 'true'], + \ 'errorformat': '%W%f:%l:%c: Warning: %m', + \ } +endfunction + +function! neomake#makers#ft#html#htmlhint() abort + return { + \ 'args': ['--format', 'unix', '--nocolor'], + \ 'errorformat': '%f:%l:%c: %m,%-G,%-G%*\d problems', + \ } +endfunction + +function! neomake#makers#ft#html#EnabledMakers() abort + return ['tidy', 'htmlhint'] +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/idris.vim b/dotfiles/.vim/autoload/neomake/makers/ft/idris.vim new file mode 100644 index 0000000..5d95edb --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/idris.vim @@ -0,0 +1,25 @@ +function! neomake#makers#ft#idris#EnabledMakers() abort + return ['idris'] +endfunction + +function! neomake#makers#ft#idris#Postprocess(entry) abort + call neomake#postprocess#compress_whitespace(a:entry) + " Extract length from the beginning of the entry ('-4:When checking left hand side of xor:'). + if a:entry.text =~# '\v^\d+:' + let end = 0 + a:entry.text " cast to int + let a:entry.length = end - a:entry.col + let a:entry.text = substitute(a:entry.text, '\v^([^:]+:){2} ', '', '') + endif +endfunction + +function! neomake#makers#ft#idris#idris() abort + return { + \ 'exe': 'idris', + \ 'args': ['--check', '--warn', '--total', '--warnpartial', '--warnreach'], + \ 'errorformat': + \ '%E%f:%l:%c:%.%#,%-C %#%m,%-C%.%#,'. + \ '%E%f:%l:%c-%m,%-C %#%m,%-C%.%#', + \ 'postprocess': function('neomake#makers#ft#idris#Postprocess'), + \ } +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/jade.vim b/dotfiles/.vim/autoload/neomake/makers/ft/jade.vim new file mode 100644 index 0000000..c747950 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/jade.vim @@ -0,0 +1,13 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#jade#EnabledMakers() abort + return ['jadelint'] +endfunction + +function! neomake#makers#ft#jade#jadelint() abort + return { + \ 'exe': 'jade-lint', + \ 'args': ['--reporter', 'inline'], + \ 'errorformat': '%f:%l:%c %m' + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/jasmine.vim b/dotfiles/.vim/autoload/neomake/makers/ft/jasmine.vim new file mode 100644 index 0000000..56e0a4f --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/jasmine.vim @@ -0,0 +1,9 @@ +function! neomake#makers#ft#jasmine#SupersetOf() abort + return 'javascript' +endfunction + +function! neomake#makers#ft#jasmine#EnabledMakers() abort + return ['jshint', 'eslint', 'jscs'] +endfunction + +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/java.vim b/dotfiles/.vim/autoload/neomake/makers/ft/java.vim new file mode 100644 index 0000000..1c09bda --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/java.vim @@ -0,0 +1,396 @@ +"============================================================================ +"File: java.vim +"Description: Syntax checking plugin for neomake +"Maintainer: Wang Shidong +"License: This program is free software. It comes without any warranty, +" to the extent permitted by applicable law. You can redistribute +" it and/or modify it under the terms of the Do What The Fuck You +" Want To Public License, Version 2, as published by Sam Hocevar. +" See http://sam.zoy.org/wtfpl/COPYING for more details. +"============================================================================ + +let s:save_cpo = &cpoptions +set cpoptions&vim + +if exists('g:loaded_neomake_java_javac_maker') + finish +endif +let g:loaded_neomake_java_javac_maker = 1 + +let g:neomake_java_javac_maven_pom_tags = ['build', 'properties'] +let g:neomake_java_javac_maven_pom_properties = {} +let s:is_windows = has('win32') || has('win64') || has('win16') || has('dos32') || has('dos16') +if s:is_windows + let s:fsep = ';' + let s:psep = '\' +else + let s:fsep = ':' + let s:psep = '/' +endif +let g:neomake_java_checker_home = fnamemodify(expand(''), ':p:h:gs?\\?/?') + +" custom options +let g:neomake_java_javac_executable = + \ get(g:, 'neomake_java_javac_executable', 'javac') + +let g:neomake_java_maven_executable = + \ get(g:, 'neomake_java_maven_executable', 'mvn') + +let g:neomake_java_gradle_executable = + \ get(g:, 'neomake_java_gradle_executable', s:is_windows? '.\gradlew.bat' : './gradlew') + +let g:neomake_java_ant_executable = + \ get(g:, 'neomake_java_ant_executable', 'ant') + +let g:neomake_java_checkstyle_executable = + \ get(g:, 'neomake_java_checkstyle_executable', 'checkstyle') + +let g:neomake_java_javac_options = + \ get(g:, 'neomake_java_javac_options', ['-Xlint']) + +let g:neomake_java_maven_options = + \ get(g:, 'neomake_java_maven_options', '') + +let g:neomake_java_javac_classpath = + \ get(g:, 'neomake_java_javac_classpath', '') + +let g:neomake_java_javac_outputdir = + \ get(g:, 'neomake_java_javac_outputdir', '') + +let g:neomake_java_checkstyle_xml = + \ get(g:, 'neomake_java_checkstyle_xml', '/usr/share/checkstyle/google_checks.xml') + +let g:neomake_java_javac_delete_output = + \ get(g:, 'neomake_java_javac_delete_output', 1) + +let g:neomake_java_javac_autoload_maven_classpath = + \ get(g:, 'neomake_java_javac_autoload_maven_classpath', 1) + +let g:neomake_java_javac_autoload_gradle_classpath = + \ get(g:, 'neomake_java_javac_autoload_gradle_classpath', 1) + +let g:neomake_java_javac_autoload_ant_classpath = + \ get(g:, 'neomake_java_javac_autoload_ant_classpath', 1) + +let g:neomake_java_javac_autoload_eclipse_classpath = + \ get(g:, 'neomake_java_javac_autoload_eclipse_classpath', 1) + +let g:neomake_java_javac_maven_pom_ftime = + \ get(g:, 'neomake_java_javac_maven_pom_ftime', {}) + +let g:neomake_java_javac_maven_pom_classpath = + \ get(g:, 'neomake_java_javac_maven_pom_classpath', {}) + +let g:neomake_java_javac_gradle_ftime = + \ get(g:, 'neomake_java_javac_gradle_ftime', {}) + +let g:neomake_java_javac_gradle_classpath = + \ get(g:, 'neomake_java_javac_gradle_classpath', {}) + +let g:neomake_java_javac_ant_ftime = + \ get(g:, 'neomake_java_javac_ant_ftime', {}) + +let g:neomake_java_javac_ant_classpath = + \ get(g:, 'neomake_java_javac_ant_classpath', {}) + + +let s:has_maven = executable(expand(g:neomake_java_maven_executable, 1)) +let s:has_gradle = executable(expand(g:neomake_java_gradle_executable, 1)) +let s:has_ant = executable(expand(g:neomake_java_ant_executable, 1)) + +function! s:tmpdir() abort + let tempdir = tempname() + call mkdir(tempdir, 'p', 0700) + return tempdir +endfunction + +function! s:ClassSep() abort + return (s:is_windows || has('win32unix')) ? ';' : ':' +endfunction + +function! s:shescape(string) abort + return neomake#utils#shellescape(a:string) +endfunction + +function! s:AddToClasspath(classpath, path) abort + if a:path ==# '' + return a:classpath + endif + return (a:classpath !=# '') ? a:classpath . s:ClassSep() . a:path : a:path +endfunction + +" @vimlint(EVL103, 1, a:classpathFile) +function! s:ReadClassPathFile(classpathFile) abort + let cp = '' + let file = g:neomake_java_checker_home. s:psep. 'java'. s:psep. 'classpath.py' + if has('python3') + execute 'py3file' file + py3 import vim + py3 vim.command("let cp = '%s'" % os.pathsep.join(ReadClasspathFile(vim.eval('a:classpathFile'))).replace('\\', '/')) + elseif has('python') + execute 'pyfile' file + py import vim + py vim.command("let cp = '%s'" % os.pathsep.join(ReadClasspathFile(vim.eval('a:classpathFile'))).replace('\\', '/')) + endif + return cp +endfunction +" @vimlint(EVL103, 0, a:classpathFile) + +function! neomake#makers#ft#java#EnabledMakers() abort + let makers = [] + if executable(expand(g:neomake_java_javac_executable, 1)) + call add(makers, g:neomake_java_javac_executable) + endif + if executable(expand(g:neomake_java_checkstyle_executable, 1)) + call add(makers, g:neomake_java_checkstyle_executable) + endif + return makers +endfunction + +function! neomake#makers#ft#java#javac() abort + let javac_opts = extend([], g:neomake_java_javac_options) + + let output_dir = '' + if g:neomake_java_javac_delete_output + let output_dir = s:tmpdir() + let javac_opts = extend(javac_opts, ['-d', s:shescape(output_dir)]) + endif + + let javac_classpath = get(g:, 'neomake_java_javac_classpath', '') + + if s:has_maven && g:neomake_java_javac_autoload_maven_classpath && empty(javac_classpath) + if !g:neomake_java_javac_delete_output + let javac_opts = extend(javac_opts, ['-d', s:shescape(s:MavenOutputDirectory())]) + endif + let javac_classpath = s:AddToClasspath(javac_classpath, s:GetMavenClasspath()) + endif + + if s:has_gradle && g:neomake_java_javac_autoload_gradle_classpath && empty(javac_classpath) + if !g:neomake_java_javac_delete_output + let javac_opts = extend(javac_opts, ['-d', s:shescape(s:GradleOutputDirectory())]) + endif + let javac_classpath = s:AddToClasspath(javac_classpath, s:GetGradleClasspath()) + endif + + if s:has_ant && g:neomake_java_javac_autoload_ant_classpath && empty(javac_classpath) + let javac_classpath = s:AddToClasspath(javac_classpath, s:GetAntClasspath()) + endif + + if (has('python') || has('python3')) && empty(javac_classpath) + let classpathFile = fnamemodify(findfile('.classpath', escape(expand('.'), '*[]?{}, ') . ';'), ':p') + if !empty(classpathFile) && filereadable(classpathFile) + let javac_classpath = s:ReadClassPathFile(classpathFile) + endif + endif + + if javac_classpath !=# '' + let javac_opts = extend(javac_opts, ['-cp', javac_classpath]) + endif + + return { + \ 'args': javac_opts, + \ 'exe': g:neomake_java_javac_executable, + \ 'errorformat': + \ '%E%f:%l: error: %m,'. + \ '%W%f:%l: warning: %m,'. + \ '%E%f:%l: %m,'. + \ '%Z%p^,'. + \ '%-G%.%#', + \ 'version_arg': '-version' + \ } +endfunction + +function! neomake#makers#ft#java#checkstyle() abort + return { + \ 'args': ['-c', g:neomake_java_checkstyle_xml], + \ 'exe': g:neomake_java_checkstyle_executable, + \ 'errorformat': + \ '%-GStarting audit...,'. + \ '%-GAudit done.,'. + \ '%-GPicked up _JAVA_OPTIONS:%.%#,'. + \ '[%t%*[^]]] %f:%l:%c: %m [%s],'. + \ '[%t%*[^]]] %f:%l: %m [%s]', + \ 'version_arg': '-v' + \ } +endfunction + +function! s:findFileInParent(what, where) abort " {{{2 + let old_suffixesadd = &suffixesadd + let &suffixesadd = '' + let file = findfile(a:what, escape(a:where, ' ') . ';') + let &suffixesadd = old_suffixesadd + return file +endfunction " }}}2 + +function! s:GetMavenProperties() abort " {{{2 + let mvn_properties = {} + let pom = s:findFileInParent('pom.xml', expand('%:p:h', 1)) + if s:has_maven && filereadable(pom) + if !has_key(g:neomake_java_javac_maven_pom_properties, pom) + let mvn_cmd = s:shescape(expand(g:neomake_java_maven_executable, 1)) . + \ ' -f ' . s:shescape(pom) . + \ ' ' . g:neomake_java_maven_options + let mvn_is_managed_tag = 1 + let mvn_settings_output = split(system(mvn_cmd . ' help:effective-pom'), "\n") + let current_path = 'project' + for line in mvn_settings_output + let matches = matchlist(line, '\m^\s*<\([a-zA-Z0-9\-\.]\+\)>\s*$') + if mvn_is_managed_tag && !empty(matches) + let mvn_is_managed_tag = index(g:neomake_java_javac_maven_pom_tags, matches[1]) >= 0 + let current_path .= '.' . matches[1] + else + let matches = matchlist(line, '\m^\s*\s*$') + if !empty(matches) + let mvn_is_managed_tag = index(g:neomake_java_javac_maven_pom_tags, matches[1]) < 0 + let current_path = substitute(current_path, '\m\.' . matches[1] . '$', '', '') + else + let matches = matchlist(line, '\m^\s*<\([a-zA-Z0-9\-\.]\+\)>\(.\+\)\s*$') + if mvn_is_managed_tag && !empty(matches) + let mvn_properties[current_path . '.' . matches[1]] = matches[2] + endif + endif + endif + endfor + let g:neomake_java_javac_maven_pom_properties[pom] = mvn_properties + endif + return g:neomake_java_javac_maven_pom_properties[pom] + endif + return mvn_properties +endfunction " }}}2 + +function! s:GetMavenClasspath() abort " {{{2 + let pom = s:findFileInParent('pom.xml', expand('%:p:h', 1)) + if s:has_maven && filereadable(pom) + if !has_key(g:neomake_java_javac_maven_pom_ftime, pom) || g:neomake_java_javac_maven_pom_ftime[pom] != getftime(pom) + let mvn_cmd = s:shescape(expand(g:neomake_java_maven_executable, 1)) . + \ ' -f ' . s:shescape(pom) . + \ ' ' . g:neomake_java_maven_options + let mvn_classpath_output = split(system(mvn_cmd . ' dependency:build-classpath -DincludeScope=test'), "\n") + let mvn_classpath = '' + let class_path_next = 0 + + for line in mvn_classpath_output + if class_path_next == 1 + let mvn_classpath = substitute(line, "\r", '', 'g') + break + endif + if stridx(line, 'Dependencies classpath:') >= 0 + let class_path_next = 1 + endif + endfor + + let mvn_properties = s:GetMavenProperties() + + let output_dir = get(mvn_properties, 'project.build.outputDirectory', join(['target', 'classes'], s:psep)) + let mvn_classpath = s:AddToClasspath(mvn_classpath, output_dir) + + let test_output_dir = get(mvn_properties, 'project.build.testOutputDirectory', join(['target', 'test-classes'], s:psep)) + let mvn_classpath = s:AddToClasspath(mvn_classpath, test_output_dir) + + let g:neomake_java_javac_maven_pom_ftime[pom] = getftime(pom) + let g:neomake_java_javac_maven_pom_classpath[pom] = mvn_classpath + endif + return g:neomake_java_javac_maven_pom_classpath[pom] + endif + return '' +endfunction " }}}2 + +function! s:MavenOutputDirectory() abort " {{{2 + let pom = s:findFileInParent('pom.xml', expand('%:p:h', 1)) + if s:has_maven && filereadable(pom) + let mvn_properties = s:GetMavenProperties() + let output_dir = get(mvn_properties, 'project.properties.build.dir', getcwd()) + + let src_main_dir = get(mvn_properties, 'project.build.sourceDirectory', join(['src', 'main', 'java'], s:psep)) + let src_test_dir = get(mvn_properties, 'project.build.testsourceDirectory', join(['src', 'test', 'java'], s:psep)) + if stridx(expand('%:p:h', 1), src_main_dir) >= 0 + let output_dir = get(mvn_properties, 'project.build.outputDirectory', join ([output_dir, 'target', 'classes'], s:psep)) + endif + if stridx(expand('%:p:h', 1), src_test_dir) >= 0 + let output_dir = get(mvn_properties, 'project.build.testOutputDirectory', join([output_dir, 'target', 'test-classes'], s:psep)) + endif + + if has('win32unix') + let output_dir = substitute(system('cygpath -m ' . s:shescape(output_dir)), "\n", '', 'g') + endif + return output_dir + endif + return '.' +endfunction " }}}2 + +function! s:GradleOutputDirectory() abort + let gradle_build = s:findFileInParent('build.gradle', expand('%:p:h', 1)) + let items = split(gradle_build, s:psep) + if len(items)==1 + return join(['build', 'intermediates', 'classes', 'debug'], s:psep) + endif + let outputdir = '' + for i in items + if i !=# 'build.gradle' + let outputdir .= i . s:psep + endif + endfor + return outputdir . join(['build', 'intermediates', 'classes', 'debug'], s:psep) +endf + +function! s:GetGradleClasspath() abort + let gradle = s:findFileInParent('build.gradle', expand('%:p:h', 1)) + if s:has_gradle && filereadable(gradle) + if !has_key(g:neomake_java_javac_gradle_ftime, gradle) || g:neomake_java_javac_gradle_ftime[gradle] != getftime(gradle) + try + let f = tempname() + if s:is_windows + let gradle_cmd = '.\gradlew.bat' + else + let gradle_cmd = './gradlew' + endif + call writefile(["allprojects{apply from: '" . g:neomake_java_checker_home . s:psep. 'java'. s:psep. "classpath.gradle'}"], f) + let ret = system(gradle_cmd . ' -q -I ' . shellescape(f) . ' classpath' ) + if v:shell_error == 0 + let cp = filter(split(ret, "\n"), "v:val =~# '^CLASSPATH:'")[0][10:] + if filereadable(getcwd() . s:psep . 'build.gradle') + let out_putdir = neomake#compat#globpath_list(getcwd(), join( + \ ['**', 'build', 'intermediates', 'classes', 'debug'], + \ s:psep), 0) + for classes in out_putdir + let cp .= s:ClassSep() . classes + endfor + endif + else + let cp = '' + endif + catch + finally + call delete(f) + endtry + let g:neomake_java_javac_gradle_ftime[gradle] = getftime(gradle) + let g:neomake_java_javac_gradle_classpath[gradle] = cp + endif + return g:neomake_java_javac_gradle_classpath[gradle] + endif + return '' +endf + +function! s:GetAntClasspath() abort + let ant = s:findFileInParent('build.xml', expand('%:p:h', 1)) + if s:has_ant && filereadable(ant) + if !has_key(g:neomake_java_javac_ant_ftime, ant) || g:neomake_java_javac_ant_ftime[ant] != getftime(ant) + try + let ant_cmd = 'ant classpath -f build.xml -S -q' + let cp = system(ant_cmd) + if v:shell_error != 0 + let cp = '' + endif + catch + endtry + let g:neomake_java_javac_ant_ftime[ant] = getftime(ant) + let g:neomake_java_javac_ant_classpath[ant] = cp + endif + return g:neomake_java_javac_ant_classpath[ant] + endif + return '' +endf + +let &cpoptions = s:save_cpo +unlet s:save_cpo +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/java/classpath.gradle b/dotfiles/.vim/autoload/neomake/makers/ft/java/classpath.gradle new file mode 100644 index 0000000..f548c0d --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/java/classpath.gradle @@ -0,0 +1,46 @@ +task classpath << { + + String finalFileContents = "" + HashSet classpathFiles = new HashSet() + for (proj in allprojects) { + + def exploded = proj.getBuildDir().absolutePath + File.separator + "intermediates" + File.separator + "exploded-aar" + def listFiles = new File(exploded) + if (listFiles.exists()) { + listFiles.eachFileRecurse(){ file -> + if (file.name.endsWith(".jar")){ + classpathFiles += file + } + } + } + + def rjava = proj.getBuildDir().absolutePath + File.separator + "intermediates" + File.separator + "classes" + File.separator + "debug" + def rFiles = new File(rjava) + if (rFiles.exists()) { + classpathFiles += rFiles + } + + for (conf in proj.configurations) { + for (dependency in conf) { + if (dependency.name.endsWith("aar")){ + } else { + classpathFiles += dependency + } + } + } + if (proj.hasProperty("android")){ + classpathFiles += proj.android.bootClasspath + } + + if (proj.hasProperty("sourceSets")) { + + for (srcSet in proj.sourceSets) { + for (dir in srcSet.java.srcDirs) { + classpathFiles += dir.absolutePath + } + } + } + } + def paths = classpathFiles.join(File.pathSeparator) + println "CLASSPATH:" + paths +} diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/java/classpath.py b/dotfiles/.vim/autoload/neomake/makers/ft/java/classpath.py new file mode 100644 index 0000000..5a7ea8d --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/java/classpath.py @@ -0,0 +1,15 @@ +import os +from xml.etree.ElementTree import * + + +def ReadClasspathFile(fn): + cp = [] + for a in parse(fn).findall('classpathentry'): + kind = a.get('kind') + if kind == 'src' and 'output' in a.keys(): + cp.append(os.path.abspath(a.get('output'))) + elif kind == 'lib' and 'path' in a.keys(): + cp.append(os.path.abspath(a.get('path'))) + elif kind == 'output' and 'path' in a.keys(): + cp.append(os.path.abspath(a.get('path'))) + return cp diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/javascript.vim b/dotfiles/.vim/autoload/neomake/makers/ft/javascript.vim new file mode 100644 index 0000000..7bb379f --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/javascript.vim @@ -0,0 +1,119 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#javascript#EnabledMakers() abort + return ['jshint', 'jscs', + \ executable('eslint_d') ? 'eslint_d' : 'eslint', + \] +endfunction + +function! neomake#makers#ft#javascript#tsc() abort + return neomake#makers#ft#typescript#tsc() +endfunction + +function! neomake#makers#ft#javascript#gjslint() abort + return { + \ 'args': ['--nodebug_indentation', '--nosummary', '--unix_mode', '--nobeep'], + \ 'errorformat': '%f:%l:(New Error -%\\?\%n) %m,' . + \ '%f:%l:(-%\\?%n) %m,' . + \ '%-G1 files checked,' . + \ ' no errors found.,' . + \ '%-G%.%#' + \ } +endfunction + +function! neomake#makers#ft#javascript#jshint() abort + return { + \ 'args': ['--verbose'], + \ 'errorformat': '%A%f: line %l\, col %v\, %m \(%t%*\d\),%-G,%-G%\\d%\\+ errors', + \ 'postprocess': function('neomake#postprocess#generic_length'), + \ } +endfunction + +function! neomake#makers#ft#javascript#jscs() abort + return { + \ 'args': ['--no-colors', '--reporter', 'inline'], + \ 'errorformat': '%E%f: line %l\, col %c\, %m', + \ } +endfunction + +function! neomake#makers#ft#javascript#eslint() abort + let maker = { + \ 'args': ['--format=compact'], + \ 'errorformat': '%E%f: line %l\, col %c\, Error - %m,' . + \ '%W%f: line %l\, col %c\, Warning - %m,%-G,%-G%*\d problems%#', + \ 'cwd': '%:p:h', + \ 'output_stream': 'stdout', + \ } + + function! maker.supports_stdin(_jobinfo) abort + let self.args += ['--stdin', '--stdin-filename=%:p'] + let self.tempfile_name = '' + return 1 + endfunction + + return maker +endfunction + +function! neomake#makers#ft#javascript#eslint_d() abort + return neomake#makers#ft#javascript#eslint() +endfunction + +function! neomake#makers#ft#javascript#standard() abort + return { + \ 'args': ['-v'], + \ 'errorformat': '%W %f:%l:%c: %m,%-Gstandard: %.%#' + \ } +endfunction + +function! neomake#makers#ft#javascript#semistandard() abort + return { + \ 'errorformat': '%W %f:%l:%c: %m' + \ } +endfunction + +function! neomake#makers#ft#javascript#rjsx() abort + return { + \ 'exe': 'emacs', + \ 'args': ['%t','--quick','--batch','--eval=' + \ .'(progn(setq package-load-list ''((js2-mode t)(rjsx-mode t)))(package-initialize)(require ''rjsx-mode)' + \ .' (setq js2-include-node-externs t js2-include-rhino-externs t js2-include-browser-externs t js2-strict-missing-semi-warning nil)' + \ .' (rjsx-mode)(js2-reparse)(js2-display-error-list)' + \ .' (princ(replace-regexp-in-string "^" (concat buffer-file-name " ")' + \ .' (with-current-buffer "*js-lint*" (buffer-substring-no-properties(point-min)(point-max)))))(terpri))'], + \ 'errorformat': '%f line %l: %m,%-G%.%#', + \ 'append_file': 0, + \ } +endfunction + +function! neomake#makers#ft#javascript#flow() abort + return { + \ 'args': ['--from=vim', '--show-all-errors'], + \ 'errorformat': + \ '%-GNo errors!,' + \ .'%EFile "%f"\, line %l\, characters %c-%m,' + \ .'%trror: File "%f"\, line %l\, characters %c-%m,' + \ .'%C%m,%Z', + \ 'postprocess': function('neomake#makers#ft#javascript#FlowProcess') + \ } +endfunction + +function! neomake#makers#ft#javascript#FlowProcess(entry) abort + let lines = split(a:entry.text, '\n') + if !empty(lines) + let a:entry.text = join(lines[1:]) + let a:entry.length = lines[0] - a:entry.col + 1 + endif +endfunction + +function! neomake#makers#ft#javascript#xo() abort + return { + \ 'args': ['--compact'], + \ 'errorformat': '%E%f: line %l\, col %c\, Error - %m,' . + \ '%W%f: line %l\, col %c\, Warning - %m', + \ } +endfunction + +function! neomake#makers#ft#javascript#stylelint() abort + return neomake#makers#ft#css#stylelint() +endfunction + diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/json.vim b/dotfiles/.vim/autoload/neomake/makers/ft/json.vim new file mode 100644 index 0000000..89a38e0 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/json.vim @@ -0,0 +1,38 @@ +function! neomake#makers#ft#json#EnabledMakers() abort + return ['jsonlint'] +endfunction + +function! neomake#makers#ft#json#jsonlintpy() abort + return { + \ 'exe': 'jsonlint-py', + \ 'args': ['--strict'], + \ 'errorformat': + \ '%f:%l:%c: %trror: %m,' . + \ '%f:%l:%c: %tarning: %m,', + \ } +endfunction + +function! neomake#makers#ft#json#jsonlint() abort + return { + \ 'args': ['--compact'], + \ 'errorformat': + \ '%ELine %l:%c,'. + \ '%Z\\s%#Reason: %m,'. + \ '%C%.%#,'. + \ '%f: line %l\, col %c\, %m,'. + \ '%-G%.%#' + \ } +endfunction + +function! neomake#makers#ft#json#eslint() abort + let maker = neomake#makers#ft#javascript#eslint() + let maker.args += ['--plugin', 'json'] + return maker +endfunction + +function! neomake#makers#ft#json#eslint_d() abort + let maker = neomake#makers#ft#javascript#eslint_d() + let maker.args += ['--plugin', 'json'] + return maker +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/jsx.vim b/dotfiles/.vim/autoload/neomake/makers/ft/jsx.vim new file mode 100644 index 0000000..38d3cc3 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/jsx.vim @@ -0,0 +1,17 @@ +function! neomake#makers#ft#jsx#SupersetOf() abort + return 'javascript' +endfunction + +function! neomake#makers#ft#jsx#EnabledMakers() abort + return ['jshint', executable('eslint_d') ? 'eslint_d' : 'eslint'] +endfunction + +function! neomake#makers#ft#jsx#jsxhint() abort + return neomake#makers#ft#javascript#jshint() +endfunction + +function! neomake#makers#ft#jsx#stylelint() abort + return neomake#makers#ft#css#stylelint() +endfunction + +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/julia.vim b/dotfiles/.vim/autoload/neomake/makers/ft/julia.vim new file mode 100644 index 0000000..a6fed9f --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/julia.vim @@ -0,0 +1,24 @@ +function! neomake#makers#ft#julia#EnabledMakers() abort + return ['lint'] +endfunction + +function! neomake#makers#ft#julia#lint() abort + return { +\ 'errorformat': '%f:%l %t%*[^ ] %m', +\ 'exe': 'julia', +\ 'args': ['-e', ' +\ try +\ using Lint +\ catch +\ println("$(basename(ARGS[1])):1 E999 Install Lint.jl: Pkg.add(""Lint"")"); +\ exit(1) +\ end; +\ r = lintfile(ARGS[1]); +\ if !isempty(r) +\ display(r); +\ exit(1) +\ end +\ '] +\ } +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/kotlin.vim b/dotfiles/.vim/autoload/neomake/makers/ft/kotlin.vim new file mode 100644 index 0000000..d7273e3 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/kotlin.vim @@ -0,0 +1,12 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#kotlin#EnabledMakers() abort + return ['ktlint'] +endfunction + +function! neomake#makers#ft#kotlin#ktlint() abort + return { + \ 'errorformat': '%E%f:%l:%c: %m', + \ } +endfunction + diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/less.vim b/dotfiles/.vim/autoload/neomake/makers/ft/less.vim new file mode 100644 index 0000000..51ba941 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/less.vim @@ -0,0 +1,19 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#less#EnabledMakers() abort + return executable('stylelint') ? ['stylelint'] : ['lessc'] +endfunction + +function! neomake#makers#ft#less#lessc() abort + return { + \ 'args': ['--lint', '--no-color'], + \ 'errorformat': + \ '%m in %f on line %l\, column %c:,' . + \ '%m in %f:%l:%c,' . + \ '%-G%.%#' + \ } +endfunction + +function! neomake#makers#ft#less#stylelint() abort + return neomake#makers#ft#css#stylelint() +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/lex.vim b/dotfiles/.vim/autoload/neomake/makers/ft/lex.vim new file mode 100644 index 0000000..7dafebf --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/lex.vim @@ -0,0 +1,11 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#lex#EnabledMakers() abort + return ['flex'] +endfunction + +function! neomake#makers#ft#lex#flex() abort + return { + \ 'errorformat': '%f:%l: %m' + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/lua.vim b/dotfiles/.vim/autoload/neomake/makers/ft/lua.vim new file mode 100644 index 0000000..c0e6bce --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/lua.vim @@ -0,0 +1,33 @@ +function! neomake#makers#ft#lua#EnabledMakers() abort + return executable('luacheck') ? ['luacheck'] : ['luac'] +endfunction + +" luacheck: postprocess: use pattern (%s) for end column. +function! neomake#makers#ft#lua#PostprocessLuacheck(entry) abort + let end_col = matchstr(a:entry.pattern, '\v\d+') + if !empty(end_col) + let a:entry.length = end_col - a:entry.col + 1 + else + echom 'luacheck: no end_col: '.string(a:entry) + endif + let a:entry.pattern = '' +endfunction + +function! neomake#makers#ft#lua#luacheck() abort + " cwd: luacheck looks for .luacheckrc upwards from there. + return { + \ 'args': ['--no-color', '--formatter=plain', '--ranges', '--codes', '--filename', '%:p'], + \ 'cwd': '%:p:h', + \ 'errorformat': '%E%f:%l:%c-%s: \(%t%n\) %m', + \ 'postprocess': function('neomake#makers#ft#lua#PostprocessLuacheck'), + \ 'supports_stdin': 1, + \ } +endfunction + +function! neomake#makers#ft#lua#luac() abort + return { + \ 'args': ['-p'], + \ 'errorformat': '%*\f: %#%f:%l: %m', + \ } +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/mail.vim b/dotfiles/.vim/autoload/neomake/makers/ft/mail.vim new file mode 100644 index 0000000..54cd09e --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/mail.vim @@ -0,0 +1,8 @@ +function! neomake#makers#ft#mail#EnabledMakers() abort + return ['proselint'] +endfunction + +function! neomake#makers#ft#mail#proselint() abort + return neomake#makers#ft#text#proselint() +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/markdown.vim b/dotfiles/.vim/autoload/neomake/makers/ft/markdown.vim new file mode 100644 index 0000000..1146488 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/markdown.vim @@ -0,0 +1,97 @@ +function! neomake#makers#ft#markdown#SupersetOf() abort + return 'text' +endfunction + +function! neomake#makers#ft#markdown#EnabledMakers() abort + let makers = executable('mdl') ? ['mdl'] : ['markdownlint'] + if executable('vale') | let makers += ['vale'] | endif + return makers + neomake#makers#ft#text#EnabledMakers() +endfunction + +function! neomake#makers#ft#markdown#mdl() abort + let maker = { + \ + \ 'errorformat': + \ '%W%f:%l: %m,%-G%.%#', + \ 'output_stream': 'stdout', + \ } + function! maker.postprocess(entry) abort + if a:entry.text[0:1] ==# 'MD' + let [code, text] = split(a:entry.text, '\v^MD\d+\zs ') + let a:entry.nr = str2nr(code[2:]) + let a:entry.text = printf('%s (%s)', text, code) + endif + return a:entry + endfunction + return maker +endfunction + +function! neomake#makers#ft#markdown#markdownlint() abort + return { + \ 'errorformat': '%f: %l: %m' + \ } +endfunction + +let s:alex_supports_stdin = {} +function! neomake#makers#ft#markdown#alex() abort + let maker = { + \ 'errorformat': + \ '%P%f,' + \ .'%-Q,' + \ .'%*[ ]%l:%c-%*\d:%n%*[ ]%tarning%*[ ]%m,' + \ .'%-G%.%#' + \ } + + function! maker.supports_stdin(_jobinfo) abort + let exe = exists('*exepath') ? exepath(self.exe) : self.exe + let support = get(s:alex_supports_stdin, exe, -1) + if support == -1 + let ver = neomake#compat#systemlist(['alex', '--version']) + let ver_split = split(ver[0], '\.') + if len(ver_split) > 1 && (ver_split[0] > 0 || +ver_split[1] >= 6) + let support = 1 + else + let support = 0 + endif + let s:alex_supports_stdin[exe] = support + call neomake#log#debug('alex: stdin support: '.support.'.') + endif + if support + let self.args += ['--stdin'] + let self.tempfile_name = '' + endif + return support + endfunction + + return maker +endfunction + +function! neomake#makers#ft#markdown#ProcessVale(context) abort + let entries = [] + for [filename, items] in items(a:context['json']) + for data in items + let entry = { + \ 'maker_name': 'vale', + \ 'filename': filename, + \ 'text': data.Message, + \ 'lnum': data.Line, + \ 'col': data.Span[0], + \ 'length': data.Span[1] - data.Span[0] + 1, + \ 'type': toupper(data.Severity[0]) + \ } + call add(entries, entry) + endfor + endfor + return entries +endfunction + +function! neomake#makers#ft#markdown#vale() abort + return { + \ 'args': [ + \ '--no-wrap', + \ '--output', 'JSON' + \ ], + \ 'process_json': function('neomake#makers#ft#markdown#ProcessVale') + \ } +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/matlab.vim b/dotfiles/.vim/autoload/neomake/makers/ft/matlab.vim new file mode 100644 index 0000000..f208be6 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/matlab.vim @@ -0,0 +1,15 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#matlab#EnabledMakers() abort + return ['mlint'] +endfunction + +function! neomake#makers#ft#matlab#mlint() abort + return { + \ 'args': ['-id'], + \ 'mapexpr': "neomake_bufname.':'.v:val", + \ 'errorformat': + \ '%f:L %l (C %c): %m,'. + \ '%f:L %l (C %c-%*[0-9]): %m,', + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/moon.vim b/dotfiles/.vim/autoload/neomake/makers/ft/moon.vim new file mode 100644 index 0000000..486bea7 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/moon.vim @@ -0,0 +1,15 @@ +function! neomake#makers#ft#moon#EnabledMakers() abort + return ['moonc'] +endfunction + +function! neomake#makers#ft#moon#moonc() abort + return { + \ 'args': ['-l'], + \ 'errorformat': + \ '%-G,' . + \ '%-G>%#,' . + \ '%+P%f,'. + \ 'line\ %l:\ %m' + \ } +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/neomake_tests.vim b/dotfiles/.vim/autoload/neomake/makers/ft/neomake_tests.vim new file mode 100644 index 0000000..4d06e7a --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/neomake_tests.vim @@ -0,0 +1,58 @@ +if !exists('g:neomake_test_messages') + " Only use it during tests. + finish +endif + +function! neomake#makers#ft#neomake_tests#EnabledMakers() abort + return get(b:, 'neomake_test_enabledmakers', + \ get(g:, 'neomake_test_enabledmakers', + \ ['maker_without_exe', 'nonexisting'])) +endfunction + +function! neomake#makers#ft#neomake_tests#maker_without_exe() abort + return {} +endfunction + +function! neomake#makers#ft#neomake_tests#maker_with_nonstring_exe() abort + return {'exe': function('tr')} +endfunction + +function! neomake#makers#ft#neomake_tests#echo_maker() abort + return { + \ 'exe': 'printf', + \ 'args': 'neomake_tests_echo_maker', + \ 'errorformat': '%m', + \ 'append_file': 0, + \ } +endfunction + +function! neomake#makers#ft#neomake_tests#echo_args() abort + return { + \ 'exe': 'echo', + \ 'errorformat': '%m', + \ } +endfunction + +function! neomake#makers#ft#neomake_tests#true() abort + return {} +endfunction + +function! neomake#makers#ft#neomake_tests#error_maker() abort + return { + \ 'exe': 'printf', + \ 'args': ['%s:1:error_msg_1'], + \ 'errorformat': '%E%f:%l:%m', + \ 'append_file': 1, + \ 'short_name': 'errmkr', + \ } +endfunction + +function! neomake#makers#ft#neomake_tests#process_output_error() abort + let maker = {'exe': 'echo', 'args': 'output', 'append_file': 0} + + function! maker.process_output(...) abort + return [{'valid': 1, 'text': 'error', 'lnum': 1, 'bufnr': bufnr('%')}] + endfunction + return maker +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/nim.vim b/dotfiles/.vim/autoload/neomake/makers/ft/nim.vim new file mode 100644 index 0000000..68b72a3 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/nim.vim @@ -0,0 +1,16 @@ +function! neomake#makers#ft#nim#EnabledMakers() abort + return ['nim'] +endfunction + +function! neomake#makers#ft#nim#nim() abort + return { + \ 'exe': 'nim', + \ 'args': ['--listFullPaths', '--verbosity:0', '--colors:off', + \ '-c', 'check'], + \ 'errorformat': + \ '%I%f(%l\, %c) Hint: %m,' . + \ '%W%f(%l\, %c) Warning: %m,' . + \ '%E%f(%l\, %c) Error: %m' + \ } +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/nix.vim b/dotfiles/.vim/autoload/neomake/makers/ft/nix.vim new file mode 100644 index 0000000..f239789 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/nix.vim @@ -0,0 +1,14 @@ +" vim: ts=4 sw=4 et +" +function! neomake#makers#ft#nix#EnabledMakers() abort + return ['nix_instantiate'] +endfunction + +function! neomake#makers#ft#nix#nix_instantiate() abort + return { + \ 'exe': 'nix-instantiate', + \ 'args': ['--parse-only'], + \ 'errorformat': 'error: %m at %f:%l:%c' + \ } +endfunction + diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/node.vim b/dotfiles/.vim/autoload/neomake/makers/ft/node.vim new file mode 100644 index 0000000..a6cd321 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/node.vim @@ -0,0 +1,9 @@ +function! neomake#makers#ft#node#SupersetOf() abort + return 'javascript' +endfunction + +function! neomake#makers#ft#node#EnabledMakers() abort + return ['jshint', 'eslint', 'jscs'] +endfunction + +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/objc.vim b/dotfiles/.vim/autoload/neomake/makers/ft/objc.vim new file mode 100644 index 0000000..5b093f4 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/objc.vim @@ -0,0 +1,55 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#objc#EnabledMakers() abort + let makers = ['clang', 'clangtidy', 'clangcheck'] + return makers +endfunction + +function! neomake#makers#ft#objc#clang() abort + " We will enable ARC and disable warnings about unused parameters because + " it is quite common in Cocoa not to use every method parameter. + return { + \ 'args': ['-fsyntax-only', '-fobjc-arc', '-Wall', '-Wextra', '-Wno-unused-parameter'], + \ 'errorformat': + \ '%-G%f:%s:,' . + \ '%f:%l:%c: %trror: %m,' . + \ '%f:%l:%c: %tarning: %m,' . + \ '%I%f:%l:%c: note: %m,' . + \ '%f:%l:%c: %m,'. + \ '%f:%l: %trror: %m,'. + \ '%f:%l: %tarning: %m,'. + \ '%I%f:%l: note: %m,'. + \ '%f:%l: %m' + \ } +endfunction + +" The -p option followed by the path to the build directory should be set in +" the maker's arguments. That directory should contain the compile command +" database (compile_commands.json). +function! neomake#makers#ft#objc#clangtidy() abort + return { + \ 'exe': 'clang-tidy', + \ 'errorformat': + \ '%E%f:%l:%c: fatal error: %m,' . + \ '%E%f:%l:%c: error: %m,' . + \ '%W%f:%l:%c: warning: %m,' . + \ '%-G%\m%\%%(LLVM ERROR:%\|No compilation database found%\)%\@!%.%#,' . + \ '%E%m', + \ } +endfunction + +function! neomake#makers#ft#objc#clangcheck() abort + return { + \ 'exe': 'clang-check', + \ 'errorformat': + \ '%-G%f:%s:,' . + \ '%f:%l:%c: %trror: %m,' . + \ '%f:%l:%c: %tarning: %m,' . + \ '%I%f:%l:%c: note: %m,' . + \ '%f:%l:%c: %m,'. + \ '%f:%l: %trror: %m,'. + \ '%f:%l: %tarning: %m,'. + \ '%I%f:%l: note: %m,'. + \ '%f:%l: %m', + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/pandoc.vim b/dotfiles/.vim/autoload/neomake/makers/ft/pandoc.vim new file mode 100644 index 0000000..ae56b04 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/pandoc.vim @@ -0,0 +1,8 @@ +function! neomake#makers#ft#pandoc#SupersetOf() abort + return 'markdown' +endfunction + +function! neomake#makers#ft#pandoc#EnabledMakers() abort + return neomake#makers#ft#markdown#EnabledMakers() +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/perl.vim b/dotfiles/.vim/autoload/neomake/makers/ft/perl.vim new file mode 100644 index 0000000..da07694 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/perl.vim @@ -0,0 +1,34 @@ +" vim: ts=4 sw=4 et +function! neomake#makers#ft#perl#EnabledMakers() abort + return ['perl', 'perlcritic'] +endfunction + +function! neomake#makers#ft#perl#perlcritic() abort + return { + \ 'args' : ['--quiet', '--nocolor', '--verbose', + \ '\\%f:\\%l:\\%c:(\\%s) \\%m (\\%e)\\n'], + \ 'errorformat': '%f:%l:%c:%m,' + \} +endfunction + +function! neomake#makers#ft#perl#perl() abort + return { + \ 'args' : ['-c', '-X', '-Mwarnings'], + \ 'errorformat': '%-G%.%#had too many errors.,' + \ . '%-G%.%#had compilation errors.,' + \ . '%-G%.%#syntax OK,' + \ . '%m at %f line %l.,' + \ . '%+E%.%# at %f line %l\,%.%#,' + \ . '%+C%.%#', + \ 'postprocess': function('neomake#makers#ft#perl#PerlEntryProcess'), + \} +endfunction + +function! neomake#makers#ft#perl#PerlEntryProcess(entry) abort + let extramsg = substitute(a:entry.pattern, '\^\\V', '', '') + let extramsg = substitute(extramsg, '\\\$', '', '') + + if !empty(extramsg) + let a:entry.text .= ' ' . extramsg + endif +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/php.vim b/dotfiles/.vim/autoload/neomake/makers/ft/php.vim new file mode 100644 index 0000000..7edefa3 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/php.vim @@ -0,0 +1,72 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#php#EnabledMakers() abort + return ['php', 'phpmd', 'phpcs', 'phpstan'] +endfunction + +function! neomake#makers#ft#php#php() abort + return { + \ 'args': ['-l', '-d', 'display_errors=1', '-d', 'log_errors=0', + \ '-d', 'xdebug.cli_color=0'], + \ 'errorformat': + \ '%-GNo syntax errors detected in%.%#,'. + \ '%EParse error: %#syntax error\, %m in %f on line %l,'. + \ '%EParse error: %m in %f on line %l,'. + \ '%EFatal error: %m in %f on line %l,'. + \ '%-G\s%#,'. + \ '%-GErrors parsing %.%#', + \ 'output_stream': 'stdout', + \ } +endfunction + +function! neomake#makers#ft#php#phpcs() abort + let args = ['--report=csv', '-q'] + + "Add standard argument if one is set. + if exists('g:neomake_php_phpcs_args_standard') + call add(args, '--standard=' . expand(g:neomake_php_phpcs_args_standard)) + endif + + return { + \ 'args': args, + \ 'errorformat': + \ '%-GFile\,Line\,Column\,Type\,Message\,Source\,Severity%.%#,'. + \ '"%f"\,%l\,%c\,%t%*[a-zA-Z]\,"%m"\,%*[a-zA-Z0-9_.-]\,%*[0-9]%.%#', + \ } +endfunction + +function! neomake#makers#ft#php#phpmd() abort + return { + \ 'args': ['%t', 'text', 'codesize,design,unusedcode,naming'], + \ 'append_file': 0, + \ 'errorformat': '%W%f:%l%\s%\s%#%m' + \ } +endfunction + +function! neomake#makers#ft#php#phpstan() abort + " PHPStan normally considers 0 to be the default level, so that is used here as the default: + let maker = { + \ 'args': ['analyse', '--error-format', 'raw', '--no-progress', '--level', get(g:, 'neomake_phpstan_level', 0)], + \ 'errorformat': '%E%f:%l:%m', + \ } + " Check for the existence of a default PHPStan project configuration file. + " Technically PHPStan does not have a concept of a default filename for a + " project configuration file, but phpstan.neon is the filename shown in the + " example in the PHPStan documentation, so this is the default name expected + " by Neomake. + let phpStanConfigFilePath = neomake#utils#FindGlobFile('phpstan.neon') + if !empty(phpStanConfigFilePath) + call extend(maker.args, ['-c', phpStanConfigFilePath]) + endif + return maker +endfunction + +function! neomake#makers#ft#php#psalm() abort + let maker = { + \ 'args': [ + \ '--output-format=pylint' + \ ], + \ 'errorformat': '%A%f:%l:%\s[%t%n]%\s%m', + \ } + return maker +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/proto.vim b/dotfiles/.vim/autoload/neomake/makers/ft/proto.vim new file mode 100644 index 0000000..fcff577 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/proto.vim @@ -0,0 +1,12 @@ +function! neomake#makers#ft#proto#EnabledMakers() abort + return ['prototool'] +endfunction + +function! neomake#makers#ft#proto#prototool() abort + return { + \ 'exe': 'prototool', + \ 'args': ['lint'], + \ 'errorformat': '%f:%l:%c:%m', + \ } +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/pug.vim b/dotfiles/.vim/autoload/neomake/makers/ft/pug.vim new file mode 100644 index 0000000..53f2214 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/pug.vim @@ -0,0 +1,13 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#pug#EnabledMakers() abort + return ['puglint'] +endfunction + +function! neomake#makers#ft#pug#puglint() abort + return { + \ 'exe': 'pug-lint', + \ 'args': ['--reporter', 'inline'], + \ 'errorformat': '%f:%l:%c %m' + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/puppet.vim b/dotfiles/.vim/autoload/neomake/makers/ft/puppet.vim new file mode 100644 index 0000000..c7a467d --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/puppet.vim @@ -0,0 +1,29 @@ +function! neomake#makers#ft#puppet#EnabledMakers() abort + return ['puppet', 'puppetlint'] +endfunction + +function! neomake#makers#ft#puppet#puppetlint() abort + return { + \ 'exe': 'puppet-lint', + \ 'args': ['--log-format', '%%{path}:%%{line}:%%{column}:%%{kind}:[%%{check}] %%{message}'], + \ 'errorformat': '%f:%l:%c:%t%*[a-zA-Z]:%m', + \ 'short_name': 'pupl', + \ 'output_stream': 'stdout', + \ } +endfunction + +function! neomake#makers#ft#puppet#puppet() abort + return { + \ 'args': ['parser', 'validate', '--color=false'], + \ 'errorformat': + \ '%-Gerr: Try ''puppet help parser validate'' for usage,' . + \ '%-GError: Try ''puppet help parser validate'' for usage,' . + \ '%t%*[a-zA-Z]: %m at %f:%l:%c,' . + \ '%t%*[a-zA-Z]: %m at %f:%l,'. + \ '%t%*[a-zA-Z]: Could not parse for environment production: %m (file: %f\, line: %l\, column: %c),' . + \ '%t%*[a-zA-Z]: Could not parse for environment production: %m (file: %f)', + \ 'short_name': 'pupp', + \ 'output_stream': 'stderr', + \ } +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/purescript.vim b/dotfiles/.vim/autoload/neomake/makers/ft/purescript.vim new file mode 100644 index 0000000..a26a40f --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/purescript.vim @@ -0,0 +1,63 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#purescript#EnabledMakers() abort + return ['pulp'] +endfunction + +function! neomake#makers#ft#purescript#pulp() abort + " command is `pulp build --no-psa -- --json-errors` + " as indicated in https://github.com/nwolverson/atom-ide-purescript/issues/136 + let maker = { + \ 'args': ['build', '--no-psa', '--', '--json-errors'], + \ 'append_file': 0, + \ 'process_output': function('neomake#makers#ft#purescript#PSProcessOutput'), + \ } + + " Find project root, since files are reported relative to it. + let bower_file = neomake#utils#FindGlobFile('bower.json') + if !empty(bower_file) + let maker.cwd = fnamemodify(bower_file, ':h') + endif + + return maker +endfunction + +function! neomake#makers#ft#purescript#PSProcessOutput(context) abort + let errors = [] + for line in a:context.output + if line[0] !=# '{' + continue + endif + let decoded = neomake#compat#json_decode(line) + for [key, values] in items(decoded) + let code = key ==# 'warnings' ? 'W' : 'E' + for item in values + let compiler_error = item['errorCode'] + let message = item['message'] + let position = item['position'] + let filename = item['filename'] + if position is g:neomake#compat#json_null + let row = 1 + let col = 1 + let end_col = 1 + let length = 1 + else + let row = position['startLine'] + let col = position['startColumn'] + let end_col = position['endColumn'] + let length = end_col - col + endif + + call add(errors, { + \ 'text': compiler_error . ' : ' . message, + \ 'type': code, + \ 'lnum': row, + \ 'col': col, + \ 'length': length, + \ 'filename': filename, + \ }) + endfor + endfor + endfor + return errors +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/python.vim b/dotfiles/.vim/autoload/neomake/makers/ft/python.vim new file mode 100644 index 0000000..d8c8369 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/python.vim @@ -0,0 +1,419 @@ +" vim: ts=4 sw=4 et + +if !exists('s:compile_script') + let s:slash = neomake#utils#Slash() + let s:compile_script = expand(':p:h', 1).s:slash.'python'.s:slash.'compile.py' +endif + +function! neomake#makers#ft#python#EnabledMakers() abort + let makers = ['python', 'frosted'] + if executable('pylama') + call add(makers, 'pylama') + else + if executable('flake8') + call add(makers, 'flake8') + else + call extend(makers, ['pyflakes', 'pycodestyle', 'pydocstyle']) + endif + call add(makers, 'pylint') " Last because it is the slowest + endif + return makers +endfunction + +let neomake#makers#ft#python#project_root_files = ['setup.cfg', 'tox.ini'] + +function! neomake#makers#ft#python#DetectPythonVersion() abort + let output = neomake#compat#systemlist('python -V 2>&1') + if v:shell_error + call neomake#log#error(printf( + \ 'Failed to detect Python version: %s.', + \ join(output))) + let s:python_version = [-1, -1, -1] + else + let s:python_version = split(split(output[0])[1], '\.') + endif +endfunction + +let s:ignore_python_warnings = [ + \ '\v[\/]inspect.py:\d+: Warning:', + \ '\v^.{-}:\d+: FutureWarning:', + \ ] + +" Filter Python warnings (the warning and the following line). +" To be used as a funcref with filter(). +function! s:filter_py_warning(v) abort + if s:filter_next_py_warning + let s:filter_next_py_warning = 0 + " Only keep (expected) lines starting with two spaces. + return a:v[0:1] !=# ' ' + endif + for pattern in s:ignore_python_warnings + if a:v =~# pattern + let s:filter_next_py_warning = 1 + return 0 + endif + endfor + return 1 +endfunction + +function! neomake#makers#ft#python#FilterPythonWarnings(lines, context) abort + if a:context.source ==# 'stderr' + let s:filter_next_py_warning = 0 + call filter(a:lines, 's:filter_py_warning(v:val)') + endif +endfunction + +function! neomake#makers#ft#python#pylint() abort + let maker = { + \ 'args': [ + \ '--output-format=text', + \ '--msg-template="{path}:{line}:{column}:{C}: [{symbol}] {msg} [{msg_id}]"', + \ '--reports=no' + \ ], + \ 'errorformat': + \ '%A%f:%l:%c:%t: %m,' . + \ '%A%f:%l: %m,' . + \ '%A%f:(%l): %m,' . + \ '%-Z%p^%.%#,' . + \ '%-G%.%#', + \ 'output_stream': 'stdout', + \ 'postprocess': [ + \ function('neomake#postprocess#generic_length'), + \ function('neomake#makers#ft#python#PylintEntryProcess'), + \ ]} + function! maker.filter_output(lines, context) abort + if a:context.source ==# 'stderr' + call filter(a:lines, "v:val !=# 'No config file found, using default configuration' && v:val !~# '^Using config file '") + endif + call neomake#makers#ft#python#FilterPythonWarnings(a:lines, a:context) + endfunction + return maker +endfunction + +function! neomake#makers#ft#python#PylintEntryProcess(entry) abort + if a:entry.type ==# 'F' " Fatal error which prevented further processing + let type = 'E' + elseif a:entry.type ==# 'E' " Error for important programming issues + let type = 'E' + elseif a:entry.type ==# 'W' " Warning for stylistic or minor programming issues + let type = 'W' + elseif a:entry.type ==# 'R' " Refactor suggestion + let type = 'W' + elseif a:entry.type ==# 'C' " Convention violation + let type = 'W' + elseif a:entry.type ==# 'I' " Informations + let type = 'I' + else + let type = '' + endif + let a:entry.type = type + " Pylint uses 0-indexed columns, vim uses 1-indexed columns + let a:entry.col += 1 +endfunction + +function! neomake#makers#ft#python#flake8() abort + let maker = { + \ 'args': ['--format=default'], + \ 'errorformat': + \ '%E%f:%l: could not compile,%-Z%p^,' . + \ '%A%f:%l:%c: %t%n %m,' . + \ '%A%f:%l: %t%n %m,' . + \ '%-G%.%#', + \ 'postprocess': function('neomake#makers#ft#python#Flake8EntryProcess'), + \ 'short_name': 'fl8', + \ 'output_stream': 'stdout', + \ 'filter_output': function('neomake#makers#ft#python#FilterPythonWarnings'), + \ } + + function! maker.supports_stdin(jobinfo) abort + let self.args += ['--stdin-display-name', '%:p'] + + let bufpath = bufname(a:jobinfo.bufnr) + if !empty(bufpath) + let bufdir = fnamemodify(bufpath, ':p:h') + if stridx(bufdir, getcwd()) != 0 + " The buffer is not below the current dir, so let's cd for lookup + " of config files etc. + " This avoids running into issues with flake8's per-file-ignores, + " which is handled not relative to the config file currently + " (https://gitlab.com/pycqa/flake8/issues/517). + call a:jobinfo.cd(bufdir) + endif + endif + return 1 + endfunction + return maker +endfunction + +function! neomake#makers#ft#python#Flake8EntryProcess(entry) abort + if a:entry.type ==# 'F' " pyflakes + " Ref: http://flake8.pycqa.org/en/latest/user/error-codes.html + if a:entry.nr > 400 && a:entry.nr < 500 + if a:entry.nr == 407 + let type = 'E' " 'an undefined __future__ feature name was imported' + else + let type = 'W' + endif + elseif a:entry.nr == 841 + let type = 'W' + else + let type = 'E' + endif + elseif a:entry.type ==# 'E' && a:entry.nr >= 900 " PEP8 runtime errors (E901, E902) + let type = 'E' + elseif a:entry.type ==# 'E' || a:entry.type ==# 'W' " PEP8 errors & warnings + let type = 'W' + elseif a:entry.type ==# 'N' || a:entry.type ==# 'D' " Naming (PEP8) & docstring (PEP257) conventions + let type = 'W' + elseif a:entry.type ==# 'C' || a:entry.type ==# 'T' " McCabe complexity & todo notes + let type = 'I' + elseif a:entry.type ==# 'I' " keep at least 'I' from isort (I1), could get style subtype?! + let type = a:entry.type + else + let type = '' + endif + + let token_pattern = '\v''\zs[^'']+\ze' + if a:entry.type ==# 'F' && (a:entry.nr == 401 || a:entry.nr == 811) + " Special handling for F401 (``module`` imported but unused) and + " F811 (redefinition of unused ``name`` from line ``N``). + " The unused column is incorrect for import errors and redefinition + " errors. + let token = matchstr(a:entry.text, token_pattern) + if !empty(token) + let view = winsaveview() + call cursor(a:entry.lnum, a:entry.col) + " The number of lines to give up searching afterwards + let search_lines = 5 + + if searchpos('\', 'cnW', a:entry.lnum)[1] == a:entry.col + " for 'from xxx.yyy import zzz' the token looks like + " xxx.yyy.zzz, but only the zzz part should be highlighted. So + " this discards the module part + let token = split(token, '\.')[-1] + + " Also the search should be started at the import keyword. + " Otherwise for 'from os import os' the first os will be + " found. This moves the cursor there. + call search('\', 'cW', a:entry.lnum + search_lines) + endif + + " Search for the first occurrence of the token and highlight in + " the next couple of lines and change the lnum and col to that + " position. + " Don't match entries surrounded by dots, even though + " it ends a word, we want to find a full identifier. It also + " matches all seperators such as spaces and newlines with + " backslashes until it knows for sure the previous real character + " was not a dot. + let ident_pos = searchpos('\(\.\(\_s\|\\\)*\)\@\(\(\_s\|\\\)*\.\)\@!', + \ 'cnW', + \ a:entry.lnum + search_lines) + if ident_pos[1] > 0 + let a:entry.lnum = ident_pos[0] + let a:entry.col = ident_pos[1] + endif + + call winrestview(view) + + let a:entry.length = strlen(token) + endif + else + call neomake#postprocess#generic_length_with_pattern(a:entry, token_pattern) + + " Special processing for F821 (undefined name) in f-strings. + if !has_key(a:entry, 'length') && a:entry.type ==# 'F' && a:entry.nr == 821 + let token = matchstr(a:entry.text, token_pattern) + if !empty(token) + " Search for '{token}' in reported and following lines. + " It seems like for the first line it is correct already (i.e. + " flake8 reports the column therein), but we still test there + " to be sure. + " https://gitlab.com/pycqa/flake8/issues/407 + let line = get(getbufline(a:entry.bufnr, a:entry.lnum), 0, '') + " NOTE: uses byte offset, starting at col means to start after + " the opening quote. + let pattern = '\V\C{\.\{-}\zs'.escape(token, '\').'\>' + let pos = match(line, pattern, a:entry.col) + if pos == -1 + let line_offset = 0 + while line_offset < 10 + let line_offset += 1 + let line = get(getbufline(a:entry.bufnr, a:entry.lnum + line_offset), 0, '') + let pos = match(line, pattern) + if pos != -1 + let a:entry.lnum = a:entry.lnum + line_offset + break + endif + endwhile + endif + if pos > 0 + let a:entry.col = pos + 1 + let a:entry.length = strlen(token) + endif + endif + endif + endif + + let a:entry.text = a:entry.type . a:entry.nr . ' ' . a:entry.text + let a:entry.type = type + " Reset "nr" to Avoid redundancy with neomake#GetCurrentErrorMsg. + " TODO: This is rather bad, since "nr" itself can be useful. + " This should rather use the entry via Neomake's list, and then a + " new property like "current_error_text" could be used. + " Or with the maker being available a callback could be used. + let a:entry.nr = -1 +endfunction + +function! neomake#makers#ft#python#pyflakes() abort + return { + \ 'errorformat': + \ '%E%f:%l: could not compile,' . + \ '%-Z%p^,'. + \ '%E%f:%l:%c: %m,' . + \ '%E%f:%l: %m,' . + \ '%-G%.%#', + \ } +endfunction + +function! neomake#makers#ft#python#pycodestyle() abort + if !exists('s:_pycodestyle_exe') + " Use the preferred exe to avoid deprecation warnings. + let s:_pycodestyle_exe = executable('pycodestyle') ? 'pycodestyle' : 'pep8' + endif + return { + \ 'exe': s:_pycodestyle_exe, + \ 'errorformat': '%f:%l:%c: %m', + \ 'postprocess': function('neomake#makers#ft#python#Pep8EntryProcess') + \ } +endfunction + +" Note: pep8 has been renamed to pycodestyle, but is kept also as alias. +function! neomake#makers#ft#python#pep8() abort + return neomake#makers#ft#python#pycodestyle() +endfunction + +function! neomake#makers#ft#python#Pep8EntryProcess(entry) abort + if a:entry.text =~# '^E9' " PEP8 runtime errors (E901, E902) + let a:entry.type = 'E' + elseif a:entry.text =~# '^E113' " unexpected indentation (IndentationError) + let a:entry.type = 'E' + else " Everything else is a warning + let a:entry.type = 'W' + endif +endfunction + +function! neomake#makers#ft#python#pydocstyle() abort + if !exists('s:_pydocstyle_exe') + " Use the preferred exe to avoid deprecation warnings. + let s:_pydocstyle_exe = executable('pydocstyle') ? 'pydocstyle' : 'pep257' + endif + return { + \ 'exe': s:_pydocstyle_exe, + \ 'errorformat': + \ '%W%f:%l %.%#:,' . + \ '%+C %m', + \ 'postprocess': function('neomake#postprocess#compress_whitespace'), + \ } +endfunction + +" Note: pep257 has been renamed to pydocstyle, but is kept also as alias. +function! neomake#makers#ft#python#pep257() abort + return neomake#makers#ft#python#pydocstyle() +endfunction + +function! neomake#makers#ft#python#PylamaEntryProcess(entry) abort + if a:entry.nr == -1 + " Get number from the beginning of text. + let nr = matchstr(a:entry.text, '\v^\u\zs\d+') + if !empty(nr) + let a:entry.nr = nr + 0 + endif + endif + if a:entry.type ==# 'C' && a:entry.text =~# '\v\[%(pycodestyle|pep8)\]$' + call neomake#makers#ft#python#Pep8EntryProcess(a:entry) + elseif a:entry.type ==# 'D' " pydocstyle/pep257 + let a:entry.type = 'W' + elseif a:entry.type ==# 'C' && a:entry.nr == 901 " mccabe + let a:entry.type = 'I' + elseif a:entry.type ==# 'R' " Radon + let a:entry.type = 'W' + endif +endfunction + +function! neomake#makers#ft#python#pylama() abort + let maker = { + \ 'args': ['--format', 'parsable'], + \ 'errorformat': '%f:%l:%c: [%t] %m', + \ 'postprocess': function('neomake#makers#ft#python#PylamaEntryProcess'), + \ 'output_stream': 'stdout', + \ } + " Pylama looks for the config only in the current directory. + " Therefore we change to where the config likely is. + " --options could be used to pass a config file, but we cannot be sure + " which one really gets used. + let ini_file = neomake#utils#FindGlobFile('{pylama.ini,setup.cfg,tox.ini,pytest.ini}') + if !empty(ini_file) + let maker.cwd = fnamemodify(ini_file, ':h') + endif + return maker +endfunction + +function! neomake#makers#ft#python#python() abort + return { + \ 'args': [s:compile_script], + \ 'errorformat': '%E%f:%l:%c: %m', + \ 'serialize': 1, + \ 'serialize_abort_on_error': 1, + \ 'output_stream': 'stdout', + \ 'short_name': 'py', + \ } +endfunction + +function! neomake#makers#ft#python#frosted() abort + return { + \ 'args': [ + \ '-vb' + \ ], + \ 'errorformat': + \ '%f:%l:%c:%m,' . + \ '%E%f:%l: %m,' . + \ '%-Z%p^,' . + \ '%-G%.%#' + \ } +endfunction + +function! neomake#makers#ft#python#vulture() abort + return { + \ 'errorformat': '%f:%l: %m', + \ } +endfunction + +" --fast-parser: adds experimental support for async/await syntax +" --silent-imports: replaced by --ignore-missing-imports +function! neomake#makers#ft#python#mypy() abort + let args = ['--check-untyped-defs', '--ignore-missing-imports'] + + " Append '--py2' to args with Python 2 for Python 2 mode. + if !exists('s:python_version') + call neomake#makers#ft#python#DetectPythonVersion() + endif + if s:python_version[0] ==# '2' + call add(args, '--py2') + endif + + return { + \ 'args': args, + \ 'errorformat': + \ '%E%f:%l: error: %m,' . + \ '%W%f:%l: warning: %m,' . + \ '%I%f:%l: note: %m', + \ } +endfunction + +function! neomake#makers#ft#python#py3kwarn() abort + return { + \ 'errorformat': '%W%f:%l:%c: %m', + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/python/compile.py b/dotfiles/.vim/autoload/neomake/makers/ft/python/compile.py new file mode 100755 index 0000000..d211673 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/python/compile.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python + +from __future__ import print_function +from sys import argv, exit + + +if len(argv) != 2: + exit(64) + +try: + compile(open(argv[1]).read(), argv[1], 'exec', 0, 1) +except SyntaxError as err: + print('%s:%s:%s: %s' % (err.filename, err.lineno, err.offset, err.msg)) + exit(1) diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/r.vim b/dotfiles/.vim/autoload/neomake/makers/ft/r.vim new file mode 100644 index 0000000..59f488a --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/r.vim @@ -0,0 +1,17 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#r#EnabledMakers() abort + return ['lintr'] +endfunction + +function! neomake#makers#ft#r#lintr() abort + return { + \ 'exe': 'R', + \ 'args': ['--slave', '--no-restore', '--no-save', '-e lintr::lint("%t")'], + \ 'append_file': 0, + \ 'errorformat': + \ '%W%f:%l:%c: style: %m,' . + \ '%W%f:%l:%c: warning: %m,' . + \ '%E%f:%l:%c: error: %m,' + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/racket.vim b/dotfiles/.vim/autoload/neomake/makers/ft/racket.vim new file mode 100644 index 0000000..fc7145a --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/racket.vim @@ -0,0 +1,32 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#racket#EnabledMakers() abort + return ['raco'] +endfunction + +" This is the same form of syntax-checking used by DrRacket as well. The +" downside is that it will only catch the first error, but none of the +" subsequent ones. This is due to how evaluation in Racket works. +" +" About the error format: raco will print the first line as +" :: +" Every successive line will be indented by two spaces: +" in: +" context...: +" ::: +" The last pattern will be repeated as often as necessary. Example: +" foo.rkt:4:1: dfine: unbound identifier in modulemessage +" in: dfine +" context...: +" /usr/local/Cellar/racket/6.5/share/racket/pkgs/compiler-lib/compiler/commands/expand.rkt:34:15: loop +" /usr/local/Cellar/racket/6.5/share/racket/pkgs/compiler-lib/compiler/commands/expand.rkt:10:2: show-program +" /usr/local/Cellar/racket/6.5/share/racket/pkgs/compiler-lib/compiler/commands/expand.rkt: [running body] +" /usr/local/Cellar/minimal-racket/6.6/share/racket/collects/raco/raco.rkt: [running body] +" /usr/local/Cellar/minimal-racket/6.6/share/racket/collects/raco/main.rkt: [running body] +function! neomake#makers#ft#racket#raco() abort + return { + \ 'exe': 'raco', + \ 'args': ['expand'], + \ 'errorformat': '%-G %.%#,%E%f:%l:%c: %m' + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/rst.vim b/dotfiles/.vim/autoload/neomake/makers/ft/rst.vim new file mode 100644 index 0000000..a7874ec --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/rst.vim @@ -0,0 +1,89 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#rst#SupersetOf() abort + return 'text' +endfunction + +" Get Sphinx source dir for the current buffer (determined by looking for +" conf.py, typically in docs/ or doc/). +" Caches the value in a buffer-local setting. +function! s:get_sphinx_srcdir() abort + let srcdir = neomake#config#get('sphinx.source_dir') + if srcdir isnot# g:neomake#config#undefined + return srcdir + endif + + let r = '' + let project_root = neomake#utils#get_project_root() + let bufname = bufname('%') + if empty(bufname) + call neomake#log#debug('sphinx: skipping setting of source_dir for empty bufname.', {'bufnr': bufnr('%')}) + return '' + endif + let f = findfile('conf.py', printf('%s;%s', fnamemodify(bufname, ':p:h'), project_root)) + if !empty(f) + let r = fnamemodify(f, ':p:h') + endif + call neomake#log#debug(printf('sphinx: setting b:neomake.sphinx.source_dir=%s.', string(r)), {'bufnr': bufnr('%')}) + call neomake#config#set('b:sphinx.source_dir', r) + return r +endfunction + +function! neomake#makers#ft#rst#EnabledMakers() abort + if executable('sphinx-build') && !empty(s:get_sphinx_srcdir()) + return ['sphinx'] + endif + return ['rstlint', 'rstcheck'] +endfunction + +function! neomake#makers#ft#rst#rstlint() abort + return { + \ 'exe': 'rst-lint', + \ 'errorformat': + \ '%ESEVERE %f:%l %m,'. + \ '%EERROR %f:%l %m,'. + \ '%WWARNING %f:%l %m,'. + \ '%IINFO %f:%l %m,'. + \ '%C%m', + \ 'postprocess': function('neomake#postprocess#compress_whitespace'), + \ 'output_stream': 'stdout', + \ } +endfunction + +function! neomake#makers#ft#rst#rstcheck() abort + return { + \ 'errorformat': + \ '%I%f:%l: (INFO/1) %m,'. + \ '%W%f:%l: (WARNING/2) %m,'. + \ '%E%f:%l: (ERROR/3) %m,'. + \ '%E%f:%l: (SEVERE/4) %m', + \ } +endfunction + +function! neomake#makers#ft#rst#sphinx() abort + " TODO: + " - project mode (after cleanup branch) + let srcdir = s:get_sphinx_srcdir() + if empty(srcdir) + throw 'Neomake: sphinx: could not find conf.py (you can configure sphinx.source_dir)' + endif + if !exists('s:sphinx_cache') + let s:sphinx_cache = tempname() + endif + " NOTE: uses '%Z%m,%-G%.%#' instead of '%C%m,%-G' to include next line in + " multiline errors (fixed in 7.4.203). + return { + \ 'exe': 'sphinx-build', + \ 'args': ['-n', '-E', '-q', '-N', '-b', 'dummy', srcdir, s:sphinx_cache], + \ 'append_file': 0, + \ 'errorformat': + \ '%f:%l: %tARNING: %m,' . + \ '%EWARNING: %f:%l: (SEVER%t/4) %m,' . + \ '%EWARNING: %f:%l: (%tRROR/3) %m,' . + \ '%EWARNING: %f:%l: (%tARNING/2) %m,' . + \ '%Z%m,' . + \ '%-G%.%#', + \ 'output_stream': 'stderr', + \ 'postprocess': function('neomake#postprocess#compress_whitespace'), + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/ruby.vim b/dotfiles/.vim/autoload/neomake/makers/ft/ruby.vim new file mode 100644 index 0000000..ceb6a46 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/ruby.vim @@ -0,0 +1,90 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#ruby#EnabledMakers() abort + return ['flog', 'mri', 'rubocop', 'reek', 'rubylint'] +endfunction + +function! neomake#makers#ft#ruby#rubocop() abort + return { + \ 'args': ['--format', 'emacs', '--force-exclusion', '--display-cop-names'], + \ 'errorformat': '%f:%l:%c: %t: %m,%E%f:%l: %m', + \ 'postprocess': function('neomake#makers#ft#ruby#RubocopEntryProcess'), + \ 'output_stream': 'stdout', + \ } +endfunction + +function! neomake#makers#ft#ruby#RubocopEntryProcess(entry) abort + if a:entry.type ==# 'F' " Fatal error which prevented further processing + let a:entry.type = 'E' + elseif a:entry.type ==# 'E' " Error for important programming issues + let a:entry.type = 'E' + elseif a:entry.type ==# 'W' " Warning for stylistic or minor programming issues + let a:entry.type = 'W' + elseif a:entry.type ==# 'R' " Refactor suggestion + let a:entry.type = 'W' + elseif a:entry.type ==# 'C' " Convention violation + let a:entry.type = 'I' + endif +endfunction + +function! neomake#makers#ft#ruby#rubylint() abort + return { + \ 'exe': 'ruby-lint', + \ 'args': ['--presenter', 'syntastic'], + \ 'errorformat': '%f:%t:%l:%c: %m', + \ } +endfunction + +function! neomake#makers#ft#ruby#mri() abort + let errorformat = '%-G%\m%.%#warning: %\%%(possibly %\)%\?useless use of == in void context,' + let errorformat .= '%-G%\%.%\%.%\%.%.%#,' + let errorformat .= + \ '%-GSyntax OK,'. + \ '%E%f:%l: syntax error\, %m,'. + \ '%Z%p^,'. + \ '%W%f:%l: warning: %m,'. + \ '%Z%p^,'. + \ '%W%f:%l: %m,'. + \ '%-C%.%#' + + return { + \ 'exe': 'ruby', + \ 'args': ['-c', '-T1', '-w'], + \ 'errorformat': errorformat, + \ 'output_stream': 'both', + \ } +endfunction + +function! neomake#makers#ft#ruby#jruby() abort + let errorformat = + \ '%-GSyntax OK for %f,'. + \ '%ESyntaxError in %f:%l: syntax error\, %m,'. + \ '%Z%p^,'. + \ '%W%f:%l: warning: %m,'. + \ '%Z%p^,'. + \ '%W%f:%l: %m,'. + \ '%-C%.%#' + + return { + \ 'exe': 'jruby', + \ 'args': ['-c', '-T1', '-w'], + \ 'errorformat': errorformat + \ } +endfunction + +function! neomake#makers#ft#ruby#reek() abort + return { + \ 'args': ['--format', 'text', '--single-line'], + \ 'errorformat': '%W%f:%l: %m', + \ } +endfunction + +function! neomake#makers#ft#ruby#flog() abort + return { + \ 'errorformat': + \ '%W%m %f:%l-%c,' . + \ '%-G\s%#,' . + \ '%-G%.%#: flog total,' . + \ '%-G%.%#: flog/method average,' + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/rust.vim b/dotfiles/.vim/autoload/neomake/makers/ft/rust.vim new file mode 100644 index 0000000..71ddec1 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/rust.vim @@ -0,0 +1,233 @@ +function! neomake#makers#ft#rust#EnabledMakers() abort + return ['cargo'] +endfunction + +function! neomake#makers#ft#rust#rustc() abort + return { + \ 'errorformat': + \ '%-Gerror: aborting due to previous error,'. + \ '%-Gerror: aborting due to %\\d%\\+ previous errors,'. + \ '%-Gerror: Could not compile `%s`.,'. + \ '%Eerror[E%n]: %m,'. + \ '%Eerror: %m,'. + \ '%Wwarning: %m,'. + \ '%Inote: %m,'. + \ '%-Z\ %#-->\ %f:%l:%c,'. + \ '%G\ %#\= %*[^:]: %m,'. + \ '%G\ %#|\ %#%\\^%\\+ %m,'. + \ '%I%>help:\ %#%m,'. + \ '%Z\ %#%m,'. + \ '%-G%.%#', + \ } +endfunction + +function! s:get_cargo_workspace_root() abort + if !exists('b:_neomake_cargo_workspace') + let cmd = 'cargo metadata --no-deps --format-version 1' + let [cd_error, cd_back_cmd] = neomake#utils#temp_cd(expand('%:h')) + if !empty(cd_error) + call neomake#log#debug(printf( + \ 's:get_cargo_workspace_root: failed to cd to buffer directory: %s.', + \ cd_error)) + endif + let output = system(cmd) + if !empty(cd_back_cmd) + exe cd_back_cmd + endif + if v:shell_error + call neomake#log#debug(printf( + \ 'Failed to get cargo metadata for workspace using %s.', + \ string(cmd))) + let b:_neomake_cargo_workspace = '' + else + let json = neomake#compat#json_decode(output) + let b:_neomake_cargo_workspace = json['workspace_root'] + endif + endif + return b:_neomake_cargo_workspace +endfunction + +function! s:get_cargo_maker_cwd(default) abort + let cargo_workspace_root = s:get_cargo_workspace_root() + if !empty(cargo_workspace_root) + return cargo_workspace_root + endif + + let cargo_toml = neomake#utils#FindGlobFile('Cargo.toml') + if !empty(cargo_toml) + return fnamemodify(cargo_toml, ':h') + endif + + return a:default +endfunction + +function! neomake#makers#ft#rust#cargotest() abort + " NOTE: duplicates are removed due to https://github.com/rust-lang/cargo/issues/5128. + let maker = { + \ 'exe': 'cargo', + \ 'args': ['test', '%:t:r', '--quiet'], + \ 'append_file': 0, + \ 'uses_filename': 0, + \ 'postprocess': copy(g:neomake#postprocess#remove_duplicates), + \ 'errorformat': + \ '%-G,' . + \ '%-Gtest %s,' . + \ '%-Grunning %\\d%# test%s,' . + \ '%-Gfailures:%s,' . + \ '%-G----%s,' . + \ '%-G%.%#--verbose%s,' . + \ '%-G%.%#--explain%s,' . + \ '%-Gerror: aborting due to previous error,' . + \ '%-G%\ %#error: aborting due to %\\d%#%\ %#previous errors,' . + \ '%E%\ %#error[E%n]:\ %m,' . + \ '%E%\ %#error:\ %m,' . + \ '%I%\ %#note:\ %m,'. + \ '%W%\ %#warning:\ %m,' . + \ '%-Z%\ %#-->\ %f:%l:%c,' . + \ '%-G%\\d%# %#|\ %s,' . + \ '%-G%\\d%# %#|,' . + \ '%-G\ %#\= %*[^:]:\ %m,'. + \ '%E%\ %#%m,' . + \ '%G%\ %#%s%\\,,' . + \ '%Z%\ %#%s%\\,%\\s%f:%l:%c' + \ } + + function! maker.InitForJob(_jobinfo) abort + if !has_key(self, 'cwd') + let self.cwd = s:get_cargo_maker_cwd('%:p:h') + return self + endif + endfunction + return maker +endfunction + +function! neomake#makers#ft#rust#cargo() abort + let maker_command = get(b:, 'neomake_rust_cargo_command', + \ get(g:, 'neomake_rust_cargo_command', ['check'])) + let maker = { + \ 'args': maker_command + ['--message-format=json', '--quiet'], + \ 'append_file': 0, + \ 'process_output': function('neomake#makers#ft#rust#CargoProcessOutput'), + \ } + + function! maker.InitForJob(_jobinfo) abort + if !has_key(self, 'cwd') + let self.cwd = s:get_cargo_maker_cwd('%:p:h') + return self + endif + endfunction + return maker +endfunction + +" NOTE: does not use process_json, since cargo outputs multiple JSON root +" elements per line. +function! neomake#makers#ft#rust#CargoProcessOutput(context) abort + let errors = [] + for line in a:context['output'] + if line[0] !=# '{' + continue + endif + + let decoded = neomake#compat#json_decode(line) + let data = get(decoded, 'message', -1) + if type(data) != type({}) || empty(data['spans']) + continue + endif + + let error = {'maker_name': 'cargo'} + let code_dict = get(data, 'code', -1) + if code_dict is g:neomake#compat#json_null + if get(data, 'level', '') ==# 'warning' + let error.type = 'W' + else + let error.type = 'E' + endif + else + let error.type = code_dict['code'][0] + let error.nr = code_dict['code'][1:] + endif + + let span = data.spans[0] + for candidate_span in data.spans + if candidate_span.is_primary + let span = candidate_span + break + endif + endfor + + let expanded = 0 + let has_expansion = type(span.expansion) == type({}) + \ && type(span.expansion.span) == type({}) + \ && type(span.expansion.def_site_span) == type({}) + + if span.file_name =~# '^<.*>$' && has_expansion + let expanded = 1 + call neomake#makers#ft#rust#FillErrorFromSpan(error, + \ span.expansion.span) + else + call neomake#makers#ft#rust#FillErrorFromSpan(error, span) + endif + + let error.text = data.message + let detail = span.label + let children = data.children + if type(detail) == type('') && !empty(detail) + let error.text = error.text . ': ' . detail + elseif !empty(children) && has_key(children[0], 'message') + let error.text = error.text . '. ' . children[0].message + endif + + call add(errors, error) + + if has_expansion && !expanded + let error = copy(error) + call neomake#makers#ft#rust#FillErrorFromSpan(error, + \ span.expansion.span) + call add(errors, error) + endif + + for child in children[1:] + if !has_key(child, 'message') + continue + endif + + let info = deepcopy(error) + let info.type = 'I' + let info.text = child.message + call neomake#postprocess#compress_whitespace(info) + if has_key(child, 'rendered') + \ && !(child.rendered is g:neomake#compat#json_null) + let info.text = info.text . ': ' . child.rendered + endif + + if len(child.spans) + let span = child.spans[0] + if span.file_name =~# '^<.*>$' + \ && type(span.expansion) == type({}) + \ && type(span.expansion.span) == type({}) + \ && type(span.expansion.def_site_span) == type({}) + call neomake#makers#ft#rust#FillErrorFromSpan(info, + \ span.expansion.span) + else + call neomake#makers#ft#rust#FillErrorFromSpan(info, span) + endif + let detail = span.label + if type(detail) == type('') && len(detail) + let info.text = info.text . ': ' . detail + endif + endif + + call add(errors, info) + endfor + endfor + return errors +endfunction + +function! neomake#makers#ft#rust#FillErrorFromSpan(error, span) abort + let a:error.filename = a:span.file_name + let a:error.col = a:span.column_start + let a:error.lnum = a:span.line_start + let a:error.length = a:span.byte_end - a:span.byte_start +endfunction + +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/scala.vim b/dotfiles/.vim/autoload/neomake/makers/ft/scala.vim new file mode 100644 index 0000000..0899881 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/scala.vim @@ -0,0 +1,40 @@ +" vim: ts=4 sw=4 et +function! neomake#makers#ft#scala#EnabledMakers() abort + " use let g:neomake_scala_enabled_makers = ['fsc','scalastyle'] for fsc + let makers = ['scalac', 'scalastyle'] + return makers +endfunction + +function! neomake#makers#ft#scala#fsc() abort + return { + \ 'args': [ + \ '-Ystop-after:parser' + \ ], + \ 'errorformat': + \ '%E%f:%l: %trror: %m,' . + \ '%Z%p^,' . + \ '%-G%.%#' + \ } +endfunction + +function! neomake#makers#ft#scala#scalac() abort + return { + \ 'args': [ + \ '-Ystop-after:parser' + \ ], + \ 'errorformat': + \ '%E%f:%l: %trror: %m,' . + \ '%Z%p^,' . + \ '%-G%.%#' + \ } +endfunction + +function! neomake#makers#ft#scala#scalastyle() abort + return { + \ 'errorformat': + \ '%trror file=%f message=%m line=%l column=%c,' . + \ '%trror file=%f message=%m line=%l,' . + \ '%tarning file=%f message=%m line=%l column=%c,' . + \ '%tarning file=%f message=%m line=%l' + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/scss.vim b/dotfiles/.vim/autoload/neomake/makers/ft/scss.vim new file mode 100644 index 0000000..e33ea6f --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/scss.vim @@ -0,0 +1,25 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#scss#EnabledMakers() abort + return executable('stylelint') ? ['stylelint'] : executable('sass-lint') ? ['sasslint'] : ['scsslint'] +endfunction + +function! neomake#makers#ft#scss#sasslint() abort + return { + \ 'exe': 'sass-lint', + \ 'args': ['--no-exit', '--verbose', '--format', 'compact'], + \ 'errorformat': neomake#makers#ft#javascript#eslint()['errorformat'] + \ } +endfunction + +function! neomake#makers#ft#scss#scsslint() abort + return { + \ 'exe': 'scss-lint', + \ 'errorformat': '%A%f:%l:%v [%t] %m,' . + \ '%A%f:%l [%t] %m' + \ } +endfunction + +function! neomake#makers#ft#scss#stylelint() abort + return neomake#makers#ft#css#stylelint() +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/serpent.vim b/dotfiles/.vim/autoload/neomake/makers/ft/serpent.vim new file mode 100644 index 0000000..eff20ba --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/serpent.vim @@ -0,0 +1,13 @@ +function! neomake#makers#ft#serpent#EnabledMakers() abort + return ['serplint'] +endfunction + +function! neomake#makers#ft#serpent#serplint() abort + return { + \ 'exe': 'serplint', + \ 'args': [], + \ 'errorformat': + \ '%f:%l:%c %t%n %m', + \ } +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/sh.vim b/dotfiles/.vim/autoload/neomake/makers/ft/sh.vim new file mode 100644 index 0000000..00889b9 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/sh.vim @@ -0,0 +1,86 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#sh#EnabledMakers() abort + return ['sh', 'shellcheck'] +endfunction + +let s:shellcheck = { + \ 'args': ['-fgcc', '-x'], + \ 'errorformat': + \ '%f:%l:%c: %trror: %m [SC%n],' . + \ '%f:%l:%c: %tarning: %m [SC%n],' . + \ '%I%f:%l:%c: Note: %m [SC%n]', + \ 'output_stream': 'stdout', + \ 'short_name': 'SC', + \ 'cwd': '%:h', + \ } + +function! neomake#makers#ft#sh#shellcheck() abort + let maker = deepcopy(s:shellcheck) + + let line1 = getline(1) + if match(line1, '\v^#!.*<%(sh|dash|bash|ksh)') < 0 + \ && match(line1, '\v^#\s*shellcheck\s+shell\=') < 0 + " shellcheck does not read the shebang by itself. + let ext = expand('%:e') + if ext ==# 'ksh' + let maker.args += ['-s', 'ksh'] + elseif ext ==# 'sh' + if exists('g:is_sh') + let maker.args += ['-s', 'sh'] + elseif exists('g:is_posix') || exists('g:is_kornshell') + let maker.args += ['-s', 'ksh'] + else + let maker.args += ['-s', 'bash'] + endif + else + let maker.args += ['-s', 'bash'] + endif + endif + return maker +endfunction + +function! neomake#makers#ft#sh#checkbashisms() abort + return { + \ 'args': ['-fx'], + \ 'errorformat': + \ '%-Gscript %f is already a bash script; skipping,' . + \ '%Eerror: %f: %m\, opened in line %l,' . + \ '%Eerror: %f: %m,' . + \ '%Ecannot open script %f for reading: %m,' . + \ '%Wscript %f %m,%C%.# lines,' . + \ '%Wpossible bashism in %f line %l (%m):,%C%.%#,%Z.%#,' . + \ '%-G%.%#', + \ 'output_stream': 'stderr', + \ } +endfunction + +function! neomake#makers#ft#sh#sh() abort + let shebang = matchstr(getline(1), '^#!\s*\zs.*$') + if !empty(shebang) + let l = split(shebang) + let exe = l[0] + let args = l[1:] + ['-n'] + else + let exe = '/usr/bin/env' + let args = ['sh', '-n'] + endif + + " NOTE: the format without "line" is used by dash. + return { + \ 'exe': exe, + \ 'args': args, + \ 'errorformat': + \ '%E%f: line %l: %m,' . + \ '%E%f: %l: %m', + \ 'output_stream': 'stderr', + \} +endfunction + +function! neomake#makers#ft#sh#dash() abort + return { + \ 'args': ['-n'], + \ 'errorformat': '%E%f: %l: %m', + \ 'output_stream': 'stderr', + \} +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/slim.vim b/dotfiles/.vim/autoload/neomake/makers/ft/slim.vim new file mode 100644 index 0000000..931f57f --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/slim.vim @@ -0,0 +1,13 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#slim#EnabledMakers() abort + return ['slimlint'] +endfunction + +function! neomake#makers#ft#slim#slimlint() abort + return { + \ 'exe': 'slim-lint', + \ 'args': ['--no-color'], + \ 'errorformat': '%f:%l [%t] %m' + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/sml.vim b/dotfiles/.vim/autoload/neomake/makers/ft/sml.vim new file mode 100644 index 0000000..46e0bd0 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/sml.vim @@ -0,0 +1,19 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#sml#EnabledMakers() abort + return ['smlnj'] +endfunction + +" This comes straight out of syntastic. +function! neomake#makers#ft#sml#smlnj() abort + return { + \ 'exe': 'sml', + \ 'errorformat': + \ '%E%f:%l%\%.%c %trror: %m,' . + \ '%E%f:%l%\%.%c-%\d%\+%\%.%\d%\+ %trror: %m,' . + \ '%W%f:%l%\%.%c %tarning: %m,' . + \ '%W%f:%l%\%.%c-%\d%\+%\%.%\d%\+ %tarning: %m,' . + \ '%C%\s%\+%m,' . + \ '%-G%.%#' + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/solidity.vim b/dotfiles/.vim/autoload/neomake/makers/ft/solidity.vim new file mode 100644 index 0000000..200e910 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/solidity.vim @@ -0,0 +1,16 @@ +function! neomake#makers#ft#solidity#EnabledMakers() abort + return ['solium', 'solhint'] +endfunction + +function! neomake#makers#ft#solidity#solium() abort + return { + \ 'args': ['--reporter', 'gcc', '--file'], + \ 'errorformat': + \ '%f:%l:%c: %t%s: %m', + \ } +endfunction + +function! neomake#makers#ft#solidity#solhint() abort + return neomake#makers#ft#javascript#eslint() +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/spar.vim b/dotfiles/.vim/autoload/neomake/makers/ft/spar.vim new file mode 100644 index 0000000..9efe7a1 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/spar.vim @@ -0,0 +1,13 @@ +function! neomake#makers#ft#spar#EnabledMakers() abort + return ['spar'] +endfunction + +function! neomake#makers#ft#spar#spar() abort + return { + \ 'args': ['-g', '-c'], + \ 'errorformat': + \ '%f:%l:%c: %m', + \ 'nvim_job_opts': {'pty': 1} + \ } +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/spec.vim b/dotfiles/.vim/autoload/neomake/makers/ft/spec.vim new file mode 100644 index 0000000..2723340 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/spec.vim @@ -0,0 +1,16 @@ +function! neomake#makers#ft#spec#EnabledMakers() abort + return ['rpmlint'] +endfunction + +function! neomake#makers#ft#spec#rpmlint() abort + return { + \ 'errorformat': + \ '%E%f:%l: E: %m,' . + \ '%E%f: E: %m,' . + \ '%W%f:%l: W: %m,' . + \ '%W%f: W: %m,' . + \ '%-G%.%#' + \ } +endfunction + +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/sql.vim b/dotfiles/.vim/autoload/neomake/makers/ft/sql.vim new file mode 100644 index 0000000..bdbfdfa --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/sql.vim @@ -0,0 +1,13 @@ +function! neomake#makers#ft#sql#EnabledMakers() abort + return ['sqlint'] +endfunction + +function! neomake#makers#ft#sql#sqlint() abort + return { + \ 'errorformat': + \ '%E%f:%l:%c:ERROR %m,' . + \ '%W%f:%l:%c:WARNING %m,' . + \ '%C %m' + \ } +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/stylus.vim b/dotfiles/.vim/autoload/neomake/makers/ft/stylus.vim new file mode 100644 index 0000000..113a194 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/stylus.vim @@ -0,0 +1,16 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#stylus#EnabledMakers() abort + return ['stylint'] +endfunction + +function! neomake#makers#ft#stylus#stylint() abort + return { + \ 'errorformat': + \ '%WWarning: %m,' . + \ '%EError: %m,' . + \ '%-Csee file: %f for the original selector,' . + \ '%CFile: %f,' . + \ '%ZLine: %l:%.%#' + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/swift.vim b/dotfiles/.vim/autoload/neomake/makers/ft/swift.vim new file mode 100644 index 0000000..76bb440 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/swift.vim @@ -0,0 +1,54 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#swift#EnabledMakers() abort + if !empty(s:get_swiftpm_config()) + return ['swiftpm'] + endif + return ['swiftc'] +endfunction + +function! s:get_swiftpm_config() abort + return neomake#utils#FindGlobFile('Package.swift') +endfunction + +function! s:get_swiftpm_base_maker() abort + let maker = { + \ 'exe': 'swift', + \ 'append_file': 0, + \ 'errorformat': + \ '%E%f:%l:%c: error: %m,' . + \ '%E%f:%l: error: %m,' . + \ '%W%f:%l:%c: warning: %m,' . + \ '%Z%\s%#^~%#,' . + \ '%-G%.%#', + \ } + let config = s:get_swiftpm_config() + if !empty(config) + let maker.cwd = fnamemodify(config, ':h') + endif + return maker +endfunction + +function! neomake#makers#ft#swift#swiftpm() abort + let maker = s:get_swiftpm_base_maker() + let maker.args = ['build', '--build-tests'] + return maker +endfunction + +function! neomake#makers#ft#swift#swiftpmtest() abort + let maker = s:get_swiftpm_base_maker() + let maker.args = ['test'] + return maker +endfunction + +function! neomake#makers#ft#swift#swiftc() abort + " `export SDKROOT="$(xcodebuild -version -sdk macosx Path)"` + return { + \ 'args': ['-parse'], + \ 'errorformat': + \ '%E%f:%l:%c: error: %m,' . + \ '%W%f:%l:%c: warning: %m,' . + \ '%Z%\s%#^~%#,' . + \ '%-G%.%#', + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/tcl.vim b/dotfiles/.vim/autoload/neomake/makers/ft/tcl.vim new file mode 100644 index 0000000..76c5af4 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/tcl.vim @@ -0,0 +1,15 @@ +function! neomake#makers#ft#tcl#EnabledMakers() abort + return ['nagelfar'] +endfunction + +function! neomake#makers#ft#tcl#nagelfar() abort + return { + \ 'exe': 'nagelfar', + \ 'args': ['-H'], + \ 'errorformat': + \ '%I%f: %l: N %m,' . + \ '%f: %l: %t %m,' . + \ '%-GChecking file %f' + \ } +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/tex.vim b/dotfiles/.vim/autoload/neomake/makers/ft/tex.vim new file mode 100644 index 0000000..9fca53b --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/tex.vim @@ -0,0 +1,69 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#tex#EnabledMakers() abort + return ['chktex', 'lacheck', 'rubberinfo', 'proselint'] +endfunction + +function! neomake#makers#ft#tex#chktex() abort + let maker = { + \ 'args': [], + \ 'errorformat': + \ '%EError %n in %f line %l: %m,' . + \ '%WWarning %n in %f line %l: %m,' . + \ '%WMessage %n in %f line %l: %m,' . + \ '%Z%p^,' . + \ '%-G%.%#' + \ } + let rcfile = neomake#utils#FindGlobFile('.chktexrc') + if !empty(rcfile) + let maker.args += ['-l', fnamemodify(rcfile, ':h')] + endif + return maker +endfunction + +function! neomake#makers#ft#tex#lacheck() abort + return { + \ 'errorformat': + \ '%-G** %f:,' . + \ '%E"%f"\, line %l: %m' + \ } +endfunction + +function! neomake#makers#ft#tex#rubber() abort + return { + \ 'args': ['--pdf', '-f', '--warn=all'], + \ 'errorformat': + \ '%f:%l: %m,' . + \ '%f: %m' + \ } +endfunction + +function! neomake#makers#ft#tex#rubberinfo() abort + return { + \ 'exe': 'rubber-info', + \ 'errorformat': + \ '%f:%l: %m,' . + \ '%f:%l-%\d%\+: %m,' . + \ '%f: %m' + \ } +endfunction + +function! neomake#makers#ft#tex#latexrun() abort + return { + \ 'args': ['--color', 'never'], + \ 'errorformat': + \ '%f:%l: %m' + \ } +endfunction + +function! neomake#makers#ft#tex#pdflatex() abort + return { + \ 'exe': 'pdflatex', + \ 'args': ['-shell-escape', '-file-line-error', '-interaction', 'nonstopmode'], + \ 'errorformat': '%E%f:%l: %m' + \ } +endfunction + +function! neomake#makers#ft#tex#proselint() abort + return neomake#makers#ft#text#proselint() +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/text.vim b/dotfiles/.vim/autoload/neomake/makers/ft/text.vim new file mode 100644 index 0000000..a1ebe0a --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/text.vim @@ -0,0 +1,30 @@ +function! neomake#makers#ft#text#EnabledMakers() abort + " No makers enabled by default, since text is used as fallback often. + return [] +endfunction + +function! neomake#makers#ft#text#proselint() abort + return { + \ 'errorformat': '%W%f:%l:%c: %m', + \ 'postprocess': function('neomake#postprocess#generic_length'), + \ } +endfunction + +function! neomake#makers#ft#text#PostprocessWritegood(entry) abort + let a:entry.col += 1 + if a:entry.text[0] ==# '"' + let matchend = match(a:entry.text, '\v^[^"]+\zs"', 1) + if matchend != -1 + let a:entry.length = matchend - 1 + endif + endif +endfunction + +function! neomake#makers#ft#text#writegood() abort + return { + \ 'args': ['--parse'], + \ 'errorformat': '%W%f:%l:%c:%m,%C%m,%-G', + \ 'postprocess': function('neomake#makers#ft#text#PostprocessWritegood'), + \ } +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/toml.vim b/dotfiles/.vim/autoload/neomake/makers/ft/toml.vim new file mode 100644 index 0000000..d314911 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/toml.vim @@ -0,0 +1,15 @@ +function! neomake#makers#ft#toml#EnabledMakers() abort + return ['tomlcheck'] +endfunction + +function! neomake#makers#ft#toml#tomlcheck() abort + return { + \ 'args': ['-f'], + \ 'errorformat': + \ '%E%f:%l:%c:,' . + \ '%E%m' + \ } +endfunction + +" vim: et sw=4 ts=4 +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/tsx.vim b/dotfiles/.vim/autoload/neomake/makers/ft/tsx.vim new file mode 100644 index 0000000..2a31b4d --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/tsx.vim @@ -0,0 +1,15 @@ +function! neomake#makers#ft#tsx#SupersetOf() abort + return 'typescript' +endfunction + +function! neomake#makers#ft#tsx#EnabledMakers() abort + return ['tsc', 'tslint'] +endfunction + +function! neomake#makers#ft#tsx#tsc() abort + let config = neomake#makers#ft#typescript#tsc() + let config.args = config.args + ['--jsx', 'preserve'] + return config +endfunction + +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/typescript.vim b/dotfiles/.vim/autoload/neomake/makers/ft/typescript.vim new file mode 100644 index 0000000..4d011b7 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/typescript.vim @@ -0,0 +1,45 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#typescript#EnabledMakers() abort + return ['tsc', 'tslint'] +endfunction + +function! neomake#makers#ft#typescript#tsc() abort + " tsc should not be passed a single file. + let maker = { + \ 'args': ['--noEmit', '--watch', 'false', '--pretty', 'false'], + \ 'append_file': 0, + \ 'errorformat': + \ '%E%f %#(%l\,%c): error %m,' . + \ '%E%f %#(%l\,%c): %m,' . + \ '%Eerror %m,' . + \ '%C%\s%\+%m' + \ } + let config = neomake#utils#FindGlobFile('tsconfig.json') + if !empty(config) + let maker.args += ['--project', config] + endif + return maker +endfunction + +function! neomake#makers#ft#typescript#tslint() abort + " NOTE: output format changed in tslint 5.12.0. + let maker = { + \ 'args': ['-t', 'prose'], + \ 'errorformat': '%-G,' + \ .'%EERROR: %f:%l:%c - %m,' + \ .'%WWARNING: %f:%l:%c - %m,' + \ .'%EERROR: %f[%l\, %c]: %m,' + \ .'%WWARNING: %f[%l\, %c]: %m', + \ } + let config = neomake#utils#FindGlobFile('tsconfig.json') + if !empty(config) + let maker.args += ['--project', config] + let maker.cwd = fnamemodify(config, ':h') + endif + return maker +endfunction + +function! neomake#makers#ft#typescript#eslint() abort + return neomake#makers#ft#javascript#eslint() +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/verilog.vim b/dotfiles/.vim/autoload/neomake/makers/ft/verilog.vim new file mode 100644 index 0000000..78d9189 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/verilog.vim @@ -0,0 +1,16 @@ +function! neomake#makers#ft#verilog#EnabledMakers() abort + return ['iverilog'] +endfunction + +function! neomake#makers#ft#verilog#iverilog() abort + return { + \ 'args' : ['-tnull', '-Wall', '-y./'], + \ 'cwd' : '%:h', + \ 'errorformat' : '%f:%l: %trror: %m,' . + \ '%f:%l: %tarning: %m,' . + \ '%E%f:%l: : %m,' . + \ '%W%f:%l: : %m,' . + \ '%f:%l: %m', + \ } +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/vhdl.vim b/dotfiles/.vim/autoload/neomake/makers/ft/vhdl.vim new file mode 100644 index 0000000..dffa813 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/vhdl.vim @@ -0,0 +1,12 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#vhdl#EnabledMakers() abort + return ['ghdl'] +endfunction + +function! neomake#makers#ft#vhdl#ghdl() abort + return { + \ 'args' : ['-s'], + \ 'errorformat' : '%E%f:%l:%c: %m', + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/vim.vim b/dotfiles/.vim/autoload/neomake/makers/ft/vim.vim new file mode 100644 index 0000000..8cd1318 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/vim.vim @@ -0,0 +1,87 @@ +function! neomake#makers#ft#vim#EnabledMakers() abort + return ['vint'] +endfunction + +let s:slash = neomake#utils#Slash() +let s:neomake_root = expand(':p:h:h:h:h:h', 1) + +let s:vint_supports_stdin = {} + +function! neomake#makers#ft#vim#neomake_checks() abort + let maker = { + \ 'exe': join([s:neomake_root, 'contrib', 'vim-checks'], s:slash), + \ 'errorformat': '%f:%l: %m', + \ } + + return maker +endfunction + +function! neomake#makers#ft#vim#vint() abort + let args = ['--style-problem', '--no-color', + \ '-f', '{file_path}:{line_number}:{column_number}:{severity}:{description} ({policy_name})'] + + if has('nvim') + call add(args, '--enable-neovim') + endif + + let maker = { + \ 'args': args, + \ 'errorformat': '%I%f:%l:%c:style_problem:%m,' + \ .'%f:%l:%c:%t%*[^:]:E%n: %m,' + \ .'%f:%l:%c:%t%*[^:]:%m', + \ 'output_stream': 'stdout', + \ 'postprocess': { + \ 'fn': function('neomake#postprocess#generic_length'), + \ 'pattern': '\v%(^:|%([^:]+: ))\zs(\S+)', + \ }} + + function! maker.supports_stdin(_jobinfo) abort + let exe = exists('*exepath') ? exepath(self.exe) : self.exe + let support = get(s:vint_supports_stdin, exe, -1) + if support == -1 + let ver = neomake#compat#systemlist(['vint', '--version']) + let ver_split = split(ver[0], '\.') + if len(ver_split) > 1 && (ver_split[0] > 0 || +ver_split[1] >= 4) + let support = 1 + else + let support = 0 + endif + let s:vint_supports_stdin[exe] = support + call neomake#log#debug('vint: stdin support: '.support.'.') + endif + if support + let self.args += ['--stdin-display-name', '%:.'] + endif + return support + endfunction + return maker +endfunction + +function! neomake#makers#ft#vim#vimlint() abort + return { + \ 'args': ['-u'], + \ 'errorformat': '%f:%l:%c:%trror: EVL%n: %m,' + \ . '%f:%l:%c:%tarning: EVL%n: %m,' + \ . '%f:%l:%c:%t%*[^:]: EVP_%#E%#%n: %m', + \ 'postprocess': function('neomake#makers#ft#vim#PostprocessVimlint'), + \ 'output_stream': 'stdout', + \ } +endfunction + +function! neomake#makers#ft#vim#PostprocessVimlint(entry) abort + let m = matchlist(a:entry.text, '\v`\zs[^`]{-}\ze`') + if empty(m) + return + endif + + " Ensure that the text is there. + let l = len(m[0]) + let line = getline(a:entry.lnum) + if line[a:entry.col-1 : a:entry.col-2+l] == m[0] + let a:entry.length = l + elseif m[0][0:1] ==# 'l:' && line[a:entry.col-1 : a:entry.col-4+l] == m[0][2:] + " Ignore implicit 'l:' prefix. + let a:entry.length = l - 2 + endif +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/vue.vim b/dotfiles/.vim/autoload/neomake/makers/ft/vue.vim new file mode 100644 index 0000000..d9f5303 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/vue.vim @@ -0,0 +1,28 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#vue#EnabledMakers() abort + return ['eslint', 'standard'] +endfunction + +function! neomake#makers#ft#vue#eslint() abort + let maker = neomake#makers#ft#javascript#eslint() + call extend(get(maker, 'args', []), ['--plugin', 'html']) + return maker +endfunction + +function! neomake#makers#ft#vue#eslint_d() abort + return neomake#makers#ft#vue#eslint() +endfunction + +function! neomake#makers#ft#vue#standard() abort + let maker = neomake#makers#ft#javascript#standard() + call extend(get(maker, 'args', []), ['--plugin', 'html']) + return maker +endfunction + +function! neomake#makers#ft#vue#semistandard() abort + let maker = neomake#makers#ft#javascript#semistandard() + call extend(get(maker, 'args', []), ['--plugin', 'html']) + return maker +endfunction + diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/xml.vim b/dotfiles/.vim/autoload/neomake/makers/ft/xml.vim new file mode 100644 index 0000000..75b6996 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/xml.vim @@ -0,0 +1,25 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#xml#EnabledMakers() abort + return ['xmllint'] +endfunction + +function! neomake#makers#ft#xml#xmllint() abort + let args = ['--xinclude', '--postvalid', '--noout'] + + return { + \ 'args': args, + \ 'supports_stdin': 1, + \ 'errorformat': + \ '%E%f:%l: error : %m,' . + \ '%-G%f:%l: validity error : Validation failed: no DTD found %m,' . + \ '%W%f:%l: warning : %m,' . + \ '%W%f:%l: validity warning : %m,' . + \ '%E%f:%l: validity error : %m,' . + \ '%E%f:%l: parser error : %m,' . + \ '%E%f:%l: %m,' . + \ '%-Z%p^,' . + \ '%-C%.%#,' . + \ '%-G%.%#', + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/xslt.vim b/dotfiles/.vim/autoload/neomake/makers/ft/xslt.vim new file mode 100644 index 0000000..61bcf02 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/xslt.vim @@ -0,0 +1,8 @@ +function! neomake#makers#ft#xslt#EnabledMakers() abort + return ['xmllint'] +endfunction + +function! neomake#makers#ft#xslt#xmllint() abort + return neomake#makers#ft#xml#xmllint() +endfunction +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/yacc.vim b/dotfiles/.vim/autoload/neomake/makers/ft/yacc.vim new file mode 100644 index 0000000..8a2edd5 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/yacc.vim @@ -0,0 +1,17 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#yacc#EnabledMakers() abort + return ['bison'] +endfunction + +function! neomake#makers#ft#yacc#bison() abort + return { + \ 'errorformat': + \ '%E%f:%l%.%v-%.%\{-}: %trror: %m,' . + \ '%E%f:%l%.%v: %trror: %m,' . + \ '%W%f:%l%.%v-%.%\{-}: %tarning: %m,' . + \ '%W%f:%l%.%v: %tarning: %m,' . + \ '%I%f:%l%.%v-%.%\{-}: %\s%\+%m,' . + \ '%I%f:%l%.%v: %\s%\+%m' + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/yaml.vim b/dotfiles/.vim/autoload/neomake/makers/ft/yaml.vim new file mode 100644 index 0000000..338ca8c --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/yaml.vim @@ -0,0 +1,12 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#yaml#EnabledMakers() abort + return ['yamllint'] +endfunction + +function! neomake#makers#ft#yaml#yamllint() abort + return { + \ 'args': ['-f', 'parsable'], + \ 'errorformat': '%E%f:%l:%c: [error] %m,%W%f:%l:%c: [warning] %m', + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/ft/zsh.vim b/dotfiles/.vim/autoload/neomake/makers/ft/zsh.vim new file mode 100644 index 0000000..a63e365 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/ft/zsh.vim @@ -0,0 +1,19 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#ft#zsh#EnabledMakers() abort + return ['zsh'] +endfunction + +" Note: newer versions of shellcheck do not support zsh. +function! neomake#makers#ft#zsh#shellcheck() abort + let maker = neomake#makers#ft#sh#shellcheck() + let maker.args += ['--shell', 'zsh'] + return maker +endfunction + +function! neomake#makers#ft#zsh#zsh() abort + return { + \ 'args': ['-n'], + \ 'errorformat': '%E%f:%l: %m' + \} +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/gradle.vim b/dotfiles/.vim/autoload/neomake/makers/gradle.vim new file mode 100644 index 0000000..de892a7 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/gradle.vim @@ -0,0 +1,28 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#gradle#gradle() abort + let g:gradleBin = filereadable('./gradlew') ? './gradlew' : 'gradle' + + return { + \ 'exe': g:gradleBin, + \ 'append_file': 0, + \ 'args': ['assemble', '--daemon'], + \ 'errorformat': '\%+ATask\ %.%#\ not\ found\ %.%#.,'. + \'%EExecution\ failed\ for\ task\ %m,'. + \'findbugs:\ %tarning\ %f:%l:%c\ %m,'. + \'pmd:\ %tarning\ %f:%l:%c\ %m,'. + \'checkstyle:\ %tarning\ %f:%l:%c\ %m,'. + \'lint:\ %tarning\ %f:%l:%c\ %m,'. + \'%A>\ %f:%l:%c:\ %trror:\ %m,'. + \'%A>\ %f:%l:%c:\ %tarning:\ %m,'. + \'%A%f:%l:\ %trror:\ %m,'. + \'%A%f:%l:\ %tarning:\ %m,'. + \'%A%f:%l:\ %trror\ -\ %m,'. + \'%A%f:%l:\ %tarning\ -\ %m,'. + \'%E%f:%l\ :\ %m,'. + \'%C>\ %m,'. + \'%-G%p^,'. + \'%+G\ \ %.%#,'. + \'%-G%.%#' + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/mvn.vim b/dotfiles/.vim/autoload/neomake/makers/mvn.vim new file mode 100644 index 0000000..cac2a80 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/mvn.vim @@ -0,0 +1,9 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#mvn#mvn() abort + return { + \ 'exe': 'mvn', + \ 'args': ['install'], + \ 'errorformat': '[%tRROR]\ %f:[%l]\ %m,%-G%.%#' + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/makers/sbt.vim b/dotfiles/.vim/autoload/neomake/makers/sbt.vim new file mode 100644 index 0000000..93e233b --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/makers/sbt.vim @@ -0,0 +1,13 @@ +" vim: ts=4 sw=4 et + +function! neomake#makers#sbt#sbt() abort + return { + \ 'exe': 'sbt', + \ 'args': ['-Dsbt.log.noformat=true', 'compile'], + \ 'errorformat': + \ '%E[%trror]\ %f:%l:%c:\ %m,' . + \ '%-Z[error]\ %p^,' . + \ '%-C%.%#,' . + \ '%-G%.%#' + \ } +endfunction diff --git a/dotfiles/.vim/autoload/neomake/postprocess.vim b/dotfiles/.vim/autoload/neomake/postprocess.vim new file mode 100644 index 0000000..d92a897 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/postprocess.vim @@ -0,0 +1,77 @@ +" Generic postprocessor to add `length` to `a:entry`. +" The pattern can be overridden on `self` and should adhere to this: +" - the matched word should be returned as the whole match (you can use \zs +" and \ze). +" - enclosing patterns should be returned as \1 and \2, where \1 is used as +" offset when the first entry did not match. +" See tests/postprocess.vader for tests/examples. +" See neomake#postprocess#generic_length_with_pattern for a non-dict variant. +function! neomake#postprocess#generic_length(entry) abort dict + if a:entry.lnum > 0 && a:entry.col + let pattern = get(self, 'pattern', '\v(["''`])\zs[^\1]{-}\ze(\1)') + let start = 0 + let best = 0 + while 1 + let m = matchlist(a:entry.text, pattern, start) + if empty(m) + break + endif + let l = len(m[0]) + if l > best + " Ensure that the text is there. + let line = get(getbufline(a:entry.bufnr, a:entry.lnum), 0, '') + if line[a:entry.col-1 : a:entry.col-2+l] == m[0] + let best = l + endif + endif + if exists('*matchstrpos') " vim73 + let pos = matchstrpos(a:entry.text, pattern, start) + if pos[1] == -1 + break + endif + let start += pos[2] + len(m[2]) + else + break + endif + endwhile + if best + let a:entry.length = best + endif + endif +endfunction + +" Wrapper to call neomake#process#generic_length (a dict function). +function! neomake#postprocess#generic_length_with_pattern(entry, pattern) abort + let this = {'pattern': a:pattern} + return call('neomake#postprocess#generic_length', [a:entry], this) +endfunction + +" Deprecated: renamed to neomake#postprocess#generic_length. +function! neomake#postprocess#GenericLengthPostprocess(entry) abort dict + return neomake#postprocess#generic_length(a:entry) +endfunction + +function! neomake#postprocess#compress_whitespace(entry) abort + let text = a:entry.text + let text = substitute(text, "\001", '', 'g') + let text = substitute(text, '\r\?\n', ' ', 'g') + let text = substitute(text, '\m\s\{2,}', ' ', 'g') + let text = substitute(text, '\m^\s\+', '', '') + let text = substitute(text, '\m\s\+$', '', '') + let a:entry.text = text +endfunction + +let g:neomake#postprocess#remove_duplicates = {} +function! g:neomake#postprocess#remove_duplicates.fn(entry) abort + if exists('self._seen_entries') + if index(self._seen_entries, a:entry) != -1 + let a:entry.valid = -1 + else + call add(self._seen_entries, a:entry) + endif + else + let self._seen_entries = [a:entry] + endif +endfunction +lockvar g:neomake#postprocess#remove_duplicates " Needs to be copied. +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/quickfix.vim b/dotfiles/.vim/autoload/neomake/quickfix.vim new file mode 100644 index 0000000..8e22836 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/quickfix.vim @@ -0,0 +1,363 @@ +" vim: ts=4 sw=4 et +scriptencoding utf-8 + +let s:is_enabled = 0 + +let s:match_base_priority = 10 + +" args: a:1: force enabling? (used in tests and for VimEnter callback) +function! neomake#quickfix#enable(...) abort + if has('vim_starting') && !(a:0 && a:1) + " Delay enabling for our FileType autocommand to happen as late as + " possible, since placing signs triggers a redraw, and together with + " vim-qf_resize this causes flicker. + " https://github.com/vim/vim/issues/2763 + augroup neomake_qf + autocmd! + autocmd VimEnter * call neomake#quickfix#enable(1) + augroup END + return + endif + call neomake#log#debug('enabling custom quickfix list handling.') + let s:is_enabled = 1 + augroup neomake_qf + autocmd! + autocmd FileType qf call neomake#quickfix#FormatQuickfix() + augroup END + if &filetype ==# 'qf' + call neomake#quickfix#FormatQuickfix() + endif +endfunction + +function! neomake#quickfix#disable() abort + call neomake#log#debug('disabling custom quickfix list handling.') + let s:is_enabled = 0 + if &filetype ==# 'qf' + call neomake#quickfix#FormatQuickfix() + endif + if exists('#neomake_qf') + autocmd! neomake_qf + augroup! neomake_qf + endif +endfunction + +function! neomake#quickfix#is_enabled() abort + return s:is_enabled +endfunction + +function! s:cursor_moved() abort + if b:neomake_start_col + if col('.') <= b:neomake_start_col + 1 + call cursor(line('.'), b:neomake_start_col + 2) + endif + + if exists('w:_neomake_cursor_match_id') + silent! call matchdelete(w:_neomake_cursor_match_id) + endif + if exists('*matchaddpos') + let w:_neomake_cursor_match_id = matchaddpos('neomakeCursorListNr', + \ [[line('.'), (b:neomake_start_col - b:neomake_number_len) + 2, b:neomake_number_len]], + \ s:match_base_priority+3) + else + let w:_neomake_cursor_match_id = matchadd('neomakeCursorListNr', + \ '\%' . line('.') . 'c' + \. '\%' . ((b:neomake_start_col - b:neomake_number_len) + 2) . 'c' + \. '.\{' . b:neomake_number_len . '}', + \ s:match_base_priority+3) + endif + endif +endfunction + +function! s:set_qf_lines(lines) abort + let ul = &l:undolevels + setlocal modifiable nonumber undolevels=-1 + + call setline(1, a:lines) + + let &l:undolevels = ul + setlocal nomodifiable nomodified +endfunction + +function! s:clean_qf_annotations() abort + call neomake#log#debug('cleaning qf annotations.', {'bufnr': bufnr('%')}) + if exists('b:_neomake_qf_orig_lines') + call s:set_qf_lines(b:_neomake_qf_orig_lines) + unlet b:_neomake_qf_orig_lines + endif + unlet b:neomake_qf + augroup neomake_qf + autocmd! * + augroup END + + call s:clean_matches() +endfunction + +function! s:clean_matches() abort + if exists('w:_neomake_maker_match_id') + silent! call matchdelete(w:_neomake_maker_match_id) + endif + if exists('w:_neomake_gutter_match_id') + silent! call matchdelete(w:_neomake_gutter_match_id) + endif + if exists('w:_neomake_bufname_match_id') + silent! call matchdelete(w:_neomake_bufname_match_id) + endif + if exists('w:_neomake_cursor_match_id') + silent! call matchdelete(w:_neomake_cursor_match_id) + endif + call neomake#signs#ResetFile(bufnr('%')) +endfunction + +function! neomake#quickfix#FormatQuickfix() abort + let buf = bufnr('%') + if !s:is_enabled || &filetype !=# 'qf' + if exists('b:neomake_qf') + call s:clean_qf_annotations() + endif + return + endif + + let src_buf = 0 + if has('patch-7.4.2215') + let is_loclist = getwininfo(win_getid())[0].loclist + if is_loclist + let qflist = getloclist(0) + else + let qflist = getqflist() + endif + else + let is_loclist = 1 + let qflist = getloclist(0) + if empty(qflist) + let is_loclist = 0 + let qflist = getqflist() + endif + endif + + if empty(qflist) || qflist[0].text !~# ' nmcfg:{.\{-}}$' + if exists('b:neomake_qf') + call neomake#log#debug('Resetting custom qf for non-Neomake change.') + call s:clean_qf_annotations() + endif + return + endif + + if is_loclist + let b:neomake_qf = 'file' + let src_buf = qflist[0].bufnr + else + let b:neomake_qf = 'project' + endif + + let lines = [] + let signs = [] + let i = 0 + let lnum_width = 0 + let col_width = 0 + let maker_width = 0 + let nmcfg = {} + let makers = {} + + for item in qflist + " Look for marker at end of entry. + if item.text[-1:] ==# '}' + let idx = strridx(item.text, ' nmcfg:{') + if idx != -1 + let config = item.text[idx+7:] + try + let nmcfg = eval(config) + if !has_key(makers, nmcfg.name) + let makers[nmcfg.name] = 0 + endif + let item.text = idx == 0 ? '' : item.text[:(idx-1)] + catch + call neomake#log#exception(printf( + \ 'Error when evaluating nmcfg (%s): %s.', + \ config, v:exception)) + endtry + endif + endif + + " Count entries. + if !empty(nmcfg) + let makers[nmcfg.name] += 1 + endif + + let item.maker_name = get(nmcfg, 'short', '????') + let maker_width = max([len(item.maker_name), maker_width]) + + if item.lnum + let lnum_width = max([len(item.lnum), lnum_width]) + let col_width = max([len(item.col), col_width]) + endif + + let i += 1 + endfor + + let syntax = keys(makers) + if src_buf + for ft in split(neomake#compat#getbufvar(src_buf, '&filetype', ''), '\.') + if !empty(ft) && index(syntax, ft) == -1 + call add(syntax, ft) + endif + endfor + endif + if get(b:, '_neomake_cur_syntax', []) != syntax + runtime! syntax/neomake/qf.vim + for name in syntax + execute 'runtime! syntax/neomake/'.name.'.vim ' + \ . 'syntax/neomake/'.name.'/*.vim' + endfor + let b:_neomake_cur_syntax = syntax + endif + + if maker_width + lnum_width + col_width > 0 + let b:neomake_start_col = maker_width + lnum_width + col_width + 2 + let b:neomake_number_len = lnum_width + col_width + 2 + let blank_col = repeat(' ', lnum_width + col_width + 1) + else + let b:neomake_start_col = 0 + let b:neomake_number_len = 0 + let blank_col = '' + endif + + " Count number of different buffers and cache their names. + let buffers = neomake#compat#uniq(sort( + \ filter(map(copy(qflist), 'v:val.bufnr'), 'v:val != 0'))) + let buffer_names = {} + if len(buffers) > 1 + for b in buffers + let bufname = bufname(b) + if empty(bufname) + let bufname = 'buf:'.b + else + let bufname = fnamemodify(bufname, ':t') + if len(bufname) > 15 + let bufname = bufname[0:13].'…' + endif + endif + let buffer_names[b] = bufname + endfor + endif + + let i = 1 + let last_bufnr = -1 + for item in qflist + if item.lnum + call add(signs, {'lnum': i, 'bufnr': buf, 'type': item.type}) + endif + let i += 1 + + let text = item.text + if item.bufnr != 0 && !empty(buffer_names) + if last_bufnr != item.bufnr + let text = printf('[%s] %s', buffer_names[item.bufnr], text) + let last_bufnr = item.bufnr + endif + endif + + if !item.lnum + call add(lines, printf('%*s %s %s', + \ maker_width, item.maker_name, + \ blank_col, text)) + else + call add(lines, printf('%*s %*s:%*s %s', + \ maker_width, item.maker_name, + \ lnum_width, item.lnum, + \ col_width, item.col ? item.col : '-', + \ text)) + endif + endfor + + if !exists('b:_neomake_qf_orig_lines') + let b:_neomake_qf_orig_lines = getbufline('%', 1, '$') + endif + call s:set_qf_lines(lines) + + if exists('+breakindent') + " Keeps the text aligned with the fake gutter. + setlocal breakindent linebreak + let &breakindentopt = 'shift:'.(b:neomake_start_col + 1) + endif + + call neomake#signs#Reset(buf, 'file') + call neomake#signs#PlaceSigns(buf, signs, 'file') + + call s:add_window_matches(maker_width) + + augroup neomake_qf + autocmd! * + autocmd CursorMoved call s:cursor_moved() + + " Annotate in new window, e.g. with "tab sp". + " It keeps the syntax there, so should also have the rest. + " This happens on Neovim already through CursorMoved being invoked + " always then. + if exists('##WinNew') + exe 'autocmd WinNew call s:add_window_matches('.maker_width.')' + endif + + " Clear matches when opening another buffer in the same window, with + " the original window/buffer still being visible (e.g. in another + " tab). + autocmd BufLeave call s:on_bufleave() + augroup END + + " Set title. + " Fallback without patch-7.4.2200, fix for without 8.0.1831. + if !has('patch-7.4.2200') || !exists('w:quickfix_title') || w:quickfix_title[0] ==# ':' + let maker_info = [] + for [maker, c] in items(makers) + call add(maker_info, maker.'('.c.')') + endfor + let maker_info_str = join(maker_info, ', ') + if is_loclist + let prefix = 'file' + else + let prefix = 'project' + endif + let w:quickfix_title = neomake#list#get_title(prefix, src_buf, maker_info_str) + endif +endfunction + +function! s:on_bufleave() abort + let s:left_winnr = winnr() + augroup neomake_qf + autocmd BufEnter * call s:on_bufenter_after_bufleave() + augroup END +endfunction + +function! s:on_bufenter_after_bufleave() abort + if winnr() == s:left_winnr + call s:clean_matches() + endif + unlet s:left_winnr + augroup neomake_qf + autocmd! BufEnter + augroup END +endfunction + +function! s:add_window_matches(maker_width) abort + if !b:neomake_start_col + return + endif + if exists('w:_neomake_maker_match_id') + silent! call matchdelete(w:_neomake_maker_match_id) + endif + let w:_neomake_maker_match_id = matchadd('neomakeMakerName', + \ '.*\%<'.(a:maker_width + 1).'c', + \ s:match_base_priority+1) + if exists('w:_neomake_gutter_match_id') + silent! call matchdelete(w:_neomake_gutter_match_id) + endif + let w:_neomake_gutter_match_id = matchadd('neomakeListNr', + \ '\%>'.(a:maker_width).'c' + \ .'.*\%<'.(b:neomake_start_col + 2).'c', + \ s:match_base_priority+2) + if exists('w:_neomake_bufname_match_id') + silent! call matchdelete(w:_neomake_bufname_match_id) + endif + let w:_neomake_bufname_match_id = matchadd('neomakeBufferName', + \ '.*\%<'.(a:maker_width + 1).'c', + \ s:match_base_priority+3) +endfunction diff --git a/dotfiles/.vim/autoload/neomake/setup.vim b/dotfiles/.vim/autoload/neomake/setup.vim new file mode 100644 index 0000000..e0c5298 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/setup.vim @@ -0,0 +1,37 @@ +if has('signs') + let g:neomake_place_signs = get(g:, 'neomake_place_signs', 1) +else + let g:neomake_place_signs = 0 + lockvar g:neomake_place_signs +endif + +function! neomake#setup#define_highlights() abort + if g:neomake_place_signs + call neomake#signs#DefineHighlights() + endif + if get(g:, 'neomake_highlight_columns', 1) + \ || get(g:, 'neomake_highlight_lines', 0) + call neomake#highlights#DefineHighlights() + endif +endfunction + +function! neomake#setup#setup_autocmds() abort + augroup neomake + au! + if !exists('*nvim_buf_add_highlight') + autocmd BufEnter * call neomake#highlights#ShowHighlights() + endif + if has('timers') + autocmd CursorMoved * call neomake#CursorMovedDelayed() + " Force-redraw display of current error after resizing Vim, which appears + " to clear the previously echoed error. + autocmd VimResized * call timer_start(100, function('neomake#EchoCurrentError')) + else + autocmd CursorHold,CursorHoldI * call neomake#CursorMoved() + endif + autocmd VimLeave * call neomake#VimLeave() + autocmd ColorScheme * call neomake#setup#define_highlights() + augroup END +endfunction + +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/signs.vim b/dotfiles/.vim/autoload/neomake/signs.vim new file mode 100644 index 0000000..fb96934 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/signs.vim @@ -0,0 +1,289 @@ +" vim: ts=4 sw=4 et +scriptencoding utf-8 + +if !has('signs') + call neomake#log#error('Trying to load signs.vim, without +signs.') + finish +endif + +let s:base_sign_id = 5000 +let s:placed_signs = {'project': {}, 'file': {}} +let s:last_placed_signs = {'project': {}, 'file': {}} + +exe 'sign define neomake_invisible' + +" Reset signs placed by a :Neomake! call +function! neomake#signs#ResetProject() abort + for buf in keys(s:placed_signs.project) + call neomake#signs#Reset(buf, 'project') + call neomake#signs#CleanOldSigns(buf, 'project') + endfor +endfunction + +" Reset signs placed by a :Neomake call in a buffer +function! neomake#signs#ResetFile(bufnr) abort + call neomake#signs#Reset(a:bufnr, 'file') + call neomake#signs#CleanOldSigns(a:bufnr, 'file') +endfunction + +function! neomake#signs#Reset(bufnr, type) abort + if has_key(s:placed_signs[a:type], a:bufnr) + " Clean any lingering, already retired signs. + call neomake#signs#CleanOldSigns(a:bufnr, a:type) + let s:last_placed_signs[a:type][a:bufnr] = s:placed_signs[a:type][a:bufnr] + unlet s:placed_signs[a:type][a:bufnr] + endif +endfunction + +let s:sign_order = {'neomake_file_err': 0, 'neomake_file_warn': 1, + \ 'neomake_file_info': 2, 'neomake_file_msg': 3, + \ 'neomake_project_err': 4, 'neomake_project_warn': 5, + \ 'neomake_project_info': 6, 'neomake_project_msg': 7} + +" Get the defined signs for a:bufnr. +" It returns a dictionary with line numbers as keys. +" If there are multiple entries for a line only the first (visible) entry is +" returned. +function! neomake#signs#by_lnum(bufnr) abort + let bufnr = a:bufnr + 0 + if !bufexists(bufnr) + return {} + endif + + let r = {} + if exists('*sign_getplaced') " patch-8.1.0614 + for sign in sign_getplaced(bufnr)[0].signs + if has_key(r, sign.lnum) + continue + endif + let r[sign.lnum] = [sign.id, sign.name] + endfor + return r + endif + + let signs_output = split(neomake#utils#redir('sign place buffer='.a:bufnr), '\n') + + " Originally via ALE. + " Matches output like : + " line=4 id=1 name=neomake_err + " строка=1 id=1000001 имя=neomake_err + " 行=1 識別子=1000001 名前=neomake_err + " línea=12 id=1000001 nombre=neomake_err + " riga=1 id=1000001, nome=neomake_err + for line in reverse(signs_output[2:]) + " XXX: does not really match "name=" + " (broken by patch-8.1.0614, but handled above) + let sign_type = line[strridx(line, '=')+1:] + if sign_type[0:7] ==# 'neomake_' + let lnum_idx = stridx(line, '=') + let lnum = line[lnum_idx+1:] + 0 + if lnum + let sign_id = line[stridx(line, '=', lnum_idx+1)+1:] + 0 + let r[lnum] = [sign_id, sign_type] + endif + endif + endfor + return r +endfunction + +let s:entry_to_sign_type = {'W': 'warn', 'I': 'info', 'M': 'msg'} + +" Place signs for list a:entries in a:bufnr for a:type ('file' or 'project'). +" List items in a:entries need to have a "type" and "lnum" (non-zero) property. +function! neomake#signs#PlaceSigns(bufnr, entries, type) abort + " Query the list of currently placed signs. + " This allows to cope with movements, e.g. when lines were added. + let placed_signs = neomake#signs#by_lnum(a:bufnr) + + let entries_by_linenr = {} + for entry in a:entries + let lnum = entry.lnum + let sign_type = printf('neomake_%s_%s', + \ a:type, + \ get(s:entry_to_sign_type, toupper(entry.type), 'err')) + if !exists('entries_by_linenr[lnum]') + \ || s:sign_order[entries_by_linenr[lnum]] + \ > s:sign_order[sign_type] + let entries_by_linenr[lnum] = sign_type + endif + endfor + + let place_new = [] + let log_context = {'bufnr': a:bufnr} + let count_reused = 0 + for [lnum, sign_type] in items(entries_by_linenr) + let existing_sign = get(placed_signs, lnum, []) + if empty(existing_sign) || existing_sign[1] !~# '^neomake_'.a:type.'_' + call add(place_new, [lnum, sign_type]) + continue + endif + + let sign_id = existing_sign[0] + if existing_sign[1] == sign_type + let count_reused += 1 + " call neomake#log#debug(printf( + " \ 'Reusing sign: id=%d, type=%s, lnum=%d.', + " \ sign_id, existing_sign[1], lnum), log_context) + else + let cmd = printf('sign place %s name=%s buffer=%d', + \ sign_id, sign_type, a:bufnr) + call neomake#log#debug('Upgrading sign for lnum='.lnum.': '.cmd.'.', log_context) + exe cmd + endif + + " Keep this sign from being cleaned. + if exists('s:last_placed_signs[a:type][a:bufnr][sign_id]') + unlet s:last_placed_signs[a:type][a:bufnr][sign_id] + endif + endfor + if count_reused + call neomake#log#debug(printf('Reused %d signs.', count_reused), log_context) + endif + + for [lnum, sign_type] in place_new + if !exists('next_sign_id') + if !empty(placed_signs) + let next_sign_id = max(map(values(copy(placed_signs)), 'v:val[0]')) + 1 + else + let next_sign_id = s:base_sign_id + endif + else + let next_sign_id += 1 + endif + let cmd = 'sign place '.next_sign_id.' line='.lnum. + \ ' name='.sign_type. + \ ' buffer='.a:bufnr + call neomake#log#debug('Placing sign: '.cmd.'.', log_context) + let placed_signs[lnum] = [next_sign_id, sign_type] + exe cmd + endfor + + let s:placed_signs[a:type][a:bufnr] = {} + for [lnum, sign_info] in items(placed_signs) + let s:placed_signs[a:type][a:bufnr][sign_info[0]] = sign_info[1] + endfor +endfunction + +function! neomake#signs#CleanAllOldSigns(type) abort + call neomake#log#debug_obj('Removing signs', s:last_placed_signs) + for buf in keys(s:last_placed_signs[a:type]) + call neomake#signs#CleanOldSigns(buf, a:type) + endfor +endfunction + +" type may be either 'file' or 'project' +function! neomake#signs#CleanOldSigns(bufnr, type) abort + if !has_key(s:last_placed_signs[a:type], a:bufnr) + return + endif + let placed_signs = s:last_placed_signs[a:type][a:bufnr] + unlet s:last_placed_signs[a:type][a:bufnr] + if bufexists(+a:bufnr) + call neomake#log#debug(printf('Cleaning %d old signs.', len(placed_signs)), {'bufnr': a:bufnr}) + for sign_id in keys(placed_signs) + exe 'sign unplace '.sign_id.' buffer='.a:bufnr + if has_key(s:placed_signs[a:type], a:bufnr) + if has_key(s:placed_signs[a:type][a:bufnr], sign_id) + unlet s:placed_signs[a:type][a:bufnr][sign_id] + endif + endif + endfor + else + call neomake#log#debug_obj('Skipped cleaning of old signs in non-existing buffer '.a:bufnr, placed_signs) + endif +endfunction + +function! neomake#signs#RedefineSign(name, opts) abort + let sign_define = 'sign define '.a:name + for attr in keys(a:opts) + let sign_define .= ' '.attr.'='.a:opts[attr] + endfor + call neomake#log#debug(printf('Defining sign: %s.', sign_define)) + exe sign_define +endfunction + +function! neomake#signs#RedefineErrorSign(...) abort + let default_opts = {'text': '✖', 'texthl': 'NeomakeErrorSign'} + let opts = {} + if a:0 + call extend(opts, a:1) + elseif exists('g:neomake_error_sign') + call extend(opts, g:neomake_error_sign) + endif + call extend(opts, default_opts, 'keep') + call neomake#signs#RedefineSign('neomake_file_err', opts) + call neomake#signs#RedefineSign('neomake_project_err', opts) +endfunction + +function! neomake#signs#RedefineWarningSign(...) abort + let default_opts = {'text': '‼', 'texthl': 'NeomakeWarningSign'} + let opts = {} + if a:0 + call extend(opts, a:1) + elseif exists('g:neomake_warning_sign') + call extend(opts, g:neomake_warning_sign) + endif + call extend(opts, default_opts, 'keep') + call neomake#signs#RedefineSign('neomake_file_warn', opts) + call neomake#signs#RedefineSign('neomake_project_warn', opts) +endfunction + +function! neomake#signs#RedefineMessageSign(...) abort + let default_opts = {'text': '➤', 'texthl': 'NeomakeMessageSign'} + let opts = {} + if a:0 + call extend(opts, a:1) + elseif exists('g:neomake_message_sign') + call extend(opts, g:neomake_message_sign) + endif + call extend(opts, default_opts, 'keep') + call neomake#signs#RedefineSign('neomake_file_msg', opts) + call neomake#signs#RedefineSign('neomake_project_msg', opts) +endfunction + +function! neomake#signs#RedefineInfoSign(...) abort + let default_opts = {'text': 'ℹ', 'texthl': 'NeomakeInfoSign'} + let opts = {} + if a:0 + call extend(opts, a:1) + elseif exists('g:neomake_info_sign') + call extend(opts, g:neomake_info_sign) + endif + call extend(opts, default_opts, 'keep') + call neomake#signs#RedefineSign('neomake_file_info', opts) + call neomake#signs#RedefineSign('neomake_project_info', opts) +endfunction + +function! neomake#signs#DefineHighlights() abort + " Use background from SignColumn. + let ctermbg = neomake#utils#GetHighlight('SignColumn', 'bg', 'Normal') + let guibg = neomake#utils#GetHighlight('SignColumn', 'bg#', 'Normal') + + " Define NeomakeErrorSign, NeomakeWarningSign etc. + call neomake#utils#define_derived_highlights('Neomake%sSign', [ctermbg, guibg]) +endfunction + +function! neomake#signs#DefineSigns() abort + call neomake#signs#RedefineErrorSign() + call neomake#signs#RedefineWarningSign() + call neomake#signs#RedefineInfoSign() + call neomake#signs#RedefineMessageSign() +endfunction + +function! s:wipe_signs(bufnr) abort + for type in ['file', 'project'] + if has_key(s:placed_signs[type], a:bufnr) + unlet s:placed_signs[type][a:bufnr] + endif + if has_key(s:last_placed_signs[type], a:bufnr) + unlet s:last_placed_signs[type][a:bufnr] + endif + endfor +endfunction +augroup neomake_signs + au! + autocmd BufWipeout * call s:wipe_signs(expand('')) +augroup END + +call neomake#signs#DefineSigns() +call neomake#signs#DefineHighlights() diff --git a/dotfiles/.vim/autoload/neomake/statusline.vim b/dotfiles/.vim/autoload/neomake/statusline.vim new file mode 100644 index 0000000..14fb543 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/statusline.vim @@ -0,0 +1,423 @@ +scriptencoding utf-8 + +unlockvar s:unknown_counts +let s:unknown_counts = {} +lockvar s:unknown_counts + +let s:counts = {} + +" Key: bufnr, Value: dict with cache keys. +let s:cache = {} + +" For debugging. +let g:neomake#statusline#_s = s: + +function! s:clear_cache(bufnr) abort + if has_key(s:cache, a:bufnr) + unlet s:cache[a:bufnr] + endif +endfunction + +function! neomake#statusline#clear_cache() abort + let s:cache = {} +endfunction + +function! s:incCount(counts, item, buf) abort + if !empty(a:item.type) && (!a:buf || a:item.bufnr ==# a:buf) + let type = toupper(a:item.type) + let a:counts[type] = get(a:counts, type, 0) + 1 + if a:buf + call s:clear_cache(a:buf) + else + let s:cache = {} + endif + return 1 + endif + return 0 +endfunction + +function! neomake#statusline#make_finished(make_info) abort + if a:make_info.options.file_mode + let bufnr = a:make_info.options.bufnr + if !empty(a:make_info.finished_jobs) && !has_key(s:counts, bufnr) + let s:counts[bufnr] = {} + endif + call s:clear_cache(bufnr) + else + let s:cache = {} + if !empty(a:make_info.finished_jobs) && !has_key(s:counts, 'project') + let s:counts['project'] = {} + endif + endif + + " Trigger redraw of all statuslines. + " TODO: only do this if some relevant formats are used?! + redrawstatus! +endfunction + +function! neomake#statusline#ResetCountsForBuf(...) abort + let bufnr = a:0 ? +a:1 : bufnr('%') + call s:clear_cache(bufnr) + if has_key(s:counts, bufnr) + let r = s:counts[bufnr] != {} + unlet s:counts[bufnr] + if r + call neomake#utils#hook('NeomakeCountsChanged', { + \ 'reset': 1, 'file_mode': 1, 'bufnr': bufnr}) + endif + return r + endif + return 0 +endfunction + +function! neomake#statusline#ResetCountsForProject(...) abort + let s:cache = {} + if !has_key(s:counts, 'project') + return 0 + endif + let r = s:counts['project'] != {} + let bufnr = bufnr('%') + unlet s:counts['project'] + if r + call neomake#utils#hook('NeomakeCountsChanged', { + \ 'reset': 1, 'file_mode': 0, 'bufnr': bufnr}) + endif + return r +endfunction + +function! neomake#statusline#ResetCounts() abort + let r = neomake#statusline#ResetCountsForProject() + for bufnr in keys(s:counts) + let r = neomake#statusline#ResetCountsForBuf(bufnr) || r + endfor + let s:counts = {} + return r +endfunction + +function! neomake#statusline#AddLoclistCount(buf, item) abort + let s:counts[a:buf] = get(s:counts, a:buf, {}) + return s:incCount(s:counts[a:buf], a:item, a:buf) +endfunction + +function! neomake#statusline#AddQflistCount(item) abort + let s:counts['project'] = get(s:counts, 'project', {}) + return s:incCount(s:counts['project'], a:item, 0) +endfunction + +function! neomake#statusline#LoclistCounts(...) abort + let buf = a:0 ? a:1 : bufnr('%') + if buf is# 'all' + return s:counts + endif + return get(s:counts, buf, {}) +endfunction + +function! neomake#statusline#QflistCounts() abort + return get(s:counts, 'project', s:unknown_counts) +endfunction + +function! s:showErrWarning(counts, prefix) abort + let w = get(a:counts, 'W', 0) + let e = get(a:counts, 'E', 0) + if w || e + let result = a:prefix + if e + let result .= 'E:'.e + endif + if w + if e + let result .= ',' + endif + let result .= 'W:'.w + endif + return result + else + return '' + endif +endfunction + +function! neomake#statusline#LoclistStatus(...) abort + return s:showErrWarning(neomake#statusline#LoclistCounts(), a:0 ? a:1 : '') +endfunction + +function! neomake#statusline#QflistStatus(...) abort + return s:showErrWarning(neomake#statusline#QflistCounts(), a:0 ? a:1 : '') +endfunction + +" Get counts for a bufnr or 'project'. +" Returns all counts when used without arguments. +function! neomake#statusline#get_counts(...) abort + if a:0 + return get(s:counts, a:1, s:unknown_counts) + endif + return s:counts +endfunction + + +let s:formatter = { + \ 'args': {}, + \ } +function! s:formatter.running_job_names() abort + let jobs = get(self.args, 'running_jobs', s:running_jobs(self.args.bufnr)) + let sep = get(self.args, 'running_jobs_separator', ', ') + let format_running_job_file = get(self.args, 'format_running_job_file', '%s') + let format_running_job_project = get(self.args, 'format_running_job_project', '%s!') + let formatted = [] + for job in jobs + if job.file_mode + call add(formatted, printf(format_running_job_file, job.name)) + else + call add(formatted, printf(format_running_job_project, job.name)) + endif + endfor + return join(formatted, sep) +endfunction + +function! s:formatter._substitute(m) abort + if has_key(self.args, a:m) + return self.args[a:m] + endif + if !has_key(self, a:m) + let self.errors += [printf('Unknown statusline format: {{%s}}.', a:m)] + return '{{'.a:m.'}}' + endif + try + return call(self[a:m], [], self) + catch + call neomake#log#error(printf( + \ 'Error while formatting statusline: %s.', v:exception)) + endtry +endfunction + +function! s:formatter.format(f, args) abort + if empty(a:f) + return a:f + endif + let self.args = a:args + let self.errors = [] + let r = substitute(a:f, '{{\(.\{-}\)}}', '\=self._substitute(submatch(1))', 'g') + if !empty(self.errors) + call neomake#log#error(printf( + \ 'Error%s when formatting %s: %s', + \ len(self.errors) > 1 ? 's' : '', + \ string(a:f), join(self.errors, ', '))) + endif + return r +endfunction + + +function! s:running_jobs(bufnr) abort + return filter(copy(neomake#GetJobs()), + \ "v:val.bufnr == a:bufnr && !get(v:val, 'canceled', 0)") +endfunction + +function! s:format_running(format_running, options, bufnr, running_jobs) abort + let args = {'bufnr': a:bufnr, 'running_jobs': a:running_jobs} + for opt in ['running_jobs_separator', 'format_running_job_project', 'format_running_job_file'] + if has_key(a:options, opt) + let args[opt] = a:options[opt] + endif + endfor + return s:formatter.format(a:format_running, args) +endfunction + +function! neomake#statusline#get_status(bufnr, options) abort + let filemode_jobs = [] + let project_jobs = [] + let format_running = get(a:options, 'format_running', '… ({{running_job_names}})') + if format_running isnot 0 + let running_jobs = s:running_jobs(a:bufnr) + if !empty(running_jobs) + for j in running_jobs + if j.file_mode + let filemode_jobs += [j] + else + let project_jobs += [j] + endif + endfor + endif + endif + + let r_loclist = '' + let r_quickfix = '' + + let use_highlights_with_defaults = get(a:options, 'use_highlights_with_defaults', 1) + + " Location list counts. + let loclist_counts = get(s:counts, a:bufnr, s:unknown_counts) + if !empty(filemode_jobs) + let r_loclist = s:format_running(format_running, a:options, a:bufnr, filemode_jobs) + elseif empty(loclist_counts) + if loclist_counts is s:unknown_counts + let format_unknown = get(a:options, 'format_loclist_unknown', '?') + let r_loclist = s:formatter.format(format_unknown, {'bufnr': a:bufnr}) + else + let format_ok = get(a:options, 'format_loclist_ok', use_highlights_with_defaults ? '%#NeomakeStatusGood#✓%#NeomakeStatReset#' : '✓') + let r_loclist = s:formatter.format(format_ok, {'bufnr': a:bufnr}) + endif + else + let format_loclist = get(a:options, 'format_loclist_issues', + \ use_highlights_with_defaults ? '%s%%#NeomakeStatReset#' : '%s') + if !empty(format_loclist) + let loclist = '' + for [type, c] in items(loclist_counts) + if has_key(a:options, 'format_loclist_type_'.type) + let format = a:options['format_loclist_type_'.type] + elseif has_key(a:options, 'format_loclist_type_default') + let format = a:options['format_loclist_type_default'] + else + let hl = '' + if use_highlights_with_defaults + if hlexists('NeomakeStatColorType'.type) + let hl = '%#NeomakeStatColorType{{type}}#' + elseif hlexists('NeomakeStatColorDefault') + let hl = '%#NeomakeStatColorDefault#' + endif + endif + let format = hl.' {{type}}:{{count}} ' + endif + let loclist .= s:formatter.format(format, { + \ 'bufnr': a:bufnr, + \ 'count': c, + \ 'type': type}) + endfor + let r_loclist = printf(format_loclist, loclist) + endif + endif + + " Quickfix counts. + let qflist_counts = get(s:counts, 'project', s:unknown_counts) + if !empty(project_jobs) + let r_quickfix = s:format_running(format_running, a:options, a:bufnr, project_jobs) + elseif empty(qflist_counts) + let format_ok = get(a:options, 'format_quickfix_ok', '') + if !empty(format_ok) + let r_quickfix = s:formatter.format(format_ok, {'bufnr': a:bufnr}) + endif + else + let format_quickfix = get(a:options, 'format_quickfix_issues', + \ use_highlights_with_defaults ? '%s%%#NeomakeStatReset#' : '%s') + if !empty(format_quickfix) + let quickfix = '' + for [type, c] in items(qflist_counts) + if has_key(a:options, 'format_quickfix_type_'.type) + let format = a:options['format_quickfix_type_'.type] + elseif has_key(a:options, 'format_quickfix_type_default') + let format = a:options['format_quickfix_type_default'] + else + let hl = '' + if use_highlights_with_defaults + if hlexists('NeomakeStatColorQuickfixType'.type) + let hl = '%#NeomakeStatColorQuickfixType{{type}}#' + elseif hlexists('NeomakeStatColorQuickfixDefault') + let hl = '%#NeomakeStatColorQuickfixDefault#' + endif + endif + let format = hl.' Q{{type}}:{{count}} ' + endif + if !empty(format) + let quickfix .= s:formatter.format(format, { + \ 'bufnr': a:bufnr, + \ 'count': c, + \ 'type': type}) + endif + endfor + let r_quickfix = printf(format_quickfix, quickfix) + endif + endif + + let format_lists = get(a:options, 'format_lists', '{{loclist}}{{lists_sep}}{{quickfix}}') + if empty(r_loclist) || empty(r_quickfix) + let lists_sep = '' + else + let lists_sep = get(a:options, 'lists_sep', ' ') + endif + return s:formatter.format(format_lists, {'loclist': r_loclist, 'quickfix': r_quickfix, 'lists_sep': lists_sep}) +endfunction + +function! neomake#statusline#get(bufnr, ...) abort + let options = a:0 ? a:1 : {} + let cache_key = string(options) + if !exists('s:cache[a:bufnr][cache_key]') + if !has_key(s:cache, a:bufnr) + let s:cache[a:bufnr] = {} + endif + let bufnr = +a:bufnr + + " TODO: needs to go into cache key then! + if getbufvar(bufnr, '&filetype') ==# 'qf' + let s:cache[bufnr][cache_key] = '' + else + let [disabled, src] = neomake#config#get_with_source('disabled', -1, {'bufnr': bufnr, 'log_source': 'statusline#get'}) + if src ==# 'default' + let disabled_scope = '' + else + let disabled_scope = src[0] + endif + if disabled != -1 && disabled + " Automake Disabled + let format_disabled_info = get(options, 'format_disabled_info', '{{disabled_scope}}-') + let disabled_info = s:formatter.format(format_disabled_info, + \ {'disabled_scope': disabled_scope}) + " Defaults to showing the disabled information (i.e. scope) + let format_disabled = get(options, 'format_status_disabled', '{{disabled_info}} %s') + let outer_format = s:formatter.format(format_disabled, {'disabled_info': disabled_info}) + else + " Automake Enabled + " Defaults to showing only the status + let format_enabled = get(options, 'format_status_enabled', '%s') + let outer_format = s:formatter.format(format_enabled, {}) + endif + let format_status = get(options, 'format_status', '%s') + let status = neomake#statusline#get_status(bufnr, options) + + let r = printf(outer_format, printf(format_status, status)) + + let s:cache[bufnr][cache_key] = r + endif + endif + return s:cache[a:bufnr][cache_key] +endfunction + +" XXX: TODO: cleanup/doc?! +function! neomake#statusline#DefineHighlights() abort + for suffix in ['', 'NC'] + let hl = 'StatusLine'.suffix + + " Highlight used for resetting color (used after counts). + exe 'hi default link NeomakeStatReset'.suffix.' StatusLine'.suffix + + " Uses "green" for NeomakeStatusGood, but the default with + " NeomakeStatusGoodNC (since it might be underlined there, and should + " not stand out in general there). + exe 'hi default NeomakeStatusGood'.suffix + \ . ' ctermfg=' . (suffix ? neomake#utils#GetHighlight(hl, 'fg') : 'green') + \ . ' guifg=' . (suffix ? neomake#utils#GetHighlight(hl, 'fg#') : 'green') + \ . ' ctermbg='.neomake#utils#GetHighlight(hl, 'bg') + \ . ' guifg='.neomake#utils#GetHighlight(hl, 'bg#') + \ . (neomake#utils#GetHighlight(hl, 'underline') ? ' cterm=underline' : '') + \ . (neomake#utils#GetHighlight(hl, 'underline#') ? ' gui=underline' : '') + \ . (neomake#utils#GetHighlight(hl, 'reverse') ? ' cterm=reverse' : '') + \ . (neomake#utils#GetHighlight(hl, 'reverse#') ? ' gui=reverse' : '') + endfor + + " Default highlight for type counts. + exe 'hi NeomakeStatColorDefault cterm=NONE ctermfg=white ctermbg=blue' + hi link NeomakeStatColorQuickfixDefault NeomakeStatColorDefault + + " Specific highlights for types. Only used if defined. + exe 'hi NeomakeStatColorTypeE cterm=NONE ctermfg=white ctermbg=red' + hi link NeomakeStatColorQuickfixTypeE NeomakeStatColorTypeE + + exe 'hi NeomakeStatColorTypeW cterm=NONE ctermfg=white ctermbg=yellow' + hi link NeomakeStatColorQuickfixTypeW NeomakeStatColorTypeW +endfunction + +" Global augroup, gets configured always currently when autoloaded. +augroup neomake_statusline + autocmd! + autocmd BufWipeout * call s:clear_cache(expand('')) + autocmd ColorScheme * call neomake#statusline#DefineHighlights() +augroup END +call neomake#statusline#DefineHighlights() +" vim: ts=4 sw=4 et diff --git a/dotfiles/.vim/autoload/neomake/utils.vim b/dotfiles/.vim/autoload/neomake/utils.vim new file mode 100644 index 0000000..860fe41 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/utils.vim @@ -0,0 +1,795 @@ +" vim: ts=4 sw=4 et +scriptencoding utf-8 + +" Get verbosity, optionally based on jobinfo's make_id (a:1). +function! neomake#utils#get_verbosity(...) abort + if a:0 && has_key(a:1, 'make_id') + return neomake#GetMakeOptions(a:1.make_id).verbosity + endif + return get(g:, 'neomake_verbose', 1) + &verbose +endfunction + +function! neomake#utils#Stringify(obj) abort + if type(a:obj) == type([]) + let ls = map(copy(a:obj), 'neomake#utils#Stringify(v:val)') + return '['.join(ls, ', ').']' + elseif type(a:obj) == type({}) + let ls = [] + for [k, l:V] in items(neomake#utils#fix_self_ref(a:obj)) + if type(V) == type(function('tr')) + let fname = substitute(string(V), ', {\zs.*\ze})', '…', '') + call add(ls, k.': '.fname) + else + call add(ls, k.': '.neomake#utils#Stringify(V)) + endif + unlet V " vim73 + endfor + return '{'.join(ls, ', ').'}' + elseif type(a:obj) == type(function('tr')) + return string(a:obj) + else + return a:obj + endif +endfunction + +function! neomake#utils#truncate_width(string, width) abort + let pos = a:width + while pos >= 0 + let s = matchstr(a:string, '.\{,'.pos.'}', 0, 1) + let w = strwidth(s) + if w <= a:width + return s + endif + let pos -= max([(w-a:width)/2, 1]) + endwhile + return '' +endfunction + +" This comes straight out of syntastic. +"print as much of a:msg as possible without "Press Enter" prompt appearing +function! neomake#utils#WideMessage(msg) abort " {{{2 + let old_ruler = &ruler + let old_showcmd = &showcmd + + " Replace newlines (typically in the msg) with a single space. This + " might happen with writegood. + let msg = substitute(a:msg, '\r\?\n', ' ', 'g') + + "convert tabs to spaces so that the tabs count towards the window + "width as the proper amount of characters + let chunks = split(msg, "\t", 1) + let msg = join(map(chunks[:-2], "v:val . repeat(' ', &tabstop - strwidth(v:val) % &tabstop)"), '') . chunks[-1] + let msg = neomake#utils#truncate_width(msg, &columns-1) + + set noruler noshowcmd + redraw + + call neomake#log#debug('WideMessage: echo '.msg.'.') + echo msg + + let &ruler = old_ruler + let &showcmd = old_showcmd +endfunction " }}}2 + +" This comes straight out of syntastic. +function! neomake#utils#IsRunningWindows() abort + return has('win32') || has('win64') +endfunction + +" Get directory/path separator. +function! neomake#utils#Slash() abort + return (!exists('+shellslash') || &shellslash) ? '/' : '\' +endfunction + +function! neomake#utils#Exists(exe) abort + " DEPRECATED: just use executable() directly. + return executable(a:exe) +endfunction + +" Object used with neomake#utils#MakerFromCommand. +let s:maker_from_command = extend(copy(g:neomake#core#command_maker_base), { + \ 'remove_invalid_entries': 0, + \ }) +function! s:maker_from_command._get_argv(jobinfo) abort dict + let fname = self._get_fname_for_args(a:jobinfo) + let args = neomake#utils#ExpandArgs(self.args, a:jobinfo) + if !empty(fname) + if self.__command_is_string + let fname = neomake#utils#shellescape(fname) + let args[-1] .= ' '.fname + else + call add(args, fname) + endif + endif + return neomake#compat#get_argv(self.exe, args, 1) +endfunction + +" Create a maker object for a given command. +" Args: command (string or list). Gets wrapped in a shell in case it is a +" string. +function! neomake#utils#MakerFromCommand(command) abort + let maker = copy(s:maker_from_command) + if type(a:command) == type('') + let argv = split(&shell) + split(&shellcmdflag) + let maker.exe = argv[0] + let maker.args = argv[1:] + [a:command] + let maker.__command_is_string = 1 + else + let maker.exe = a:command[0] + let maker.args = a:command[1:] + let maker.__command_is_string = 0 + endif + return maker +endfunction + +let s:super_ft_cache = {} +function! neomake#utils#GetSupersetOf(ft) abort + if !has_key(s:super_ft_cache, a:ft) + call neomake#utils#load_ft_makers(a:ft) + let l:SupersetOf = 'neomake#makers#ft#'.a:ft.'#SupersetOf' + if exists('*'.SupersetOf) + let s:super_ft_cache[a:ft] = call(SupersetOf, []) + else + let s:super_ft_cache[a:ft] = '' + endif + endif + return s:super_ft_cache[a:ft] +endfunction + +let s:loaded_ft_maker_runtime = [] +function! neomake#utils#load_ft_makers(ft) abort + " Load ft maker, but only once (for performance reasons and to allow for + " monkeypatching it in tests). + if index(s:loaded_ft_maker_runtime, a:ft) == -1 + if !exists('*neomake#makers#ft#'.a:ft.'#EnabledMakers') + silent exe 'runtime! autoload/neomake/makers/ft/'.a:ft.'.vim' + endif + call add(s:loaded_ft_maker_runtime, a:ft) + endif +endfunction + +let s:loaded_global_maker_runtime = 0 +function! neomake#utils#load_global_makers() abort + " Load global makers, but only once (for performance reasons and to allow + " for monkeypatching it in tests). + if !s:loaded_global_maker_runtime + exe 'runtime! autoload/neomake/makers/*.vim' + let s:loaded_global_maker_runtime = 1 + endif +endfunction + +function! neomake#utils#get_ft_confname(ft, ...) abort + return substitute(a:ft, '\W', a:0 ? a:1 : '_', 'g') +endfunction + +" Resolve filetype a:ft into a list of filetypes suitable for config vars +" (i.e. 'foo.bar' => ['foo_bar', 'foo', 'bar']). +function! neomake#utils#get_config_fts(ft, ...) abort + let delim = a:0 ? a:1 : '_' + let cache_key = a:ft . delim + if !has_key(s:cache_config_fts, cache_key) + let r = [] + let fts = split(a:ft, '\.') + for ft in fts + call add(r, ft) + let super_ft = neomake#utils#GetSupersetOf(ft) + while !empty(super_ft) + if index(fts, super_ft) == -1 + call add(r, super_ft) + endif + let super_ft = neomake#utils#GetSupersetOf(super_ft) + endwhile + endfor + if len(fts) > 1 + call insert(r, a:ft, 0) + endif + let s:cache_config_fts[cache_key] = map(r, 'neomake#utils#get_ft_confname(v:val, delim)') + endif + return s:cache_config_fts[cache_key] +endfunction +let s:cache_config_fts = {} + +let s:unset = {} " Sentinel. + +" Get a setting by key, based on filetypes, from the buffer or global +" namespace, defaulting to default. +" Use an empty bufnr ('') to ignore buffer-local settings. +function! neomake#utils#GetSetting(key, maker, default, ft, bufnr, ...) abort + let maker_only = a:0 ? a:1 : 0 + + " Check new-style config. + if exists('g:neomake') || !empty(getbufvar(a:bufnr, 'neomake')) + let context = {'ft': a:ft, 'maker': a:maker, 'bufnr': a:bufnr, 'maker_only': maker_only} + let [l:Ret, source] = neomake#config#get_with_source(a:key, g:neomake#config#undefined, context) + " Check old-style setting when source is the maker. + if source ==# 'maker' && !maker_only + let tmpmaker = {} + if has_key(a:maker, 'name') + let tmpmaker.name = a:maker.name + endif + let l:RetOld = s:get_oldstyle_setting(a:key, tmpmaker, s:unset, a:ft, a:bufnr, 1) + if RetOld isnot# s:unset + return RetOld + endif + endif + if Ret isnot g:neomake#config#undefined + return Ret + endif + endif + + return s:get_oldstyle_setting(a:key, a:maker, a:default, a:ft, a:bufnr, maker_only) +endfunction + +function! s:get_oldstyle_setting(key, maker, default, ft, bufnr, maker_only) abort + let maker_name = get(a:maker, 'name', '') + if a:maker_only && empty(maker_name) + if has_key(a:maker, a:key) + return get(a:maker, a:key) + endif + return a:default + endif + + if !empty(a:ft) + let fts = neomake#utils#get_config_fts(a:ft) + [''] + else + let fts = [''] + endif + for ft in fts + let part = join(filter([ft, maker_name], '!empty(v:val)'), '_') + if empty(part) + break + endif + let config_var = 'neomake_'.part.'_'.a:key + if a:bufnr isnot# '' + let l:Bufcfgvar = neomake#compat#getbufvar(a:bufnr, config_var, s:unset) + if Bufcfgvar isnot s:unset + return copy(Bufcfgvar) + endif + endif + if has_key(g:, config_var) + return copy(get(g:, config_var)) + endif + unlet! Bufcfgvar " vim73 + endfor + + if has_key(a:maker, a:key) + return get(a:maker, a:key) + endif + + let key = a:key + if a:maker_only + let key = maker_name.'_'.key + endif + let key = a:maker_only ? maker_name.'_'.a:key : a:key + " Look for 'neomake_'.key in the buffer and global namespace. + let bufvar = neomake#compat#getbufvar(a:bufnr, 'neomake_'.key, s:unset) + if bufvar isnot s:unset + return bufvar + endif + if a:key !=# 'enabled_makers' && has_key(g:, 'neomake_'.key) + return get(g:, 'neomake_'.key) + endif + return a:default +endfunction + +" Helper function to define default highlight for a:group (e.g. +" "Neomake%sSign"), using fg from another highlight, abd given background. +function! neomake#utils#define_derived_highlights(group_format, bg) abort + for [type, fg_from] in items({ + \ 'Error': ['Error', 'bg'], + \ 'Warning': ['Todo', 'fg'], + \ 'Info': ['Question', 'fg'], + \ 'Message': ['ModeMsg', 'fg'] + \ }) + let group = printf(a:group_format, type) + call s:define_derived_highlight_group(group, fg_from, a:bg) + endfo +endfunction + +function! s:define_derived_highlight_group(group, fg_from, bg) abort + let [fg_group, fg_attr] = a:fg_from + let [ctermbg, guibg] = a:bg + let bg = 'ctermbg='.ctermbg.' guibg='.guibg + + " NOTE: fg falls back to "Normal" always, not bg (for e.g. "SignColumn") + " inbetween. + let ctermfg = neomake#utils#GetHighlight(fg_group, fg_attr, 'Normal') + let guifg = neomake#utils#GetHighlight(fg_group, fg_attr.'#', 'Normal') + + " Ensure that we're not using bg as fg (as with gotham + " colorscheme, issue https://github.com/neomake/neomake/pull/659). + if ctermfg !=# 'NONE' && ctermfg ==# ctermbg + let ctermfg = neomake#utils#GetHighlight(fg_group, neomake#utils#ReverseSynIDattr(fg_attr)) + endif + if guifg !=# 'NONE' && guifg ==# guibg + let guifg = neomake#utils#GetHighlight(fg_group, neomake#utils#ReverseSynIDattr(fg_attr).'#') + endif + exe 'hi '.a:group.'Default ctermfg='.ctermfg.' guifg='.guifg.' '.bg + if !neomake#utils#highlight_is_defined(a:group) + exe 'hi link '.a:group.' '.a:group.'Default' + endif +endfunction + +" Get property from highlighting group. +function! neomake#utils#GetHighlight(group, what, ...) abort + let fallback = a:0 ? a:1 : '' + let mode = a:what[-1:] ==# '#' ? 'gui' : 'cterm' + let reverse = synIDattr(synIDtrans(hlID(a:group)), 'reverse', mode) + let what = a:what + if reverse + let what = neomake#utils#ReverseSynIDattr(what) + endif + if what[-1:] ==# '#' + let val = synIDattr(synIDtrans(hlID(a:group)), what, mode) + else + let val = synIDattr(synIDtrans(hlID(a:group)), what, mode) + endif + if empty(val) || val == -1 + if !empty(fallback) + " NOTE: this might still be NONE also for "Normal", with + " e.g. `vim -u NONE`. + return neomake#utils#GetHighlight(fallback, a:what) + endif + return 'NONE' + endif + return val +endfunction + +function! neomake#utils#ReverseSynIDattr(attr) abort + if a:attr ==# 'fg' + return 'bg' + elseif a:attr ==# 'bg' + return 'fg' + elseif a:attr ==# 'fg#' + return 'bg#' + elseif a:attr ==# 'bg#' + return 'fg#' + endif + return a:attr +endfunction + +" Deprecated: moved to neomake#postprocess#compress_whitespace. +function! neomake#utils#CompressWhitespace(entry) abort + call neomake#postprocess#compress_whitespace(a:entry) +endfunction + +function! neomake#utils#redir(cmd) abort + " @vimlint(EVL108, 1) + if exists('*execute') && has('nvim-0.2.0') + " @vimlint(EVL108, 0) + " NOTE: require Neovim, since Vim has at least an issue when using + " this in a :command-completion function. + " Ref: https://github.com/neomake/neomake/issues/650. + " Neovim 0.1.7 also parses 'highlight' wrongly. + return execute(a:cmd) + endif + if type(a:cmd) == type([]) + let r = '' + for cmd in a:cmd + let r .= neomake#utils#redir(cmd) + endfor + return r + endif + try + redir => neomake_redir + silent exe a:cmd + catch /^Vim(redir):E121:/ + throw printf('Neomake: neomake#utils#redir: called with outer :redir (error: %s).', + \ v:exception) + finally + redir END + endtry + return neomake_redir +endfunction + +function! neomake#utils#ExpandArgs(args, jobinfo) abort + if has_key(a:jobinfo, 'tempfile') + let fname = a:jobinfo.tempfile + else + let fname = bufname(a:jobinfo.bufnr) + if !empty(fname) + let fname = fnamemodify(fname, ':p') + endif + endif + let ret = map(copy(a:args), "substitute(v:val, '%t', fname, 'g')") + + " Expand % in args similar to when using :! + " \% is ignored + " \\% is expanded to \\file.ext + " %% becomes % + " % must be followed with an expansion keyword + let ret = map(ret, + \ 'substitute(v:val, ' + \ . '''\(\%(\\\@'), '.*\zs\d\+_'),'')) + endfunction +endif + +function! s:handle_hook(jobinfo, event, context) abort + let context_str = string(map(copy(a:context), + \ "v:key ==# 'make_info' ? 'make_info #'.get(v:val, 'make_id')" + \ .": (v:key ==# 'options' && has_key(v:val, 'jobs') ? extend(copy(v:val), {'jobs': map(copy(v:val.jobs), 'v:val.maker.name')}, 'force')" + \ .": (v:key ==# 'jobinfo' ? v:val.as_string()" + \ .": (v:key ==# 'finished_jobs' ? map(copy(v:val), 'v:val.as_string()') : v:val)))")) + + if exists('g:neomake_hook_context') + call neomake#log#debug(printf('Queuing User autocmd %s for nested invocation (%s).', a:event, context_str), + \ a:jobinfo) + return neomake#action_queue#add( + \ ['Timer', 'BufEnter', 'WinEnter', 'InsertLeave', 'CursorHold', 'CursorHoldI'], + \ [s:function('s:handle_hook'), [a:jobinfo, a:event, a:context]]) + endif + + let log_args = [printf('Calling User autocmd %s with context: %s.', + \ a:event, context_str)] + if !empty(a:jobinfo) + let log_args += [a:jobinfo] + endif + call call('neomake#log#info', log_args) + + unlockvar g:neomake_hook_context + let g:neomake_hook_context = a:context + lockvar 1 g:neomake_hook_context + try + call neomake#compat#doautocmd('User '.a:event) + catch + let error = v:exception + if error[-1:] !=# '.' + let error .= '.' + endif + call neomake#log#exception(printf( + \ 'Error during User autocmd for %s: %s', + \ a:event, error), a:jobinfo) + finally + unlet g:neomake_hook_context + endtry + return g:neomake#action_queue#processed +endfunction + +function! neomake#utils#hook(event, context, ...) abort + if exists('#User#'.a:event) + let jobinfo = a:0 ? a:1 : ( + \ has_key(a:context, 'jobinfo') ? a:context.jobinfo : {}) + return s:handle_hook(jobinfo, a:event, a:context) + endif +endfunction + +function! neomake#utils#diff_dict(old, new) abort + let diff = {'removed': {}, 'added': {}, 'changed': {}} + + for k in keys(a:old) + if !has_key(a:new, k) + let diff['removed'][k] = a:old[k] + elseif type(a:old[k]) !=# type(a:new[k]) || a:old[k] !=# a:new[k] + let diff['changed'][k] = [a:old[k], a:new[k]] + endif + endfor + + for k in keys(a:new) + if !has_key(a:old, k) + let diff['added'][k] = a:new[k] + endif + endfor + + call filter(diff, '!empty(v:val)') + + return diff +endfunction + +" Sort quickfix/location list entries by distance to current cursor position's +" column, but preferring entries starting at or behind the cursor position. +function! neomake#utils#sort_by_col(a, b) abort + let col = getpos('.')[2] + if a:a.col > col + if a:b.col < col + return 1 + endif + elseif a:b.col > col + return -1 + endif + return abs(col - a:a.col) - abs(col - a:b.col) +endfunction + +function! neomake#utils#path_sep() abort + return neomake#utils#IsRunningWindows() ? ';' : ':' +endfunction + +" Find a file matching `a:glob` (using `globpath()`) by going up the +" directories from the start directory (a:1, defaults to `expand('%:p:h')`, +" i.e. the directory of the current buffer's file).) +function! neomake#utils#FindGlobFile(glob, ...) abort + let curDir = a:0 ? a:1 : expand('%:p:h') + let fileFound = [] + while 1 + let fileFound = neomake#compat#globpath_list(curDir, a:glob, 1) + if !empty(fileFound) + return fileFound[0] + endif + let lastFolder = curDir + let curDir = fnamemodify(curDir, ':h') + if curDir ==# lastFolder + break + endif + endwhile + return '' +endfunction + +function! neomake#utils#JSONdecode(json) abort + return neomake#compat#json_decode(a:json) +endfunction + +" Smarter shellescape, via vim-fugitive. +function! s:gsub(str,pat,rep) abort + return substitute(a:str,'\v\C'.a:pat,a:rep,'g') +endfunction + +function! neomake#utils#shellescape(arg) abort + if a:arg =~# '^[A-Za-z0-9_/.=-]\+$' + return a:arg + elseif &shell =~? 'cmd' || exists('+shellslash') && !&shellslash + return '"'.s:gsub(s:gsub(a:arg, '"', '""'), '\%', '"%"').'"' + endif + return shellescape(a:arg) +endfunction + +function! neomake#utils#get_buffer_lines(bufnr) abort + let buflines = getbufline(a:bufnr, 1, '$') + " Special case: empty buffer; do not write an empty line in this case. + if len(buflines) > 1 || buflines != [''] + if getbufvar(a:bufnr, '&endofline') + \ || (!getbufvar(a:bufnr, '&binary') + \ && (!exists('+fixendofline') || getbufvar(a:bufnr, '&fixendofline'))) + call add(buflines, '') + endif + endif + return buflines +endfunction + +function! neomake#utils#write_tempfile(bufnr, temp_file) abort + call writefile(neomake#utils#get_buffer_lines(a:bufnr), a:temp_file, 'b') + if exists('*setfperm') + let perms = getfperm(bufname(+a:bufnr)) + if empty(perms) + let perms = 'rw-------' + endif + call setfperm(a:temp_file, perms) + endif +endfunction + +" Wrapper around fnamemodify that handles special buffers (e.g. fugitive). +function! neomake#utils#fnamemodify(bufnr, modifier) abort + let bufnr = +a:bufnr + if empty(getbufvar(bufnr, 'fugitive_type')) + let path = bufname(bufnr) + else + if exists('*FugitivePath') + let path = FugitivePath(bufname(bufnr)) + else + let fug_buffer = fugitive#buffer(bufnr) + let path = fug_buffer.repo().translate(fug_buffer.path()) + endif + if empty(a:modifier) + let path = fnamemodify(path, ':.') + endif + endif + return empty(path) ? '' : fnamemodify(path, a:modifier) +endfunction + +function! neomake#utils#fix_self_ref(obj, ...) abort + if type(a:obj) != type({}) + if type(a:obj) == type([]) + return map(copy(a:obj), 'neomake#utils#fix_self_ref(v:val)') + endif + return a:obj + endif + let obj = copy(a:obj) + for k in keys(obj) + if a:0 + let self_ref = filter(copy(a:1), 'v:val[1][0] is obj[k]') + if !empty(self_ref) + let obj[k] = printf('', self_ref[0][0], self_ref[0][1][1]) + continue + endif + endif + if type(obj[k]) == type({}) + let obj[k] = neomake#utils#fix_self_ref(obj[k], a:0 ? a:1 + [[len(a:1)+1, [a:obj, k]]] : [[1, [a:obj, k]]]) + elseif has('nvim') + " Ensure that it can be used as a string. + " Ref: https://github.com/neovim/neovim/issues/7432 + try + call string(obj[k]) + catch /^Vim(call):E724:/ + let obj[k] = '' + endtry + endif + endfor + return obj +endfunction + +function! neomake#utils#parse_highlight(group) abort + let output = neomake#utils#redir('highlight '.a:group) + return join(split(output)[2:]) +endfunction + +function! neomake#utils#highlight_is_defined(group) abort + if !hlexists(a:group) + return 0 + endif + return neomake#utils#parse_highlight(a:group) !=# 'cleared' +endfunction + +" Get the root directory of the current project. +" This is determined by looking for specific files (e.g. `.git` and +" `Makefile`), and `g:neomake#makers#ft#X#project_root_files` (if defined for +" filetype "X"). +" a:1 buffer number (defaults to current) +function! neomake#utils#get_project_root(...) abort + let bufnr = a:0 ? a:1 : bufnr('%') + let ft = getbufvar(bufnr, '&filetype') + call neomake#utils#load_ft_makers(ft) + + let project_root_files = ['.git', 'Makefile'] + + let ft_project_root_files = 'neomake#makers#ft#'.ft.'#project_root_files' + if has_key(g:, ft_project_root_files) + let project_root_files = get(g:, ft_project_root_files) + project_root_files + endif + + let buf_dir = expand('#'.bufnr.':p:h') + for fname in project_root_files + let project_root = neomake#utils#FindGlobFile(fname, buf_dir) + if !empty(project_root) + return fnamemodify(project_root, ':h') + endif + endfor + return '' +endfunction + +" Return the number of lines for a given buffer. +" This returns 0 for unloaded buffers. +if exists('*nvim_buf_line_count') + function! neomake#utils#get_buf_line_count(bufnr) abort + if !bufloaded(a:bufnr) + " https://github.com/neovim/neovim/issues/7688 + return 0 + endif + return nvim_buf_line_count(a:bufnr) + endfunction +else + function! neomake#utils#get_buf_line_count(bufnr) abort + if a:bufnr == bufnr('%') + return line('$') + endif + " TODO: this should get cached (based on b:changedtick), and cleaned + " in BufWipeOut. + return len(getbufline(a:bufnr, 1, '$')) + endfunction +endif + +" Returns: [error, cd_back_cmd] +function! neomake#utils#temp_cd(dir, ...) abort + if a:dir ==# '.' + return ['', ''] + endif + if a:0 + let cur_wd = a:1 + else + let cur_wd = getcwd() + if cur_wd ==# a:dir + " No need to change directory. + return ['', ''] + endif + endif + let cd = haslocaldir() ? 'lcd' : (exists(':tcd') == 2 && haslocaldir(-1, 0)) ? 'tcd' : 'cd' + try + exe cd.' '.fnameescape(a:dir) + catch + " Tests fail with E344, but in reality it is E472?! + " If uncaught, both are shown - let's just catch everything. + return [v:exception, ''] + endtry + return ['', cd.' '.fnameescape(cur_wd)] +endfunction + +if exists('*nvim_buf_get_lines') + function! neomake#utils#buf_get_lines(bufnr, start, end) abort + if a:start < 1 + throw 'neomake#utils#buf_get_lines: start is lower than 1' + endif + try + return nvim_buf_get_lines(a:bufnr, a:start-1, a:end-1, 1) + catch + throw 'neomake#utils#buf_get_lines: '.substitute(v:exception, '\v^[^:]+:', '', '') + endtry + endfunction +else + function! neomake#utils#buf_get_lines(bufnr, start, end) abort + if a:bufnr != bufnr('%') + throw 'Neomake: neomake#utils#buf_get_lines: used for non-current buffer' + endif + if a:start < 1 + throw 'neomake#utils#buf_get_lines: start is lower than 1' + endif + if a:end-1 > line('$') + throw 'neomake#utils#buf_get_lines: end is higher than number of lines' + endif + let r = [] + let i = a:start + while i < a:end + let r += [getline(i)] + let i += 1 + endwhile + return r + endfunction +endif + +if exists('*nvim_buf_set_lines') + function! neomake#utils#buf_set_lines(bufnr, start, end, replacement) abort + if a:start < 1 + return 'neomake#utils#buf_set_lines: start is lower than 1' + endif + try + call nvim_buf_set_lines(a:bufnr, a:start-1, a:end-1, 1, a:replacement) + catch + " call neomake#log#error('Fixing entry failed (out of bounds)') + return 'neomake#utils#buf_set_lines: '.substitute(v:exception, '\v^[^:]+:', '', '') + endtry + return '' + endfunction +else + function! neomake#utils#buf_set_lines(bufnr, start, end, replacement) abort + if a:bufnr != bufnr('%') + return 'neomake#utils#buf_set_lines: used for non-current buffer' + endif + + if a:start < 1 + return 'neomake#utils#buf_set_lines: start is lower than 1' + endif + if a:end > line('$')+1 + return 'neomake#utils#buf_set_lines: end is higher than number of lines' + endif + + if a:start == a:end + let lnum = a:start < 0 ? line('$') - a:start : a:start + if append(lnum-1, a:replacement) == 1 + call neomake#log#error(printf('Failed to append line(s): %d (%d).', a:start, lnum), {'bufnr': a:bufnr}) + endif + + else + let range = a:end - a:start + if range > len(a:replacement) + let end = min([a:end, line('$')]) + silent execute a:start.','.end.'d_' + call setline(a:start, a:replacement) + else + let i = 0 + let n = len(a:replacement) + while i < n + call setline(a:start + i, a:replacement[i]) + let i += 1 + endwhile + endif + endif + return '' + endfunction +endif + +function! neomake#utils#shorten_list_for_log(l, max) abort + if len(a:l) > a:max + return a:l[:a:max-1] + ['... ('.len(a:l).' total)'] + endif + return a:l +endfunction diff --git a/dotfiles/.vim/autoload/neomake/virtualtext.vim b/dotfiles/.vim/autoload/neomake/virtualtext.vim new file mode 100644 index 0000000..b97f2d7 --- /dev/null +++ b/dotfiles/.vim/autoload/neomake/virtualtext.vim @@ -0,0 +1,113 @@ +scriptencoding utf8 + +let s:highlight_types = { + \ 'E': 'NeomakeVirtualtextError', + \ 'W': 'NeomakeVirtualtextWarning', + \ 'I': 'NeomakeVirtualtextInfo', + \ 'M': 'NeomakeVirtualtextMessage' + \ } + +function! neomake#virtualtext#show(...) abort + let list = neomake#list#get() + if empty(list) + echom 'Neomake: no annotations to show (no list)' + return + endif + + let filter = a:0 ? a:1 : '' + if empty(filter) + let entries = list.entries + else + let entries = map(copy(list.entries), filter) + endif + + if empty(entries) + echom 'Neomake: no annotations to show (no errors)' + return + endif + + for entry in entries + let buf_info = getbufvar(entry.bufnr, '_neomake_info', {}) + + call neomake#virtualtext#add_entry(entry, s:all_ns) + + " Keep track of added entries, because stacking is not supported. + let set_buf_info = 0 + if !has_key(buf_info, 'virtual_text_entries') + let buf_info.virtual_text_entries = [] + endif + if index(buf_info.virtual_text_entries, entry.lnum) == -1 + " Do not add it, but define it still - could return here also later. + call add(buf_info.virtual_text_entries, entry.lnum) + let set_buf_info = 1 + endif + + if set_buf_info + call setbufvar(entry.bufnr, '_neomake_info', buf_info) + endif + endfor +endfunction + +function! neomake#virtualtext#add_entry(entry, src_id) abort + let hi = get(s:highlight_types, toupper(a:entry.type), 'NeomakeVirtualtextMessage') + let prefix = get(g:, 'neomake_virtualtext_prefix', '❯ ') + let text = prefix . a:entry.text + let used_src_id = nvim_buf_set_virtual_text(a:entry.bufnr, a:src_id, a:entry.lnum-1, [[text, hi]], {}) + return used_src_id +endfunction + +function! neomake#virtualtext#show_errors() abort + call neomake#virtualtext#show('v:val ==? "e"') +endfunction + +function! neomake#virtualtext#hide() abort + let bufnr = bufnr('%') + let buf_info = getbufvar(bufnr, '_neomake_info', {}) + call nvim_buf_clear_highlight(bufnr, s:all_ns, 0, -1) + if !empty(get(buf_info, 'virtual_text_entries', [])) + let buf_info.virtual_text_entries = [] + call setbufvar(bufnr, '_neomake_info', buf_info) + endif +endfunction + +if exists('*nvim_create_namespace') " Includes nvim_buf_set_virtual_text. + let s:current_ns = nvim_create_namespace('neomake-virtualtext-current') + let s:all_ns = nvim_create_namespace('neomake-virtualtext-all') + let s:cur_virtualtext = [] + + function! neomake#virtualtext#handle_current_error() abort + if !get(g:, 'neomake_virtualtext_current_error', 1) + return + endif + + if !empty(s:cur_virtualtext) + if bufexists(s:cur_virtualtext[0]) + call nvim_buf_clear_highlight(s:cur_virtualtext[0], s:cur_virtualtext[1], 0, -1) + endif + endif + let entry = neomake#get_nearest_error() + if empty(entry) + let s:cur_virtualtext = [] + else + " Only add it when there is none already (stacking is not + " supported). https://github.com/neovim/neovim/issues/9285 + let buf_info = getbufvar(entry.bufnr, '_neomake_info', {}) + if index(get(buf_info, 'virtual_text_entries', []), entry.lnum) == -1 + let src_id = neomake#virtualtext#add_entry(entry, s:current_ns) + let s:cur_virtualtext = [bufnr('%'), src_id] + endif + endif + endfunction +else + function! neomake#virtualtext#handle_current_error() abort + endfunction +endif + +function! neomake#virtualtext#DefineHighlights() abort + " NOTE: linking to SpellBad etc is bad/distracting (with undercurl). + call neomake#utils#define_derived_highlights('NeomakeVirtualtext%s', ['NONE', 'NONE']) +endfunction + +call neomake#virtualtext#DefineHighlights() + +" vim: ts=4 sw=4 et -- cgit v1.2.3